SimulatorAdsPlcService.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. using MECF.Framework.Common.IOCore;
  2. using MECF.Framework.Common.PLC;
  3. namespace EfemDualSimulator.Instances
  4. {
  5. public class SimulatorAdsPlcService : IWcfPlcService
  6. {
  7. //diVariable="" doVariable="" aiVariable="" aoVariable=""
  8. public bool CheckIsConnected()
  9. {
  10. return true;
  11. }
  12. public bool Read(string variable, out object data, string type, int length, out string reason)
  13. {
  14. reason = string.Empty;
  15. data = null;
  16. switch (variable)
  17. {
  18. case "GVL_IO.PM1_DI_G":
  19. data = IoManager.Instance.GetDiBuffer("PM1.PLC")[0];
  20. break;
  21. case "GVL_IO.PM1_DO_G":
  22. data = IoManager.Instance.GetDoBuffer("PM1.PLC")[0];
  23. break;
  24. case "GVL_IO.PM1_AI_G":
  25. data = IoManager.Instance.GetAiBufferFloat("PM1.PLC")[0];
  26. break;
  27. case "GVL_IO.PM1_AO_G":
  28. data = IoManager.Instance.GetAoBufferFloat("PM1.PLC")[0];
  29. break;
  30. case "GVL_IO.PM2_DI_G":
  31. data = IoManager.Instance.GetDiBuffer("PM2.PLC")[0];
  32. break;
  33. case "GVL_IO.PM2_DO_G":
  34. data = IoManager.Instance.GetDoBuffer("PM2.PLC")[0];
  35. break;
  36. case "GVL_IO.PM2_AI_G":
  37. data = IoManager.Instance.GetAiBufferFloat("PM2.PLC")[0];
  38. break;
  39. case "GVL_IO.PM2_AO_G":
  40. data = IoManager.Instance.GetAoBufferFloat("PM2.PLC")[0];
  41. break;
  42. }
  43. return true;
  44. }
  45. public bool WriteArrayElement(string variable, int index, object value, out string reason)
  46. {
  47. reason = string.Empty;
  48. switch (variable)
  49. {
  50. case "GVL_IO.PM1_DI_G":
  51. break;
  52. case "GVL_IO.PM1_DO_G":
  53. IoManager.Instance.GetDoBuffer("PM1.PLC")[0][index] = (bool)value;
  54. break;
  55. case "GVL_IO.PM1_AI_G":
  56. break;
  57. case "GVL_IO.PM1_AO_G":
  58. IoManager.Instance.GetAoBufferFloat("PM1.PLC")[0][index] = (float)value;
  59. break;
  60. case "GVL_IO.PM2_DI_G":
  61. break;
  62. case "GVL_IO.PM2_DO_G":
  63. IoManager.Instance.GetDoBuffer("PM2.PLC")[0][index] = (bool)value;
  64. break;
  65. case "GVL_IO.PM2_AI_G":
  66. break;
  67. case "GVL_IO.PM2_AO_G":
  68. IoManager.Instance.GetAoBufferFloat("PM2.PLC")[0][index] = (float)value;
  69. break;
  70. }
  71. return true;
  72. }
  73. public bool[] ReadDi(int offset, int size, out string reason)
  74. {
  75. throw new System.NotImplementedException();
  76. }
  77. public float[] ReadAiFloat(int offset, int size, out string reason)
  78. {
  79. throw new System.NotImplementedException();
  80. }
  81. public int[] ReadAiInt(int offset, int size, out string reason)
  82. {
  83. throw new System.NotImplementedException();
  84. }
  85. public short[] ReadAiInt16(int offset, int size, out string reason)
  86. {
  87. throw new System.NotImplementedException();
  88. }
  89. public bool WriteDo(int offset, bool[] buffer, out string reason)
  90. {
  91. throw new System.NotImplementedException();
  92. }
  93. public bool WriteAoFloat(int offset, float[] buffer, out string reason)
  94. {
  95. throw new System.NotImplementedException();
  96. }
  97. public bool WriteAoInt(int offset, int[] buffer, out string reason)
  98. {
  99. throw new System.NotImplementedException();
  100. }
  101. public bool WriteAoInt16(int offset, short[] buffer, out string reason)
  102. {
  103. throw new System.NotImplementedException();
  104. }
  105. public int Heartbeat(int counter)
  106. {
  107. return counter;
  108. }
  109. }
  110. }