This example documents how to communicate with the Resuscitator program
to create a watchdog for both Scorpion and a Proscilica camera which is
controlled by Scorpion.
The Resuscitator program - also named Scorpion Watchdog - is a program managing tool
and is available on the Scorpion CD. This program can control startup,
shutdowns sequence and be a watchdog for
all kinds of programs.
This example shows how to use it to implement a fast watchdog if a
program stops capturing images.
The example is available on the Scorpion CD and
the Scorpion profile is called: Test Prosilica Watchdog.
Example : Test Prosilica Watchdog Requirements:
- Python
- Python for Windows Extentions
- Resuscitator
must be installed.
Scorpion is started and controlled by Resuscitator and must be
closed when it is started from Resuscitator.
The Resuscitator configuration file - Resuscitator.ini - is
placed in the profile base directory.
Scorpion and Resuscitator will communicate as follows:
Scorpion will write two lines in Resuscitator.ini file. They are stated
below [AliveStatus]
status= 1 In our example Resuscitator will check if these two lines
has been written every 10 seconds. If they
are present in the file, Resuscitator will delete them. If not, Resuscitator
will restart scorpion. It is important that Scorpion writes the program
lines above more frequently than they are written (for instance every
second)
Scorpion setup: In Central make a function named KickResuscitator as
shown below.
def KickResuscitatior(applicationName,
iniFileName)
import win32api
profile = GetStringValue('System.Profile') # when the code is executed,
profile will contain a string with the the path of the current scorpion
profile.
win32api.WriteProfileVal('AliveStatus',applicationName,1,profile + '\\' +
iniFileName) #for writing the lines to the file using the win32api (for
details read the win32 api)
The script which calls the KickResuscitator function will must be
executed both when the Scorpion is IDLE, and when Scorpion is RUNNING. If
RUNNING we call Grab action, which gets a snapshot from the camera.
When the camera has sent the snapshot, the action AfterInspect will be
trigged. In AfterInspect we'll call the KickResuscitator function, which
then only is trigged if the camera is working properly. In sytem state idle,
we won't check if the camera is operating correctly, and call the
KickResuscitator function directly. We will use Scorpion actions and events
to enable this. For more information on Scorpion actions and events, klick
here.
This example implements the strategy above by defining two actions in the
actions tab, and one event in the scheduler: CameraTrigger and AfterInspect.
After inspect is a system defined event, and should be filled with one new
command; command = Script, parameters=
KickResuscitator('Scorpion',' resuscitator.ini'). In the camera
trigger action we have added two new commands. The first one has the
command=Grab and a guard=running. The second one has command = Script,
parameters= KickResuscitator('Scorpion','
resuscitator.ini'), and guard = Inverted
running. In the scheduler create a new Event. Give it the following
attributes; name: nextImage, command: cameraTrigger, frequency: 'every nth
millisecond', period: 200 Resuscitator setup:
Place a shortcut to Resuscitator in the startup group, edit the
properties:
Target : C:\Program Files\Tordivel AS\Resuscitator for NT\FindResuscitator.exe
Start in: "C:\Program Files\Tordivel AS\Scorpion 7\Test Prosilica
Watchdog
In the Resuscitator program press configure button, and edit the
properties for each application:
Under configure for applications: Shutdown
Program path: C:\Program Files\TORDIVEL AS\Resuscitator for NT\SHUTDOWN.EXE
Start in: C:\Program Files\TORDIVEL AS\Resuscitator for NT
Select checkbox: Run at shutdown only
Under configure for applications: Server control parameters
Program path: C:\Program Files\Tordivel AS\Resuscitator for NT\FindResuscitator.exe
Parameters: -topmost
Select checkbox: Watch this program
Under configure for applications: Scorpion
Program path: C:\Program Files\TORDIVEL AS\Scorpion 6\Scorpion.exe
Parameters: system="Test Prosilica Watchdog" #This is the profile we want
to open with scorpion
Start in: C:\Program Files\TORDIVEL AS\Scorpion 6\
Select checkbox: Watch this Program
Select checkbox: Alive check
For further information of the Resuscitator program, please refer to the
Resuscitator help files on the Scorpion CD.
|