GseosMonitor.TMonitor
Previous  Top  Next

TMonitor(strName, fMonitor)

The Monitor constructor creates a new monitor. You have to specify a unique name and the monitor function. In order to start the monitor you have to add it to the list of monitors for the block(s) you want to register your monitor for.

ParameterDescription     
strNameThe unique name identifies the monitor. This is the name you will see in the GSEOS Explorer.     
fMonitorYour monitor function. It takes one parameter which is the block that triggers the monitor (if you register the monitor for more than one block you can use this parameter to determine the source block). If this function throws an exception the monitor is terminated.  

Returns
The new monitor object.

Comments
In order for the monitor to be useful you have to hook it on the arrival of a block. You do this by adding it to the list of monitors for the block you are interested in. See the example below.

Exceptions
TypeErrorThe monitor name has to be a string.     
MonitorErrorThe fMonitor parameter has to be a callable object.  

Example
The following example defines a simple limit check monitor. In case of an out of range condition a message is posted to the GSEOS message window:

#* ************************************************************************* *#
#* * Import the block names into our namespace.                            * *#
#* ************************************************************************* *#
from __main__ import *
import GseosMonitor
import Gseos


def MyMonitor1(oBlock):
  if oBlock.Temp1 > 200:
    Gseos.Message('Monitor1: Sensor temp out of range')

HK.Monitors.append(GseosMonitor.TMonitor('Sensor Temp Check', MyMonitor1))