py_ext/plc_python.c
branch1.1 Korean release
changeset 1384 02fe382c4511
parent 1288 adc79fc44079
child 1410 0d34b69cc9b5
child 1469 86797748c2a2
equal deleted inserted replaced
1280:72a826dfcfbb 1384:02fe382c4511
   161     if(PythonState & PYTHON_FINISHED) return NULL;
   161     if(PythonState & PYTHON_FINISHED) return NULL;
   162 	/* take python mutex to prevent changing PLC data while PLC running */
   162 	/* take python mutex to prevent changing PLC data while PLC running */
   163 	LockPython();
   163 	LockPython();
   164 	/* Get current FB */
   164 	/* Get current FB */
   165 	data__ = EvalFBs[Current_Python_EvalFB];
   165 	data__ = EvalFBs[Current_Python_EvalFB];
   166 	*id=data__;
       
   167 	if(data__ && /* may be null at first run */
   166 	if(data__ && /* may be null at first run */
   168 	    __GET_VAR(data__->STATE) == PYTHON_FB_PROCESSING){ /* some answer awaited*/
   167 	    __GET_VAR(data__->STATE) == PYTHON_FB_PROCESSING){ /* some answer awaited*/
   169 	   	/* If result not None */
   168 	   	/* If result not None */
   170 	   	if(result){
   169 	   	if(result){
   171 			/* Get results len */
   170 			/* Get results len */
   207 	//printf("PythonIterator\n");
   206 	//printf("PythonIterator\n");
   208 	/* make BUFFER a null terminated string */
   207 	/* make BUFFER a null terminated string */
   209 	__SET_VAR(data__->, BUFFER, 0, .body[__GET_VAR(data__->BUFFER, .len)]);
   208 	__SET_VAR(data__->, BUFFER, 0, .body[__GET_VAR(data__->BUFFER, .len)]);
   210 	/* next command is BUFFER */
   209 	/* next command is BUFFER */
   211 	next_command = (char*)__GET_VAR(data__->BUFFER, .body);
   210 	next_command = (char*)__GET_VAR(data__->BUFFER, .body);
       
   211 	*id=data__;
   212 	/* free python mutex */
   212 	/* free python mutex */
   213 	UnLockPython();
   213 	UnLockPython();
   214 	/* return the next command to eval */
   214 	/* return the next command to eval */
   215 	return next_command;
   215 	return next_command;
   216 }
   216 }