- using BPASmartClient.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<ChipStatus>
- {
- private DateTime lastRefreshTime = DateTime.MinValue;
- /// <summary>
- /// 是否在线
- /// </summary>
- public bool OnLine { get { return DateTime.Now.Subtract(lastRefreshTime).TotalSeconds <= 3; } }
- /// <summary>
- /// 取冰淇淋杯完成
- /// </summary>
- public bool CompletedTake_CPU_CUP_ICECREAM { get; set; }
- /// <summary>
- /// 取咖啡杯完成
- /// </summary>
- public bool CompletedTake_CPU_CUP_COFFEE { get; set; }
- /// <summary>
- /// 1号舵机打开完成
- /// </summary>
- public bool CompletedOpen_SE_1 { get; set; }
- /// <summary>
- /// 2号舵机打开完成
- /// </summary>
- public bool CompletedOpen_SE_2 { get; set; }
- /// <summary>
- /// 3号舵机打开完成
- /// </summary>
- public bool CompletedOpen_SE_3 { get; set; }
- /// <summary>
- /// 1号舵机关闭完成
- /// </summary>
- public bool CompletedClose_SE_1 { get; set; }
- /// <summary>
- /// 2号舵机关闭完成
- /// </summary>
- public bool CompletedClose_SE_2 { get; set; }
- /// <summary>
- /// 3号舵机关闭完成
- /// </summary>
- public bool CompletedClose_SE_3 { get; set; }
- /// <summary>
- /// 是否存在物品
- /// </summary>
- public bool ArticleExits { get; set; }
- /// <summary>
- /// 物品距离
- /// </summary>
- 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)
- {
-
- }
- }
- }
- }
|