|
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using System.Collections.Concurrent;
- using System.Collections.ObjectModel;
- using System.Windows;
- using BPASmartClient.Helper;
- using Microsoft.Toolkit.Mvvm.Input;
- using BPASmartClient.JXJFoodBigStation.Model;
-
- namespace BPASmartClient.JXJFoodBigStation.ViewModel
- {
- public class HardwareStatusViewModel : ObservableObject
- {
- public HardwareStatusViewModel()
- {
- for (int i = 0; i <8; i++)
- {
- TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus()
- {
- DeviceName = i.ToString(),
- DeviceNum=i,
- RunStatus = false,
- Weight = new Random().Next(0, 100)
- });
- }
- for (int i = 8; i < 16; i++)
- {
- BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus()
- {
- DeviceName = i.ToString(),
- DeviceNum = i,
- RunStatus = false,
- Weight = new Random().Next(0, 100)
- });
- }
-
- StartCommand = new RelayCommand<string>((deviceName) => {
- //PLC控制
-
- //动画
- if (deviceName != null)
- {
- var top= TopDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName);
- if (top != null)
- {
- ActionManage.GetInstance.Send("StartTopDevice", deviceName);
- }
- var bottom = BottomDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName);
- if (bottom != null)
- {
- ActionManage.GetInstance.Send("StartBottomDevice", deviceName);
- }
- }
- });
- StopCommand = new RelayCommand<string>((deviceName) => {
- //PLC控制
-
- //动画
- if (deviceName != null)
- {
- var top = TopDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName);
- if (top != null)
- {
- ActionManage.GetInstance.Send("StopTopDevice", deviceName);
- }
- var bottom = BottomDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName);
- if (bottom != null)
- {
- ActionManage.GetInstance.Send("StopBottomDevice", deviceName);
- }
- }
- });
- }
-
- public ObservableCollection<DeviceCurrentStatus> TopDeviceCurrentStatuses { get; set; } = new ObservableCollection<DeviceCurrentStatus>();
- public ObservableCollection<DeviceCurrentStatus> BottomDeviceCurrentStatuses { get; set; } = new ObservableCollection<DeviceCurrentStatus>();
-
- public RelayCommand<string> StartCommand { get; set; }
-
- public RelayCommand<string> StopCommand { get; set; }
- }
- }
|