using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BPASmartClient.KLMCoffee.Protocal { public class UpkeepMessage :BitValue { /// /// 1 冲泡器需要清洗, /// /// public bool 冲泡器需要清洗 { get; set; } /// /// 1 奶沫器需要清洗, /// /// public bool 奶沫器需要清洗 { get; set; } /// /// 1 咖啡机需要除垢, /// /// public bool 咖啡机需要除垢 { get; set; } /// /// 1 需要更换滤芯, /// /// public bool 需要更换滤芯 { get; set; } public UpkeepMessage(byte value) { 冲泡器需要清洗 = GetBitValue(value,3); 奶沫器需要清洗 = GetBitValue(value,2); 咖啡机需要除垢 = GetBitValue(value,1); 需要更换滤芯 = GetBitValue(value,0); } public bool IsUpkeep() { foreach (System.Reflection.PropertyInfo info in this.GetType().GetProperties()) { if ((bool)info.GetValue(this) == true) { return true; } } return false; } public string dataFault() { string message = string.Empty; foreach (System.Reflection.PropertyInfo info in this.GetType().GetProperties()) { if ((bool)info.GetValue(this) == true) { message = message + " " + info.Name; } } return string.IsNullOrEmpty(message) ? "无" : message; } } }