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