using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using BPA.Helper; using System.Collections.ObjectModel; using BPASmartClient.JXJFoodSmallStation.Model; using BPA.Helper; using BPASmartClient.CustomResource.UserControls.MessageShow; using BPASmartClient.CustomResource.UserControls; using System.Diagnostics; using BPASmartClient.JXJFoodSmallStation.Model.Siemens; using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC; using System.Threading; using System.ComponentModel; using System.Runtime.CompilerServices; using BPASmartClient.CustomResource.Pages.Model; namespace BPASmartClient.JXJFoodSmallStation.ViewModel { public class RobotViewModel : NotifyBase { public RobotViewModel() { TaskManage.GetInstance.StartLong(() => { IsRunProgramNum = GVL_SmallStation.GetInstance.RobotProgramNum; RobotIsAutoMode = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(2); RobotIsAutoRun = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(3); RobotIsStop = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(4); RobotIsRun = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(5); RobotIsAlarm = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(6); RobotIsHomed = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(7); //RobotGetEmptyBarrelComplete = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(8); //RobotPutEmptyBarrelComplete = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(9); //RobotGetFullBarrelComplete = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(10); //RobotPutFullBarrelComplete = GVL_SmallStation.GetInstance.RobotStatus.GetBitValue(11); Thread.Sleep(10); },"机器人状态",true); SystemStart = new BPARelayCommand(() => { ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX0.1"); MessageNotify.GetInstance.ShowUserLog($"手动控制,机器人启动"); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"机器人启动,操作完成!"); }); SystemStop = new BPARelayCommand(() => { ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX0.2"); MessageNotify.GetInstance.ShowUserLog($"手动控制,机器人停止"); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"机器人停止,操作完成!"); }); EStopReset = new BPARelayCommand(() => { ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX0.3"); MessageNotify.GetInstance.ShowUserLog($"手动控制,机器人急停复位"); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"机器人急停复位,操作完成!"); }); //TestRobotRun = new BPARelayCommand(() => { // ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX100.4"); //}); //AutoMode = new BPARelayCommand(() => { // ActionManage.GetInstance.Send("RobotSendFalseCommand", "DB4.DBX100.3"); //}); //TestMode = new BPARelayCommand(() => { // ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX100.3"); //}); //RobotGetEmptyBarrel = new BPARelayCommand(() => { // ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX100.7"); //}); //RobotPutEmptyBarrel = new BPARelayCommand(() => { // ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX101.0"); //}); //RobotGetFullBarrel = new BPARelayCommand(() => { // ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX101.1"); //}); //RobotPutFullBarrel = new BPARelayCommand(() => { // ActionManage.GetInstance.Send("RobotSendTrueCommand", "DB4.DBX101.2"); //}); //SetProgramNumCommand = new BPARelayCommand(() =>{ // ActionManage.GetInstance.Send("RobotSetProgramNum", SetProgramNum); //}); } public BPARelayCommand SystemStart { get; set; } public BPARelayCommand SystemStop { get; set; } public BPARelayCommand EStopReset { get; set; } public BPARelayCommand TestRobotRun { get; set; } public BPARelayCommand AutoMode { get; set; } public BPARelayCommand TestMode { get; set; } public BPARelayCommand RobotGetEmptyBarrel { get; set; } public BPARelayCommand RobotPutEmptyBarrel { get; set; } public BPARelayCommand RobotGetFullBarrel { get; set; } public BPARelayCommand RobotPutFullBarrel { get; set; } public BPARelayCommand SetProgramNumCommand { get; set; } public static short IsRunProgramNum { get { return _runProgramNum; } set { _runProgramNum = value; OnStaticPropertyChanged(); } } private static short _runProgramNum; public short SetProgramNum { get { return _SetProgramNum; } set { _SetProgramNum = value; OnPropertyChanged(); } } private short _SetProgramNum; public static bool RobotIsAutoMode { get { return _RobotIsAutoMode; } set { _RobotIsAutoMode = value; OnStaticPropertyChanged(); } } private static bool _RobotIsAutoMode; public static bool RobotIsAutoRun { get { return _RobotIsAutoRun; } set { _RobotIsAutoRun = value; OnStaticPropertyChanged(); } } private static bool _RobotIsAutoRun; public static bool RobotIsStop { get { return _RobotIsStop; } set { _RobotIsStop = value; OnStaticPropertyChanged(); } } private static bool _RobotIsStop; public static bool RobotIsRun { get { return _RobotIsRun; } set { _RobotIsRun = value; OnStaticPropertyChanged(); } } private static bool _RobotIsRun; public static bool RobotIsAlarm { get { return _RobotIsAlarm; } set { _RobotIsAlarm = value; OnStaticPropertyChanged(); } } private static bool _RobotIsAlarm; public static bool RobotIsHomed { get { return _RobotIsHomed; } set { _RobotIsHomed = value; OnStaticPropertyChanged(); } } private static bool _RobotIsHomed; public bool RobotGetEmptyBarrelComplete { get { return _RobotGetEmptyBarrelComplete; } set { _RobotGetEmptyBarrelComplete = value; OnPropertyChanged(); } } private bool _RobotGetEmptyBarrelComplete; public bool RobotPutEmptyBarrelComplete { get { return _RobotPutEmptyBarrelComplete; } set { _RobotPutEmptyBarrelComplete = value; OnPropertyChanged(); } } private bool _RobotPutEmptyBarrelComplete; public bool RobotGetFullBarrelComplete { get { return _RobotGetFullBarrelComplete; } set { _RobotGetFullBarrelComplete = value; OnPropertyChanged(); } } private bool _RobotGetFullBarrelComplete; public bool RobotPutFullBarrelComplete { get { return _RobotPutFullBarrelComplete; } set { _RobotPutFullBarrelComplete = value; OnPropertyChanged(); } } private bool _RobotPutFullBarrelComplete; public static event EventHandler StaticPropertyChanged; public static void OnStaticPropertyChanged([CallerMemberName] string PropName = "") { StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(PropName)); } } }