|
@@ -1,333 +1,23 @@
|
|
|
|
|
+//_Slave_Ports.h
|
|
|
|
|
+
|
|
|
#include "_Slave_Ports_ttl_decrement.h"
|
|
#include "_Slave_Ports_ttl_decrement.h"
|
|
|
//#include "_Slave_Ports_Protocol.h"
|
|
//#include "_Slave_Ports_Protocol.h"
|
|
|
-#include "Slave_Ports_Status_QUEUE.h"
|
|
|
|
|
-//#include "Slave_Ports_Status_S.h"
|
|
|
|
|
-
|
|
|
|
|
-/*
|
|
|
|
|
- *
|
|
|
|
|
-_Slave_Port _Slave_Ports[] = {
|
|
|
|
|
- {"CAN", 0x102, 0x01, 0x00, 0x00, 0x00, 0x00 }
|
|
|
|
|
- //,
|
|
|
|
|
- //{"CAN", 0x102, 0x01, 0x00, 0x01, 0xFF, 0x6d } //testowy ttl
|
|
|
|
|
-};
|
|
|
|
|
-*/
|
|
|
|
|
-//#include "_Slave_Ports_LOCAL.h"
|
|
|
|
|
-//#include "_Slave_Ports_queue_task_type_LIST.h"
|
|
|
|
|
-#include "Slave_Ports_Status_QUEUE.h"
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-_Slave_Ports_queue_tasksT _Slave_Ports_queue_tasks_LIST[11];
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-void _Slave_Ports_queue__INIT( _Slave_Ports_queue_tasksT* _Slave_Ports_queue_tasks_LIST) {
|
|
|
|
|
- Serial.println("_Slave_Ports_queue__INIT");
|
|
|
|
|
- int i;
|
|
|
|
|
- for(i=0;i<10;i++) {
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[i].queueID = 0;
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[i]._Slave_Ports_queue_task_type = 0x00;
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[i]._Slave_Port_link = 0x00;
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[i].time_seq_id = 0;
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[i].time_min_run = 0;
|
|
|
|
|
-
|
|
|
|
|
- // _Slave_Ports_queue_tasks_LIST[i]=_Slave_Ports_queue_tasks_LIST[i];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-void _Slave_Ports_queue_task_type_DESC( int _Slave_Ports_queue_task_type ) {//, int* res
|
|
|
|
|
- if(_Slave_Ports_queue_task_type == TASK_TYPE_T_NOT_USED_________________) {
|
|
|
|
|
- Serial.println("TASK_TYPE_T_NOT_USED_________________");
|
|
|
|
|
- } else if(_Slave_Ports_queue_task_type == TASK_TYPE_T_Slave_Ports_ttl_decrement) { Serial.println("TASK_TYPE_T_Slave_Ports_ttl_decrement");
|
|
|
|
|
- } else if(_Slave_Ports_queue_task_type == TASK_TYPE_T_request_confirm_Exp_state) { Serial.println("TASK_TYPE_T_request_confirm_Exp_state");
|
|
|
|
|
- } else if(_Slave_Ports_queue_task_type == TASK_TYPE_T_request_set_new_Exp_state) { Serial.println("TASK_TYPE_T_request_set_new_Exp_state");
|
|
|
|
|
- } else if(_Slave_Ports_queue_task_type == TASK_TYPE_T_Slave_Ports_broadcast____) { Serial.println("TASK_TYPE_T_Slave_Ports_broadcast____");
|
|
|
|
|
- } else if(_Slave_Ports_queue_task_type == TASK_TYPE_T_Slave_Ports_set_I2C______) { Serial.println("TASK_TYPE_T_Slave_Ports_set_I2C______");
|
|
|
|
|
- } else { Serial.println("106 unknown _Slave_Ports_queue_task_type");
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-//Queue<_Slave_Ports_queueT> _Slave_Ports_queue = Queue<_Slave_Ports_queueT>(5);
|
|
|
|
|
-void _Slave_Ports_queue__list( _Slave_Ports_queue_tasksT* _Slave_Ports_queue_tasks_LIST) {
|
|
|
|
|
- int i;
|
|
|
|
|
- Serial.println("#100 _Slave_Ports_queue_tasks_LIST): ");
|
|
|
|
|
- //Serial.println(sizeof(_Slave_Ports_queue_tasks_LIST));
|
|
|
|
|
- for(i=0;i<=10;i++) { //sizeof(_LCD_print_buffors)
|
|
|
|
|
-
|
|
|
|
|
- if(_Slave_Ports_queue_tasks_LIST[i].queueID == 0 and _Slave_Ports_queue_tasks_LIST[i].queueID == 0 and _Slave_Ports_queue_tasks_LIST[i]._Slave_Ports_queue_task_type == 0 and _Slave_Ports_queue_tasks_LIST[i]._Slave_Port_link == 0 and _Slave_Ports_queue_tasks_LIST[i].time_seq_id == 0 and _Slave_Ports_queue_tasks_LIST[i].time_min_run == 0 ) {
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
- Serial.print(" $i[");
|
|
|
|
|
- Serial.print(i);
|
|
|
|
|
-
|
|
|
|
|
- Serial.print("] queueID: ");
|
|
|
|
|
- Serial.print(_Slave_Ports_queue_tasks_LIST[i].queueID);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- Serial.print("] _Slave_Ports_queue_task_type: ");
|
|
|
|
|
- Serial.print(_Slave_Ports_queue_tasks_LIST[i]._Slave_Ports_queue_task_type);
|
|
|
|
|
- Serial.print("] desc: ");
|
|
|
|
|
- //Slave_Ports_queue_task_type_DESC(_Slave_Ports_queue_tasks_LIST[i]._Slave_Ports_queue_task_type);
|
|
|
|
|
- //char res;
|
|
|
|
|
- // res = _Slave_Ports_queue_task_type_DESC(_Slave_Ports_queue_tasks_LIST[i]._Slave_Ports_queue_task_type); Serial.print(res);
|
|
|
|
|
-
|
|
|
|
|
- // Serial.print(" - map["); Serial.print(_Slave_Ports_queue_task_type_LIST[_Slave_Ports_queue_tasks_LIST[i]._Slave_Ports_queue_task_type]); Serial.print("]");
|
|
|
|
|
- _Slave_Ports_queue_task_type_DESC(_Slave_Ports_queue_tasks_LIST[i]._Slave_Ports_queue_task_type) ; //(res); //_Slave_Ports_queue_task_type_DESC(_Slave_Ports_queue_tasks_LIST[i]._Slave_Ports_queue_task_type
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- Serial.print("] _Slave_Port_link: ");
|
|
|
|
|
- Serial.print(_Slave_Ports_queue_tasks_LIST[i]._Slave_Port_link);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- Serial.print("] time_seq_id: ");
|
|
|
|
|
- Serial.print(_Slave_Ports_queue_tasks_LIST[i].time_seq_id);
|
|
|
|
|
-
|
|
|
|
|
- Serial.print("] time_min_run: ");
|
|
|
|
|
- Serial.println(_Slave_Ports_queue_tasks_LIST[i].time_min_run);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-/*
|
|
|
|
|
- struct _Slave_Ports_queue_tasksS {
|
|
|
|
|
- int queueID;
|
|
|
|
|
- int _Slave_Ports_queue_task_type ; /*
|
|
|
|
|
- { 0x01 _Slave_Ports_ttl_decrement,
|
|
|
|
|
- 0x02 request_confirm_Exp_state ,
|
|
|
|
|
- 0x03 request_set_new_Exp_state,
|
|
|
|
|
- 0x04 _Slave_Ports_ttl_decrement }
|
|
|
|
|
-
|
|
|
|
|
- int _Slave_Port_link; //todo link
|
|
|
|
|
- long time_seq_id;
|
|
|
|
|
- long time_min_run;
|
|
|
|
|
-} ;
|
|
|
|
|
-
|
|
|
|
|
- */
|
|
|
|
|
-void _Slave_Ports_queue__add( _Slave_Ports_queue_tasksT* _Slave_Ports_queue_tasks_LIST,int _Slave_Ports_queue_task_type,int _Slave_Port_link,long time_seq_id, long time_min_run //,
|
|
|
|
|
-//int _Slave_Ports_queue_peek , int _Slave_Ports_queue_push , int _Slave_Ports_queue_peek_new
|
|
|
|
|
-) {
|
|
|
|
|
- Serial.println(".");
|
|
|
|
|
- Serial.print("#152 _Slave_Ports_queue__add peek: [");
|
|
|
|
|
- int _Slave_Ports_queue_peek = _Slave_Ports_queue.peek() ;
|
|
|
|
|
- int _Slave_Ports_queue_back = _Slave_Ports_queue.back() ;
|
|
|
|
|
- // int _Slave_Ports_queue_push_new_ref;
|
|
|
|
|
- // if(_Slave_Ports_queue_back > _Slave_Ports_queue_peek)
|
|
|
|
|
- Serial.print(_Slave_Ports_queue_peek); Serial.print("] cur back["); Serial.print(_Slave_Ports_queue_back); Serial.print("] ");
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- _Slave_Ports_queue.push(_Slave_Ports_queue_back + 1);
|
|
|
|
|
- int _Slave_Ports_queue_peek_new = _Slave_Ports_queue.peek() ;
|
|
|
|
|
- // int _Slave_Ports_queue__push = _Slave_Ports_queue__peek + 1 ;
|
|
|
|
|
- Serial.print("] new peek[");
|
|
|
|
|
- Serial.print(_Slave_Ports_queue_peek_new ); Serial.print("] planned["); Serial.print(_Slave_Ports_queue_back + 1 );
|
|
|
|
|
- Serial.print("] front["); Serial.print(_Slave_Ports_queue.front()); Serial.print("] back["); Serial.print(_Slave_Ports_queue.back()); Serial.println("] ");
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_back + 1 ].queueID=_Slave_Ports_queue_back + 1 ;
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_back + 1 ]._Slave_Ports_queue_task_type=_Slave_Ports_queue_task_type ;
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_back + 1 ]._Slave_Port_link=_Slave_Port_link ;
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_back + 1 ].time_seq_id=time_seq_id ;
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_back + 1 ].time_min_run=time_min_run ;
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-/*
|
|
|
|
|
- void _Slave_Ports_queue__add(const _Slave_Ports_queue_tasksT* &_Slave_Ports_queue_tasks_LIST ,
|
|
|
|
|
-int _Slave_Ports_queue_task_type, int _Slave_Port_link, long time_seq_id, long time_min_run //,
|
|
|
|
|
-//int _Slave_Ports_queue_peek , int _Slave_Ports_queue_push , int _Slave_Ports_queue_peek_new
|
|
|
|
|
-) {
|
|
|
|
|
- Serial.print("#152 _Slave_Ports_queue__add peek: [");
|
|
|
|
|
- int _Slave_Ports_queue_peek = _Slave_Ports_queue.peek() ;
|
|
|
|
|
- Serial.print(_Slave_Ports_queue_peek);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- int _Slave_Ports_queue_push = _Slave_Ports_queue_peek + 1;
|
|
|
|
|
- int _Slave_Ports_queue_peek_new = _Slave_Ports_queue_push ; //_Slave_Ports_queue.peek() ;
|
|
|
|
|
- // int _Slave_Ports_queue__push = _Slave_Ports_queue__peek + 1 ;
|
|
|
|
|
- Serial.print("] new peek[");
|
|
|
|
|
- Serial.print(_Slave_Ports_queue_peek_new ); Serial.print("] planned["); Serial.print(_Slave_Ports_queue_peek + 1 ); Serial.println("]");
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_peek_new].queueID=_Slave_Ports_queue_peek_new;
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_peek_new]._Slave_Ports_queue_task_type=_Slave_Ports_queue_task_type ;
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_peek_new]._Slave_Port_link=_Slave_Port_link ;
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_peek_new].time_seq_id=time_seq_id ;
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_peek_new].time_min_run=time_min_run ;
|
|
|
|
|
-
|
|
|
|
|
- //return _Slave_Ports_queue_tasks_LIST;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-*/
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-#include "_Slave_Ports_ttl_decrement_POP.h"
|
|
|
|
|
-
|
|
|
|
|
- void _Slave_Ports_broadcast_POP(_Slave_Ports_queue_tasksT* _Slave_Ports_queue_tasks_LIST, int _Slave_Ports_queue_pop , _Slave_Port* _Slave_Ports, int LCDtim ) {
|
|
|
|
|
- Serial.println("#251 _Slave_Ports_broadcast_POP");
|
|
|
|
|
- int i;
|
|
|
|
|
- for(i=0;i<=100;i++) {
|
|
|
|
|
- if(_Slave_Ports[i]._Protocol == "CAN") {
|
|
|
|
|
- Serial.print(" ind:"); Serial.print(i); Serial.print("] Prot:");
|
|
|
|
|
- Serial.print(_Slave_Ports[i]._Protocol);
|
|
|
|
|
- Serial.print(" , ID:");
|
|
|
|
|
- Serial.print(_Slave_Ports[i]._Slave_ID, HEX); Serial.print(" , PortTypes:");
|
|
|
|
|
- Serial.print(_Slave_Ports[i].PortTypes, HEX); Serial.print(" , Addr:"); Serial.print(_Slave_Ports[i].Address, HEX);
|
|
|
|
|
- Serial.print(" , Local:"); Serial.print(_Slave_Ports[i].LocalPort);
|
|
|
|
|
- Serial.print(" , Exp state:"); Serial.print(_Slave_Ports[i].Exp_state);
|
|
|
|
|
- Serial.print(" , Exp_state_ttl"); Serial.println(_Slave_Ports[i].Exp_state_ttl);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- Serial.println(" Prepared data");
|
|
|
|
|
- #if defined(HAS_LCD1602)
|
|
|
|
|
- String LCDarray1 = "P[";
|
|
|
|
|
- LCDarray1.concat(_Slave_Ports[i]._Protocol); LCDarray1.concat("] ID["); LCDarray1.concat(String(_Slave_Ports[i]._Slave_ID, HEX)); LCDarray1.concat("] T["); LCDarray1.concat(String(_Slave_Ports[i].PortTypes, HEX));
|
|
|
|
|
- // lcd.print(LCDarray1);
|
|
|
|
|
- String LCDarray2 = " >"; LCDarray2.concat(String(_Slave_Ports[i].Address, HEX)); LCDarray2.concat( "< {"); LCDarray2.concat( String(_Slave_Ports[i].LocalPort, HEX)); LCDarray2.concat( "} =[" ); LCDarray2.concat(String(_Slave_Ports[i].Exp_state, HEX) ); LCDarray2.concat("] ?[" ) ;
|
|
|
|
|
- LCDarray2.concat(String(_Slave_Ports[i].Exp_state_ttl, HEX)) ; LCDarray2.concat("]") ;
|
|
|
|
|
- LCD_print(LCDarray1, LCDarray2, LCDtim / 2 ) ;
|
|
|
|
|
- #endif
|
|
|
|
|
- // (0) (1) (2) (3) (4) (5) (6)
|
|
|
|
|
- byte data[8] = {_Slave_Ports[i].Address, 0x04, _Slave_Ports[i].LocalPort, _Slave_Ports[i].PortTypes, _Slave_Ports[i].LocalPort, _Slave_Ports[i].Exp_state, _Slave_Ports[i].Exp_state_ttl, 0x07};
|
|
|
|
|
- // byte data[8] = {element.Address, 0x04, element.LocalPort, element.PortTypes, element.LocalPort, element.Exp_state, element.Exp_state_ttl, 0x07};
|
|
|
|
|
- Serial.print("#303 byte data[8] 1["); Serial.print(_Slave_Ports[i].Address); Serial.print("] 2["); Serial.print(0x04); Serial.print("] 3[");
|
|
|
|
|
- Serial.print(_Slave_Ports[i].LocalPort); Serial.print("] 4["); Serial.print(_Slave_Ports[i].PortTypes); Serial.print("] 5["); Serial.print(_Slave_Ports[i].Exp_state); Serial.print("] 6[");
|
|
|
|
|
- Serial.print( _Slave_Ports[i].Exp_state_ttl); Serial.print("] 7["); Serial.print(0x07); Serial.println("] ");
|
|
|
|
|
- byte sndStat = CAN0.sendMsgBuf(_Slave_Ports[i]._Slave_ID, 0, 8, data);
|
|
|
|
|
- // byte sndStat ;
|
|
|
|
|
- if(sndStat == CAN_OK){
|
|
|
|
|
- Serial.println("Message Sent Successfully!");
|
|
|
|
|
- String LCDarray1 = "Message Sent";
|
|
|
|
|
- String LCDarray2 = "Successfully";
|
|
|
|
|
- } else {
|
|
|
|
|
- Serial.println("Error Sending Message...");
|
|
|
|
|
- String LCDarray1 = "Error Sending";
|
|
|
|
|
- String LCDarray2 = "Message...";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- #if defined(HAS_LCD1602)
|
|
|
|
|
- LCD_print(LCDarray1,LCDarray2,LCDtim);
|
|
|
|
|
- /*
|
|
|
|
|
- delay(LCDtim * 5);
|
|
|
|
|
- //lcd.setCursor(0,1);
|
|
|
|
|
- lcd.print(lcdPattern);
|
|
|
|
|
- //lcd.print(lcdPos % 10);
|
|
|
|
|
- if(lcdPos >= 16) {
|
|
|
|
|
- //lcd.print("N");
|
|
|
|
|
- lcd.setCursor(0,1);
|
|
|
|
|
- lcdPos = 0;
|
|
|
|
|
- if(lcdPattern=="s") lcdPattern = "S" ;
|
|
|
|
|
- else lcdPattern = "s" ;
|
|
|
|
|
- }
|
|
|
|
|
- lcdPos ++;
|
|
|
|
|
- |*/
|
|
|
|
|
- #endif
|
|
|
|
|
- // #if defined(HAS_TFT_ILI9163C)
|
|
|
|
|
- // delay(LCDtim);
|
|
|
|
|
- // display.setCursor(0,60);
|
|
|
|
|
- // display.print(LCDarray1); display.print(" "); display.print(LCDarray2);
|
|
|
|
|
- // #endif
|
|
|
|
|
-
|
|
|
|
|
- delay(5000); // send data per 100ms
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- /*
|
|
|
|
|
- for (auto element: _Slave_Ports) {
|
|
|
|
|
- ind++;
|
|
|
|
|
- Serial.print(" ind:"); Serial.print(ind); Serial.print("] Prot:"); Serial.print(element._Protocol); Serial.print(" , ID:"); Serial.print(element._Slave_ID); Serial.print(" , PortTypes:");
|
|
|
|
|
- Serial.print(element.PortTypes); Serial.print(" , Addr:"); Serial.print(element.Address);
|
|
|
|
|
- Serial.print(" , Local:"); Serial.print(element.LocalPort);
|
|
|
|
|
- Serial.print(" , Exp state:"); Serial.print(element.Exp_state);
|
|
|
|
|
- Serial.print(" , Exp_state_ttl"); Serial.println(element.Exp_state_ttl);
|
|
|
|
|
- if(element._Protocol == "CAN") {
|
|
|
|
|
- Serial.println(" Prepared data");
|
|
|
|
|
- #if defined(HAS_LCD1602)
|
|
|
|
|
-
|
|
|
|
|
- String LCDarray1 = "P[";
|
|
|
|
|
- LCDarray1.concat(element._Protocol); LCDarray1.concat("] ID["); LCDarray1.concat(String(element._Slave_ID, HEX)); LCDarray1.concat("] T["); LCDarray1.concat(String(element.PortTypes, HEX));
|
|
|
|
|
- // lcd.print(LCDarray1);
|
|
|
|
|
- String LCDarray2 = " >"; LCDarray2.concat(String(element.Address, HEX)); LCDarray2.concat( "< {"); LCDarray2.concat( String(element.LocalPort, HEX)); LCDarray2.concat( "} =[" ); LCDarray2.concat(String(element.Exp_state, HEX) ); LCDarray2.concat("] ?[" ) ;
|
|
|
|
|
- LCDarray2.concat(String(element.Exp_state_ttl, HEX)) ; LCDarray2.concat("]") ;
|
|
|
|
|
- LCD_print(LCDarray1, LCDarray2, LCDtim / 2 ) ;
|
|
|
|
|
- #endif
|
|
|
|
|
- byte data[8] = {element.Address, 0x04, element.LocalPort, element.PortTypes, element.LocalPort, element.Exp_state, element.Exp_state_ttl, 0x07};
|
|
|
|
|
- // }
|
|
|
|
|
- byte sndStat = CAN0.sendMsgBuf(element._Slave_ID, 0, 8, data);
|
|
|
|
|
-
|
|
|
|
|
- if(sndStat == CAN_OK){
|
|
|
|
|
- Serial.println("Message Sent Successfully!");
|
|
|
|
|
- String LCDarray1 = "Message Sent";
|
|
|
|
|
- String LCDarray2 = "Successfully";
|
|
|
|
|
- } else {
|
|
|
|
|
- Serial.println("Error Sending Message...");
|
|
|
|
|
- String LCDarray1 = "Error Sending";
|
|
|
|
|
- String LCDarray2 = "Message...";
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
+//#include "Slave_Ports_Status_S.h"
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- #if defined(HAS_LCD1602)
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- delay(LCDtim * 5);
|
|
|
|
|
- //lcd.setCursor(0,1);
|
|
|
|
|
- lcd.print(lcdPattern);
|
|
|
|
|
- //lcd.print(lcdPos % 10);
|
|
|
|
|
- if(lcdPos >= 16) {
|
|
|
|
|
- //lcd.print("N");
|
|
|
|
|
- lcd.setCursor(0,1);
|
|
|
|
|
- lcdPos = 0;
|
|
|
|
|
- if(lcdPattern=="s") lcdPattern = "S" ;
|
|
|
|
|
- else lcdPattern = "s" ;
|
|
|
|
|
- }
|
|
|
|
|
- lcdPos ++;
|
|
|
|
|
- #endif
|
|
|
|
|
- #if defined(HAS_TFT_ILI9163C)
|
|
|
|
|
- delay(LCDtim);
|
|
|
|
|
- display.setCursor(0,60);
|
|
|
|
|
- display.print(LCDarray1); display.print(" "); display.print(LCDarray2);
|
|
|
|
|
- #endif
|
|
|
|
|
- delay(5000); // send data per 100ms
|
|
|
|
|
|
|
+Slave_Ports_Status_QUEUE_T Slave_Ports_Status_QUEUE_A[11];
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- }*/
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // byte sndStat = CAN0.sendMsgBuf(_Slave1_ID, 0, 8, data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- } //EOF _Slave_Ports_broadcast_POP
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
- void _Slave_Ports_queue__POP( _Slave_Ports_queue_tasksT* _Slave_Ports_queue_tasks_LIST,
|
|
|
|
|
|
|
+ void _Slave_Ports_queue__POP( Slave_Ports_Status_QUEUE_T* Slave_Ports_Status_QUEUE_A,
|
|
|
int _Slave_Ports_queue_count,
|
|
int _Slave_Ports_queue_count,
|
|
|
int _Slave_Ports_queue_pop,
|
|
int _Slave_Ports_queue_pop,
|
|
|
int _Slave_Ports_queue_front,
|
|
int _Slave_Ports_queue_front,
|
|
|
int _Slave_Ports_queue_back,
|
|
int _Slave_Ports_queue_back,
|
|
|
int _Slave_Ports_queue_peek,
|
|
int _Slave_Ports_queue_peek,
|
|
|
- int LCDtim, _Slave_Port* _Slave_Ports) {
|
|
|
|
|
|
|
+ int LCDtim, Slave_Ports_Status_T* Slave_Ports_Status_A) {
|
|
|
//int count = _Slave_Ports_queuev.count();
|
|
//int count = _Slave_Ports_queuev.count();
|
|
|
//int _Slave_Ports_queue_pop _Slave_Ports_queuev.pop();
|
|
//int _Slave_Ports_queue_pop _Slave_Ports_queuev.pop();
|
|
|
Serial.print("#180 run _Slave_Ports_queue__POP cnt "); Serial.print(_Slave_Ports_queue_count); Serial.print(" , pop: "); Serial.println(_Slave_Ports_queue_pop);
|
|
Serial.print("#180 run _Slave_Ports_queue__POP cnt "); Serial.print(_Slave_Ports_queue_count); Serial.print(" , pop: "); Serial.println(_Slave_Ports_queue_pop);
|
|
@@ -353,12 +43,12 @@ int _Slave_Ports_queue_task_type, int _Slave_Port_link, long time_seq_id, long t
|
|
|
Serial.println(LCDarray2);
|
|
Serial.println(LCDarray2);
|
|
|
// LCD_print(LCDarray1, LCDarray2, LCDtim / 3 ) ;
|
|
// LCD_print(LCDarray1, LCDarray2, LCDtim / 3 ) ;
|
|
|
|
|
|
|
|
- if(_Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_pop].queueID == 0 and
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_pop].queueID == 0 and
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_pop]._Slave_Ports_queue_task_type == 0 and
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_pop]._Slave_Port_link == 0 and
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_pop].time_seq_id == 0 and
|
|
|
|
|
- _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_pop].time_min_run == 0 ) {
|
|
|
|
|
|
|
+ if(Slave_Ports_Status_QUEUE_A[_Slave_Ports_queue_pop].QUEUE_ID_A == 0 and
|
|
|
|
|
+ Slave_Ports_Status_QUEUE_A[_Slave_Ports_queue_pop].QUEUE_ID_A == 0 and
|
|
|
|
|
+ Slave_Ports_Status_QUEUE_A[_Slave_Ports_queue_pop].TASK_TYPE_A == 0 and
|
|
|
|
|
+ //Slave_Ports_Status_QUEUE_A[_Slave_Ports_queue_pop].TASK_PORT_ASSOC_A == 0 and
|
|
|
|
|
+ Slave_Ports_Status_QUEUE_A[_Slave_Ports_queue_pop].time_seq_id == 0 and
|
|
|
|
|
+ Slave_Ports_Status_QUEUE_A[_Slave_Ports_queue_pop].time_min_run == 0 ) {
|
|
|
String LCDarray1 = "#206 Error with queue";
|
|
String LCDarray1 = "#206 Error with queue";
|
|
|
String LCDarray2 = "ID: ";
|
|
String LCDarray2 = "ID: ";
|
|
|
LCDarray2.concat( _Slave_Ports_queue_pop); LCDarray2.concat("] ");
|
|
LCDarray2.concat( _Slave_Ports_queue_pop); LCDarray2.concat("] ");
|
|
@@ -370,25 +60,28 @@ int _Slave_Ports_queue_task_type, int _Slave_Port_link, long time_seq_id, long t
|
|
|
String LCDarray2 = "ID: ";
|
|
String LCDarray2 = "ID: ";
|
|
|
LCDarray2.concat( _Slave_Ports_queue_pop); LCDarray2.concat("] task_type[");
|
|
LCDarray2.concat( _Slave_Ports_queue_pop); LCDarray2.concat("] task_type[");
|
|
|
|
|
|
|
|
- LCDarray2.concat( _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_pop]._Slave_Ports_queue_task_type); LCDarray2.concat("] ");
|
|
|
|
|
|
|
+ LCDarray2.concat( Slave_Ports_Status_QUEUE_A[_Slave_Ports_queue_pop].TASK_TYPE_A); LCDarray2.concat("] ");
|
|
|
|
|
|
|
|
Serial.print(LCDarray1);
|
|
Serial.print(LCDarray1);
|
|
|
Serial.println(LCDarray2);
|
|
Serial.println(LCDarray2);
|
|
|
// LCD_print(LCDarray1, LCDarray2, LCDtim / 3 ) ;
|
|
// LCD_print(LCDarray1, LCDarray2, LCDtim / 3 ) ;
|
|
|
|
|
|
|
|
- if( _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_pop]._Slave_Ports_queue_task_type == 0x01 ) {
|
|
|
|
|
- Serial.print("#224 running _Slave_Ports_ttl_decrement = "); Serial.println( _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_pop]._Slave_Ports_queue_task_type);
|
|
|
|
|
- #include "_Slave_Ports_ttl_decrement.h"
|
|
|
|
|
- _Slave_Ports_ttl_decrement_POP(_Slave_Ports_queue_tasks_LIST, _Slave_Ports_queue_pop , _Slave_Ports ) ;
|
|
|
|
|
-
|
|
|
|
|
- } else if( _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_pop]._Slave_Ports_queue_task_type == 0x04 ) {
|
|
|
|
|
- Serial.print("#337 running _Slave_Ports_broadcast = "); Serial.println( _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_pop]._Slave_Ports_queue_task_type);
|
|
|
|
|
- #include "_Slave_Ports_ttl_decrement.h"
|
|
|
|
|
- _Slave_Ports_broadcast_POP(_Slave_Ports_queue_tasks_LIST, _Slave_Ports_queue_pop , _Slave_Ports, LCDtim ) ;
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
- Serial.print("Error unsupported type "); Serial.println( _Slave_Ports_queue_tasks_LIST[_Slave_Ports_queue_pop]._Slave_Ports_queue_task_type);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ switch (Slave_Ports_Status_QUEUE_A[_Slave_Ports_queue_pop].TASK_TYPE_A) {
|
|
|
|
|
+ case TASK_TYPE_T_Slave_Ports_ttl_decrement: // your hand is on the sensor
|
|
|
|
|
+ Serial.print("#224 running _Slave_Ports_ttl_decrement = "); Serial.println( Slave_Ports_Status_QUEUE_A[_Slave_Ports_queue_pop].TASK_TYPE_A);
|
|
|
|
|
+ //#include "_Slave_Ports_ttl_decrement.h"
|
|
|
|
|
+ _Slave_Ports_ttl_decrement_POP(Slave_Ports_Status_QUEUE_A, _Slave_Ports_queue_pop , Slave_Ports_Status_A ) ;
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ case TASK_TYPE_T_Slave_Ports_broadcast____:
|
|
|
|
|
+ Serial.print("#337 running _Slave_Ports_broadcast = "); Serial.println( Slave_Ports_Status_QUEUE_A[_Slave_Ports_queue_pop].TASK_TYPE_A);
|
|
|
|
|
+ // #include "_Slave_Ports_ttl_decrement.h"
|
|
|
|
|
+ _Slave_Ports_broadcast_POP(Slave_Ports_Status_QUEUE_A, _Slave_Ports_queue_pop , Slave_Ports_Status_A, LCDtim ) ;
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ Serial.print("Error unsupported type "); Serial.println( Slave_Ports_Status_QUEUE_A[_Slave_Ports_queue_pop].TASK_TYPE_A);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -434,94 +127,3 @@ int _Slave_Ports_queue_task_type, int _Slave_Port_link, long time_seq_id, long t
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-/*
|
|
|
|
|
-struct _Slave_Port
|
|
|
|
|
-{
|
|
|
|
|
- char _Protocol ;
|
|
|
|
|
- int _Slave_ID;
|
|
|
|
|
- char Port_Type;
|
|
|
|
|
- int Address;
|
|
|
|
|
- int LocalPort ;
|
|
|
|
|
- void (*fn)();
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-struct _Slave_Port {
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-#define _Slave_Port = { "CAN" , 0x102 , "PWM", 0x00, 0 }
|
|
|
|
|
-
|
|
|
|
|
-*/
|
|
|
|
|
-
|
|
|
|
|
- /* #define __CAN_Ports { _Slave1_ID } ;
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- #define __CAN_Ports_PWM { _Slave1_ID
|
|
|
|
|
- {0x00 , 0 } ,
|
|
|
|
|
- {0x00 , 1 }
|
|
|
|
|
- } ;
|
|
|
|
|
-
|
|
|
|
|
- */
|
|
|
|
|
-/*
|
|
|
|
|
- typedef struct
|
|
|
|
|
- {
|
|
|
|
|
- int Slave1_ID;
|
|
|
|
|
- String PortType;
|
|
|
|
|
- int Address;
|
|
|
|
|
- int LocalPort ;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-*/
|
|
|
|
|
-/*
|
|
|
|
|
-
|
|
|
|
|
-struct buttons
|
|
|
|
|
-{
|
|
|
|
|
- int color[3];
|
|
|
|
|
- int positions[4];
|
|
|
|
|
- char init[20];
|
|
|
|
|
- void (*fn)();
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-//void func1();
|
|
|
|
|
-//void func2();
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-buttons test[] =
|
|
|
|
|
-{
|
|
|
|
|
- { {0,0,0}, {0,0,100,100}, "getSomething", func1 },
|
|
|
|
|
- { {40,40,40}, {50,50,10,10}, "somethingElse", func2 },
|
|
|
|
|
-};
|
|
|
|
|
-*/
|
|
|
|
|
-
|
|
|
|
|
-/*
|
|
|
|
|
-typedef struct {
|
|
|
|
|
- const char * const l_name;
|
|
|
|
|
- byte x_m;
|
|
|
|
|
- byte y_m;
|
|
|
|
|
- boolean period[4];
|
|
|
|
|
-} myStruct;
|
|
|
|
|
-
|
|
|
|
|
-myStruct structs[] = {
|
|
|
|
|
- {"My Name", 0, 0, {true, true, false, false}},
|
|
|
|
|
- {"My Second Name", 0, 0, {true, false, true, false}}
|
|
|
|
|
-};
|
|
|
|
|
-*/
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- //#define _CAN_P_0x102_PWM0x00_0 { _Slave1_ID , "PWM", 0x00, 0 }
|
|
|
|
|
- //#define _CAN_P_0x102_PWM0x00_1 { _Slave1_ID , "PWM", 0x00, 1 }
|
|
|
|
|
- // char _Slave_Ports ;
|
|
|
|
|
- // _Slave_Ports[0] = "_CAN_P_0x102_PWM0x00_0" ;
|
|
|
|
|
- // _Slave_Ports[1] = "_CAN_P_0x102_PWM0x00_1" ;
|
|
|
|
|
-
|
|
|
|
|
- // char *_Slave_Ports[] = { "_CAN_P_0x102_PWM0x00_0", "_CAN_P_0x102_PWM0x00_1" } ;
|
|
|