|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace DataVAPI.Tool.IOT
- {
- /// <summary>
- /// IOT Model
- /// </summary>
- public class IotModel<T>
- {
- 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";
- }
- /// <summary>
- /// IOT 接收数据Model
- /// </summary>
- public class ReceiveModel
- {
- /// <summary>
- /// 设备详细信息
- /// </summary>
- public DevBase deviceContext { get; set; }
- /// <summary>
- /// 设备属性
- /// </summary>
- public ReceiveSXModel props { get; set; }
- /// <summary>
- /// 设备上下线状态
- /// </summary>
- public Vls status { get; set; }
-
- }
- /// <summary>
- /// 接收数据Model
- /// </summary>
- public class ReceiveSXModel
- {
- /// <summary>
- /// 告警消息
- /// </summary>
- public Vls GJXX { get; set; }
- /// <summary>
- /// 扩展属性
- /// </summary>
- public Vls KZSX { get; set; }
- /// <summary>
- /// 基本属性
- /// </summary>
- public Vls JBSX { get; set; }
- /// <summary>
- /// 节点状态
- /// </summary>
- public Vls NodeStatus { get; set; }
- /// <summary>
- /// 日志消息
- /// </summary>
- public Vls SZXX { get; set; }
- }
- /// <summary>
- /// IOT 设备属性 Model
- /// </summary>
- public class IOTDevSXModel
- {
- ///// <summary>
- ///// 硬件状态
- ///// </summary>
- //public string HardwareStatus { get; set; }
- ///// <summary>
- ///// 扩展属性
- ///// </summary>
- //public string KZSX { get; set; }
- ///// <summary>
- ///// 基本属性
- ///// </summary>
- //public string JBSX { get; set; }
- /// <summary>
- /// 节点状态
- /// </summary>
- public string NodeStatus { get; set; }
- ///// <summary>
- ///// 运行日志
- ///// </summary>
- //public string SZXX { get; set; }
- ///// <summary>
- ///// 运行告警
- ///// </summary>
- //public string GJXX { get; set; }
- /// <summary>
- /// Model
- /// </summary>
- public IOTDevSXModel()
- {
-
- }
- /// <summary>
- /// 序列化为JSON
- /// </summary>
- /// <returns></returns>
- public string Tojson()
- {
- try
- {
- IotModel<IOTDevSXModel> iotModel = new IotModel<IOTDevSXModel> { @params = this };
- string json = Tools.JsonConvertTools(iotModel);
- return json;
- }
- catch (Exception ex)
- {
- return string.Empty;
- }
- }
- ///// <summary>
- ///// 设置基本属性
- ///// </summary>
- ///// <param name="devSX"></param>
- ///// <returns></returns>
- //public void SetJBSX(DevSX devSX)
- //{
- // try
- // {
- // JBSX = Tools.JsonConvertTools(devSX);
- // }
- // catch (Exception ex)
- // {
- // JBSX = string.Empty;
- // }
- //}
- ///// <summary>
- ///// 设置基本属性状态
- ///// </summary>
- ///// <param name="devSX"></param>
- ///// <returns></returns>
- //public void SetJBSXStatus(DevSXBase sXBase, bool Status)
- //{
- // try
- // {
- // if (sXBase == null) return;
- // DevSX dev = Tools.JsonToObjectTools<DevSX>(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;
- // }
- //}
- ///// <summary>
- ///// 设置扩展属性
- ///// </summary>
- ///// <param name="devSX"></param>
- //public void SetKZSX(DevSX devSX)
- //{
- // try
- // {
- // KZSX = Tools.JsonConvertTools(devSX);
- // }
- // catch (Exception ex)
- // {
- // KZSX = string.Empty;
- // }
- //}
- ///// <summary>
- ///// 设置扩展属性状态
- ///// </summary>
- ///// <param name="devSX"></param>
- ///// <returns></returns>
- //public void SetKZSXStatus(DevSXBase sXBase, bool Status)
- //{
- // try
- // {
- // if (sXBase == null) return;
- // DevSX dev = Tools.JsonToObjectTools<DevSX>(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;
- // }
- //}
- }
- /// <summary>
- /// 告警消息
- /// </summary>
- public class AlarmMessage
- {
- public List<AlarmModel> data { get; set; }
- }
- /// <summary>
- /// 告警Model
- /// </summary>
- public class AlarmModel : DeviceBase
- {
- /// <summary>
- /// 告警程度:提示 一般 严重
- /// </summary>
- 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; }
- /// <summary>
- /// 颜色
- /// </summary>
- public ALYColor DeviceColor { get; set; }
- }
- /// <summary>
- /// 设备上报属性
- /// </summary>
- public class DevSX
- {
- public List<DevSXBase> data { get; set; }
- }
- /// <summary>
- /// 设备基本属性Model
- /// </summary>
- public class DevSXBase
- {
- /// <summary>
- /// 属性名称
- /// </summary>
- public string SXMC { get; set; }
- /// <summary>
- /// 属性类型
- /// </summary>
- public string SXLX { get; set; }
- /// <summary>
- /// 属性状态
- /// </summary>
- private bool _SXStatus { get; set; }
- public bool SXStatus
- {
- get { return _SXStatus; }
- set
- {
- _SXStatus = value;
- if (_SXStatus)
- {
- SXZT = "正常";
- }
- else
- {
- SXZT = "异常";
- }
- }
- }
- private string _SXZT { get; set; }
- /// <summary>
- /// 属性状态:正常 异常
- /// </summary>
- 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 };
- }
- }
- }
- /// <summary>
- /// 属性异常描述
- /// </summary>
- public string SXYCMS { get; set; }
- public string YCZT { get; set; }
- /// <summary>
- /// 属性颜色
- /// </summary>
- public ALYColor SXYC { get; set; }
- /// <summary>
- /// 按钮文字
- /// </summary>
- public string ButtonText { get; set; }
- /// <summary>
- /// 按钮颜色
- /// </summary>
- 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 };
- }
- }
-
- /// <summary>
- /// 设备颜色
- /// </summary>
- public class ALYColor
- {
- public int r { get; set; }
- public int g { get; set; }
- public int b { get; set; }
- public double a { get; set; }
- }
-
- /// <summary>
- /// 变量
- /// </summary>
- public class Vls
- {
- public long time { get; set; }
- public string value { get; set; }
- }
- }
|