equal
deleted
inserted
replaced
87 * Called by the PLC, each time a python_eval |
87 * Called by the PLC, each time a python_eval |
88 * FB instance is executed |
88 * FB instance is executed |
89 */ |
89 */ |
90 void __PythonEvalFB(int poll, PYTHON_EVAL* data__) |
90 void __PythonEvalFB(int poll, PYTHON_EVAL* data__) |
91 { |
91 { |
|
92 if(!__GET_VAR(data__->TRIG)){ |
|
93 /* ACK is False when TRIG is false, except a pulse when receiving result */ |
|
94 __SET_VAR(data__->, ACK,, 0); |
|
95 } |
92 /* detect rising edge on TRIG to trigger evaluation */ |
96 /* detect rising edge on TRIG to trigger evaluation */ |
93 if(((__GET_VAR(data__->TRIG) && !__GET_VAR(data__->TRIGM1)) || |
97 if(((__GET_VAR(data__->TRIG) && !__GET_VAR(data__->TRIGM1)) || |
94 /* polling is equivalent to trig on value rather than on rising edge*/ |
98 /* polling is equivalent to trig on value rather than on rising edge*/ |
95 (poll && __GET_VAR(data__->TRIG) )) && |
99 (poll && __GET_VAR(data__->TRIG) )) && |
96 /* trig only if not already trigged */ |
100 /* trig only if not already trigged */ |
107 if( PythonState & PYTHON_LOCKED_BY_PLC){ |
111 if( PythonState & PYTHON_LOCKED_BY_PLC){ |
108 /* if some answer are waiting, publish*/ |
112 /* if some answer are waiting, publish*/ |
109 if(__GET_VAR(data__->STATE) == PYTHON_FB_ANSWERED){ |
113 if(__GET_VAR(data__->STATE) == PYTHON_FB_ANSWERED){ |
110 /* Copy buffer content into result*/ |
114 /* Copy buffer content into result*/ |
111 __SET_VAR(data__->, RESULT,, __GET_VAR(data__->BUFFER)); |
115 __SET_VAR(data__->, RESULT,, __GET_VAR(data__->BUFFER)); |
112 /* signal result presece to PLC*/ |
116 /* signal result presence to PLC*/ |
113 __SET_VAR(data__->, ACK,, 1); |
117 __SET_VAR(data__->, ACK,, 1); |
114 /* Mark as free */ |
118 /* Mark as free */ |
115 __SET_VAR(data__->, STATE,, PYTHON_FB_FREE); |
119 __SET_VAR(data__->, STATE,, PYTHON_FB_FREE); |
116 /* mark as not trigged */ |
120 /* mark as not trigged */ |
117 if(!poll) |
121 if(!poll) |