using BPA.Helper; using BPASmartClient.Model.单片机.Enum; using BPASmartClient.SCChip; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BPASmartClient.SCChip { public class ChipStatus : Singleton { private DateTime lastRefreshTime = DateTime.MinValue; /// /// 是否在线 /// public bool OnLine { get { return DateTime.Now.Subtract(lastRefreshTime).TotalSeconds <= 3; } } /// /// 取冰淇淋杯完成 /// public bool CompletedTake_CPU_CUP_ICECREAM { get; set; } /// /// 取咖啡杯完成 /// public bool CompletedTake_CPU_CUP_COFFEE { get; set; } /// /// 1号舵机打开完成 /// public bool CompletedOpen_SE_1 { get; set; } /// /// 2号舵机打开完成 /// public bool CompletedOpen_SE_2 { get; set; } /// /// 3号舵机打开完成 /// public bool CompletedOpen_SE_3 { get; set; } /// /// 1号舵机关闭完成 /// public bool CompletedClose_SE_1 { get; set; } /// /// 2号舵机关闭完成 /// public bool CompletedClose_SE_2 { get; set; } /// /// 3号舵机关闭完成 /// public bool CompletedClose_SE_3 { get; set; } /// /// 是否存在物品 /// public bool ArticleExits { get; set; } /// /// 物品距离 /// public byte ArticleDist { get; set; } public bool CanDo { get { if (!OnLine) return false; return true; } } public void ProcessMsg(ICChipPackage data) { try { switch (data.Cmd) { case IC_CMD.HEART_BEAT: lastRefreshTime = DateTime.Now; break; case IC_CMD.TAKE_CUP: switch ((IC_CUP)data.Value) { case IC_CUP.CUP_COFFEE: CompletedTake_CPU_CUP_COFFEE = true; break; case IC_CUP.CUP_ICECREAM: CompletedTake_CPU_CUP_ICECREAM = true; break; } break; case IC_CMD.OPEN_SE: switch ((IC_SE)data.Value) { case IC_SE.SE_1: CompletedOpen_SE_1 = true; break; case IC_SE.SE_2: CompletedOpen_SE_2 = true; break; case IC_SE.SE_3: CompletedOpen_SE_3 = true; break; } break; case IC_CMD.CLOSE_SE: switch ((IC_SE)data.Value) { case IC_SE.SE_1: CompletedClose_SE_1 = true; break; case IC_SE.SE_2: CompletedClose_SE_2 = true; break; case IC_SE.SE_3: CompletedClose_SE_3 = true; break; } break; case IC_CMD.ARTICLE_EXITS: ArticleExits = data.Value > 0; break; case IC_CMD.ARTICLE_DIST: ArticleDist = data.Value; break; } } catch (Exception ex) { } } } }