using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DataVAPI.Tool.IOT { /// /// IOT Model /// public class IotModel { public string id { get; set; } = Guid.NewGuid().ToString(); public string version { get; set; } = "1.0"; public T @params { get; set; } public string method { get; set; } = "thing.event.property.post"; } /// /// IOT 接收数据Model /// public class ReceiveModel { /// /// 设备详细信息 /// public DevBase deviceContext { get; set; } /// /// 设备属性 /// public ReceiveSXModel props { get; set; } /// /// 设备上下线状态 /// public Vls status { get; set; } } /// /// 接收数据Model /// public class ReceiveSXModel { /// /// 告警消息 /// public Vls GJXX { get; set; } /// /// 扩展属性 /// public Vls KZSX { get; set; } /// /// 基本属性 /// public Vls JBSX { get; set; } /// /// 节点状态 /// public Vls NodeStatus { get; set; } /// /// 日志消息 /// public Vls SZXX { get; set; } } /// /// IOT 设备属性 Model /// public class IOTDevSXModel { /// /// 设备一状态 /// public string Device1 { get; set; } /// /// 设备二状态 /// public string Device2 { get; set; } /// /// 设备三状态 /// public string Device3 { get; set; } /// /// 节点状态 /// public string NodeStatus { get; set; } /// /// 维修保护 /// public string Maintain { get; set; } ///// ///// 运行告警 ///// //public string GJXX { get; set; } /// /// Model /// public IOTDevSXModel() { } /// /// 序列化为JSON /// /// public string Tojson() { try { IotModel iotModel = new IotModel { @params = this }; string json = Tools.JsonConvertTools(iotModel); return json; } catch (Exception ex) { return string.Empty; } } ///// ///// 设置基本属性 ///// ///// ///// //public void SetJBSX(DevSX devSX) //{ // try // { // JBSX = Tools.JsonConvertTools(devSX); // } // catch (Exception ex) // { // JBSX = string.Empty; // } //} ///// ///// 设置基本属性状态 ///// ///// ///// //public void SetJBSXStatus(DevSXBase sXBase, bool Status) //{ // try // { // if (sXBase == null) return; // DevSX dev = Tools.JsonToObjectTools(JBSX); // dev.data?.ForEach(x => // { // if (x.SXMC == sXBase.SXMC && x.SXLX == sXBase.SXLX) // { // x.SXStatus = Status; // } // }); // JBSX = Tools.JsonConvertTools(dev); // } // catch (Exception ex) // { // JBSX = string.Empty; // } //} ///// ///// 设置扩展属性 ///// ///// //public void SetKZSX(DevSX devSX) //{ // try // { // KZSX = Tools.JsonConvertTools(devSX); // } // catch (Exception ex) // { // KZSX = string.Empty; // } //} ///// ///// 设置扩展属性状态 ///// ///// ///// //public void SetKZSXStatus(DevSXBase sXBase, bool Status) //{ // try // { // if (sXBase == null) return; // DevSX dev = Tools.JsonToObjectTools(KZSX); // dev.data?.ForEach(x => // { // if (x.SXMC == sXBase.SXMC && x.SXLX == sXBase.SXLX) // { // x.SXStatus = Status; // } // }); // KZSX = Tools.JsonConvertTools(dev); // } // catch (Exception ex) // { // KZSX = string.Empty; // } //} } /// /// 告警消息 /// public class AlarmMessage { public List data { get; set; } } /// /// 告警Model /// public class AlarmModel : DeviceBase { /// /// 告警程度:提示 一般 严重 /// public string AlarmCD { get { return _AlarmCD; } set { _AlarmCD = value; if (_AlarmCD == "提示") DeviceColor = new ALYColor { r = 13, g = 254, b = 73, a = 1 }; else if (_AlarmCD == "一般") DeviceColor = new ALYColor { r = 245, g = 216, b = 13, a = 1 }; else if (_AlarmCD == "严重") DeviceColor = new ALYColor { r = 245, g = 13, b = 13, a = 1 }; } } private string _AlarmCD { get; set; } /// /// 颜色 /// public ALYColor DeviceColor { get; set; } } /// /// 设备上报属性 /// public class DevSX { public List data { get; set; } } /// /// 设备基本属性Model /// public class DevSXBase { /// /// 属性名称 /// public string SXMC { get; set; } /// /// 属性类型 /// public string SXLX { get; set; } /// /// 属性状态 /// private bool _SXStatus { get; set; } public bool SXStatus { get { return _SXStatus; } set { _SXStatus = value; if (_SXStatus) { SXZT = "正常"; } else { SXZT = "异常"; } } } private string _SXZT { get; set; } /// /// 属性状态:正常 异常 /// public string SXZT { get { return _SXZT; } set { _SXZT = value; if (_SXZT == "正常") { SXYC = new ALYColor { r = 13, g = 254, b = 73, a = 1 };//绿色 SXYCMS = ""; YCZT = ""; ButtonText = ""; ButtonYC = new ALYColor { r = 0, g = 0, b = 0, a = 0 }; } else if (_SXZT == "异常") { SXYC = new ALYColor { r = 245, g = 13, b = 13, a = 1 };//红色 ButtonText = "详情"; ButtonYC = new ALYColor { r = 48, g = 109, b = 201, a = 0.18 }; } } } /// /// 属性异常描述 /// public string SXYCMS { get; set; } public string YCZT { get; set; } /// /// 属性颜色 /// public ALYColor SXYC { get; set; } /// /// 按钮文字 /// public string ButtonText { get; set; } /// /// 按钮颜色 /// public ALYColor ButtonYC { get; set; } public DevSXBase() { SXZT = ""; SXYC = new ALYColor { r = 13, g = 254, b = 73, a = 1 };//绿色 SXYCMS = ""; YCZT = ""; ButtonText = ""; ButtonYC = new ALYColor { r = 0, g = 0, b = 0, a = 0 }; } } /// /// 设备颜色 /// public class ALYColor { public int r { get; set; } public int g { get; set; } public int b { get; set; } public double a { get; set; } } /// /// 变量 /// public class Vls { public long time { get; set; } public string value { get; set; } } }