终端一体化运控平台
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

93 righe
3.1 KiB

  1. using BPA.Helper;
  2. using BPASmartClient.JakaRobot;
  3. using BPASmartClient.Model;
  4. using BPASmartClient.Peripheral;
  5. using static BPA.Helper.EventBus;
  6. namespace BPASmartClient.JAKA
  7. {
  8. public class JakaMachine : BasePeripheral
  9. {
  10. JaKaHelper jaKaHelper = new JaKaHelper();
  11. public override void Init()
  12. {
  13. jaKaHelper.Connect(communicationPar.IPAddress);
  14. TaskManage.GetInstance.StartLong(new Action(() =>
  15. {
  16. IsConnected = jaKaHelper.IsConnected;
  17. if (!IsConnected)
  18. {
  19. IsWork = false;
  20. }
  21. if (IsConnected)
  22. {
  23. IsWork = true;
  24. if (status != null)
  25. {
  26. SetStatus("Get_JakaRobotProgramStatus", (int)jaKaHelper.GetProgramStatus());
  27. SetStatus("Get_JakaRobotAO1", Convert.ToInt32(jaKaHelper.Get_RobotAO1()));
  28. SetStatus("Get_JakaRobotDI0", jaKaHelper.Get_RobotDI(0));
  29. SetStatus("Get_JakaRobotDI1", jaKaHelper.Get_RobotDI(1));
  30. SetStatus("Get_JakaRobotDI2", jaKaHelper.Get_RobotDI(2));
  31. SetStatus("Get_JakaRobotDI3", jaKaHelper.Get_RobotDI(3));
  32. SetStatus("Get_JakaRobotDI5", jaKaHelper.Get_RobotDI(5));
  33. }
  34. Thread.Sleep(500);
  35. }
  36. Thread.Sleep(1000);
  37. }), $"设备[{DeviceId}]节卡机器人读取线程", true);
  38. EventBus.GetInstance().Subscribe<WriteJaka>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  39. {
  40. if (@event == null) return;
  41. var par = @event as WriteJaka;
  42. switch (par?.TagName)
  43. {
  44. case "Power_On":
  45. jaKaHelper.Power_On();
  46. break;
  47. case "Enable_robot":
  48. jaKaHelper.Enable_robot();
  49. break;
  50. case "Set_RobotAO1":
  51. if (par?.Value is int intvalue) jaKaHelper.Set_RobotAO1(intvalue);
  52. break;
  53. case "JaKaProgramName":
  54. if (par?.Value is string stringvalue) jaKaHelper.JaKaProgramName(stringvalue);
  55. break;
  56. case "JakaDOutput":
  57. if (par?.Value is bool DO_value && par?.DO_Index is int DO_Index) jaKaHelper.Set_RobotDO(DO_Index, DO_value);
  58. break;
  59. default:
  60. break;
  61. }
  62. });
  63. }
  64. //public override void ReadData(string address)
  65. //{
  66. //}
  67. public override void Start()
  68. {
  69. }
  70. public override void Stop()
  71. {
  72. }
  73. public override void WriteData(string address, object value)
  74. {
  75. }
  76. protected override void InitStatus()
  77. {
  78. }
  79. }
  80. }