|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 |
- 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
- {
- /// <summary>
- /// 加热挡位
- /// </summary>
- public ObservableCollection<int> FireGear { get; set; } = new ObservableCollection<int>() { 1, 2, 3, 4, 5 };
- /// <summary>
- /// 搅拌挡位
- /// </summary>
- public ObservableCollection<int> StirGear { get; set; } = new ObservableCollection<int>() { 1, 2, 3, 4, 5 };
- /// <summary>
- /// 炒锅角度
- /// </summary>
- public ObservableCollection<int> PotAngle { get; set; } = new ObservableCollection<int>() { 1, 2, 3, 4, };
- /// <summary>
- /// 通道号
- /// </summary>
- public ObservableCollection<int> PassWay { get; set; } = new ObservableCollection<int>() { 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 炒锅
- /// <summary>
- /// 设定加热挡位
- /// </summary>
- [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});
- }
-
- }
- /// <summary>
- /// 加热启动
- /// </summary>
- [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 });
- }
-
- }
- /// <summary>
- /// 关闭加热
- /// </summary>
- [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 });
- }
- }
-
- /// <summary>
- /// 设定搅拌挡位
- /// </summary>
- [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 });
- }
- }
- /// <summary>
- /// 搅拌启动
- /// </summary>
- [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 });
- }
- }
- /// <summary>
- /// 搅拌停止
- /// </summary>
- [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 });
- }
- }
- /// <summary>
- /// 翻转频率设定
- /// </summary>
- [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 });
- }
- }
- /// <summary>
- /// 设定炒锅角度
- /// </summary>
- [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 });
- }
- }
-
- /// <summary>
- /// 通道出料启动
- /// </summary>
- [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 });
- }
- }
-
- /// <summary>
- /// 复位
- /// </summary>
- [RelayCommand]
- private void FirePot_Reset(object o)
- {
- //ActionManage.GetInstance.Send("FirePot1_Reset", o);
- }
- /// <summary>
- /// 炒锅回原点
- /// </summary>
- [RelayCommand]
- private void FirePot_PotGotoOrigin(object o)
- {
- ActionManage.GetInstance.Send("FirePot_PotGotoOrigin", int.Parse(o.ToString()));
- }
-
- /// <summary>
- /// 炒锅去投料位置
- /// </summary>
- [RelayCommand]
- private void FirePot_PotGotoInFoodPosition(object o)
- {
-
- ActionManage.GetInstance.Send("FirePot_PotGotoInFoodPosition", int.Parse(o.ToString()));
- }
- /// <summary>
- /// 出餐启动
- /// </summary>
- [RelayCommand]
- private void FirePot_StartOutFood(object o)
- {
- ActionManage.GetInstance.Send("FirePot_StartOutFood", int.Parse(o.ToString()));
- }
- /// <summary>
- /// 清洗
- /// </summary>
- [RelayCommand]
- private void FirePot_Clean(object o)
- {
- ActionManage.GetInstance.Send("FirePot_Clean", int.Parse(o.ToString()));
- }
- /// <summary>
- /// 抽水启动
- /// </summary>
- [RelayCommand]
- private void FirePot_StartPumpWater(object o)
- {
- ActionManage.GetInstance.Send("FirePot_StartPumpWater", new object[] { int.Parse(o.ToString()), true });
- }
- /// <summary>
- /// 抽水关闭
- /// </summary>
- [RelayCommand]
- private void FirePot_StopPumpWater(object o)
- {
- ActionManage.GetInstance.Send("FirePot_StopPumpWater", new object[] { int.Parse(o.ToString()), false });
- }
- /// <summary>
- /// 推杆伸出
- /// </summary>
- [RelayCommand]
- private void FirePot_PushReach(object o)
- {
- ActionManage.GetInstance.Send("FirePot_PushReach", int.Parse(o.ToString()) );
- }
- /// <summary>
- /// 推杆缩回
- /// </summary>
- [RelayCommand]
- private void FirePot_PushRetract(object o)
- {
- ActionManage.GetInstance.Send("FirePot_PushRetract", int.Parse(o.ToString()));
- }
- /// <summary>
- /// 翻转正转
- /// </summary>
- [RelayCommand]
- private void FirePot_PotForward(object o)
- {
- ActionManage.GetInstance.Send("FirePot_PotForward", int.Parse(o.ToString()));
- }
- /// <summary>
- /// 翻转反转
- /// </summary>
- [RelayCommand]
- private void FirePot_PotReversal(object o)
- {
- ActionManage.GetInstance.Send("FirePot_PotReversal", int.Parse(o.ToString()) );
- }
-
-
-
- #endregion
-
-
- #region 机器人
- public ObservableCollection<MainTask> RobotMainTask { get; set; } = new ObservableCollection<MainTask>(Enum.GetValues<MainTask>());
- public ObservableCollection<SubTask1> RobotSubTask1 { get; set; } = new ObservableCollection<SubTask1>(Enum.GetValues<SubTask1>());
- public ObservableCollection<SubTask2> RobotSubTask2 { get; set; } = new ObservableCollection<SubTask2>(Enum.GetValues<SubTask2>());
- public ObservableCollection<SubTask3> RobotSubTask3 { get; set; } = new ObservableCollection<SubTask3>(Enum.GetValues<SubTask3>());
- public ObservableCollection<SubTask4> RobotSubTask4 { get; set; } = new ObservableCollection<SubTask4>(Enum.GetValues<SubTask4>());
-
- [ObservableProperty]
- private MainTask _mainTask;
- [ObservableProperty]
- private SubTask1 _subTask1;
- [ObservableProperty]
- private SubTask2 _subTask2;
- [ObservableProperty]
- private SubTask3 _subTask3;
- [ObservableProperty]
- private SubTask4 _subTask4;
-
- /// <summary>
- /// 机器人启动
- /// </summary>
- [RelayCommand]
- private void RobotStart()
- {
- ActionManage.GetInstance.Send("RobotStart");
- }
- /// <summary>
- /// 机器人停止
- /// </summary>
- [RelayCommand]
- private void RobotStop()
- {
- ActionManage.GetInstance.Send("RobotStop");
- }
- /// <summary>
- /// 复位
- /// </summary>
- [RelayCommand]
- private void RobotReset()
- {
- ActionManage.GetInstance.Send("RobotReset");
- }
- /// <summary>
- /// 机器人上使能
- /// </summary>
- [RelayCommand]
- private void RobotEnable()
- {
- ActionManage.GetInstance.Send("RobotEnable");
- }
-
- /// <summary>
- /// 机器人动作
- /// </summary>
- [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
-
-
-
-
- }
- }
|