Difference between revisions of "Adding support for floorplan devices"

From LinuxMCE
Jump to: navigation, search
Line 5: Line 5:
 
Major steps :
 
Major steps :
  
1. create proper template for device (watch proper category and parent settings)
+
1. create proper template for device (watch proper category and parent settings) <br>
2. create coresponding event, that will be used to report current values for floorplan device' state
+
2. create coresponding event, that will be used to report current values for floorplan device' state <br>
3. add proper icon and other data in database
+
3. add proper icon and other data in database <br>
 +
<br>
 +
<br>
 +
Since steps 1.-3. were already made for brightness sensors, I did only steps that follow below. I guess Dan can describe steps 1. to 3. much better... <br>
 +
First I wanted to discover how this feature already works for temperature sensors...
 +
<br>
 +
It goes like this :<br>
 +
First there is event called "Temperature changed" that reporting device (home automation controller for instance) creates with parameter of current temperature value. Message gets through DCERouter to Climate Plugin that does this
 +
     
 +
else if( pMessage->m_dwMessage_Type==MESSAGETYPE_EVENT && pMessage->m_dwID==EVENT_Temperature_Changed_CONST )
 +
{
 +
  // Replace the current temp
 +
      string sLevel = pMessage->m_mapParameters[EVENTPARAMETER_Value_CONST];
 +
      string sCurrentState = pDevice->m_sState_get();
 +
      string::size_type pos = sCurrentState.find('(');
 +
      if( pos!=string::npos )
 +
              sCurrentState = sCurrentState.substr(0,pos-1); // Get rid of the current temp
 +
      pDevice->m_sState_set(sCurrentState + " (" + sLevel + ")");
 +
}
  
Since steps 1.-3. were already made for brightness sensors, I did only steps that follow below. I guess Dan can describe steps 1. to 3. much better...
+
in
  
First I wanted to discover how this feature already works for temperature sensors...
+
void Climate_Plugin::PreprocessClimateMessage(DeviceData_Router *pDevice,Message *pMessage)
  
It goes like this :
+
and sets state of device to reported value.
Orbiter plugin at line 1367 and procedure  
+
<br><br>
 +
Then Orbiter plugin at line 1367 and procedure  
  
 
  void Orbiter_Plugin::CMD_Get_Current_Floorplan(string sID,int iPK_FloorplanType,string *sValue_To_Assign,string &sCMD_Result,Message *pMessage)
 
  void Orbiter_Plugin::CMD_Get_Current_Floorplan(string sID,int iPK_FloorplanType,string *sValue_To_Assign,string &sCMD_Result,Message *pMessage)
Line 55: Line 74:
 
  OSD=pDeviceData_Router->m_sState_get()
 
  OSD=pDeviceData_Router->m_sState_get()
  
OSD is string that will get displayed beside icon and here it gets device state and puts it into displayed string container...
+
It basically reads state of device and puts it into OSD. OSD is string that will get displayed beside icon.<br>
  
 
Now I'll try to replicate everything similar to Lighting Plugin and brightness sensors :
 
Now I'll try to replicate everything similar to Lighting Plugin and brightness sensors :
 +
<br><br>
  
 
4. Lighting Plugin
 
4. Lighting Plugin
 +
<br><br>
  
 
Added this line  
 
Added this line  

Revision as of 17:27, 14 November 2006

This page was written by Pluto and imported with their permission when LinuxMCE branched off in February, 2007. In general any information should apply to LinuxMCE. However, this page should be edited to reflect changes to LinuxMCE and remove old references to Pluto.
In construction !!!

I need support for brightness sensors - particularly to display them on floorplan with current values...

Major steps :

1. create proper template for device (watch proper category and parent settings)
2. create coresponding event, that will be used to report current values for floorplan device' state
3. add proper icon and other data in database


Since steps 1.-3. were already made for brightness sensors, I did only steps that follow below. I guess Dan can describe steps 1. to 3. much better...
First I wanted to discover how this feature already works for temperature sensors...
It goes like this :
First there is event called "Temperature changed" that reporting device (home automation controller for instance) creates with parameter of current temperature value. Message gets through DCERouter to Climate Plugin that does this

else if( pMessage->m_dwMessage_Type==MESSAGETYPE_EVENT && pMessage->m_dwID==EVENT_Temperature_Changed_CONST )
{
 // Replace the current temp
      string sLevel = pMessage->m_mapParameters[EVENTPARAMETER_Value_CONST];
      string sCurrentState = pDevice->m_sState_get();
      string::size_type pos = sCurrentState.find('(');
      if( pos!=string::npos )
             sCurrentState = sCurrentState.substr(0,pos-1); // Get rid of the current temp
      pDevice->m_sState_set(sCurrentState + " (" + sLevel + ")");
}

in

void Climate_Plugin::PreprocessClimateMessage(DeviceData_Router *pDevice,Message *pMessage)

and sets state of device to reported value.

Then Orbiter plugin at line 1367 and procedure

void Orbiter_Plugin::CMD_Get_Current_Floorplan(string sID,int iPK_FloorplanType,string *sValue_To_Assign,string &sCMD_Result,Message *pMessage)

does this (line 1429) :

pFloorplanInfoProvider->GetFloorplanDeviceInfo(pDeviceData_Router,fpObj->m_pEntertainArea,fpObj->Type,iPK_FloorplanObjectType_Color,iColor,sDescription,OSD,PK_DesignObj_Toolbar);

FloorplanInfoProvider is actually coresponding plugin that provides more info about floorplan object. In Climate plugin there is this procedure :

void Climate_Plugin::GetFloorplanDeviceInfo(DeviceData_Router *pDeviceData_Router,EntertainArea *pEntertainArea,int iFloorplanObjectType,int &iPK_FloorplanObjectType_Color,int &Color,string &sDescription,string &OSD,int &PK_DesignObj_Toolbar)
{
switch(iFloorplanObjectType)
{
case FLOORPLANOBJECTTYPE_CLIMATE_THERMOSTAT_CONST:
         PK_DesignObj_Toolbar=DESIGNOBJ_grpThermostatControls_CONST;
         break;
case FLOORPLANOBJECTTYPE_CLIMATE_THERMOMETER_CONST:
         PK_DesignObj_Toolbar=0;
         break;
case FLOORPLANOBJECTTYPE_CLIMATE_WEATHER_STATION_CONST:
         PK_DesignObj_Toolbar=0;
         break;
case FLOORPLANOBJECTTYPE_CLIMATE_DAMPER_CONST:
         PK_DesignObj_Toolbar=0;
         break;
case FLOORPLANOBJECTTYPE_CLIMATE_POOL_CONST:
         PK_DesignObj_Toolbar=DESIGNOBJ_grpPoolControls_CONST;
         break;
case FLOORPLANOBJECTTYPE_CLIMATE_SPRINKLER_CONST:
         PK_DesignObj_Toolbar=DESIGNOBJ_grpSprinklerControls_CONST;
         break;
};
if( (OSD=pDeviceData_Router->m_sState_get())=="OFF" )
         iPK_FloorplanObjectType_Color = FLOORPLANOBJECTTYPE_COLOR_CLIMATE_THERMOSTAT_OFF_CONST;
else
         iPK_FloorplanObjectType_Color = FLOORPLANOBJECTTYPE_COLOR_CLIMATE_THERMOSTAT_COOLING_CONST;
}

and most important is this line (near bottom) :

OSD=pDeviceData_Router->m_sState_get()

It basically reads state of device and puts it into OSD. OSD is string that will get displayed beside icon.

Now I'll try to replicate everything similar to Lighting Plugin and brightness sensors :

4. Lighting Plugin

Added this line

       case FLOORPLANOBJECTTYPE_BRIGHTNESS_SENSOR_CONST:
               OSD = pDeviceData_Router->m_sState_get();

to

void Lighting_Plugin::GetFloorplanDeviceInfo(DeviceData_Router *pDeviceData_Router,EntertainArea *pEntertainArea,int iFloorplanObjectType,int &iPK_FloorplanObjectType_Color,int &Color,string &sDescription,string &OSD,int &PK_DesignObj_Toolbar)