User Guide

Programming i!-Weather
15
i!-Weather
Receive New Weather Data
Once the i!-WeatherEngine module receives new weather data, it will send a notification on the
virtual weather device. Upon receiving this notification, your program can take the
chSTRUCTURE_ENCODED_BUFFER and decode it using the STRING_TO_VARIABLE function to
your local weather structure. An example is provided below:
//CHECK IN STRUCTURE TO SEE IF QUERY WAS SUCCESSFUL
IF(sWEATHER.nQUERY_SUCCESSFUL)
{
SEND_STRING 0 , "' '"
SEND_STRING 0 ,"'===================================================='"
SEND_STRING 0 ,"'===================================================='"
SEND_STRING 0 ,"' It is currently [',sWEATHER.cTEMP,'] in the city of
[',sWEATHER.cCITY,']'"
SEND_STRING 0 ,"' with conditions of [',sWEATHER.cCONDITION,']'"
SEND_STRING 0 ,"' The winds are at [',sWEATHER.cWIND_SPEED,'] in the
[',sWEATHER.cWIND_DIRECTION,'] direction'"
SEND_STRING 0 ,"' Reported By [',sWEATHER.cSTATION,'] at
[',sWEATHER.cLAST_UPDATE,']'"
SEND_STRING 0 ,"'===================================================='"
SEND_STRING 0 ,"'===================================================='"
SEND_STRING 0 , "' '"
}
}
}
Changing Temperature, Pressure, & Speed Formats
The i!-WeatherEngine module can return weather data in multiple conversion formats.
i!-WeatherEngine module exposes these format controls via the virtual weather device channel
(see Channels).
A source code example is provided below to demonstrate how to set a particular format:
//Set i!-Weather Temperature Format to i!-WeatherEngine
DO_PUSH_TIMED(vdvWEATHER,VIRTUAL_CHANNEL_TEMP_FARENHEIT,5)
//Set i!-Weather Speed Format
DO_PUSH_TIMED(vdvWEATHER,VIRTUAL_CHANNEL_SPEED_MPH,5)
//Set i!-Weather Pressure Format
DO_PUSH_TIMED(vdvWEATHER,VIRTUAL_CHANNEL_PRESSURE_INCHES,5)
Temperature, Pressure, & Speed Formats
Temperature Fahrenheit (°F)
Celsius (°C)
Pressure Inches of Mercury (inches)
Millimeters of Mercury (torr)
Millibars (millibar)
Speed Miles per hour (MPH)
Kilometers per hour (KPH)
Knots (KNOTS)