Java Programming

From HSYCO
Revision as of 10:07, 18 February 2014 by Hsyco (talk | contribs)
Jump to navigation Jump to 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.