overloading for ladder logic
jimzat at gmail.com
jimzat at gmail.com
Fri Nov 7 08:48:49 EST 2008
I am trying to simulate the execution of some PLC ladder logic in
python.
I manually modified the rungs and executed this within python as a
proof of concept, but I'd like to be able to skip the modification
step. My thought was that this might be able to be completed via
overloading, but I am not sure if (or how) it could be done.
overloadings:
+ ==> OR
* ==> AND
/ ==> NOT
Example original code:
A=/B+C*D
translates to:
A=not B or C and D
I tried
def __add__ (a,b):
return (a or b)
which gives me this:
>>> x=False
>>> y=True
>>> x+y
1
>>> x=True
>>> x+y
2
How can this be done?
More information about the Python-list
mailing list