using BPA.Utility;
using HBLConsole.Communication;
using HBLConsole.Service;
using HBLDevice.Coffee;
using HBLDevice.IceCream;
using PropertyChanged;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace HBLConsole.Debug
{
[AddINotifyPropertyChangedInterface]
internal class ViewModel_MORKIC
{
public string RobotConnected { get; set; }
public string IceCreamConnected { get; set; }
public string CoffeeConnected { get; set; }
#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 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 = MorkIStatus.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 ? "打料完成" : "打料中";
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();
}
}
}