|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- using HBLConsole.Service;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace HBLDevice.ICChip
- {
- 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)
- {
-
- }
- }
- }
- }
|