Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

76 řádky
3.2 KiB

  1. using HBLConsole.Model;
  2. using HBLConsole.Service;
  3. using Newtonsoft.Json;
  4. using System;
  5. using System.Text;
  6. using HBLConsole.Communication;
  7. using System.Threading;
  8. namespace HBLConsole.Business
  9. {
  10. public class M2MqttHelper
  11. {
  12. private volatile static M2MqttHelper _Instance;
  13. public static M2MqttHelper GetInstance => _Instance ?? (_Instance = new M2MqttHelper());
  14. private M2MqttHelper() { }
  15. IotMessage iotMessage = new IotMessage();
  16. LowerComputerStateInfo lowerComputerStateInfoClass = new LowerComputerStateInfo();
  17. string PublishContent;
  18. public void Init()
  19. {
  20. ThreadManage.GetInstance.StartLong(new Action(() =>
  21. {
  22. //AlarmHelper.GetInstance.EdgeAlarm(GVL_Fault.GetInstance.MCUDisconnected, "单片机掉线", AlarmLevel.严重报警);
  23. //AlarmHelper.GetInstance.EdgeAlarm(GVL_Fault.GetInstance.IceCreamAbnormal, "冰淇淋机异常");
  24. //AlarmHelper.GetInstance.EdgeAlarm(GVL_Fault.GetInstance.TakeBowlAbnormal, "取碗异常");
  25. //AlarmHelper.GetInstance.EdgeAlarm(GVL_Fault.GetInstance.RobotAbnormal, "机器人异常", AlarmLevel.严重报警);
  26. #region 报警信息设置
  27. lowerComputerStateInfoClass.AlarmInfo.Clear();
  28. //foreach (var item in AlarmHelper.GetInstance.GetAlarmInfo)
  29. //{
  30. // lowerComputerStateInfoClass.AlarmInfo.Add(new IotAlarmInfo()
  31. // {
  32. // time = item.date,
  33. // AlarmLevel = item.AlarmLevel,
  34. // info = item.AlarmInfomation,
  35. // color = new ColorSet()
  36. // {
  37. // a = AlarmHelper.GetInstance.colorValue[item.AlarmLevel].A,
  38. // b = AlarmHelper.GetInstance.colorValue[item.AlarmLevel].B,
  39. // g = AlarmHelper.GetInstance.colorValue[item.AlarmLevel].G,
  40. // r = AlarmHelper.GetInstance.colorValue[item.AlarmLevel].R,
  41. // },
  42. // infoSrc = ""
  43. // });
  44. //}
  45. #endregion
  46. #region 报警频率显示
  47. lowerComputerStateInfoClass.AlarmHzObj.Clear();
  48. foreach (var item in Json<AlarmHzParameter>.Data.AlarmHz)
  49. {
  50. lowerComputerStateInfoClass.AlarmHzObj.Add(new AlarmHz() { Count = item.Value, Name = item.Key });
  51. }
  52. #endregion
  53. #region 忙碌状态显示
  54. //lowerComputerStateInfoClass.Busy = GVL_VAR.GetInstance.Busy ? "空闲" : "忙碌";
  55. #endregion
  56. iotMessage.@params.LowerComputerStateInfo = JsonConvert.SerializeObject(lowerComputerStateInfoClass);
  57. PublishContent = JsonConvert.SerializeObject(iotMessage);
  58. MqttM2.GetInstance.PublishInfo(PublishContent);
  59. //mqttClient.Publish($"/sys/grgp0rFA2uu/{deviceName}/thing/event/property/post", Encoding.UTF8.GetBytes(PublishContent), 0, false);
  60. }), "阿里云数据上报", false, new Action(() => { MqttM2.GetInstance.DisConnect(); }));
  61. }
  62. }
  63. }