|
- using BPASmartClient.Business;
- using BPASmartClient.Device;
- using BPA.Helper;
- using BPASmartClient.MorkF.Model;
- using BPA.Helper;
-
- 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 : NotifyBase
- {
- 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 BPARelayCommand PlcInite { get; set; }
- public BPARelayCommand FoodPlcInite { get; set; }
- public BPARelayCommand Plc1Reset { get; set; }
- public BPARelayCommand StartOrder { get; set; }
-
- public BPARelayCommand StopLocalOrder { get; set; }
- public BPARelayCommand 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 BPARelayCommand SetNowPosition { get; set; }//设置机械臂当前坐标
- public BPARelayCommand FoodLibInit { get; set; }//初始化
- public BPARelayCommand SurplusCheck { get; set; }//初始化
- public BPARelayCommand StartElectromagnetism { get; set; }//电磁阀启动
- public BPARelayCommand StopElectromagnetism { get; set; }
- public BPARelayCommand SetSpeed { get; set; }//速度设定
- public BPARelayCommand GetDistance_1 { get; set; }//感应测距1
- public BPARelayCommand GetDistance_2 { get; set; }//感应测距2
- public BPARelayCommand GetDistance_3 { get; set; }//感应测距3
- public BPARelayCommand PawTurnFront { get; set; }//夹爪正转
- public BPARelayCommand PawTurnBack { get; set; }//夹爪反转
- public BPARelayCommand SetArmPosition { get; set; }//机器臂位置设定
- public BPARelayCommand ArmRun { get; set; }//机械臂运动
- public BPARelayCommand PawToPoint1 { get; set; }//感应测距1
- public BPARelayCommand PawToPoint2 { get; set; }//感应测距2
- public BPARelayCommand 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 BPARelayCommand OutMaterials { get; set; }
- #endregion
-
- #region 炒锅1
- public BPARelayCommand Pot1SimOrder { get; set; }
- public BPARelayCommand AddOil { get; set; }
- public BPARelayCommand StartFire { get; set; }
- public BPARelayCommand StopFire { get; set; }
- public BPARelayCommand StartStir { get; set; }
- public BPARelayCommand StopStir { get; set; }
- public BPARelayCommand MagnetOn { get; set; }
- public BPARelayCommand MagnetOff { get; set; }
- public BPARelayCommand OutFood { get; set; }
- public BPARelayCommand StirArmGoOrigin { get; set; }
- public BPARelayCommand StirArmGoWork { get; set; }
- public BPARelayCommand HBOTGoWork { get; set; }
- public BPARelayCommand OutMeal { get; set; }
- public BPARelayCommand SetFire { get; set; }
- public BPARelayCommand SetFry { get; set; }
- public BPARelayCommand 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 BPARelayCommand SecAddOil { get; set; }
- public BPARelayCommand SecTempTurnOff { get; set; }
- public BPARelayCommand SecOneBlock { get; set; }
- public BPARelayCommand SecTwoBlock { get; set; }
- public BPARelayCommand SecThreeBlock { get; set; }
- public BPARelayCommand SecOverTurnOff { get; set; }
- public BPARelayCommand SecOverOneBlock { get; set; }
- public BPARelayCommand SecOverTwoBlock { get; set; }
- public BPARelayCommand SecOverThreeBlock { get; set; }
- public BPARelayCommand SecOverGoOn { get; set; }
- public BPARelayCommand SecOverGoDown { get; set; }
- public BPARelayCommand SecAutoModel { get; set; }
- public BPARelayCommand SecManualModel { get; set; }
- #endregion
-
- public DebugViewModel()
- {
- #region 设备控制
- PlcInite = new BPARelayCommand(() => { ActionManage.GetInstance.Send("InitCommand"); });
- Plc1Reset = new BPARelayCommand(() => { ActionManage.GetInstance.Send("Plc1Reset"); });
- StartOrder = new BPARelayCommand(() => { ActionManage.GetInstance.Send("StartOrder", FoodMenuID); });
- StopLocalOrder = new BPARelayCommand(() => { ActionManage.GetInstance.Send("StopLocalOrder"); });
- ModeChange = new BPARelayCommand(() => {
- ActionManage.GetInstance.Send("ModeChange");
- if(ModeButten == "联网模式")
- {
- ModeButten = "本地模式";
- }
- else
- {
- ModeButten = "联网模式";
- }
- });
- #endregion
-
- #region 菜品控制
-
- FoodLibInit = new BPARelayCommand(() => { ActionManage.GetInstance.Send("FoodLibInit"); });//菜品库初始化
- SurplusCheck = new BPARelayCommand(() => { ActionManage.GetInstance.Send("SurplusCheck"); });//菜品库初始化
- StartElectromagnetism = new BPARelayCommand(() => { ActionManage.GetInstance.Send("Electromagnetism", new List<bool> { false }); });//电磁阀启动
- StopElectromagnetism = new BPARelayCommand(() => { ActionManage.GetInstance.Send("Electromagnetism", new List<bool> { true });});//电磁阀关闭
- SetSpeed = new BPARelayCommand(() =>
- {
- ActionManage.GetInstance.Send("SetSpeed", new List<int> { MoveSpeed });
- });//设定速度
- PawToPoint1 = new BPARelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint1"); });//爪子去1号位
- PawToPoint2 = new BPARelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint2"); });//爪子去2号位
- PawToPoint3 = new BPARelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint3"); });//爪子去3号位
- GetDistance_1 = new BPARelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_1"); });//感应距离1
- GetDistance_2 = new BPARelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_2"); });//感应距离2
- GetDistance_3 = new BPARelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_3"); });//感应距离3
- PawTurnFront = new BPARelayCommand(() => { ActionManage.GetInstance.Send("PawTurnFront"); });//夹爪正转
- PawTurnBack = new BPARelayCommand(() => { ActionManage.GetInstance.Send("PawTurnBack"); });//夹爪反转
- SetArmPosition = new BPARelayCommand(() => { ActionManage.GetInstance.Send("SetArmPosition", new List<int> { SettingX, SettingY }); });//设定机械臂位置
- SetNowPosition = new BPARelayCommand(() => { ActionManage.GetInstance.Send("SetNowPosition", new List<int> { SettingX, SettingY }); });//设定机械臂当前位置
- ArmRun = new BPARelayCommand(() => {
- //判断是否都未点击
- 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 BPARelayCommand(() => { ActionManage.GetInstance.Send("OutMaterials" ,new List<int> { PassagePosition + 1,Weight } ); });
- #endregion
-
- #region 炒锅1
- Pot1SimOrder = new BPARelayCommand(() => { ActionManage.GetInstance.Send("模拟小炒锅1订单",new List<int> { OilTime,OilFirGear,OilStrGear,Food1Time,Food1FirGear,Food1StrGear,Food2Time,Food2FirGear,Food2StrGear }); });//模拟订单
- AddOil = new BPARelayCommand(() => { ActionManage.GetInstance.Send("AddOil", 1); });//加油
- StartFire = new BPARelayCommand(() => { ActionManage.GetInstance.Send("StartFire"); });//加热启动
- StopFire = new BPARelayCommand(() => { ActionManage.GetInstance.Send("StopFire"); });//加热停止
- StartStir = new BPARelayCommand(() => { ActionManage.GetInstance.Send("StartStir"); });//搅拌启动
- StopStir = new BPARelayCommand(() => { ActionManage.GetInstance.Send("StopStir"); });//搅拌停止
- MagnetOn = new BPARelayCommand(() => { ActionManage.GetInstance.Send("MagnetOn"); });//磁吸开启
- MagnetOff = new BPARelayCommand(() => { ActionManage.GetInstance.Send("MagnetOff"); });//磁吸开启
- OutFood = new BPARelayCommand(() => { ActionManage.GetInstance.Send("OutFood"); });//倒菜启动
- StirArmGoOrigin = new BPARelayCommand(() => { ActionManage.GetInstance.Send("StirArmGoOrigin"); });//搅拌臂去原点位
- StirArmGoWork = new BPARelayCommand(() => { ActionManage.GetInstance.Send("StirArmGoWork"); });//搅拌臂去炒制位
- HBOTGoWork = new BPARelayCommand(() => { ActionManage.GetInstance.Send("HBOTGoWork"); });//放盒子到位
- OutMeal = new BPARelayCommand(() => { ActionManage.GetInstance.Send("OutMeal"); });//出餐启动
- SetFire = new BPARelayCommand(() => { ActionManage.GetInstance.Send("SetFire", new List<int> { FireGear }); });//加热挡位设定
- SetStir = new BPARelayCommand(() => { ActionManage.GetInstance.Send("SetStir", new List<int> { StirGear }); });//搅拌挡位设定
- SetFry = new BPARelayCommand(() => { ActionManage.GetInstance.Send("SetFry", new List<int> { FryGear }); });//炒锅选择
- #endregion
-
- #region 炒锅2
- SecAddOil = new BPARelayCommand(() => { ActionManage.GetInstance.Send("AddOil", 2); });
- SecTempTurnOff = new BPARelayCommand(() => { ActionManage.GetInstance.Send("TakeOff", 2); });
- SecOneBlock = new BPARelayCommand(() => { ActionManage.GetInstance.Send("OneBlock", 2); });
- SecTwoBlock = new BPARelayCommand(() => { ActionManage.GetInstance.Send("TwoBlock", 2); });
- SecThreeBlock = new BPARelayCommand(() => { ActionManage.GetInstance.Send("ThreeBlock", 2); });
- SecOverTurnOff = new BPARelayCommand(() => { ActionManage.GetInstance.Send("OverTurnOff", 2); });
- SecOverOneBlock = new BPARelayCommand(() => { ActionManage.GetInstance.Send("OverOneBlock", 2); });
- SecOverTwoBlock = new BPARelayCommand(() => { ActionManage.GetInstance.Send("OverTwoBlock", 2); });
- SecOverThreeBlock = new BPARelayCommand(() => { ActionManage.GetInstance.Send("OverThreeBlock", 2); });
- SecOverGoOn = new BPARelayCommand(() => { ActionManage.GetInstance.Send("OverGoOn", 2); });
- SecOverGoDown = new BPARelayCommand(() => { ActionManage.GetInstance.Send("OverGoDown", 2); });
- SecAutoModel = new BPARelayCommand(() => { ActionManage.GetInstance.Send("AutoModel", 2); });
- SecManualModel = new BPARelayCommand(() => { ActionManage.GetInstance.Send("ManualModel", 2); });
- #endregion
-
- Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices().ForEach(device =>
- {
- if (device.Name == "MorkT") DeviceId = device.DeviceId
- ;
- });
-
- TaskManage.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;
- }
- }), "获取小炒数据");
- }
-
- }
- }
|