终端一体化运控平台
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ů.
 
 
 

71 řádky
2.0 KiB

  1. using BPASmartClient.EventBus;
  2. using BPASmartClient.Model.PLC;
  3. using BPASmartClient.Model.单片机;
  4. using BPASmartClient.Peripheral;
  5. using BPASmartClient.SerialPort;
  6. using static BPASmartClient.EventBus.EventBus;
  7. namespace BPASmartClient.MCU
  8. {
  9. public class MCUMachine : BasePeripheral
  10. {
  11. MCUSerialHelper mCUSerialHelper = new MCUSerialHelper();
  12. public override void Init()
  13. {
  14. mCUSerialHelper.Open(communicationPar.SerialPort, communicationPar.BaudRate);
  15. EventBus.EventBus.GetInstance().Subscribe<ReadMcu>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  16. {
  17. if (@event == null) return;
  18. var par = @event as ReadMcu;
  19. if (status != null)
  20. {
  21. SetStatus(par?.TagName, mCUSerialHelper.GetInputStatus(Convert.ToByte(par?.ReadPar)));
  22. }
  23. });
  24. EventBus.EventBus.GetInstance().Subscribe<WriteMcu>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  25. {
  26. if (@event == null) return;
  27. var par = @event as WriteMcu;
  28. switch (par?.TagName)
  29. {
  30. case "OutputControl":
  31. mCUSerialHelper.OutputControl(Convert.ToByte(par?.Address), Convert.ToBoolean(par?.Value));
  32. break;
  33. case "ServoControl":
  34. mCUSerialHelper.ServoControl(Convert.ToByte(par?.Address), Convert.ToByte(par?.Value));
  35. break;
  36. default:
  37. break;
  38. }
  39. });
  40. }
  41. //public override void ReadData(string address)
  42. //{
  43. //}
  44. public override void Start()
  45. {
  46. }
  47. public override void Stop()
  48. {
  49. }
  50. public override void WriteData(string address, object value)
  51. {
  52. }
  53. protected override void InitStatus()
  54. {
  55. }
  56. }
  57. }