WcfPlcServiceClient.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using Aitex.Core.WCF;
  2. namespace MECF.Framework.Common.PLC
  3. {
  4. public class WcfPlcServiceClient : ServiceClientWrapper<IWcfPlcService>, IWcfPlcService
  5. {
  6. public WcfPlcServiceClient(string configName)
  7. : base(configName, "WcfPlcService")
  8. {
  9. }
  10. public WcfPlcServiceClient()
  11. : base("Client_IWcfPlcService", "WcfPlcService")
  12. {
  13. }
  14. public bool Read(string variable, out object data, string type, int length, out string reason)
  15. {
  16. bool result = false;
  17. object data1 = null;
  18. string reason1 = string.Empty;
  19. Invoke(svc =>
  20. {
  21. result = svc.Read(variable, out data1, type, length, out reason1);
  22. });
  23. data = data1;
  24. reason = reason1;
  25. return result;
  26. }
  27. public bool WriteArrayElement(string variable, int index, object value, out string reason)
  28. {
  29. bool result = false;
  30. string reason1 = string.Empty;
  31. Invoke(svc =>
  32. {
  33. result = svc.WriteArrayElement(variable, index, value, out reason1);
  34. });
  35. reason = reason1;
  36. return result;
  37. }
  38. public int Heartbeat(int counter)
  39. {
  40. int result = 0;
  41. Invoke(svc =>
  42. {
  43. result = svc.Heartbeat(counter);
  44. });
  45. return result;
  46. }
  47. public bool[] ReadDi(int offset, int size, out string reason)
  48. {
  49. bool[] result = null;
  50. string reason1 = string.Empty;
  51. Invoke(svc => { result = svc.ReadDi(offset, size, out reason1); });
  52. reason = reason1;
  53. return result;
  54. }
  55. public float[] ReadAiFloat(int offset, int size, out string reason)
  56. {
  57. float[] result = null;
  58. string reason1 = string.Empty;
  59. Invoke(svc => { result = svc.ReadAiFloat(offset, size, out reason1); });
  60. reason = reason1;
  61. return result;
  62. }
  63. public int[] ReadAiInt(int offset, int size, out string reason)
  64. {
  65. int[] result = null;
  66. string reason1 = string.Empty;
  67. Invoke(svc => { result = svc.ReadAiInt(offset, size, out reason1); });
  68. reason = reason1;
  69. return result;
  70. }
  71. public short[] ReadAiInt16(int offset, int size, out string reason)
  72. {
  73. short[] result = null;
  74. string reason1 = string.Empty;
  75. Invoke(svc => { result = svc.ReadAiInt16(offset, size, out reason1); });
  76. reason = reason1;
  77. return result;
  78. }
  79. public bool WriteDo(int offset, bool[] buffer, out string reason)
  80. {
  81. bool result = false;
  82. string reason1 = string.Empty;
  83. Invoke(svc => { result = svc.WriteDo(offset, buffer, out reason1); });
  84. reason = reason1;
  85. return result;
  86. }
  87. public bool WriteAoFloat(int offset, float[] buffer, out string reason)
  88. {
  89. bool result = false;
  90. string reason1 = string.Empty;
  91. Invoke(svc => { result = svc.WriteAoFloat(offset, buffer, out reason1); });
  92. reason = reason1;
  93. return result;
  94. }
  95. public bool WriteAoInt(int offset, int[] buffer, out string reason)
  96. {
  97. bool result = false;
  98. string reason1 = string.Empty;
  99. Invoke(svc => { result = svc.WriteAoInt(offset, buffer, out reason1); });
  100. reason = reason1;
  101. return result;
  102. }
  103. public bool WriteAoInt16(int offset, short[] buffer, out string reason)
  104. {
  105. bool result = false;
  106. string reason1 = string.Empty;
  107. Invoke(svc => { result = svc.WriteAoInt16(offset, buffer, out reason1); });
  108. reason = reason1;
  109. return result;
  110. }
  111. }
  112. }