| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638 |
- //#include "_Slave_Ports_ttl_decrement.h"
- typedef struct {
- const char * const _Protocol;
- int _Slave_ID; //remote id - use FF for broadcast
- int PortTypes; //0xFF = 1111 1111 s
- /*
- {
- bit 1 - PWM port
- bit 2 - on I2C managed port
- bit 3 - expanded port with LocalPort address
- bit 4 - not allocated
- bit 2 - not allocated
- bit 5 - not allocated
- bit 6 - not allocated
- bit 7 - not allocated
- bit 8 - not allocated
- }
- */
- // byte has_Address;
- int Address ;
- // byte has_Local_Port;
- int LocalPort;
- int Exp_state; /*0xFF = 1111 1111
- 0x00 = 0000 0000 = OFF = 0V
- 0x01 = 0000 0001 = ON = PWM max
- {
- bit 1 - OFF = 0V
- bit 2 - ON = PWM max
- bit 3 - not allocated
- bit 4 - not allocated
- bit 2 - not allocated
- bit 5 - not allocated
- bit 6 - not allocated
- bit 7 - not allocated
- bit 8 - not allocated
- }*/
- int Exp_state_ttl; // 0x00 = odswiezyc
- int Broadcast_state; //0x00 - not broadcast; 0x01
- } _Slave_Port;
- /*
- *
- _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"
- 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
- }
- */
- int _Slave_Port_link; //todo link
- long time_seq_id;
- long time_min_run;
- } ;
- typedef struct _Slave_Ports_queue_tasksS _Slave_Ports_queue_tasksT;
- _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 == 0x01) res=0x99; //res="_Slave_Ports_ttl_decrement";
- else if(_Slave_Ports_queue_task_type == 0x02) res=0x99; //res="request_confirm_Exp_state";
- else if(_Slave_Ports_queue_task_type == 0x03) res=0x99; //res="request_set_new_Exp_state";
- else {
- res=0x99; // res="_UNKNOIWN";
- Serial.print("#82 Get ["); Serial.print(_Slave_Ports_queue_task_type); Serial.println("] #82 [U] ");
- }
- *//*
- // char return_i;
- Serial.print("=["); Serial.print(_Slave_Ports_queue_task_type); Serial.print("] ");
- if(_Slave_Ports_queue_task_type == 0x01) Serial.print("_Slave_Ports_ttl_decrement"); // return "_Slave_Ports_ttl_decrement";
- else if(_Slave_Ports_queue_task_type == 0x02) Serial.print("request_confirm_Exp_state"); //return "request_confirm_Exp_state";
- else if(_Slave_Ports_queue_task_type == 0x03) Serial.print("request_set_new_Exp_state"); //return "request_set__new_Exp_state";
- else //return_i = "_UNKNOIWN"; //return "_UNKNOIWN";
- Serial.print("_UNKNOIWN");
- // Serial.print((String)return_i);
- // return return_i ;
- */
- //Serial.print(_Slave_Ports_queue_task_type[_Slave_Ports_queue_task_type]);
- Serial.print(_Slave_Ports_queue_task_type_LIST[_Slave_Ports_queue_task_type]);
- // String ret = "aaaaxxx";
- //return ret;
- }
- //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);
- _Slave_Ports_queue_task_type_DESC(_Slave_Ports_queue_tasks_LIST[i]._Slave_Ports_queue_task_type);
- Serial.print(" - map["); Serial.print(_Slave_Ports_queue_task_type_LIST[_Slave_Ports_queue_tasks_LIST[i]._Slave_Ports_queue_task_type]); Serial.print("]");
- // 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;
- }
- */
- void _Slave_Ports_ttl_decrement_POP(_Slave_Ports_queue_tasksT* _Slave_Ports_queue_tasks_LIST,int _Slave_Ports_queue_pop , _Slave_Port* _Slave_Ports) {
- Serial.print("#213 _Slave_Ports_ttl_decrement_POP. sizeof _Slave_Ports["); Serial.print(sizeof(_Slave_Ports));
- int i;
- for(i=0;i<=100;i++) {
- if(_Slave_Ports[i]._Protocol == "CAN") {
- if(_Slave_Ports[i].Exp_state_ttl > 0x00 ) {
- Serial.print("#217 ttl min for: Prot["); Serial.print(_Slave_Ports[i]._Protocol); Serial.print("] ttl["); Serial.print(_Slave_Ports[i].Exp_state_ttl); Serial.print(" id["); Serial.print(i); Serial.println("] ");
- }
- }
- }
- /*
- const char * const _Protocol;
- int _Slave_ID;
- int PortTypes; //0xFF = 1111 1111 { PWM, .....} = 0x80
- // byte has_Address;
- int Address ;
- // byte has_Local_Port;
- int LocalPort;
- int Exp_state; /*0xFF = 1111 1111
- 0x00 = 0000 0000 = OFF = 0V
- 0x01 = 0000 0001 = ON = PWM max
- {
- bit 1 - OFF = 0V
- bit 2 - ON = PWM max
- bit 3 - not allocated
- bit 4 - not allocated
- bit 2 - not allocated
- bit 5 - not allocated
- bit 6 - not allocated
- bit 7 - not allocated
- bit 8 - not allocated
-
- int Exp_state_ttl; // 0x00 = odswiezyc
- */
-
- }
- 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 = 0;
- // int count = Slave_Ports_Status_C.get_count() ;
- //Slave_Ports_Status_S Slave_Ports_Status_A[1] ;
- /* for(i=0;i<=10;i++) {
- Slave_Ports_Status_S Slave_Ports_Status_AP = Slave_Ports_Status_C.get_port(i);
- //i++;
- // if( Slave_Ports_Status_A[i].Port_ID == 0 ) break;
- Serial.print("#293 i[");
- Serial.print(i); Serial.print("] Port_ID[");
- Serial.print(Slave_Ports_Status_AP.Port_ID); Serial.print("] PortTypes[");
- Serial.print(Slave_Ports_Status_AP.PortTypes); Serial.println("] ");
- delay(5000);
-
- }
- */
- /*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("#299 Prepared data");
- #if defined(HAS_LCD1602)
- // String LCDarray1 = "P[";
- LCD_print1(" Prepared data P[", LCDtim / 2);
- Serial.println("#303");
- LCD_print1(_Slave_Ports[i]._Protocol, LCDtim / 2);
- Serial.println("#305");
- // 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)
-
-
- _Slave_Ports_Protocol_CAN_broadcast_T _Slave_Ports_Protocol_CAN_broadcast_A;
- // _Slave_Ports_Protocol_CAN_broadcast_A[1]._Slave_ID_BROADCAST = 0xFF;
- // _Slave_Ports_Protocol_CAN_broadcast_A[1]._SENDER = Active_ControllerID ;
- _Slave_Ports_Protocol_CAN_broadcast_A.Port_ID = i ;
- _Slave_Ports_Protocol_CAN_broadcast_A.PortTypes = _Slave_Ports[i].PortTypes ;
-
- _Slave_Ports_Protocol_CAN_broadcast_A.Exp_state = _Slave_Ports[i].Exp_state ;
- _Slave_Ports_Protocol_CAN_broadcast_A.Exp_state_ttl = _Slave_Ports[i].Exp_state_ttl ;
- _Slave_Ports_Protocol_CAN_broadcast_A.Broadcast_state = _Slave_Ports[i].Broadcast_state ;
- //_Slave_Ports_Protocol_CAN_broadcast_A[1]._CAN_8 = 0x07 ;
-
- /* byte data[8] = { _Slave_Ports_Protocol_CAN_broadcast_A._Slave_ID_BROADCAST,
- _Slave_Ports_Protocol_CAN_broadcast_A._SENDER,
- _Slave_Ports_Protocol_CAN_broadcast_A.Port_ID,
- _Slave_Ports_Protocol_CAN_broadcast_A.PortTypes,
- _Slave_Ports_Protocol_CAN_broadcast_A.Exp_state,
- _Slave_Ports_Protocol_CAN_broadcast_A.Exp_state_ttl,
- _Slave_Ports_Protocol_CAN_broadcast_A.Broadcast_state,
- _Slave_Ports_Protocol_CAN_broadcast_A._CAN_8
- } ;
- //_Slave_Ports_Protocol_CAN_broadcast_AS _Slave_Ports_Protocol_CAN_broadcast_B[8];
- //byte _Slave_Ports_Protocol_CAN_broadcast_B[8] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
- byte _Slave_Ports_Protocol_CAN_broadcast_B[8] ;
- _Slave_Ports_Protocol_CAN_broadcast_AF(_Slave_Ports_Protocol_CAN_broadcast_A, _Slave_Ports_Protocol_CAN_broadcast_B);
- //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};
- //_Slave_Ports_Protocol_CAN_broadcast_AS data = _Slave_Ports_Protocol_CAN_broadcast_F(_Slave_Ports_Protocol_CAN_broadcast_A) ;
- // byte data[8] = {element.Address, 0x04, element.LocalPort, element.PortTypes, element.LocalPort, element.Exp_state, element.Exp_state_ttl, 0x07};
- // byte data[8] = { _Slave_Ports_Protocol_CAN_broadcast_A };
- // _Slave_Ports_Protocol_CAN_broadcast_AS data = _Slave_Ports_Protocol_CAN_broadcast_AF(_Slave_Ports_Protocol_CAN_broadcast_A);
- /* 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("] ");
-
- Serial.print("#343 byte data[8] ");
- // Serial.print((char)data);
- Serial.println("]");
- byte sndStat = CAN0.sendMsgBuf(_Slave_Ports[i]._Slave_ID, 0, 8, _Slave_Ports_Protocol_CAN_broadcast_B); //_Slave_Ports_Protocol_CAN_broadcast_A //data
- // byte sndStat ;
- if(sndStat == CAN_OK){
- Serial.println("#349 Message Sent Successfully!");
- String LCDarray1 = "Message Sent";
- String LCDarray2 = "Successfully";
- #if defined(HAS_LCD1602)
- LCD_print(LCDarray1,LCDarray2,LCDtim);
- #endif
- } else {
- Serial.println("#356 Error Sending Message...");
- String LCDarray1 = "Error Sending";
- String LCDarray2 = "Message...";
- #if defined(HAS_LCD1602)
- LCD_print(LCDarray1,LCDarray2,LCDtim);
- #endif
- }
- /*
- #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(1000); // send data per 100ms
- }
- */
-
-
-
-
-
- // }
-
- } //EOF _Slave_Ports_broadcast_POP
-
- void _Slave_Ports_queue__POP( _Slave_Ports_queue_tasksT* _Slave_Ports_queue_tasks_LIST,
- int _Slave_Ports_queue_count,
- int _Slave_Ports_queue_pop,
- int _Slave_Ports_queue_front,
- int _Slave_Ports_queue_back,
- int _Slave_Ports_queue_peek,
- int LCDtim, _Slave_Port* _Slave_Ports) {
- //int count = _Slave_Ports_queuev.count();
- //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);
-
- if (_Slave_Ports_queue_count > 0) {
- Serial.println("#472");
- /* String LCDarray1 = "`Slave_Ports_queue size [";
- Serial.println("#474");
- LCDarray1.concat(_Slave_Ports_queue_count);
- Serial.println("#476");
- //LCDarray1.concat("] Oldest[");
- Serial.println("#477");
- LCDarray1.concat(_Slave_Ports_queue_pop);
- Serial.println("#478");
- LCDarray1.concat("] Curr[");
- LCDarray1.concat(_Slave_Ports_queue_front);
-
- String LCDarray2 = "] last[";
- LCDarray2.concat(_Slave_Ports_queue_back);
- LCDarray2.concat("] Next[");
- LCDarray2.concat(_Slave_Ports_queue_peek);
-
-
- Serial.print(LCDarray1);
- Serial.println(LCDarray2);
- 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 ) {
- /* String LCDarray1 = "#206 Error with queue";
- String LCDarray2 = "ID: ";
- LCDarray2.concat( _Slave_Ports_queue_pop); LCDarray2.concat("] ");
- Serial.print(LCDarray1);
- Serial.println(LCDarray2);
- LCD_print(LCDarray1, LCDarray2, LCDtim / 3 ) ;
- */
- Serial.println("#507");
- } else {
- Serial.println("#509");
- /*
- String LCDarray1 = "#407 Running task";
- String LCDarray2 = "ID: ";
- 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("] ");
-
- Serial.print(LCDarray1);
- Serial.println(LCDarray2);
- 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);
-
- _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);
-
- _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);
- }
-
- }
-
- } else {
- String LCDarray1 = "Nothing to";
- String LCDarray2 = "process...";
- //LCDarray2.reserve(16);
- Serial.print(LCDarray1);
- Serial.println(LCDarray2);
- // Serial.print("#32 String LCDarray2 len");
- // int LCDarray2_length = LCDarray2.length;
- /* Serial.print(LCDarray2.length());
- Serial.println("] now ");
- LCDarray2 = make_str16(LCDarray2);
- Serial.print(LCDarray2.length());
- Serial.println("] next #338");
- for(int i = 0; i < (17 - LCDarray2.length()); i++)
- LCDarray2 += 'x';
-
- Serial.print(LCDarray2.length());
- Serial.println("] ");
- */
-
- Serial.print(" #364 scount ");
- Serial.print(_Slave_Ports_queue_count);
- Serial.print(" _Slave_Ports_queue.front(): ");
- Serial.print(_Slave_Ports_queue_front);
- Serial.print(" _Slave_Ports_queue.back(): ");
- Serial.print(_Slave_Ports_queue_back);
- Serial.print(" _Slave_Ports_queue.peek(): ");
- Serial.println(_Slave_Ports_queue_peek);
- #if defined(HAS_LCD1602)
- LCD_print(LCDarray1, LCDarray2, LCDtim / 3 ) ;
- #endif
- }
- }
- /*
- 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" } ;
|