LimitCheck
Previous  Top  Next

The most straightforward use of the monitor is as a limit check on individual items. This simple limit check example demonstrates how to set up such a simple monitor. Let's say we have a HK block with some voltage items. We want to log a message in the GSEOS message window when the voltage of Plus_12V_Mon exceeds 15. The block definition of the HK block is given below:

HK
{
  Plus_12V_Mon            ,,,8;
  Plus_28V_Mon            ,,,8;
  Plus_5V_Mon             ,,,8;
  Plus_6V_Mon             ,,,8;
  Minus_5V_Mon            ,,,8;
  Plus_5DPU_Mon           ,,,8;
  Minus_12V_Mon           ,,,8;
  Minus_6V_Mon            ,,,8;
  I_Stop_MCP_V            ,,,8;
  I_Start_MCP_V           ,,,8;
}


The monitor function has to compare the value of the item Plus_12V_Mon to the limit of 15. If the condition holds a message is issued. Here the monitor function:

#
#  Import block definitions, Monitor class and other stuff
#
from __main__ import *
import GseosMonitor
import Gseos


#
#  12V Monitor                    
#
def fMon12V(oBlock):
  "12V Monitor"

  if oBlock.Plus_12V_Mon > 15:
    Gseos.Message('12V Monitor: Limit exceeded, current voltage %d' % oBlock.Plus_12V_Mon)

Once we have the monitor function defined we have to assign it to the HK block to get executed:

#
#  Create a new monitor.
#
oMon12V = GseosMonitor.TMonitor('Mon12V', fMon12V)

#
#  Assign it to the HK block.
#
HK.Monitors.append(oMon12V)

After we execute this script we can examine the monitor in the GSEOS Explorer. If we choose the Block node and list all the blocks in the system we should see our HK source block. Extending the Monitors node beneath the HK block lists our monitor and indicates that it is running. You can also get to all monitors from the Monitors node beneath the main GSEOS node.
By right-clicking on the decoder node you can also disable or delete the decoder.






To run this example please install the mon1.blk block definition file in the demo/mon1 folder, restart GSEOS and load the mon1.py monitor script from the same directory.

Note

Keep in mind that the block definitions are not typed. This means your data items are treated as unsigned binary fields. Assume the most significant bit of the 8-bit Minus_5V_Mon item in the HK block is a sign bit a -5 would be represented as 256-5 = 251. To convert this number to a signed value which you can compare to -5 instead of 251 in your monitor function use the GseosConvert.signed() function e. g.:

#
#  -5V Monitor                    
#
def fMonNeg5V(oBlock):
  "-5V Monitor"
  Minus5V = GseosConvert.signed(oBlock.Minus_5V_Mon, 7)

  if Minus5V < -7:
    Gseos.Message('-5V Monitor: Limit exceeded, current voltage %d' % Minus5V)