|
- using BPASmartClient.Business;
- using BPASmartClient.Device;
- using BPASmartClient.DRCoffee;
- using BPASmartClient.EventBus;
- using BPASmartClient.GSIceCream;
- using BPASmartClient.Helper;
- using BPASmartClient.Lebai;
- using BPASmartClient.LebaiRobot;
- using BPASmartClient.Model;
- using BPASmartClient.Model.冰淇淋.Enum;
- using BPASmartClient.Model.咖啡机.Enum;
- using BPASmartClient.SCChip;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using Microsoft.Toolkit.Mvvm.Input;
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.ViewModel
- {
- public class MorkT_DebugViewModel : ObservableObject
- {
- #region 乐白机器人
- /// <summary>
- /// 乐白机器人连接状态
- /// </summary>
- public string RobotConnected { get; set; }
- /// <summary>
- /// 乐白机器人的模式状态
- /// </summary>
- public ELebaiRModel RobotMode { get; set; }
- /// <summary>
- /// 机器人控制指令
- /// </summary>
- public RelayCommand<object> Button_RobotControlCommand { get; set; }
- /// <summary>
- /// 机器人控制
- /// </summary>
- /// <param name="o"></param>
- private void Button_RobotControl(object o)
- {
- ActionManage.GetInstance.Send("调试控制-机器人控制",o.ToString());
- }
-
- #endregion
-
- #region 冰淇淋机器
- /// <summary>
- /// 制作冰淇淋
- /// </summary>
- public RelayCommand Button_MakeIceCreamCommand { get; set; }
- /// <summary>
- /// 选择冰淇淋模式
- /// </summary>
- public RelayCommand Button_SetIceCreamModelCommand { get; set; }
-
- /// <summary>
- /// 冰淇淋连接状态
- /// </summary>
- public string IceCreamConnected { get; set; }
- /// <summary>
- /// 预冷温度
- /// </summary>
- public short YLWD { get; set; }
- /// <summary>
- /// 回气温度
- /// </summary>
- public short HQWD { get; set; }
- /// <summary>
- /// 环境温度
- /// </summary>
- public short HJWD { get; set; }
- /// <summary>
- /// 电流
- /// </summary>
- public short DL { get; set; }
- /// <summary>
- /// 电压
- /// </summary>
- public short DY { get; set; }
- /// <summary>
- /// 当前模式
- /// </summary>
- public MORKI_MODE CurrentMode { get; set; }
- /// <summary>
- /// 故障
- /// </summary>
- public MORKI_FAULT IceCreamFault { get; set; }
- /// <summary>
- /// 成型比
- /// </summary>
- public byte CXB { get; set; }
- /// <summary>
- /// 打料完成状态
- /// </summary>
- public string DLCompleted { get; set; }
-
- public List<string> IceCreamModes { get; set; } = new List<string>();
- public string SelecteIceCreamdMode { get; set; }
-
- private void Button_MakeIceCream()
- {
-
- }
- private void Button_SetIceCreamModel()
- {
- MORKI_MODE mORKI_MODE = (MORKI_MODE)Enum.Parse(typeof(MORKI_MODE), SelecteIceCreamdMode);
- new GSIceCream_ModeSetEvent() { Mode = mORKI_MODE }.Publish();
- }
- #endregion
-
- #region 咖啡机
- /// <summary>
- /// 咖啡机连接状态
- /// </summary>
- public string CoffeeConnected { get; set; }
- /// <summary>
- /// 咖啡机状态
- /// </summary>
- public DrCoffeeStatus CoffeeStatus { get; set; }
- /// <summary>
- /// 应用状态
- /// </summary>
- public DrCoffeeAppStatus AppStatus { get; set; }
- /// <summary>
- /// 告警
- /// </summary>
- public DrCoffeeWarning Warning { get; set; }
- /// <summary>
- /// 故障信息
- /// </summary>
- public DrCoffeeFault CaffeeFault { get; set; }
-
- public List<string> Coffees { get; set; } = new List<string>();
- public string SelectedCoffee { get; set; }
-
- public List<string> CoffeeCmds { get; set; } = new List<string>();
- public string SelectedCoffeeCmd { get; set; }
- #endregion
-
-
- Dictionary<string, object> CurrentData { get; set; }
-
- public MorkT_DebugViewModel()
- {
- Button_RobotControlCommand = new RelayCommand<object>(Button_RobotControl);
- Button_MakeIceCreamCommand = new RelayCommand(Button_MakeIceCream);
- Button_SetIceCreamModelCommand = new RelayCommand(Button_SetIceCreamModel);
-
- foreach (DrCoffeeDrinksCode code in Enum.GetValues(typeof(DrCoffeeDrinksCode)))
- {
- Coffees.Add(code.ToString());
- }
- SelectedCoffee = Coffees[0];
- foreach (DrCoffeeCommCmd code in Enum.GetValues(typeof(DrCoffeeCommCmd)))
- {
- CoffeeCmds.Add(code.ToString());
- }
- SelectedCoffeeCmd = CoffeeCmds[0];
-
- foreach (MORKI_MODE code in Enum.GetValues(typeof(MORKI_MODE)))
- {
- IceCreamModes.Add(code.ToString());
- }
- SelecteIceCreamdMode = IceCreamModes[0];
-
-
-
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices().ForEach(device =>
- {
- if (device.Name == "MorkT") CurrentData = device.Status.GetStatus();
- });
- if (CurrentData != null && CurrentData.Count != 0)
- {
- RobotConnected = (bool)CurrentData["Lebai.LebaiRobot.Connected"] ? "已连接" : "未连接";
- IceCreamConnected = (bool)CurrentData["GSIceCream.IceCreamMachine.IsConnected"] ? "已连接" : "未连接";
- CoffeeConnected = (bool)CurrentData["GSIceCream.IceCreamMachine.IsConnected"] ? "已连接" : "未连接";
-
- RobotMode = (ELebaiRModel)CurrentData["Lebai.LebaiRobot.RobotMode"];
-
- CoffeeStatus = (DrCoffeeStatus)CurrentData["DRCoffee.CoffeeMachine.Status"];
- AppStatus = (DrCoffeeAppStatus)CurrentData["DRCoffee.CoffeeMachine.AppStatus"];
- Warning = (DrCoffeeWarning)CurrentData["DRCoffee.CoffeeMachine.Warning"];
- CaffeeFault = (DrCoffeeFault)CurrentData["DRCoffee.CoffeeMachine.Fault"];
-
- YLWD = (short)CurrentData["GSIceCream.IceCreamMachine.YLWD"];
- HQWD = (short)CurrentData["GSIceCream.IceCreamMachine.HQWD"];
- HJWD = (short)CurrentData["GSIceCream.IceCreamMachine.HJWD"];
- DL = (short)CurrentData["GSIceCream.IceCreamMachine.DL"];
- DY = (short)CurrentData["GSIceCream.IceCreamMachine.DY"];
- CurrentMode = (MORKI_MODE)CurrentData["GSIceCream.IceCreamMachine.CurrentMode"];
- IceCreamFault = (MORKI_FAULT)CurrentData["GSIceCream.IceCreamMachine.Fault"];
- CXB = (byte)CurrentData["GSIceCream.IceCreamMachine.CXB"];
- DLCompleted = (bool)CurrentData["GSIceCream.IceCreamMachine.DLCompleted"] ? "打料完成" : "打料中";
- }
-
-
-
-
-
- Thread.Sleep(500);
- }), "MorkT-状态刷新");
- }
-
- }
- }
|