Hello,
I’ve been troubleshooting the following error:
java.util.concurrent.TimeoutException: null
at java.base/java.util.concurrent.CompletableFuture.timedGet(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture.get(Unknown Source)
at com.inductiveautomation.ignition.gateway.script.GatewayTagUtilities.writeBlockingImpl(GatewayTagUtilities.java:261)
at com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.writeBlocking(AbstractTagUtilities.java:482)
at jdk.internal.reflect.GeneratedMethodAccessor55.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:190)
at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:540)
at org.python.core.PyObject.__call__(PyObject.java:494)
at org.python.core.PyObject.__call__(PyObject.java:498)
at org.python.pycode._pyx177310.pullOperatorLoadTimeFromPLC$6(:334)
at org.python.pycode._pyx177310.call_function()
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:168)
at org.python.core.PyFunction.__call__(PyFunction.java:437)
at org.python.pycode._pyx177304.threadType1$2(:189)
at org.python.pycode._pyx177304.call_function()
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:306)
at org.python.core.PyFunction.function___call__(PyFunction.java:474)
at org.python.core.PyFunction.__call__(PyFunction.java:469)
at org.python.core.PyFunction.__call__(PyFunction.java:464)
at org.python.core.PyObject._callextra(PyObject.java:589)
at org.python.pycode._pyx177305.run$3(:15)
at org.python.pycode._pyx177305.call_function()
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:306)
at org.python.core.PyBaseCode.call(PyBaseCode.java:197)
at org.python.core.PyFunction.__call__(PyFunction.java:485)
at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:237)
at org.python.core.PyMethod.__call__(PyMethod.java:228)
at org.python.core.PyMethod.__call__(PyMethod.java:218)
at org.python.core.PyMethod.__call__(PyMethod.java:213)
at org.python.core.PyObject._jcallexc(PyObject.java:3565)
at org.python.core.PyObject._jcall(PyObject.java:3598)
at org.python.proxies.utils$JythonRunnable$33.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
I understand that this is occurring because my writes are failing to complete within the timeout. I was originally not using the optional timeout parameter, but now I am, although I have it set to 45000ms, which is the same as the default. There is no reason my writes should take more than 5 seconds to complete, 45 seconds should be plenty.
So that leads me to my next issue, I am trying to catch the error so I can pass in some parameters to the fault message to help me diagnose which PLC it is failing on, so I can investigate for connection issues. I am using a try/except clause around my writeBlocking calls but I am still getting unhandled exceptions.
The code for the above error message looks as such:
def pullOperatorLoadTimeFromPLC(plant, deviceName, opName):
logger = system.util.getLogger("Project6.prod_record.pullOperatorLoadTimeFromPLC")
UDTPath = '[Project6]Plant %s/%s/%s/' % (plant, deviceName, opName)
paths = [
UDTPath+'OPC/Operator Load Time/Time/Time_8_/LoadTime',
UDTPath+'OPC/Operator Load Time/Time/Time_8_/ReadyToGrab',
UDTPath+'OPC/Operator Load Time/Time/Time_7_/LoadTime',
UDTPath+'OPC/Operator Load Time/Time/Time_7_/ReadyToGrab',
UDTPath+'OPC/Operator Load Time/Time/Time_6_/LoadTime',
UDTPath+'OPC/Operator Load Time/Time/Time_6_/ReadyToGrab',
UDTPath+'OPC/Operator Load Time/Time/Time_5_/LoadTime',
UDTPath+'OPC/Operator Load Time/Time/Time_5_/ReadyToGrab',
UDTPath+'OPC/Operator Load Time/Time/Time_4_/LoadTime',
UDTPath+'OPC/Operator Load Time/Time/Time_4_/ReadyToGrab',
UDTPath+'OPC/Operator Load Time/Time/Time_3_/LoadTime',
UDTPath+'OPC/Operator Load Time/Time/Time_3_/ReadyToGrab',
UDTPath+'OPC/Operator Load Time/Time/Time_2_/LoadTime',
UDTPath+'OPC/Operator Load Time/Time/Time_2_/ReadyToGrab',
UDTPath+'OPC/Operator Load Time/Time/Time_1_/LoadTime',
UDTPath+'OPC/Operator Load Time/Time/Time_1_/ReadyToGrab',
UDTPath+'OPC/Operator Load Time/Time/Time_0_/LoadTime',
UDTPath+'OPC/Operator Load Time/Time/Time_0_/ReadyToGrab',
]
values = system.tag.readBlocking(paths)
#Mass write all values back to zero immediately after reading.
try:
system.tag.writeBlocking(paths, [0,False,0,False,0,False,0,False,0,False,0,False,0,False,0,False,0,False], writeTimeout)
except:
logger.warn("Failed to write zeroes to operator load time opc tags for plant %s %s %s" % (plant, deviceName, opName))
#Get current target load time:
try:
targetLoadTime = get.getOperatorLoadTimeOPC(plant, deviceName, opName)
except:
targetLoadTime = 0
logger.warn("Failed to get target load time for plant %s %s %s" % (plant, deviceName, opName))
#
#Start sql insert
for value in values:
if isinstance(value.value,float):
loadTime = value.value
if loadTime>0:
currentTime = get.getOpCurrentLocalTime(plant, deviceName, opName).replace(tzinfo=None)
params ={
'table':'P'+str(plant)+'_pd_operator_load_time',
'deviceName': deviceName,
'opName': opName,
'operatorLoadTime':loadTime,
'date_time':currentTime,
'targetLoadTime':targetLoadTime,
}
try:
system.db.runNamedQuery("Project6","Operator Load Time/insertOperatorLoadTime", params)
except:
try:
system.db.runNamedQuery("Operator Load Time/insertOperatorLoadTime", params)
except:
logger.fatal("Failed to run sql query for plant %s %s %s" % (plant, deviceName, opName))
return
else:
pass
Does anyone have any ideas on what I can do to properly catch this error?
Thanks