UISender.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. namespace MinicsConsole.Connector;
  2. public class UISender(Hardwares hardwares, HardwareAddress hardwareAddress, ConfigFiles configFiles) : SenderBase_SignalR, IMini8DataNotifier
  3. {
  4. public string Name { get; set; } = "UI";
  5. public void ChannelInfoNotify(byte mini8, byte channel, ChannelData channelData)
  6. {
  7. this.SendAll("ChannelDataUpdate", mini8, channel, channelData);
  8. }
  9. public void Mini8ConnectNotify(byte mini8, bool connected)
  10. {
  11. this.SendAll("Mini8Connect", mini8, connected);
  12. }
  13. public void AlarmNotify(byte mini8, byte channel, float temperature)
  14. {
  15. this.SendAll("AlarmNotify", mini8, channel, temperature);
  16. }
  17. public void AlarmTcBrockenNotify(byte mini8, byte channel)
  18. {
  19. this.SendAll("AlarmTcBrockenNotify", mini8, channel);
  20. }
  21. public bool UpdateMini8(byte mini8Index, Mini8Data mini8)
  22. {
  23. return SendCaller("UpdateMini8", mini8Index, mini8);
  24. }
  25. public bool UpdateAddress(byte mini8Index, Mini8Address mini8)
  26. {
  27. return SendCaller("UpdateAddress", mini8Index, mini8);
  28. }
  29. public bool UpdateMini8All()
  30. {
  31. foreach (KeyValuePair<byte, Mini8Data> mini8 in hardwares.Mini8s)
  32. if (!UpdateMini8(mini8.Key, mini8.Value))
  33. return false;
  34. return true;
  35. }
  36. public bool UpdateAddressAll()
  37. {
  38. foreach (KeyValuePair<byte, Mini8Address> mini8 in hardwareAddress.Mini8sAddress)
  39. if (!UpdateAddress(mini8.Key, mini8.Value))
  40. return false;
  41. return true;
  42. }
  43. public bool UpdateSingleChannel(byte mini8Index, byte channelIndex, ChannelData channel)
  44. {
  45. return SendCaller("UpdateSingleChannel", mini8Index, channelIndex, channel);
  46. }
  47. public bool UpdateChannel(byte channelIndex, ConcurrentDictionary<byte, ChannelData> channel)
  48. {
  49. return SendCaller("UpdateChannel", channelIndex, channel.Values.ToList());
  50. }
  51. public bool UpdateChannelAll()
  52. {
  53. bool result = true;
  54. foreach (KeyValuePair<byte, ConcurrentDictionary<byte, ChannelData>> channel in hardwares.Mini8Channels)
  55. if (!UpdateChannel(channel.Key, channel.Value))
  56. {
  57. result = false;
  58. continue;
  59. }
  60. return result;
  61. }
  62. public bool UpdateDataBaseInfo(int duration, DateTime dateTime)
  63. {
  64. return SendCaller("UpdateDataBaseInfo", duration, dateTime);
  65. }
  66. public bool UpdateFiles(string fileName, TemperatureConfig config)
  67. {
  68. return SendCaller("UpdateFiles", fileName, config);
  69. }
  70. public bool UpdateAllFiles()
  71. {
  72. if (!SendCaller("ClearFiles"))
  73. return false;
  74. foreach (KeyValuePair<string, TemperatureConfig> file in configFiles.Files)
  75. if (!SendCaller("UpdateFiles", file.Value))
  76. return false;
  77. return true;
  78. }
  79. public bool UpdateCurrentFile()
  80. {
  81. return SendCaller("CurrentFile", configFiles.CurrentConfigFile);
  82. }
  83. }