Slave_Ports_Status.cpp 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. #include "Slave_Ports_Status.h"
  2. /*Slave_Ports_Status::Slave_Ports_Status(Client& client) : m_client(client) {
  3. m_accountName = NULL;
  4. m_appKeyName = NULL;
  5. m_appKeyValue = NULL;
  6. m_path = NULL;
  7. m_nextChar = NULL;
  8. m_nextState = END;
  9. }
  10. */
  11. /*
  12. Slave_Ports_Status::Slave_Ports_Status(Client& client) : m_client(client) {
  13. m_accountName = NULL;
  14. m_appKeyName = NULL;
  15. m_appKeyValue = NULL;
  16. m_path = NULL;
  17. m_nextChar = NULL;
  18. m_nextState = END;
  19. }
  20. */
  21. /*
  22. void Slave_Ports_Status::push() { //
  23. }
  24. */
  25. Slave_Ports_Status::Slave_Ports_Status(){
  26. Serial.print("#35 Slave_Ports_Status::Slave_Ports_Status():");
  27. _count = 0 ;
  28. Slave_Ports_Status_T Slave_Ports_Status_A[10];
  29. // Slave_Ports_Status_QUEUE_T Slave_Ports_Status_QUEUE_A[10] ;
  30. //_queue_id_current = 0 ;
  31. //_queue_count = 0;
  32. }
  33. /*
  34. inline int Slave_Ports_Status::add(Slave_Ports_Status_T item)
  35. {
  36. Serial.print("Add item... _count["); Serial.print(item.Port_ID);
  37. Serial.print("] 0 ["); Serial.print(item.Port_ID);
  38. Serial.print("1 ["); Serial.print(item._Slave_ID);
  39. Serial.print("2 ["); Serial.print(item.PortTypes);
  40. Serial.print("3 ["); Serial.print(item.Address);
  41. Serial.print("4 ["); Serial.print(item.LocalPort);
  42. Serial.print("5 ["); Serial.print(item.Exp_state);
  43. Serial.print("6 ["); Serial.print(item.Exp_state_ttl);
  44. Serial.print("7 ["); Serial.print(item.Broadcast_state);
  45. Serial.println("]");
  46. return 1 ;
  47. }
  48. */
  49. /*
  50. void Slave_Ports_Status::I2C_driver_FS(int I2C_driver) { //char*
  51. // Serial.print("I2C_driver_FS[");
  52. //Serial.print(I2C_driver_F(_NOT_USED_));
  53. if(I2C_driver_NOT_USED_ == I2C_driver) {
  54. Serial.println("_NOT_USED_");
  55. // I2C_driver_FT = "_NOT_USED______________";
  56. //return "_NOT_USED______________";
  57. }
  58. else if( I2C_driver_Adafruit_PWMServoDriver == I2C_driver) {
  59. Serial.println("Adafruit_PWMServoDriver");
  60. //12345678901234567890134
  61. // I2C_driver_FT = "Adafruit_PWMServoDriver";
  62. // return "Adafruit_PWMServoDriver";
  63. } else {
  64. Serial.print("_UNKNOWN_");
  65. // I2C_driver_FT = "_UNKNOWN_______________";
  66. // return "_UNKNOWN_______________";
  67. }
  68. // sprintf(I2C_driver_FT, "%02d", 1);
  69. // return I2C_driver_FT;
  70. }
  71. */
  72. void Slave_Ports_Status::add_port(
  73. int Port_ID,
  74. int _Slave_ID,
  75. int PortTypes,
  76. int Address,
  77. int LocalPort,
  78. int Exp_state,
  79. int Exp_state_ttl,
  80. int Broadcast_state,
  81. int I2C_port,
  82. //int I2C_driver
  83. int I2C_driver
  84. )
  85. {
  86. Serial.print("#112 add_port _count[");
  87. Serial.print(this->_count);
  88. Serial.print("] _count + 1["); Serial.print(this->_count + 1);
  89. Serial.print("] Port_ID["); Serial.print(Port_ID);
  90. Serial.print("] _Slave_ID[0x"); Serial.print( _Slave_ID);
  91. Serial.print("] PortTypes["); Serial.print(PortTypes);
  92. Serial.print("] Address["); Serial.print(Address);
  93. Serial.print("] LocalPort["); Serial.print(LocalPort);
  94. Serial.print("] Exp_state["); Serial.print(Exp_state);
  95. // Serial.print("] Exp_state_ttl["); Serial.print(Exp_state_ttl);
  96. // Serial.print("] Broadcast_state["); Serial.print(Broadcast_state);
  97. // Serial.print("] I2C_port["); Serial.print(I2C_port);
  98. // Serial.print("] I2C_driver["); I2C_driver_FS(I2C_driver);
  99. //Serial.print("] I2C_driver_Rev[");
  100. //unsigned char LCDarray1buf[24];
  101. //LCDarray1.toCharArray(LCDarray1buf, 24);
  102. // I2C_driver_FT[24] = I2C_driver_FS(I2C_driver_F(I2C_driver)) ;
  103. Serial.println("]");
  104. //Slave_Ports_Status_A[_count + 1].Port_ID = Port_ID ;
  105. if(this->_count == 0) {
  106. this->Slave_Ports_Status_A[_count ].Port_ID=0x00;
  107. this->Slave_Ports_Status_A[_count ]._Slave_ID=0x00;
  108. this->Slave_Ports_Status_A[_count ].PortTypes=0x00;
  109. this->Slave_Ports_Status_A[_count ].Address=0x00;
  110. this->Slave_Ports_Status_A[_count ].LocalPort=0x00;
  111. this->Slave_Ports_Status_A[_count ].Exp_state=0x00;
  112. this->Slave_Ports_Status_A[_count ].Exp_state_ttl=0x00;
  113. this->Slave_Ports_Status_A[_count ].Broadcast_state=0x00;
  114. this->Slave_Ports_Status_A[_count ].I2C_port=0x00;
  115. this->Slave_Ports_Status_A[_count ].I2C_driver=0x00;
  116. //_count ++;
  117. this->_count ++;
  118. /* Slave_Ports_Status::add_port(
  119. Port_ID,
  120. _Slave_ID,
  121. PortTypes,
  122. Address,
  123. LocalPort,
  124. Exp_state,
  125. Exp_state_ttl,
  126. Broadcast_state,
  127. I2C_port,
  128. I2C_driver
  129. );
  130. */
  131. }
  132. this->Slave_Ports_Status_A[_count + 1].Port_ID = Port_ID ;
  133. this->Slave_Ports_Status_A[_count + 1]._Slave_ID = _Slave_ID ;
  134. this->Slave_Ports_Status_A[_count + 1].PortTypes = PortTypes ;
  135. this->Slave_Ports_Status_A[_count + 1].Address = Address ;
  136. this->Slave_Ports_Status_A[_count + 1].LocalPort = LocalPort ;
  137. this->Slave_Ports_Status_A[_count + 1].Exp_state = Exp_state ;
  138. this->Slave_Ports_Status_A[_count + 1].Exp_state_ttl = Exp_state_ttl ;
  139. this->Slave_Ports_Status_A[_count + 1].Broadcast_state = Broadcast_state ;
  140. this->Slave_Ports_Status_A[_count + 1].I2C_port = I2C_port ;
  141. this->Slave_Ports_Status_A[_count + 1].I2C_driver = I2C_driver ;
  142. // Slave_Ports_Status_A[_count + 1].I2C_driver = I2C_driver_F(I2C_driver) ;
  143. this->_count ++;
  144. }
  145. bool Slave_Ports_Status::add_empty()
  146. {
  147. Serial.println("add_empty");
  148. }
  149. void Slave_Ports_Status::list_ports()
  150. {
  151. Serial.print("print_ports#154 _count["); Serial.print(_count); Serial.println("] ");
  152. int i;
  153. for(i=2;i<=_count;i++) {
  154. Serial.print(" #IND["); Serial.print(i);
  155. Serial.print("] Port_ID["); Serial.print(Slave_Ports_Status_A[i].Port_ID, HEX);
  156. Serial.print("] _Slave_ID[0x"); Serial.print( Slave_Ports_Status_A[i]._Slave_ID, HEX );
  157. Serial.print("] PortTypes["); Serial.print(Slave_Ports_Status_A[i].PortTypes, HEX);
  158. // Serial.println("] Address [");
  159. Serial.print("] Address["); //Serial.print(Slave_Ports_Status_A[i].Address, HEX);
  160. Serial.print("] LocalPort["); Serial.print(Slave_Ports_Status_A[i].LocalPort);
  161. Serial.print("] Exp_state["); Serial.print(Slave_Ports_Status_A[i].Exp_state, HEX);
  162. Serial.print("] Exp_state_ttl["); Serial.print(Slave_Ports_Status_A[i].Exp_state_ttl, HEX);
  163. Serial.print("] Broadcast_state["); Serial.print(Slave_Ports_Status_A[i].Broadcast_state, HEX);
  164. Serial.print("] I2C_port["); Serial.print(Slave_Ports_Status_A[i].I2C_port, HEX);
  165. // Serial.print("] I2C_driver["); Serial.print(Slave_Ports_Status_A[i].I2C_driver.CNF1);
  166. // I2C_driver_FT[24] = I2C_driver_FS(Slave_Ports_Status_A[i].I2C_driver);
  167. // Serial.print(I2C_driver_FT[24]);
  168. Serial.println("]");
  169. }
  170. }
  171. /*
  172. Slave_Ports_Status_S Slave_Ports_Status::get_port(int Port_ID)
  173. {
  174. // Serial.print("list_ports#154 _count["); Serial.print(_count); Serial.println("] ");
  175. //int i;
  176. //for(i=2;i<=_count;i++) {
  177. return Slave_Ports_Status_A[Port_ID];
  178. // }
  179. //return Slave_Ports_Status_A;
  180. }
  181. */
  182. Slave_Ports_Status::~Slave_Ports_Status(){
  183. delete[] Slave_Ports_Status_A;
  184. //Serial.print("#40 free ~Slave_Ports_Status");
  185. }
  186. /*
  187. int Slave_Ports_Status::get_count()
  188. {
  189. return _count;
  190. }
  191. */
  192. /*
  193. byte Slave_Ports_Status::_Slave_Ports_Protocol_CAN_broadcast_F() {
  194. }
  195. */