终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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