Difference between revisions of "JavaScript Callback Functions API"
Line 5: | Line 5: | ||
=== DaylightEvent === | === DaylightEvent === | ||
− | DaylightEvent(day) | + | 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. | Called at sunrise and sunset, according to the latitude and longitude values set in hsyco.ini, and the optional SunriseOffsetMinutes and SunsetOffsetMinutes parameters. | ||
Line 15: | Line 15: | ||
=== haActiveEvent === | === haActiveEvent === | ||
− | haActiveEvent(active) | + | haActiveEvent( active ) |
Triggered by the change of state of an HSYCO server in a master/slave high availability configuration. | Triggered by the change of state of an HSYCO server in a master/slave high availability configuration. | ||
Line 25: | Line 25: | ||
=== PowerEvent === | === PowerEvent === | ||
− | PowerEvent(power) | + | PowerEvent( power ) |
Triggered by a change of the current power load level, as set using the powerSet() Java API or the POWER action. | Triggered by a change of the current power load level, as set using the powerSet() Java API or the POWER action. | ||
Line 41: | Line 41: | ||
=== programTimerEvent === | === programTimerEvent === | ||
− | programTimerEvent(name) | + | 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. | Program timers are set using programTimerSet(), programTimerReset(), programTimerRepeat(), or using the corresponding actions in the EVENTS. | ||
Line 53: | Line 53: | ||
=== SchedulerEvent === | === SchedulerEvent === | ||
− | SchedulerEvent(groupname, schedulename) | + | SchedulerEvent( groupname, schedulename ) |
− | This callback blocking | + | This callback blocking function allows to call user methods at configurable intervals. |
You define schedules using a group name and a schedule name. | You define schedules using a group name and a schedule name. | ||
Line 68: | Line 68: | ||
=== StartupEvent === | === StartupEvent === | ||
− | 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 === | ||
− | SunPositionEvent(azimuth, elevation) | + | SunPositionEvent( azimuth, elevation ) |
− | + | Called when the Sun changes its height with respect to the horizon or its angle from true north. | |
'''Parameters:''' | '''Parameters:''' | ||
*azimuth - the current Sun angle from true north, in decimal degrees | *azimuth - the current Sun angle from true north, in decimal degrees | ||
*elevation - the current Sun elevation in decimal degrees from the horizon. Elevation is negative at night. | *elevation - the current Sun elevation in decimal degrees from the horizon. Elevation is negative at night. | ||
+ | |||
=== TimeEvent === | === TimeEvent === |
Revision as of 19:01, 30 January 2014
Contents
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.
If PowerEvent() returns -1 or if not defined, HSYCO status is updated with the detected power value, the value returned by PowerEvent() is otherwise used.
The JavaScript PowerEvent return value is used only if the Java PowerEvent callback is not defined or returned -1.
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.
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 - the current Sun angle from true north, in decimal degrees
- elevation - the current Sun elevation in decimal degrees from the horizon. Elevation is negative at night.