|
- using BPASmartClient.Business;
- using BPASmartClient.Device;
- using BPASmartClient.Helper;
- using BPASmartClient.MorkF.Model;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using Microsoft.Toolkit.Mvvm.Input;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.MorkF.ViewModel
- {
- internal class DebugViewModel : ObservableObject
- {
- public bool SimOrderEnable { get { return General_Config.SimOrderAllow; } set { General_Config.SimOrderAllow = value; OnPropertyChanged(); } }
- /// <summary>
- /// 设备数据
- /// </summary>
- public ObservableCollection<VariableMonitor> variableMonitors { get; set; }
-
- /// <summary>
- /// 设备ID
- /// </summary>
- public int DeviceId { get; set; }
-
- #region 设备控制
- public int FoodMenuID { get { return _foodMenuID; } set { _foodMenuID = value; OnPropertyChanged(); } }
- private int _foodMenuID;
- public RelayCommand PlcInite { get; set; }
- public RelayCommand FoodPlcInite { get; set; }
- public RelayCommand Plc1Reset { get; set; }
- public RelayCommand StartOrder { get; set; }
- public RelayCommand StartLocalOrder { get; set; }
- public RelayCommand StopLocalOrder { get; set; }
- public RelayCommand ModeChange { get; set; }
-
-
- #endregion
-
- #region 菜品控制
- public string RealX { get { return _realX; } set { _realX = value; OnPropertyChanged(); } }
- private string _realX;
- public string RealY { get { return _realY; } set { _realY = value; OnPropertyChanged(); } }
- private string _realY;
-
- public int SettingX { get { return _settingX; } set { _settingX = value; OnPropertyChanged(); } }
- private int _settingX = 0;
- public int SettingY { get { return _settingY; } set { _settingY = value; OnPropertyChanged(); } }
- private int _settingY = 0;
-
- public int SettingNowX { get { return _settingNowX; } set { _settingNowX = value; OnPropertyChanged(); } }
- private int _settingNowX = 0;
- public int SettingNowY { get { return _settingNowY; } set { _settingNowY = value; OnPropertyChanged(); } }
- private int _settingNowY = 0;
-
- public int MoveSpeed { get { return _moveSpeed; } set { _moveSpeed = value; OnPropertyChanged(); } }
- private int _moveSpeed;
- public string SensingDistance_1 { get { return _sensingDistance_1; } set { _sensingDistance_1 = value; OnPropertyChanged(); } }
- private string _sensingDistance_1 ;
- public string SensingDistance_2 { get { return _sensingDistance_2; } set { _sensingDistance_2 = value; OnPropertyChanged(); } }
- private string _sensingDistance_2 ;
- public string SensingDistance_3 { get { return _sensingDistance_3; } set { _sensingDistance_3 = value; OnPropertyChanged(); } }
- private string _sensingDistance_3;
- public bool PawPositon1 { get { return _pawPositon1; } set { _pawPositon1 = value; OnPropertyChanged(); } }
- private bool _pawPositon1;
- public bool PawPositon2 { get { return _pawPositon2; } set { _pawPositon2 = value; OnPropertyChanged(); } }
- private bool _pawPositon2;
- public bool PawPositon3 { get { return _pawPositon3; } set { _pawPositon3 = value; OnPropertyChanged(); } }
- private bool _pawPositon3;
-
- public bool ArmRunUp { get { return _armRunUp; } set { _armRunUp = value; OnPropertyChanged(); } }
- private bool _armRunUp;
- public bool ArmRunDown { get { return _armRunDown; } set { _armRunDown = value; OnPropertyChanged(); } }
- private bool _armRunDown;
- public bool ArmRunLeft { get { return _armRunLeft; } set { _armRunLeft = value; OnPropertyChanged(); } }
- private bool _armRunLeft;
- public bool ArmRunRight { get { return _armRunRight; } set { _armRunRight = value; OnPropertyChanged(); } }
- private bool _armRunRight;
- public bool ArmRunEnable { get { return _ArmRunEnable; } set { _ArmRunEnable = value; OnPropertyChanged(); } }
- private bool _ArmRunEnable = true;
-
- public string ArmButtonName { get { return _ArmButtonName; } set { _ArmButtonName = value; OnPropertyChanged(); } }
- private string _ArmButtonName = "启动";
- public string ModeButten { get { return _ModeButten; } set { _ModeButten = value; OnPropertyChanged(); } }
- private string _ModeButten = "联网模式";
-
- public RelayCommand SetNowPosition { get; set; }//设置机械臂当前坐标
- public RelayCommand FoodLibInit { get; set; }//初始化
- public RelayCommand SurplusCheck { get; set; }//初始化
- public RelayCommand StartElectromagnetism { get; set; }//电磁阀启动
- public RelayCommand StopElectromagnetism { get; set; }
- public RelayCommand SetSpeed { get; set; }//速度设定
- public RelayCommand GetDistance_1 { get; set; }//感应测距1
- public RelayCommand GetDistance_2 { get; set; }//感应测距2
- public RelayCommand GetDistance_3 { get; set; }//感应测距3
- public RelayCommand PawTurnFront { get; set; }//夹爪正转
- public RelayCommand PawTurnBack { get; set; }//夹爪反转
- public RelayCommand SetArmPosition { get; set; }//机器臂位置设定
- public RelayCommand ArmRun { get; set; }//机械臂运动
- public RelayCommand PawToPoint1 { get; set; }//感应测距1
- public RelayCommand PawToPoint2 { get; set; }//感应测距2
- public RelayCommand PawToPoint3 { get; set; }//感应测距3
-
- #endregion
-
-
- #region 配料仓控制
- public List<string> PassageWays { get; set; } = new List<string>()
- {
- "通道1",
- "通道2",
- "通道3",
- "通道4",
- "通道5",
- "通道6",
- "通道7",
- "通道8",
- "通道9",
- "通道10",
- "通道11",
- "通道12",
- "通道13",
- "通道14",
- };
- public int PassagePosition { get { return _passagePosition; } set { _passagePosition = value; OnPropertyChanged(); } }
- private int _passagePosition;
- public int Weight { get { return _weight; } set { _weight = value; OnPropertyChanged(); } }
- private int _weight;
- public RelayCommand OutMaterials { get; set; }
- #endregion
-
- #region 炒锅1
- public RelayCommand Pot1SimOrder { get; set; }
- public RelayCommand AddOil { get; set; }
- public RelayCommand StartFire { get; set; }
- public RelayCommand StopFire { get; set; }
- public RelayCommand StartStir { get; set; }
- public RelayCommand StopStir { get; set; }
- public RelayCommand MagnetOn { get; set; }
- public RelayCommand MagnetOff { get; set; }
- public RelayCommand OutFood { get; set; }
- public RelayCommand StirArmGoOrigin { get; set; }
- public RelayCommand StirArmGoWork { get; set; }
- public RelayCommand HBOTGoWork { get; set; }
- public RelayCommand OutMeal { get; set; }
- public RelayCommand SetFire { get; set; }
- public RelayCommand SetFry { get; set; }
- public RelayCommand SetStir { get; set; }
- public List<int> lstFire { get; set; } = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
- public List<int> lstFry { get; set; } = new List<int>() { 1, 2 };
- public List<int> lstStir { get; set; } = new List<int>() { 1, 2, 3 };
- public int FireGear { get { return _fireGear; } set { _fireGear = value; OnPropertyChanged(); } }
- private int _fireGear;
- public int FryGear { get { return _fryeGear; } set { _fryeGear = value; OnPropertyChanged(); } }
- private int _fryeGear;
- public int StirGear { get { return _stirGear; } set { _stirGear = value; OnPropertyChanged(); } }
- private int _stirGear;
- #region 模拟
- public int OilTime { get { return _oilTime; } set { _oilTime = value; OnPropertyChanged(); } }
- private int _oilTime = 10;
- public int OilFirGear { get { return _oilFirGear; } set { _oilFirGear = value; OnPropertyChanged(); } }
- private int _oilFirGear = 3;
- public int OilStrGear { get { return _oilStrGear; } set { _oilStrGear = value; OnPropertyChanged(); } }
- private int _oilStrGear = 1;
-
- public int Food1Time { get { return _food1Time; } set { _food1Time = value; OnPropertyChanged(); } }
- private int _food1Time = 30;
- public int Food1FirGear { get { return _food1FirGear; } set { _food1FirGear = value; OnPropertyChanged(); } }
- private int _food1FirGear = 6;
- public int Food1StrGear { get { return _food1StrGear; } set { _food1StrGear = value; OnPropertyChanged(); } }
- private int _food1StrGear = 2;
-
- public int Food2Time { get { return _food2Time; } set { _food2Time = value; OnPropertyChanged(); } }
- private int _food2Time = 30;
- public int Food2FirGear { get { return _food2FirGear; } set { _food2FirGear = value; OnPropertyChanged(); } }
- private int _food2FirGear = 6;
- public int Food2StrGear { get { return _food2StrGear; } set { _food2StrGear = value; OnPropertyChanged(); } }
- private int _food2StrGear = 2;
- #endregion
- #endregion
-
-
- #region 炒锅2
- public RelayCommand SecAddOil { get; set; }
- public RelayCommand SecTempTurnOff { get; set; }
- public RelayCommand SecOneBlock { get; set; }
- public RelayCommand SecTwoBlock { get; set; }
- public RelayCommand SecThreeBlock { get; set; }
- public RelayCommand SecOverTurnOff { get; set; }
- public RelayCommand SecOverOneBlock { get; set; }
- public RelayCommand SecOverTwoBlock { get; set; }
- public RelayCommand SecOverThreeBlock { get; set; }
- public RelayCommand SecOverGoOn { get; set; }
- public RelayCommand SecOverGoDown { get; set; }
- public RelayCommand SecAutoModel { get; set; }
- public RelayCommand SecManualModel { get; set; }
- #endregion
-
- public DebugViewModel()
- {
- #region 设备控制
- PlcInite = new RelayCommand(() => { ActionManage.GetInstance.Send("InitCommand"); });
- Plc1Reset = new RelayCommand(() => { ActionManage.GetInstance.Send("Plc1Reset"); });
- StartOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("StartOrder", FoodMenuID); });
- StartLocalOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("StartLocalOrder"); });
- StopLocalOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("StopLocalOrder"); });
- ModeChange = new RelayCommand(() => {
- ActionManage.GetInstance.Send("ModeChange");
- if(ModeButten == "联网模式")
- {
- ModeButten = "本地模式";
- }
- else
- {
- ModeButten = "联网模式";
- }
- });
- #endregion
-
- #region 菜品控制
-
- FoodLibInit = new RelayCommand(() => { ActionManage.GetInstance.Send("FoodLibInit"); });//菜品库初始化
- SurplusCheck = new RelayCommand(() => { ActionManage.GetInstance.Send("SurplusCheck"); });//菜品库初始化
- StartElectromagnetism = new RelayCommand(() => { ActionManage.GetInstance.Send("Electromagnetism", new List<bool> { false }); });//电磁阀启动
- StopElectromagnetism = new RelayCommand(() => { ActionManage.GetInstance.Send("Electromagnetism", new List<bool> { true });});//电磁阀关闭
- SetSpeed = new RelayCommand(() =>
- {
- ActionManage.GetInstance.Send("SetSpeed", new List<int> { MoveSpeed });
- });//设定速度
- PawToPoint1 = new RelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint1"); });//爪子去1号位
- PawToPoint2 = new RelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint2"); });//爪子去2号位
- PawToPoint3 = new RelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint3"); });//爪子去3号位
- GetDistance_1 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_1"); });//感应距离1
- GetDistance_2 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_2"); });//感应距离2
- GetDistance_3 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_3"); });//感应距离3
- PawTurnFront = new RelayCommand(() => { ActionManage.GetInstance.Send("PawTurnFront"); });//夹爪正转
- PawTurnBack = new RelayCommand(() => { ActionManage.GetInstance.Send("PawTurnBack"); });//夹爪反转
- SetArmPosition = new RelayCommand(() => { ActionManage.GetInstance.Send("SetArmPosition", new List<int> { SettingX, SettingY }); });//设定机械臂位置
- SetNowPosition = new RelayCommand(() => { ActionManage.GetInstance.Send("SetNowPosition", new List<int> { SettingX, SettingY }); });//设定机械臂当前位置
- ArmRun = new RelayCommand(() => {
- //判断是否都未点击
- if(!ArmRunDown&&!ArmRunUp&&!ArmRunLeft&&!ArmRunRight)
- {
- return;
- }
- ArmRunEnable = !ArmRunEnable;
- if(ArmRunEnable)
- {
- ArmButtonName = "启动";
- }
- else
- {
- ArmButtonName = "停止";
- }
- if(ArmRunUp)
- {
- ActionManage.GetInstance.Send("ArmRunUp", !ArmRunEnable);
- }
- else if(ArmRunDown)
- {
- ActionManage.GetInstance.Send("ArmRunDown", !ArmRunEnable);
- }
- else if (ArmRunLeft)
- {
- ActionManage.GetInstance.Send("ArmRunLeft", !ArmRunEnable);
- }
- else if(ArmRunRight)
- {
- ActionManage.GetInstance.Send("ArmRunRight", !ArmRunEnable);
- }
- });//设定机械臂位置
- #endregion
-
- #region 配料仓控制
- OutMaterials = new RelayCommand(() => { ActionManage.GetInstance.Send("OutMaterials" ,new List<int> { PassagePosition + 1,Weight } ); });
- #endregion
-
- #region 炒锅1
- Pot1SimOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("模拟小炒锅1订单",new List<int> { OilTime,OilFirGear,OilStrGear,Food1Time,Food1FirGear,Food1StrGear,Food2Time,Food2FirGear,Food2StrGear }); });//模拟订单
- AddOil = new RelayCommand(() => { ActionManage.GetInstance.Send("AddOil", 1); });//加油
- StartFire = new RelayCommand(() => { ActionManage.GetInstance.Send("StartFire"); });//加热启动
- StopFire = new RelayCommand(() => { ActionManage.GetInstance.Send("StopFire"); });//加热停止
- StartStir = new RelayCommand(() => { ActionManage.GetInstance.Send("StartStir"); });//搅拌启动
- StopStir = new RelayCommand(() => { ActionManage.GetInstance.Send("StopStir"); });//搅拌停止
- MagnetOn = new RelayCommand(() => { ActionManage.GetInstance.Send("MagnetOn"); });//磁吸开启
- MagnetOff = new RelayCommand(() => { ActionManage.GetInstance.Send("MagnetOff"); });//磁吸开启
- OutFood = new RelayCommand(() => { ActionManage.GetInstance.Send("OutFood"); });//倒菜启动
- StirArmGoOrigin = new RelayCommand(() => { ActionManage.GetInstance.Send("StirArmGoOrigin"); });//搅拌臂去原点位
- StirArmGoWork = new RelayCommand(() => { ActionManage.GetInstance.Send("StirArmGoWork"); });//搅拌臂去炒制位
- HBOTGoWork = new RelayCommand(() => { ActionManage.GetInstance.Send("HBOTGoWork"); });//放盒子到位
- OutMeal = new RelayCommand(() => { ActionManage.GetInstance.Send("OutMeal"); });//出餐启动
- SetFire = new RelayCommand(() => { ActionManage.GetInstance.Send("SetFire", new List<int> { FireGear }); });//加热挡位设定
- SetStir = new RelayCommand(() => { ActionManage.GetInstance.Send("SetStir", new List<int> { StirGear }); });//搅拌挡位设定
- SetFry = new RelayCommand(() => { ActionManage.GetInstance.Send("SetFry", new List<int> { FryGear }); });//炒锅选择
- #endregion
-
- #region 炒锅2
- SecAddOil = new RelayCommand(() => { ActionManage.GetInstance.Send("AddOil", 2); });
- SecTempTurnOff = new RelayCommand(() => { ActionManage.GetInstance.Send("TakeOff", 2); });
- SecOneBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OneBlock", 2); });
- SecTwoBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("TwoBlock", 2); });
- SecThreeBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("ThreeBlock", 2); });
- SecOverTurnOff = new RelayCommand(() => { ActionManage.GetInstance.Send("OverTurnOff", 2); });
- SecOverOneBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OverOneBlock", 2); });
- SecOverTwoBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OverTwoBlock", 2); });
- SecOverThreeBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OverThreeBlock", 2); });
- SecOverGoOn = new RelayCommand(() => { ActionManage.GetInstance.Send("OverGoOn", 2); });
- SecOverGoDown = new RelayCommand(() => { ActionManage.GetInstance.Send("OverGoDown", 2); });
- SecAutoModel = new RelayCommand(() => { ActionManage.GetInstance.Send("AutoModel", 2); });
- SecManualModel = new RelayCommand(() => { ActionManage.GetInstance.Send("ManualModel", 2); });
- #endregion
-
- Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices().ForEach(device =>
- {
- if (device.Name == "MorkT") DeviceId = device.DeviceId
- ;
- });
-
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- //variableMonitors = Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices()?.FirstOrDefault(p => p.DeviceId == DeviceId)?.variableMonitors;
-
- if(variableMonitors != null)
- {
- RealX = variableMonitors.FirstOrDefault(p => p.Notes == "机械手臂X").CurrentValue;
- RealY = variableMonitors.FirstOrDefault(p => p.Notes == "机械手臂Y").CurrentValue;
- }
- }), "获取小炒数据");
- }
-
- }
- }
|