Hi Martin,
that idea will work, the signal is ISIG_EMERGENCY. If you include it in your signal library you could easily set/reset outputs.
What happens in other situations is not clear. For instance if a limit switch goes active it is common for Mach to stop and disable. Whether that is the same as an
Estop I don't know but if it is then your outputs would not be set/reset as you desired because it was a signal OTHER than ISIG_EMERGENCY that caused it.
There are a couple of API calls that may be of use:
rc = mc.mcCntlEStop(
number mInst)
which allows you to invoke an Estop programatically.
rc = mc.mcCntlEnable(
number mInst,
number state)
which allows you to enable/disable Mach at will.
mcState, rc = mc.mcCntlGetState(
MINSTANCE mInst)
which allows you to read Machs state at any given time.
It should be easy enough to monitor signals like ISIG_EMERGENCY or maybe others signals which you have attached to screen buttons or physical switches
and they could directly cause the outputs to change in a manner that you determine. In addition it would be necessary to monitor Machs state to see if some other
event caused Mach to disable, like a limit event. The problem would be that once you detect Mach has been disabled its too late to set/reset outputs....I think!
My suggestion would be to experiment with some cut down code to determine what if any functionality remains active when Mach is disabled. If this phase/mode of
operation still allows you to set/reset outputs at will then the most problematic part of your proposal will achievable.
Craig