Java Programming

From HSYCO
Jump to: navigation, search

You can write custom Java code to respond to any HSYCO event.

Java is precompiled, and offers the best performance and powerful programming features of a fully standard Java language.

The Java programming framework is very similar to the EVENTS language structure - a library of callback methods are asynchronously called on system and filed events. You are allowed to extend these methods with standard Java code and a comprehensive library of command and utility methods that already implement all common functions you may need to interact with field systems and with the user interface.

You are free to use any standard Java feature or external classes. This is a fully standard Java environment, not a sandboxed solution.

You are also going to use Java to extend the core HSYCO system with plug-in applications and custom I/O Servers, as well as to access other embedded HSYCO features, like the integrated SQL engine. These topics are discussed in the Advanced Programming chapter.

user.java

The basic Java extension of HSYCO is based on a class called user, declared in a user.java file, contained in the hsyco/com/hsyco directory and compiled in a java.class file.


Note The user.class file must exist for the HSYCO to work correctly, even if there is no customized Java code.


HSYCO SERVER ships with an empty user.class file pre-installed.

The user class should extend the userBase class, a skeleton class that provides methods to execute actions on the field devices, as well as internal functions, and the callback framework methods, which are the methods called by HSYCO after any event is detected.

The dummy user.java file contains only the class declaration:


/*  HSYCO CONTROLLER, USER CODE
 *  (c) 2014 Home Systems Consulting SpA
 *  For information, see the Home Systems Consulting web site:
 *  http://www.homesystemsconsulting.com/
 */
 
package com.hsyco;
public class user extends userBase {
}


The HSYCO run-time environment should be restarted for user.class changes to become effective. The default setting of the AutoKillFiles parameter in hsyco.ini causes the automatic restart of HSYCO when user.class is changed.

The Java Callback Methods API and Java Command and Utility Methods API chapters describes the callback methods and all the command and utility methods provided by userBase.

These methods are the only official HSYCO Java API methods.

You should avoid using other public methods provided by other classes within the HSYCO package. These methods could change without notice in any new HSYCO release, causing compatibility issues between your code and different versions of HSYCO.

Predefined Constants

The table below lists the predefined constants that you should use as parameters or are returned by the HSYCO Java API.


Name Description
MERGED DMX merged channel
NOCHANGE don’t change current status
OFF off action and status
ON on action and status
PAUSE pause status (only Squeezebox music player)
PLAY play status (only Squeezebox music player)
UNKNOWN unknown status value