|
- 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
-
-
-
-
- }
- }
|