HookService to Monitoring Program State

This is the feature that you want.

Program state from RTDE - Technical Questions / Robot Communication - Universal Robots Forum (universal-robots.com)