src/states.c
changeset 320 f82e758840bd
parent 314 68e83c3ffbb5
child 343 118c1cabd0b0
equal deleted inserted replaced
319:4b331759169a 320:f82e758840bd
   141 **                                                                                                 
   141 **                                                                                                 
   142 ** @return                                                                                         
   142 ** @return                                                                                         
   143 **/  
   143 **/  
   144 UNS8 setState(CO_Data* d, e_nodeState newState)
   144 UNS8 setState(CO_Data* d, e_nodeState newState)
   145 {
   145 {
   146 	UNS16 wIndex = 0x1F22;
       
   147 	const indextable *ptrTable;
       
   148   	ODCallback_t *Callback;
       
   149 	UNS32 errorCode;
       
   150 	while(newState != d->nodeState){
   146 	while(newState != d->nodeState){
   151 		switch( newState ){
   147 		switch( newState ){
   152 			case Initialisation:
   148 			case Initialisation:
   153 			{
   149 			{
   154 				s_state_communication newCommunicationState = {1, 0, 0, 0, 0, 0};
   150 				s_state_communication newCommunicationState = {1, 0, 0, 0, 0, 0};
   169 				d->nodeState = Pre_operational;
   165 				d->nodeState = Pre_operational;
   170 				newState = Pre_operational;
   166 				newState = Pre_operational;
   171 				switchCommunicationState(d, &newCommunicationState);
   167 				switchCommunicationState(d, &newCommunicationState);
   172 				if (!(*(d->iam_a_slave)))
   168 				if (!(*(d->iam_a_slave)))
   173 				{
   169 				{
   174 					ptrTable =(*d->scanIndexOD)(wIndex, &errorCode, &Callback);
   170 					send_consise_dcf(d,0x01);
   175   					
   171                     /*(*d->preOperational)() will be called once dcf sent */
   176   					if (errorCode != OD_SUCCESSFUL)
       
   177   						{
       
   178   							(*d->preOperational)();
       
   179   						}
       
   180 					else
       
   181 						{
       
   182 							UNS32 res;
       
   183 							res = decompo_dcf(d,0x01);
       
   184 						}				
       
   185 				}
   172 				}
   186 				else 
   173 				else 
   187 				{
   174 				{
   188 					(*d->preOperational)();
   175 					(*d->preOperational)();
   189 				}
   176 				}