SHARK Device Server

Shark control  is a program that is responsibly for controlling hardware devices in the SHARK environment like the Logimat, location light and label printers. It acts as a Device Server for Shark and provides a generic interface to the hardware and thereby hides different hardware variations to the general SHARK software.

The program is running as a Windows Service and is never seen by the user, but for configuration and trouble shooting it is convenient to know how the program is working. Shark control has a built-in Telnet server for debugging.

Shark Control provides a generic interface to the hardware for the SHARK

 

SHARK control adds a generic layer between the SHARK Server and the hardware. Shark Control features are:

Separate hardware from the main Shark application, this makes it much easier to interface to other hardware, because only the much smaller Control application has to be modified. SHARK control can be put physical close to the hardware. It communicates with the server by the local network .

For smaller installations SHARK control just run on the same computer as the server, it can even be embedded into the client to avoid a separate service.

The server can control as many instances of SHARK control as required. They can be running on the same or several computers. SHARK control has a simulation mode, useful for testing larger installations, where the Server software can be tested, even when the hardware is not ready yet. SHARK control can be operated as a stand-alone application for simple operations. This can be used for trouble-shooting and for setting up an installation, where the hardware setup can be done from the smaller program. Support for external applications to control the hardware.

The SHARK Clients communicate with Shark Control through a TCP/IP socket connections. The default port is 8089, but this can be changed by the installation setup. The used protocol is a readable ASCII based command language that also can be used for direct control from a telnet client, mainly for debugging or included in scripts for automated functions.

 

Installation and Configuration

The normal procedure for installing the SHARK Device Server components is to use the SHARK Server installation program. In the following the installation will be described in detailed in case a manually installation is required.

Required Files

In folder ..\shark\bin:

 

In folder ..\shark\shark control:

File

Function

sharkjservice.exe

Service loader program. Load and executes the Java sharkcontrol.jar file.

 

 

sharkcontrol.jar

The main SHARK control program.

sharkcontrol.cmd

Script that allows SHARK control to be run as an interactive program (mainly for debugging).

init.scp

File containing initial instrument commands. Used to load and initialize the required modules.

shark-control.cfg

A configuration file used by SHARK control to keep some basic configuration parameters.

 

 

 

Installation of the SHARK control Service

Execute the command below:

sharkjservice -i SharkControl "SHARK control" "dk/logiware/sharkcontrol/SharkControl" "C:\Programmer\SHARK\Shark control\sharkcontrol.jar"
"C:\Programmer\SHARK\Shark Control" "C:\Programmer\shark\Java\1.4.2\bin\client\jvm.dll"

The pathes and parameters must be modified to reflect the actual environment.

General syntax:

<command> = [-i|-c|-r]  install|commandline|remove

sharkjservice <command> <service name> <service display name> <main-class name> <jar file> <app dir> <java vm>

This command will also set the registry.

Registry setting

A number of parameters in the SHARK registry controls how the device server works.

To access the registry open Maintenance->System Config->Registry.

The following parameters are available:

 

Name

 Values

Type

Description 

Simulate

0|1 

integer

If set to 1 SHARK control will work without the real hardware but, simulate the behavior.

ScriptFile

Path to file

string

Path to a script file (Java BeanShell) that will be evaluated when SHARK control is started.

 

Registry setting for SHARK control

Setting the Service

Loading Modules

When Shark Control starts, it load modules as defined in the Shark Registry. The default registry location is "Devices".


Common subsystem parameters

Name

 Values

Type

Description 

Enabled

true|false 

Boolean

If false the module will be ignored.

Instance

Main|<host_name>

String

This is the instance of Shark Control that should handle this module. "Main" is used when only one Shark Control exists (will always be loaded).

Type

Subsystem Name

String

This is the name of the module. It is actually a Java class name.

Debug

true|false

Boolean

If true debug mode will be enabled for this module.

 

The instance name is used when more Shark Controls are used in parallel. In that case the instance name is the host_name of the computer, that should load the subsystem. The default name is "Main", which means it always will be loaded (1 Shark Control instance).

Command Line Arguments

When SHARK control is started some command line arguments can be added to modify the functionality.

The default setup is that SHARK Control runs silently (no standard output/input) using the standard SHARK database to read the configuration.

Switch

Function

-interactive

Allows interactive use from the command line where SHARK Control is started. SHARK Control will read commands from standard input and generate a command prompt.

-debug

Enable low-level debug output.

-NoAutoload

Do not read the configuration from the database.

-nodb

Do not use the SHARK database (run in an environment without database access). The configuration must be done by commands, for example in a script file.

-script <script file>

Load and execute the specified BeanShell script file. Functions defined here can later executed from the command line or from a client. 

-run <cmd file>

Execute the commands in the specified cmd file.

-root

Set the root for the SHARK registry from where the configuration is read. Default is “devices”.

-testdb

Use the database configuration for the test environment (set in the Windows Registry).

The switches can either by supplied on a command line as for example to interactively in debug mode:

>java -jar shark_control.jar -interactive -debug

This setup will skip the setup in the database and instead make a setup from a command file "init.sc".

>java -jar shark_control.jar -interactive -debug -NoAutoload -run init.sc

or if SHARK Control is running as a service, as a parameter to the service setup in the Windows Registry. Use the parameter "AppDir".

Instrument Commands

SHARK control is controlled by instrument commands that are plain ASCII commands that can be used from SHARK itself, but also used in interactive mode for debugging and put in files for configuration.

Standard Commands

The command language has two basic forms: commands that will never return anything and queries that always returns a response (string).

The general syntax for a command is:

A:B:C

The general syntax for a query is:

A:B:C:?

Note that the only difference is the question mark (?) at the end of the command (before the parameters).

Events

The device server can generate response at its own in case of an event. An event response will always begin with a "!".

Script Commands

If a command is started with "@" the rest of the line is interpreted as a Bean Shell Command. This allows the Shark Device Server to be customized by creating script commands that are defined in a script file, loaded when the device server is started. The name and location of the script file is defined in the SHARK registry parameter SharkControl.ScriptFile.

A script has access to some predefined functions:

execute()
Will execute a standard instrument command.

message()
Will write the to standard output.

General Commands

Some commands are available in all modules, like commands for debugging etc.

 

:Debug

Scope:  All modules.

Defines the log level for SHARK control.Enable/disable debug printouts

Debug

[function [, mode]]

 

 

 

 

 

function

ALL|LOWLEVEL|EVENTS

 

mode

on|off If true debug messages will be printed to standard output

Example:

Enable debug outputs for a pickcart module called "A":

pickcart:a:debug all,on

 

:Help?

 

Scope:  All modules.

 

Display help information about commands for the specific module. If a command is supplied detailed information will be provided.

 

Help?

[command]

 

 

Command    

Help for a specific command.

Example:

Shows help for a pickcart module called "A":

pickcart:a:help?

:Status?

Scope:  All modules.

Returns a status string about the current status of the module. All modules implements this query.

 

Status?

 

 

 

 

 

 

Example:

Check the status for the PickCart:A module:

pickcart:a:status?

 

Scripting

SHARK Control supports Bean Shell Scripting. The script language is very similar to Java and provides a convenient way to make repeated functions or for testing purposes.

Function

Description

message(<message to print>)

 

exec(<cmd>)

 

query(<cmd>)

 


 

Running script code

The script code can be execute from a Telnet client.
 

Script functions can be defined in the BeanShell script file loaded by the "-script filename" argument. Functions with a single letter can be used as shortcuts from the command line. For example define the function:

t() {
  exec("logimat:a1:gettray");
}

This will define a function called "t", it can be executed simply by enter a "t" on the command line, as:

>t

Which again will execute the command: "logimat:a1:gettray".

It is also possibly to use parameters in these simple script calls. For example:

a(int n) { ..}

can be executed by the command line:

a 5

which will execute the script a(5);