Difference between revisions of "Custom Drivers Callback Methods API"

Jump to navigation Jump to search
Line 87: Line 87:
* boolean - 1: return true if successful, false on errors.
* boolean - return true if the loop processing is successful, false on errors.
=== end ===
=== end ===

Revision as of 16:55, 19 February 2014

A few callback methods are called by the HSYCO core engine during initialization, exit, and for normal operations.

You should write your custom interface code inside these methods, and also set the default values of some static properties.

Static Properties



Used to set the default IP socket port, to be used when the port field is not set in the configuration. For example, if your driver is interfacing an HTTP-based service, you may want to set DEFAULTSOCKETPORT to 80.



Defines the size of the command queue.

The command queue is used to accumulate commands that the driver should execute, and are generated by ioSet() JavaScript or Java calls, the IOSET event or users pressing (button) objects in the Web user interface.

The command queue should be large enough to let the driver have time to consume incoming commands and not lose any. At the same time a queue that is too large could let a large number of messages to accumulate in case the driver has temporary issues talking to the external system.

HSYCO's built-in drivers usually have queue sizes between 64 and 1024. 256 is normally a good value.



This is the default value of the "shutdown when inactive" configuration parameter. If true and the "shutdown when inactive" is not defined, the driver will be automatically shut down when the HSYCO server is in a high availability configuration and the server is not the active server.

Callback Methods


boolean init(String name, HashMap<String, String> config)

Called once every time the driver is started.

Returning false will fail the initialization procedure, and the driver will not start.


  • name: String - this driver's identifier
  • config: HashMap<String, String> - a hash table of all basic configuration parameters, see the table below, and all options.
Parameter Description
comm communication port identifier
host the host IP name address
port the IP port
user user name
password password
shutdowninactive the shutdown when inactive parameter


  • boolean - true if the initialization process is successful (HSYCO will consider the driver instance initialized and start calling the loop() callback); false to fail the initialization procedure (HSYCO will retry the initialization process later).


boolean loop()

Called repeatedly while the driver should be alive.

Returning false will not update the keep-alive timer, causing the driver to quit after a while.

This call should always return within about 30 seconds, to avoid the keep-alive watch-dog intervention.


  • boolean - return true if the loop processing is successful, false on errors.


boolean end()

Called once when the driver quits after it has started correctly.

Should always return true.


String user(String session, String user, String id, HashMap<String, String> fields)

Called on user keys, gui input objects, submit and user action in Events or Java, when the user interface object identifier has a prefix that matches the driver's identifier followed by a "." character.

Note This method is optional, and doesn't need to be implemented if not required.


void command(String name, String value)

Called for each command that should be processed by the driver.

Note This method is optional, and doesn't need to be implemented if not required.