User Guide

Programming i!-Weather
18
i!-Weather
Notification Channels
The i!-WeatherEngine notification channels are used by the i!-WeatherEngine to send a notification
to the parent program that information has been received, or an error has occurred. Upon detecting
a
PUSH event on these notification channels, your program can decode the weather data structure, or
process the error received.
//i!-Weather Error Channels
DEVCHAN dcWEATHER_ERROR[]=
{
{ vdvWEATHER,VIRTUAL_CHANNEL_ERROR_UNHANDLED_COMMAND },
{ vdvWEATHER,VIRTUAL_CHANNEL_ERROR_IP_CONNECT },
{ vdvWEATHER,VIRTUAL_CHANNEL_ERROR_NOT_FOUND },
{ vdvWEATHER,VIRTUAL_CHANNEL_ERROR },
{ vdvWEATHER,VIRTUAL_CHANNEL_ERROR_LOGON_FAIL }
}
//----------------------------------------------------------------------------
// i!-Weather New Data Recevied-----------------------------------------------
//----------------------------------------------------------------------------
//i!-Weather Engine Notified Us That New Data is Ready
BUTTON_EVENT[vdvWEATHER,VIRTUAL_CHANNEL_SUCESS]
{
PUSH:
{
STACK_VAR
VOLATILE SINTEGER siRESULT
//DECODE NEW STRUCTURE DATA
siRESULT = STRING_TO_VARIABLE(sWEATHER,chSTRUCTURE_ENCODED_BUFFER,1)
//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 , "' '"
}
}
}
//----------------------------------------------------------------------------
// i!-Weather Error Handling--------------------------------------------------
//----------------------------------------------------------------------------
//i!-Weather Engine Notified Us Of An Error
BUTTON_EVENT[dcWEATHER_ERROR]
{
PUSH:
{
//Interpret i!-WeatherEngine Error
WEATHER_ERROR(BUTTON.INPUT.CHANNEL)
}
}