EPDClient.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using EPInterface.Data;
  5. using System.ServiceModel;
  6. using Aitex.Core.Util;
  7. using Aitex.Core.WCF;
  8. using EPInterface.Datas;
  9. using MECF.Framework.Common.Utilities;
  10. namespace EPInterface
  11. {
  12. public class EPDClient : Singleton<EPDClient>
  13. {
  14. private IEPDService _service;
  15. public IEPDService Service
  16. {
  17. get
  18. {
  19. if (_service == null)
  20. {
  21. _service = new EPDServiceClient();
  22. }
  23. return _service;
  24. }
  25. }
  26. }
  27. public class EPDServiceClient : ServiceClientWrapper<IEPDService>, IEPDService
  28. {
  29. public EPDServiceClient()
  30. : base("Client_IEPDService", "EPDService")
  31. {
  32. }
  33. public void SetModel(int channel,string name, string model)
  34. {
  35. Invoke(svc => { svc.SetModel(channel, name, model); });
  36. }
  37. public int Heartbeat(int counter)
  38. {
  39. int result = 0;
  40. Invoke(svc => { result = svc.Heartbeat(counter); });
  41. return result;
  42. }
  43. public void Online()
  44. {
  45. Invoke(svc => { svc.Online(); });
  46. }
  47. public void Offline()
  48. {
  49. Invoke(svc => { svc.Offline(); });
  50. }
  51. public bool IsOnline()
  52. {
  53. bool result = false;
  54. Invoke(svc => { result = svc.IsOnline(); });
  55. return result;
  56. }
  57. public void SetOption(string name, string value)
  58. {
  59. Invoke(svc => { svc.SetOption(name, value); });
  60. }
  61. public string GetOption(string name )
  62. {
  63. string result = string.Empty;
  64. Invoke(svc => { result = svc.GetOption(name); });
  65. return result;
  66. }
  67. public void RecipeStart(int channel, string name)
  68. {
  69. Invoke(svc => { svc.RecipeStart(channel, name); });
  70. }
  71. public void RecipeStop(int channel)
  72. {
  73. Invoke(svc => { svc.RecipeStop(channel); });
  74. }
  75. public void Start(int channel,int idx, string name, string model)
  76. {
  77. Invoke(svc => { svc.Start(channel, idx, name, model); });
  78. }
  79. public void StartByConfig(int channel, int idx, string name, EPDConfig config)
  80. {
  81. Invoke(svc => { svc.StartByConfig(channel, idx, name, config); });
  82. }
  83. public void Stop(int channel)
  84. {
  85. Invoke(svc => { svc.Stop(channel); });
  86. }
  87. public void Pause(int channel)
  88. {
  89. Invoke(svc => { svc.Pause(channel); });
  90. }
  91. public void Resume(int channel)
  92. {
  93. Invoke(svc => { svc.Resume(channel); });
  94. }
  95. public int QueryChannels()
  96. {
  97. int result = 0;
  98. Invoke(svc => { result = svc.QueryChannels(); });
  99. return result;
  100. }
  101. public List<string> QueryChannelNames()
  102. {
  103. List<string> result = new List<string>();
  104. Invoke(svc => { result = svc.QueryChannelNames(); });
  105. return result;
  106. }
  107. public string QueryChannelName(int channel)
  108. {
  109. string result = "";
  110. Invoke(svc => { result = svc.QueryChannelName(channel); });
  111. return result;
  112. }
  113. public Tuple<string,string> QueryModel(int channel)
  114. {
  115. Tuple<string, string> result = null;
  116. Invoke(svc => { result = svc.QueryModel(channel); });
  117. return result;
  118. }
  119. public double[] QueryWave(int channel)
  120. {
  121. double[] result = null;
  122. Invoke(svc => { result = svc.QueryWave(channel); });
  123. return result;
  124. }
  125. public CRawDataItem QueryData(int channel)
  126. {
  127. CRawDataItem result = default(CRawDataItem) ;
  128. Invoke(svc => { result = svc.QueryData(channel); });
  129. return result;
  130. }
  131. public EPDState QueryState(int channel)
  132. {
  133. EPDState result = EPDState.UnSampling;
  134. Invoke(svc => { result = svc.QueryState(channel); });
  135. return result;
  136. }
  137. public bool QueryRecordState(int channel)
  138. {
  139. bool result = false;
  140. Invoke(svc => { result = svc.QueryRecordState(channel); });
  141. return result;
  142. }
  143. public long QueryRecipeTime(int channel)
  144. {
  145. long result = 0;
  146. Invoke(svc => { result = svc.QueryRecipeTime(channel); });
  147. return result;
  148. }
  149. public List<long> QueryStepTime(int channel)
  150. {
  151. List<long> result = new List<long>();
  152. Invoke(svc => { result = svc.QueryStepTime(channel); });
  153. return result;
  154. }
  155. public List<string> QueryConfigList()
  156. {
  157. List<string> result = new List<string>();
  158. Invoke(svc => { result = svc.QueryConfigList(); });
  159. return result;
  160. }
  161. public string QueryConfig(string name)
  162. {
  163. string result = string.Empty;
  164. Invoke(svc => { result = svc.QueryConfig(name); });
  165. return result;
  166. }
  167. }
  168. }