IIO.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace VehicleControlSystem.ControlLayer.IO
  7. {
  8. public interface IIO
  9. {
  10. //int GetIOTable( SIOTABLE* Input, SIOTABLE* Output )=0;
  11. int LoadIOMap(string strFileName);
  12. //int SetEtherCatAddress( int* iEcOut, int* iEcIn ) = 0;
  13. /**
  14. * Hilscher Board와의 Communication을 위한 Driver를 Open하며, Board를 초기화하고 통신 대기 상태가 되게 한다.
  15. * @precondition 이 함수는 객체가 생성된후 맨처음 한번만 실행한다. 전에 실행했을 경우는 실행하지 말아야한다.
  16. * @postcondition Hilscher Board가 통신을 위한 준비 상태가 된다.
  17. * @return 0 = Success, 그외 = Error Number
  18. */
  19. int Initialize();
  20. /**
  21. * I/O Device의 Digital Status (Bit) 를 읽어드린다.
  22. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  23. * @param usIOAddr : IO Address
  24. * @param pbVal : IO 값
  25. * @return 0 : SUCCESS
  26. else : Device \Error 코드
  27. */
  28. int GetBit(uint usIOAddr, bool pbval);
  29. /**
  30. * Hilscher Board와의 Communication을 종료하고 Device Driver를 Close한다.
  31. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  32. * @postcondition Hilscher Board와 통신 종결
  33. * @return 0 = Success, 그외 = Error Number
  34. */
  35. int Terminate();
  36. /**
  37. * I/O Device의 Digital Status (Bit) 를 읽어들여 리턴한다.
  38. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  39. * @param usIOAddr : IO Address
  40. * @return TRUE : ON
  41. FALSE : ON이 아님
  42. */
  43. bool IsOn(uint usIOAddr);
  44. /**
  45. * I/O Device의 Digital Status (Bit) 를 읽어들여 리턴한다.
  46. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  47. * @param usIOAddr : IO Address
  48. * @return TRUE : OFF
  49. FALSE : OFF가 아님
  50. */
  51. bool IsOff(uint usIOAddr);
  52. /**
  53. * Output Device에 On Command (Bit = 1) 를 보낸다.
  54. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  55. * @param usIOAddr : IO Address
  56. * @return 0 = Success, 그외 = Error Number
  57. */
  58. int OutputOn(uint usIOAddr);
  59. /**
  60. * Output Device에 Off Command (Bit = 0) 를 보낸다.
  61. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  62. * @param usIOAddr : IO Address
  63. * @return 0 = Success, 그외 = Error Number
  64. */
  65. int OutputOff(uint usIOAddr);
  66. /**
  67. * Output Device의 Digital Status가 Set이면 (Bit = 0), Output Device에 On Command (Bit = 1) 를 보내고,
  68. * Output Device의 Digital Status가 Clear이면 (Bit = 1), Output Device에 Off Command (Bit = 0) 를 보낸다.
  69. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  70. * @param usIOAddr : IO Address
  71. * @return 0 = Success, 그외 = Error Number
  72. */
  73. int OutputToggle(uint usIOAddr);
  74. /**
  75. * 연속된 8개의 IO Address로 구성된 Input Device 들의 Digital Status를 읽어들여 pcValue pointer에 넘겨준다.
  76. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  77. * @param usIOAddr : 연속된 8개의 IO Address를 시작하는 IO Address
  78. * @param pcValuse : 연속된 8개의 IO Address로 구성된 Input Device 들의 Digital Status를 읽어들여 pcValue에 저장한다.
  79. * @return 0 = Success, 그외 = Error Number
  80. */
  81. int GetByte(uint usIOAddr, byte pcValue);
  82. /**
  83. * 연속된 8개의 IO Address로 구성된 Output Device들에 On or Off Command를 보낸다.
  84. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  85. * @param usIOAddr : 연속된 8개의 IO Address를 시작하는 IO Address
  86. * @param pcValuse : Output Device에 보낼 Command를 저장하고 있는 변수이다.
  87. * @return 0 = Success, 그외 = Error Number
  88. */
  89. int PutByte(uint usIOAddr, byte pcValue);
  90. /**
  91. * 연속된 16개의 IO Address로 구성된 Input Device 들의 Digital Status를 읽어들여 pcValue pointer에 넘겨준다.
  92. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  93. * @param usIOAddr : 연속된 16개의 IO Address를 시작하는 IO Address
  94. * @param pwValuse : 연속된 16개의 IO Address로 구성된 Input Device 들의 Digital Status를 읽어들여 pcValue에 저장한다.
  95. * @return 0 = Success, 그외 = Error Number
  96. */
  97. int GetWord(uint usIOAddr, short pwValue);
  98. /**
  99. * 연속된 16개의 IO Address로 구성된 Output Device들에 On or Off Command를 보낸다.
  100. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  101. * @param usIOAddr : 연속된 16개의 IO Address를 시작하는 IO Address
  102. * @param pwValuse : Output Device에 보낼 Command를 저장하고 있는 변수이다.
  103. * @return 0 = Success, 그외 = Error Number
  104. */
  105. int PutWord(uint usIOAddr, short pwValue);
  106. /**
  107. * I/O Device의 Digital Status (Bit) 를 읽어드린다.
  108. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  109. * @param strIOAddr : IO Address String (ex, "1000:START_SW")
  110. * @param pbVal : IO 값
  111. * @return 0 : SUCCESS
  112. else : Device \Error 코드
  113. */
  114. int GetBit(string strIOAddr, bool pbVal);
  115. /**
  116. * I/O Device의 Digital Status (Bit) 를 읽어들여 Bit = 1이면, TRUE(1)를 Return하고, Bit = 0이면 FALSE(0)를 Return한다.
  117. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  118. * @param strIOAddr : IO Address String (ex, "1000:START_SW")
  119. * @param pbVal : 결과값 TRUE/FALSE
  120. * @return 0 : IO값 읽어오기 성공
  121. others : IO값 읽어오기 실패
  122. */
  123. //int IsOn( string strIOAddr, bool pbVal );
  124. bool IsOn(string ioTag, bool isInput = true);
  125. /**
  126. * I/O Device의 Digital Status (Bit) 를 읽어들여 Bit = 1이면, TRUE(1)를 Return하고, Bit = 0이면 FALSE(0)를 Return한다.
  127. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  128. * @param strIOAddr : IO Address String (ex, "1000:START_SW")
  129. * @param pbVal : 결과값 TRUE/FALSE
  130. * @return 0 : IO값 읽어오기 성공
  131. others : IO값 읽어오기 실패
  132. */
  133. //int IsOff( string strIOAddr, bool pbVal );
  134. bool IsOff(string ioTag, bool isInput = true);
  135. /**
  136. * Output Device에 On Command (Bit = 1) 를 보낸다.
  137. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  138. * @param strIOAddr : IO Address String (ex, "1000:START_SW")
  139. * @return 0 = Success, 그외 = Error Number
  140. */
  141. int OutputOn(string outputTag);
  142. /**
  143. * Output Device에 Off Command (Bit = 0) 를 보낸다.
  144. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  145. * @param strIOAddr : IO Address String (ex, "1000:START_SW")
  146. * @return 0 = Success, 그외 = Error Number
  147. */
  148. int OutputOff(string outputTag);
  149. /**
  150. * Output Device의 Digital Status가 Set이면 (Bit = 0), Output Device에 On Command (Bit = 1) 를 보내고,
  151. * Output Device의 Digital Status가 Clear이면 (Bit = 1), Output Device에 Off Command (Bit = 0) 를 보낸다.
  152. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  153. * @param strIOAddr : IO Address String (ex, "1000:START_SW")
  154. * @return 0 = Success, 그외 = Error Number
  155. */
  156. int OutputToggle(string strIOAddr);
  157. /**
  158. * 연속된 8개의 IO Address로 구성된 Input Device 들의 Digital Status를 읽어들여 pcValue pointer에 넘겨준다.
  159. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  160. * @param strIOAddr : 연속된 8개의 IO Address를 시작하는 IO Address의 String Type (ex, "1000:START_SW")
  161. * @param pcValuse : 연속된 8개의 IO Address로 구성된 Input Device 들의 Digital Status를 읽어들여 pcValue에 저장한다.
  162. * @return 0 = Success, 그외 = Error Number
  163. */
  164. int GetByte(string strIOAddr, byte pcValue);
  165. /**
  166. * 연속된 8개의 IO Address로 구성된 Output Device들에 On or Off Command를 보낸다.
  167. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  168. * @param strIOAddr : 연속된 8개의 IO Address를 시작하는 IO Address의 String Type (ex, "1000:START_SW")
  169. * @param pcValuse : Output Device에 보낼 Command를 저장하고 있는 변수이다.
  170. * @return 0 = Success, 그외 = Error Number
  171. */
  172. int PutByte(string strIOAddr, byte pcValue);
  173. /**
  174. * 연속된 16개의 IO Address로 구성된 Input Device 들의 Digital Status를 읽어들여 pcValue pointer에 넘겨준다.
  175. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  176. * @param strIOAddr : 연속된 16개의 IO Address를 시작하는 IO Address의 String Type (ex, "1000:START_SW")
  177. * @param pwValuse : 연속된 16개의 IO Address로 구성된 Input Device 들의 Digital Status를 읽어들여 pcValue에 저장한다.
  178. * @return 0 = Success, 그외 = Error Number
  179. */
  180. int GetWord(string strIOAddr, short pwValue);
  181. /**
  182. * 연속된 16개의 IO Address로 구성된 Output Device들에 On or Off Command를 보낸다.
  183. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  184. * @param strIOAddr : 연속된 16개의 IO Address를 시작하는 IO Address의 String Type (ex, "1000:START_SW")
  185. * @param pwValuse : Output Device에 보낼 Command를 저장하고 있는 변수이다.
  186. * @return 0 = Success, 그외 = Error Number
  187. */
  188. int PutWord(string strIOAddr, short pwValue);
  189. /**
  190. * Incoming Buffer를 Update하고, Outgoing Buffer의 내용을 Physical I/O에 적용하는 IOThread를 Run한다.
  191. * @precondition 이 함수를 실행하기 전에 initialize 함수가 미리 실행되었어야 한다.
  192. * @postcondition Incoming Buffer를 Update하고, Outgoing Buffer의 내용을 Physical I/O에 적용하는 IOThread가 Run한다.
  193. */
  194. void RunIOThread();
  195. ///**
  196. // * Master 모듈 및 Slave 모듈 상태 정보를 얻어온다.
  197. // *
  198. // * @param DnStatus : 마스터와 64개의 Slave에 대한 상태 정보 구조체
  199. // * @return 0 = 모두 정상
  200. // others = 하나라도 실패
  201. // */
  202. //virtual int DnStatusGet(DN_STATUS DnStatus) = 0;
  203. bool IsDeviceOpened();
  204. void WriteOutputIO(string tag, bool on, int after = 0);
  205. bool WaitChangeInputIO(bool exp, int timeout, string tag);
  206. }
  207. }