py_ext/plc_python.c
changeset 4109 2fb97bc2158a
parent 4104 9e59bb5ad9e1
equal deleted inserted replaced
4103:63c002e87c57 4109:2fb97bc2158a
   154 			Current_PLC_EvalFB = (Current_PLC_EvalFB + 1) %% %(python_eval_fb_count)d;
   154 			Current_PLC_EvalFB = (Current_PLC_EvalFB + 1) %% %(python_eval_fb_count)d;
   155 		}
   155 		}
   156 	}
   156 	}
   157 }
   157 }
   158 
   158 
   159 char* PythonIterator(char* result, void** id)
   159 char* PythonIterator(char* result, void** id, int* is_last)
   160 {
   160 {
   161 	char* next_command;
   161 	char* next_command;
   162 	PYTHON_EVAL* data__;
   162 	PYTHON_EVAL* data__;
   163 	//printf("PythonIterator result %%s\n", result);
   163 	//printf("PythonIterator result %%s\n", result);
   164     /*emergency exit*/
   164     /*emergency exit*/
   211 	/* make BUFFER a null terminated string */
   211 	/* make BUFFER a null terminated string */
   212 	__SET_VAR(data__->, BUFFER, .body[__GET_VAR(data__->BUFFER, .len)], 0);
   212 	__SET_VAR(data__->, BUFFER, .body[__GET_VAR(data__->BUFFER, .len)], 0);
   213 	/* next command is BUFFER */
   213 	/* next command is BUFFER */
   214 	next_command = (char*)__GET_VAR(data__->BUFFER, .body);
   214 	next_command = (char*)__GET_VAR(data__->BUFFER, .body);
   215 	*id=data__;
   215 	*id=data__;
       
   216     /*check if last command in the queue */
       
   217 	*is_last = EvalFBs[(Current_Python_EvalFB + 1) %% %(python_eval_fb_count)d] == NULL;
   216 	/* free python mutex */
   218 	/* free python mutex */
   217 	UnLockPython();
   219 	UnLockPython();
   218 	/* return the next command to eval */
   220 	/* return the next command to eval */
   219 	return next_command;
   221 	return next_command;
   220 }
   222 }