I am trying to simulate emergency stop in a process. If a HMI button is pressed, it should automatically pause/resume the process. The pause works, but the resume doesn’t work and I think it’s because of the While True loop.
Could anyone please suggest some modifications?
Component: Red robot
Expected Behaviour: Process stops/resumes when signal is True/False respectively
Actual behaviour: Process stops when the signal is true or false
File: 08-02-2ndAttempt.vcmx (1.4 MB)
Version: 4.5 Premium
Code:
# Emergency Stop Function
def CallEmergencyStop(signal):
global doStop
if signal.Value == True:
rx.IsEnabled = False
print("inside doStop IF")
doStop = True
elif signal.Value == False:
rx.IsEnabled = True
print("inside doStop ELSE")
else:
print("Check line 50 for error")
def OnSignal(powerSignal):
global doStop
doStop = False
rx.IsEnabled = True
while True:
condition(lambda:doStop)
BreakTaskletExecution()
mt = rc.createTarget()
mt.MotionType = VC_MOTIONTARGET_MT_JOINT
mt.UseJoints = True
jvals = [j.CurrentValue for j in rc.Joints]
mt.JointValues = jvals
rc.addTarget(mt)
rc.moveImmediate()
doStop = False
print("Inside while Loop")
if powerSignal.Value == True:
CallEmergencyStop(powerSignal)
elif powerSignal.Value == False:
resumeRun
print("resuming...")