Greetings,
I am working on a project that displays how long until a PM needs to be performed on a robot. The PLC has an "Hours" and "Minutes" that it receives from each robot. This has worked fine to simply display the amount of time left in "LED Displays", but I am trying to take it up a notch and write script that will look at the amount of time left on all of the robots in a zone, decide what robot has the least amount of time left, and display it in LED Displays.
I am very new to python and have limited programming knowledge, but think this should be pretty simple to do.
The problem I am having is any time the code executes, I get an error:
Traceback (most recent call last):
File "event:propertyChange", line 7, in
TypeError: can't convert '[default]STOLNAI_Tags/D2LC_H-Pillar_Main_Tags/ST30LR1_Hours_Left' to double
at org.python.core.Py.TypeError(Py.java:235)
at org.python.core.Py.tojava(Py.java:515)
at org.python.core.PyBeanProperty.doset(PyBeanProperty.java:63)
at org.python.core.PyObject.set(PyObject.java:3678)
at org.python.core.PyObject.object___setattr_(PyObject.java:3742)
at org.python.core.PyObject.object___setattr__(PyObject.java:3732)
at org.python.core.PyObject$object___setattr___exposer.call(Unknown Source)
at org.python.core.PyObjectDerived.setattr(PyObjectDerived.java:990)
at com.inductiveautomation.factorypmi.application.script.PyComponentWrapper.setattr(PyComponentWrapper.java:169)
at org.python.pycode._pyx171.f$0(event:propertyChange:20)
at org.python.pycode._pyx171.call_function(event:propertyChange)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1275)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:657)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:183)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.access$000(ActionAdapter.java:42)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter$ActionRunner.run(ActionAdapter.java:299)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Ignition v7.9.3 (b2017060210)
Java: Oracle Corporation 1.8.0_131
There my be logical errors in my script, but I can't really troubleshoot until I get past this error. The tags that I am trying to display in the LED Displays are Integers and I don't have any issues directly binding the tags to the displays, but it seems to not like them being integers when setting the value through the script.
Here is the script:
st30lr1Ttime = ("[default]STOLNAI_Tags/D2LC_H-Pillar_Main_Tags/ST30LR1_Hours_Left"*60)+"[default]STOLNAI_Tags/D2LC_H-Pillar_Main_Tags/ST30LR1_Minutes_Left"
st30lr2Ttime = ("[default]STOLNAI_Tags/D2LC_H-Pillar_Main_Tags/ST30LR2_Hours_Left"*60)+"[default]STOLNAI_Tags/D2LC_H-Pillar_Main_Tags/ST30LR2_Minutes_Left"
st40lr1Ttime = ("[default]STOLNAI_Tags/D2LC_H-Pillar_Main_Tags/ST40LR1_Hours_Left"*60)+"[default]STOLNAI_Tags/D2LC_H-Pillar_Main_Tags/ST40LR1_Minutes_Left"
st60lr1Ttime = ("[default]STOLNAI_Tags/D2LC_H-Pillar_Main_Tags/ST60LR1_Hours_Left"*60)+"[default]STOLNAI_Tags/D2LC_H-Pillar_Main_Tags/ST60LR1_Minutes_Left"
if st30lr1Ttime < st30lr2Ttime and st40lr1Ttime and st60lr1Ttime:
event.source.getComponent('TipChange_Hr').value="[default]STOLNAI_Tags/D2LC_H-Pillar_Main_Tags/ST30LR1_Hours_Left"
event.source.getComponent('TipChange_Min').value="[default]STOLNAI_Tags/D2LC_H-Pillar_Main_Tags/ST30LR1_Minutes_Left"
elif st30lr2Ttime < st30lr1Ttime and st40lr1Ttime and st60lr1Ttime:
event.source.getComponent('TipChange_Hr').value="[default]STOLNAI_Tags/D2LC_H-Pillar_Main_Tags/ST30LR2_Hours_Left"
event.source.getComponent('TipChange_Min').value="[default]STOLNAI_Tags/D2LC_H-Pillar_Main_Tags/ST30LR2_Minutes_Left"
elif st40lr1Ttime < st30lr2Ttime and st30lr1Ttime and st60lr1Ttime:
event.source.getComponent('TipChange_Hr').value="[default]STOLNAI_Tags/D2LC_H-Pillar_Main_Tags/ST40LR1_Hours_Left"
event.source.getComponent('TipChange_Min').value="[default]STOLNAI_Tags/D2LC_H-Pillar_Main_Tags/ST40LR1_Minutes_Left"
elif st60lr1Ttime < st30lr2Ttime and st40lr1Ttime and st30lr1Ttime:
event.source.getComponent('TipChange_Hr').value="[default]STOLNAI_Tags/D2LC_H-Pillar_Main_Tags/ST60LR1_Hours_Left"
event.source.getComponent('TipChange_Min').value="[default]STOLNAI_Tags/D2LC_H-Pillar_Main_Tags/ST60LR1_Minutes_Left"
else:
event.source.getComponent('TipChange_Group').getComponent('TipChange_Hr').value=00
event.source.getComponent('TipChange_Group').getComponent('TipChange_Min').value=00
What would be the best way to go about this?
Thanks in advance,
Steven