Switch Configuration Script Language
Ruby scripts are written to define when switch objects are to be used based on weather feed data and date.
An example of a script is shown below:
The following class names and member functions are currently implemented:
- IWLCalendar - used for all weather feed types
- IWLBaseline - used for all weather feed types
- UKMetOfficeWCF - used for UK Met Office World Cities Five Day Forecast
- UKMetOfficeDWF - used for UK Met Office UK Cities Forecast and UK Met Office World Cities Forecast
Class IWLCalendar
This class is for general use.
The status of a date (whether it is a weekend, weekday or holiday), can be defined in the Calendar tab of an IWLive Switch Controller object.
If there is no calendar defined (no Switch Controller associated with the Baseline), a default calendar is used during script execution. The default calendar has no holidays and has a weekend period of 'Saturday and Sunday'.
Member function | Description |
---|---|
bool is_holiday() |
Returns true if the current forecast date is a holiday (as defined by the calendar) |
bool is_holiday(string name) |
Returns true if the current forecast date is the named holiday (as defined by the calendar) |
bool is_weekday() |
Returns true if the current forecast date is a weekday (as defined by the calendar) |
bool is_weekend() |
Returns true if the current forecast date is a weekend (as defined by the calendar) |
to_time |
Returns a Ruby.Time object for the current forecast date. For more information on the use of Ruby time type, please follow this link. Please Note
The value given by IWLCalendar.to_time is initialised to midnight on the day of the run, so only date values can be examined in a meaningful way (i.e. hour and minute are always 0). This means that the value of IWLCalendar.to_time is in fact the date at the start of the run. |
NB: The forecast date is single-state. In other words, the date can be only one of the following: holiday, weekday or weekend.
Class IWLBaseline
This class is for general use.
Member function | Description |
---|---|
switch(type, id) |
Sets the specified model object type* and id as a switch object. |
switch(type, name) |
Sets the specified model object type* and name as a switch object. |
switch(type, guid) |
Sets the specified model object type* and guid as a switch object. |
The ID, Name and GUID of an object can be viewed by right clicking the database object in the tree view in the Model Group window and selecting Properties from the context menu.
* The type argument is the scripting type name, which in most cases is the same as the model object description:
Type argument | Object description |
---|---|
Control |
Control |
Demand Diagram |
Demand Diagram |
Demand Scaling |
Demand Scaling |
Electricity Tariff |
Electricity Tariff |
Energy GHG Factors |
Energy CO2 Factors |
RTC Scenario |
UPC Scenario |
Class UKMetOfficeWCF
This class is for use by the UK Met Office World Cities Five Day Forecast.
Member function | Description |
---|---|
double weather_code() |
Returns a weather code. Visit the Met Office for documentation for details on how to interpret the weather code. |
double max_temperature() |
Returns the maximum forecast temperature for the current forecast. |
double max_temperature() |
Returns minimum forecast temperature for the current forecast. |
Class UKMetOfficeDWF
This class is for use by the UK Met Office UK Cities Forecast and UK Met Office World Cities Forecast.
Member function | Description |
---|---|
double day_weather_code() |
Returns a weather code that describes daytime significant weather for the current forecast. |
double night_weather_code() |
Returns a weather code that describes nighttime significant weather for the current forecast. |
double max_temperature() |
Returns the maximum forecast temperature for the current forecast. |
double mix_temperature() |
Returns minimum forecast temperature for the current forecast. |