using BPA.Utility; using HBLConsole.Communication; using HBLConsole.Service; using HBLDevice.Coffee; using HBLDevice.ICChip; using HBLDevice.IceCream; using PropertyChanged; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using HBLConsole.Service; namespace HBLConsole.Debug { [AddINotifyPropertyChangedInterface] internal class ViewModel_MORKIC { public string RobotConnected { get; set; } public string IceCreamConnected { get; set; } public string CoffeeConnected { get; set; } public void SimCoffee() { Task.Run(new Action(() => { ActionManage.GetInstance.Send("SimCoffee", (DrCoffeeDrinksCode)Enum.Parse(typeof(DrCoffeeDrinksCode), SelectedCoffee)); })); } public void SimIceCream() { ActionManage.GetInstance.Send("SimIceCream"); } #region 咖啡机 /// /// 咖啡机状态 /// public DrCoffeeStatus CoffeeStatus { get; set; } /// /// 应用状态 /// public DrCoffeeAppStatus AppStatus { get; set; } public DrCoffeeWarning Warning { get; set; } /// /// 故障信息 /// public DrCoffeeFault CaffeeFault { get; set; } public List Coffees { get; set; } = new List(); public string SelectedCoffee { get; set; } public List CoffeeCmds { get; set; } = new List(); public string SelectedCoffeeCmd { get; set; } #endregion #region 冰淇淋 ///// ///// 预冷温度 ///// //public short YLWD { get; set; } ///// ///// 回气温度 ///// //public short HQWD { get; set; } ///// ///// 环境温度 ///// //public short HJWD { get; set; } ///// ///// 电流 ///// //public short DL { get; set; } ///// ///// 电压 ///// //public short DY { get; set; } ///// ///// 当前模式 ///// //public MORKI_MODE CurrentMode { get; set; } ///// ///// 故障 ///// //public MORKI_FAULT IceCreamFault { get; set; } ///// ///// 成型比 ///// //public byte CXB { get; set; } ///// ///// 打料完成状态 ///// //public string DLCompleted { get; set; } public string HasArticle { get; set; } public byte ArticleDist { get; set; } = 0; public List IceCreamModes { get; set; } = new List(); public string SelecteIceCreamdMode { get; set; } #endregion public ViewModel_MORKIC() { 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(() => { RobotConnected = LebaiHelper.GetInstance.IsConnected ? "已连接" : "未连接"; IceCreamConnected = ChipStatus.GetInstance().OnLine ? "已连接" : "未连接"; CoffeeConnected = MorkCStatus.GetInstance().OnLine ? "已连接" : "未连接"; CoffeeStatus = MorkCStatus.GetInstance().CoffeeStatus; AppStatus = MorkCStatus.GetInstance().AppStatus; Warning = MorkCStatus.GetInstance().Warning; CaffeeFault = MorkCStatus.GetInstance().Fault; //YLWD = MorkIStatus.GetInstance().YLWD; //HQWD = MorkIStatus.GetInstance().HQWD; //HJWD = MorkIStatus.GetInstance().HJWD; //DL = MorkIStatus.GetInstance().DL; //DY = MorkIStatus.GetInstance().DY; //CurrentMode = MorkIStatus.GetInstance().CurrentMode; //IceCreamFault = MorkIStatus.GetInstance().Fault; //CXB = MorkIStatus.GetInstance().CXB; //DLCompleted = MorkIStatus.GetInstance().DLCompleted ? "打料完成" : "打料中"; HasArticle = ChipStatus.GetInstance().ArticleExits ? "存在" : "无"; ArticleDist = ChipStatus.GetInstance().ArticleDist; Thread.Sleep(500); }), "MORK IC-状态刷新"); } public void MakeIceCream() { DischargeEvent dischargeEvent = new DischargeEvent(); dischargeEvent.Publish(); } public void SetIceCreamModel() { ModeSetEvent modeSetEvent = new ModeSetEvent(); modeSetEvent.Mode = (MORKI_MODE)Enum.Parse(typeof(MORKI_MODE), SelecteIceCreamdMode); modeSetEvent.Publish(); } public void MakeCoffee() { new MakeCoffeeEvent() { DrinkCode = (DrCoffeeDrinksCode)Enum.Parse(typeof(DrCoffeeDrinksCode), SelectedCoffee) }.Publish(); } public void StopMakeCoffee() { new CancelMakeCoffeeEvent().Publish(); } public void SetCoffeeModel() { new CoffeeCommCmdEvent() { CommCmd = (DrCoffeeCommCmd)Enum.Parse(typeof(DrCoffeeCommCmd), SelectedCoffeeCmd) }.Publish(); } public void OpenSE1() { new SESwitchCreamEvent() { SteeringEngine = IC_SE.SE_1, IsOpen = true }.Publish(); } public void CloseSE1() { new SESwitchCreamEvent() { SteeringEngine = IC_SE.SE_1, IsOpen = false }.Publish(); } public void OpenSE2() { new SESwitchCreamEvent() { SteeringEngine = IC_SE.SE_2, IsOpen = true }.Publish(); } public void CloseSE2() { new SESwitchCreamEvent() { SteeringEngine = IC_SE.SE_2, IsOpen = false }.Publish(); } public void OpenSE3() { new SESwitchCreamEvent() { SteeringEngine = IC_SE.SE_3, IsOpen = true }.Publish(); } public void CloseSE3() { new SESwitchCreamEvent() { SteeringEngine = IC_SE.SE_3, IsOpen = false }.Publish(); } public void TurnRoll() { new RotorSwitchEvent() { TurnOn = true }.Publish(); } public void StopTurnRoll() { new RotorSwitchEvent() { TurnOn = false }.Publish(); } public void MakeIceCreamBySE1() { new MakeIceCreamEvent() { SteeringEngine = IC_SE.SE_1 }.Publish(); } public void DoHasArticle() { new ArticleExitsEvent().Publish(); } public void DoArticleDist() { new ArticleDistEvent().Publish(); } } }