JavaScript Callback Functions API

From HSYCO
Jump to navigation Jump to search

Callback Functions

System Functions

DaylightEvent

DaylightEvent(day)

Called at sunrise and sunset, according to the latitude and longitude values set in hsyco.ini, and the optional SunriseOffsetMinutes and SunsetOffsetMinutes parameters.

Parameters:

  • day: boolean - true at sunrise, false at sunset.


haActiveEvent

haActiveEvent(active)

Triggered by the change of state of an HSYCO server in a master/slave high availability configuration.

Parameters:

  • active: boolean - true if the server is active, false if not active.


PowerEvent

PowerEvent(power)

Triggered by a change of the current power load level, as set using the powerSet() Java API or the POWER action.

Thanks to this method it is possible to alter the power value shown in the Web interface, for example to aggregate power readings acquired from other sensors.

Parameters:

  • power: numeric - the power level, in Watts.

Returns:

  • numeric - if PowerEvent() returns -1 or doesn't return a value, HSYCO status is updated with the detected power value, the value returned by PowerEvent() is otherwise used.

Note The JavaScript PowerEvent return value is used only when the Java PowerEvent callback is not defined or returned -1.


programTimerEvent

programTimerEvent(name)

Called when a program timer is activated.

Program timers are set using programTimerSet(), programTimerReset(), programTimerRepeat(), or using the corresponding actions in the EVENTS.

Parameters:

  • name: string - program timer name.


SchedulerEvent

SchedulerEvent(groupname, schedulename)

This callback blocking function allows to call user methods at configurable intervals.

You define schedules using a group name and a schedule name.

Schedules under the same group run in the same thread and are executed sequentially, based on their interval in milliseconds. Schedules in different groups run in parallel.

Parameters:

  • groupname: string - the scheduler’s group name
  • schedulename: string - the scheduler’s name.


StartupEvent

StartupEvent()

Called only once when HSYCO starts, after the initialization and HTTP server start-up, but before the execution of the different field interface threads. It is not executed in a thread, it is therefore a blocking method, that must complete its execution before all other HSYCO services can be started.


SunPositionEvent

SunPositionEvent(azimuth, elevation)

Called when the Sun changes its height with respect to the horizon or its angle from true north.

Parameters:

  • azimuth: numeric - the current Sun angle from true north, in decimal degrees
  • elevation: numeric - the current Sun elevation in decimal degrees from the horizon. Elevation is negative at night.


TimeEvent

TimeEvent(time)

Called every 60 seconds.

HSYCO tries to synchronize the execution at the beginning of the minute, executing this method at seconds 0 of every minute.

Note However, the execution is not guaranteed. In case of heavy load HSYCO might not be able to execute the call with accurate timing. In extreme cases, it could occasionally skip some calls.

Parameters:

  • time: numeric - the current time in milliseconds.


varEvent

varEvent(name, value)

Triggered by the change of value of a program variable.

Parameters:

  • name: string - the variable name. Names are case-insensitive
  • value: string - the value to be assigned to the program variable.


Cameras

CameraCommandEvent

CameraCommandEvent(function, action, camera)

Triggered by a camera control input from the Web interface.

It can be used to execute arbitrary actions when the user clicks on the active areas of the camera view, or to replace some or all of the standard PTZ commands with custom actions.

Parameters:

  • function - see the table below
  • action - see the table below
  • camera - the camera name.

Returns:

  • numeric - if CameraCommandEvent() returns -1 or doesn't return a value, the standard PTZ command associated to the PTZ driver is skipped, otherwise it is executed normally.

Note The JavaScript CameraCommandEvent return value is used only when the Java CameraCommandEvent callback is not defined or returned -1.

icon function action
Camover-ff.png focus far
Camover-fn.png focus near
Camover-zin.png zoom tele
Camover-zout.png zoom wide
Camover-l.png move left
Camover-r.png move right
Camover-u.png move up
Camover-d.png move down
move stop
Camerapanel ptz.png

CameraMotionEvent

CameraViewEvent

DMX

DmxEvent

DmxFilter

DmxStartupEvent

Infrared Control

IREvent

I/O Servers

IOEvent

IOStartupEvent

Network Location Services

LocationEvent

Modbus

ModbusEvent

PBX

PBXCallEvent

Squeezebox

SlimPowerEvent

SlimStatusEvent

SlimVolumeEvent

Timers and Schedulers

UserTimerEvent

User Interface

pageEvent

uiClearEvent

userCommand

userSubmit

WebRootRequestEvent

Command and Utility Functions