As mark has written you can evaluate the status bit INVALID in the Reaction Matrix.
Steps:
1. create an internal variable, data type INT, name e.g.: "MODBUS Connection State", property 'Calculation'="Network", 'Remanence'="Initial value", 'Initial value' = -1.
possible values of this variable will be: -1 (idle...), 0 - communication error, 1 - connected OK.
2. create 2 zenon functions 'write set value' for this internal variable, one function "set error" - to set value 0, second function "set OK" - with value 1, both function are configured with 'Direct to the Hardware'.
3. create a multi-numeric reaction matrix with at least 2 conditions:
- new condition to evaluate any value and variable status INVALID=1:

and activate check-box 'treat each change of value as new limit violation';
and link in this condition the function "set error" - created in step 2.
- new condition to evaluate any value and variable status INVALID=0 and SPONT=1 -> calling function "set OK".
4. link this reaction matrix with one of MODBUS process variables, e.g. one of registers available in the device.