终端一体化运控平台
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

DataServer.cs 3.3 KiB

1年前
1年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. using BPA.Message;
  8. using BPASmartClient.Model;
  9. using BPA.Communication;
  10. using BPA.Communication.Interfaces;
  11. namespace BPASmartClient.MorkMV1
  12. {
  13. public class DataServer
  14. {
  15. private volatile static DataServer _Instance;
  16. public static DataServer GetInstance => _Instance ?? (_Instance = new DataServer());
  17. private DataServer() { }
  18. public ScreenModelMorkS morkS { get; set; } = new ScreenModelMorkS();
  19. //MqttHelper mQTTProxy = new MqttHelper();
  20. ICommMqtt mQTTProxy = CommHelper.MQTT;
  21. public void Init()
  22. {
  23. //mQTTProxy.Connected = new Action(() =>
  24. //{
  25. // mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机));
  26. // TaskManage.GetInstance.StartLong(new Action(() =>
  27. // {
  28. // morkS.MorkS_OrderCount = Json<OrderStatistics>.Data.Count;
  29. // SendScreenDataModel sendScreenDataModel = new SendScreenDataModel();
  30. // sendScreenDataModel.Name = ScreenDeviceType.煮面机;
  31. // sendScreenDataModel.Value = morkS.ToJSON();
  32. // mQTTProxy.Publish(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机), sendScreenDataModel.ToJSON());
  33. // Thread.Sleep(100);
  34. // }), "海科食堂大屏监听");
  35. //});
  36. ////mQTTProxy.Connect("UserName", "Password", "Host", 1883, $"MORKS 设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
  37. //mQTTProxy.Connect(new BPA.Communication.Base.ConfigurationOptions()
  38. //{
  39. // UserName = "UserName",
  40. // Password = "Password",
  41. // IpAddress = "Host",
  42. // Port = 1883,
  43. // ClientId = $"MORKS 设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"
  44. //});
  45. CommHelper.CreateMqtt("Host", "UserName", "Password", $"MORKS 设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}").OnSuccess(s =>
  46. {
  47. mQTTProxy = s.Content;
  48. mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机));
  49. TaskManage.GetInstance.StartLong(new Action(() =>
  50. {
  51. morkS.MorkS_OrderCount = Json<OrderStatistics>.Data.Count;
  52. SendScreenDataModel sendScreenDataModel = new SendScreenDataModel();
  53. sendScreenDataModel.Name = ScreenDeviceType.煮面机;
  54. sendScreenDataModel.Value = morkS.ToJSON();
  55. mQTTProxy.Publish(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机), sendScreenDataModel.ToJSON());
  56. Thread.Sleep(100);
  57. }), "海科食堂大屏监听");
  58. });
  59. }
  60. //订单信息(正在制作,等待制作,制作完成)
  61. //煮面炉上下状态(6个煮面炉上或下)
  62. //温度状态(煮面炉温度是否到达)
  63. //料仓位置(当前料仓在几号位置)
  64. //料仓上下物料检测
  65. //落碗机构缺碗检测
  66. //机器人状态
  67. //当日订单总量
  68. //报警信息
  69. }
  70. }