Call us! 512-349-0334 or (877) INDUSOFT

How to Monitor Communications Driver Status in InduSoft Web Studio

Occasionally InduSoft Web Studio users wonder if these are any ways to monitor and/or programmatically control the Communications Driver Background Task. The following is a discussion on different techniques that may be helpful in various situations.

Starting and Stopping a Single Driver Programmatically

If you have only one driver configured in the project, and you need to stop and then restart the driver without shutting down the project, you can use the functions EndTask() and StartTask()

Example:

EndTask(“Driver”)

StartTask(“Driver”)

Note: You cannot stop the overall driver task with the EndTask() function, since EndTask(“Driver”) is not allowed. A driver name must always be included when using this function in conjunction with the driver task.

You can execute StartTask(“Driver”) to start all configured drivers not currently running, so this method is ok to use if you only have one driver configured. It may not be a suitable choice, however, if more than one driver is configured.

If you want to start a single driver without affecting other configured drivers (e.g., without restarting the currently running drivers or starting other currently stopped drivers)<,you need to use the () function. Several examples are shown below.

The following form will run from the Database Spy for quick tests, or from Built-In Language Structures(Math Worksheet, Scheduler Worksheet, etc.) in an InduSoft Web Studio application:

WinExec(GetProductPath() +”Bin\Studio Manager.exe “+ Asc2Str(34) + GetProductPath() + “Bin\Driver.dll” + Asc2Str(34) +”ABTCP”)

This form will run from a VBScript

$WinExec($GetProductPath()+”Bin\Studio Manager.exe “+ $Asc2Str(34) + $GetProductPath() + “Bin\Driver.dll” + $Asc2Str(34) +””)

This form will also run from VBScript, using a pair of double quote characters in place of the $Asc2Str(34) functions in the concatenation

$WinExec($GetProductPath() & “Bin\Studio Manager.exe “”” & $GetProductPath() & “Bin\Driver.dll””” & “ABTCP”)

Note:There is a space between the file extension exe and the double quote. Note also that the return value of the function $GetProductPath() already ends with a backslash, so you don’t need it in the strings.

Monitoring Driver Status

If a driver is stopping, you can monitor the status in the following manner:

The Scheduler configuration below is implemented to launch a script by writing the value 1 to the System Tag “$DriverRestart”, which is configured in the Execution field of a script that contains the following two lines:

script1

The first line resets the $DriverRestart tag to 0, so the script only runs one time when launched, and the second restarts a driver that has stopped.

The Scheduler configuration ensures that script will not be launched unless the specified driver has stopped running.

script2

If the driver task isn’t stopping, but you want to monitor the Read Status of a particular driver, then you can set up the scheduler to launch a script that stops a particular driver with EndTask() and then restarts it with WinExec(), if the Read Status tag has been set to 0 for longer than n seconds:

script3

 

This script is launched if the Read Status system tag ($RdStat) on the driver sheet is non-zero for longer than 5 seconds.

The first line resets the $StopStartDriver tag so the script only runs once, and the remaining lines stop the specified driver and then restart it. The wait may need to be adjusted to allow time for the driver to be stopped before it is restarted.

script4

Comments are closed.