global using CommunityToolkit.Mvvm.ComponentModel; global using CommunityToolkit.Mvvm.Input; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using BPASmartClient.Helper; using BPASmartClient.Model.大炒; using BPASmartClient.MorkBF.Model; using BPASmartClient.MorkBF.VIew; namespace BPASmartClient.MorkBF.ViewModel { [INotifyPropertyChanged] partial class DebugViewModel { /// /// 加热挡位 /// public ObservableCollection FireGear { get; set; } = new ObservableCollection() { 1, 2, 3, 4, 5 }; /// /// 搅拌挡位 /// public ObservableCollection StirGear { get; set; } = new ObservableCollection() { 1, 2, 3, 4, 5 }; /// /// 炒锅角度 /// public ObservableCollection PotAngle { get; set; } = new ObservableCollection() { 1, 2, 3, 4, }; /// /// 通道号 /// public ObservableCollection PassWay { get; set; } = new ObservableCollection() { 1, 2, 3, 4,5,6,7,8 }; [ObservableProperty] private int _firePot1_FireGear = 1;//加热挡位 [ObservableProperty] private int _firePot2_FireGear = 1; [ObservableProperty] private int _firePot1_StirGear = 1;//搅拌挡位 [ObservableProperty] private int _firePot2_StirGear = 1; [ObservableProperty] private int _firePot1_TurnSpeed;//翻转速度 [ObservableProperty] private int _firePot2_TurnSpeed; [ObservableProperty] private int _firePot1_PotAngle = 1;//炒锅角度 [ObservableProperty] private int _firePot2_PotAngle = 1; [ObservableProperty] private int _firePot1_PassWay = 1;//通道号 [ObservableProperty] private int _firePot2_PassWay = 1; [ObservableProperty] private int _firePot1_PassValue = 0;//通道需求值 [ObservableProperty] private int _firePot2_PassValue = 0; #region 炒锅 /// /// 设定加热挡位 /// [RelayCommand] private void FirePot_SetFireGear(object o) { if(o == null) return; if(int.TryParse(o.ToString(),out int i)) { int value = 0; if(i == 1) { value = FirePot1_FireGear; } else if(i == 2) { value = FirePot2_FireGear; } ActionManage.GetInstance.Send("FirePot_SetFireGear", new object[] { i, value}); } } /// /// 加热启动 /// [RelayCommand] private void FirePot_StartFire(object o) { if (o == null) return; if (int.TryParse(o.ToString(), out int i)) { ActionManage.GetInstance.Send("FirePot_StartFire", new object[] { i, true }); } } /// /// 关闭加热 /// [RelayCommand] private void FirePot_StopFire(object o) { if (o == null) return; if (int.TryParse(o.ToString(), out int i)) { ActionManage.GetInstance.Send("FirePot_StopFire", new object[] { i, false }); } } /// /// 设定搅拌挡位 /// [RelayCommand] private void FirePot_SetStirGear(object o) { if (o == null) return; if (int.TryParse(o.ToString(), out int i)) { int value = 0; if (i == 1) { value = FirePot1_StirGear; } else if (i == 2) { value = FirePot2_StirGear; } ActionManage.GetInstance.Send("FirePot_SetStirGear",new object[] { i, value }); } } /// /// 搅拌启动 /// [RelayCommand] private void FirePot_StartStir(object o) { if (o == null) return; if (int.TryParse(o.ToString(), out int i)) { ActionManage.GetInstance.Send("FirePot_StartStir", new object[] { i, true }); } } /// /// 搅拌停止 /// [RelayCommand] private void FirePot_StopStir(object o) { if (o == null) return; if (int.TryParse(o.ToString(), out int i)) { ActionManage.GetInstance.Send("FirePot_StopStir", new object[] { i, false }); } } /// /// 翻转频率设定 /// [RelayCommand] private void FirePot_SetTurnSpeed(object o) { if (o == null) return; if (int.TryParse(o.ToString(), out int i)) { int value = 0; if (i == 1) { value = FirePot1_TurnSpeed; } else if (i == 2) { value = FirePot2_TurnSpeed; } if (value > 800) value = 800; ActionManage.GetInstance.Send("FirePot_SetTurnSpeed", new object[] { i, value }); } } /// /// 设定炒锅角度 /// [RelayCommand] private void FirePot_SetPotAngle(object o) { if (o == null) return; if (int.TryParse(o.ToString(), out int i)) { int value = 0; if (i == 1) { value = FirePot1_PotAngle; } else if (i == 2) { value = FirePot2_PotAngle; } ActionManage.GetInstance.Send("FirePot_SetPotAngle", new object[] { i, value }); } } /// /// 通道出料启动 /// [RelayCommand] private void FirePot_StartPassWay(object o) { if (o == null) return; if (int.TryParse(o.ToString(), out int i)) { int value1 = 0; int value2 = 0; if (i == 1) { value1 = FirePot1_PassWay; value2 = FirePot1_PassValue; } else if (i == 2) { value1 = FirePot2_PassWay; value2 = FirePot2_PassValue; } ActionManage.GetInstance.Send("FirePot_StartPassWay", new object[] { i, value1,value2 }); } } /// /// 复位 /// [RelayCommand] private void FirePot_Reset(object o) { //ActionManage.GetInstance.Send("FirePot1_Reset", o); } /// /// 炒锅回原点 /// [RelayCommand] private void FirePot_PotGotoOrigin(object o) { ActionManage.GetInstance.Send("FirePot_PotGotoOrigin", int.Parse(o.ToString())); } /// /// 炒锅去投料位置 /// [RelayCommand] private void FirePot_PotGotoInFoodPosition(object o) { ActionManage.GetInstance.Send("FirePot_PotGotoInFoodPosition", int.Parse(o.ToString())); } /// /// 出餐启动 /// [RelayCommand] private void FirePot_StartOutFood(object o) { ActionManage.GetInstance.Send("FirePot_StartOutFood", int.Parse(o.ToString())); } /// /// 清洗 /// [RelayCommand] private void FirePot_Clean(object o) { ActionManage.GetInstance.Send("FirePot_Clean", int.Parse(o.ToString())); } /// /// 抽水启动 /// [RelayCommand] private void FirePot_StartPumpWater(object o) { ActionManage.GetInstance.Send("FirePot_StartPumpWater", new object[] { int.Parse(o.ToString()), true }); } /// /// 抽水关闭 /// [RelayCommand] private void FirePot_StopPumpWater(object o) { ActionManage.GetInstance.Send("FirePot_StopPumpWater", new object[] { int.Parse(o.ToString()), false }); } /// /// 推杆伸出 /// [RelayCommand] private void FirePot_PushReach(object o) { ActionManage.GetInstance.Send("FirePot_PushReach", int.Parse(o.ToString()) ); } /// /// 推杆缩回 /// [RelayCommand] private void FirePot_PushRetract(object o) { ActionManage.GetInstance.Send("FirePot_PushRetract", int.Parse(o.ToString())); } /// /// 翻转正转 /// [RelayCommand] private void FirePot_PotForward(object o) { ActionManage.GetInstance.Send("FirePot_PotForward", int.Parse(o.ToString())); } /// /// 翻转反转 /// [RelayCommand] private void FirePot_PotReversal(object o) { ActionManage.GetInstance.Send("FirePot_PotReversal", int.Parse(o.ToString()) ); } #endregion #region 机器人 public ObservableCollection RobotMainTask { get; set; } = new ObservableCollection(Enum.GetValues()); public ObservableCollection RobotSubTask1 { get; set; } = new ObservableCollection(Enum.GetValues()); public ObservableCollection RobotSubTask2 { get; set; } = new ObservableCollection(Enum.GetValues()); public ObservableCollection RobotSubTask3 { get; set; } = new ObservableCollection(Enum.GetValues()); public ObservableCollection RobotSubTask4 { get; set; } = new ObservableCollection(Enum.GetValues()); [ObservableProperty] private MainTask _mainTask; [ObservableProperty] private SubTask1 _subTask1; [ObservableProperty] private SubTask2 _subTask2; [ObservableProperty] private SubTask3 _subTask3; [ObservableProperty] private SubTask4 _subTask4; /// /// 机器人启动 /// [RelayCommand] private void RobotStart() { ActionManage.GetInstance.Send("RobotStart"); } /// /// 机器人停止 /// [RelayCommand] private void RobotStop() { ActionManage.GetInstance.Send("RobotStop"); } /// /// 复位 /// [RelayCommand] private void RobotReset() { ActionManage.GetInstance.Send("RobotReset"); } /// /// 机器人上使能 /// [RelayCommand] private void RobotEnable() { ActionManage.GetInstance.Send("RobotEnable"); } /// /// 机器人动作 /// [RelayCommand] private void RobotAction(object o) { if(int.TryParse(o.ToString(), out int value)) { object item = new object(); switch (value) { case 0: item = MainTask; break; case 1: item = SubTask1; break; case 2: item = SubTask2; break; case 3: item = SubTask3; break; case 4: item = SubTask4; break; default: break; } ActionManage.GetInstance.Send("RobotAction", new object[] { value, item }); } } #endregion } }