MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / SetDeviceClasses

Method SetDeviceClasses

cpp/src/Node.cpp:3185–3311  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Set the device class data for the node -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

3183// Set the device class data for the node
3184//-----------------------------------------------------------------------------
3185bool Node::SetDeviceClasses
3186(
3187 uint8 const _basic,
3188 uint8 const _generic,
3189 uint8 const _specific
3190)
3191{
3192 m_basic = _basic;
3193 m_generic = _generic;
3194 m_specific = _specific;
3195
3196 // Read in the device class data if it has not been read already.
3197 if( !s_deviceClassesLoaded )
3198 {
3199 ReadDeviceClasses();
3200 }
3201
3202 // Get the basic device class label
3203 map<uint8,string>::iterator bit = s_basicDeviceClasses.find( _basic );
3204 if( bit != s_basicDeviceClasses.end() )
3205 {
3206 m_type = bit->second;
3207 Log::Write( LogLevel_Info, m_nodeId, " Basic device class (0x%.2x) - %s", m_basic, m_type.c_str() );
3208 }
3209 else
3210 {
3211 Log::Write( LogLevel_Info, m_nodeId, " Basic device class unknown" );
3212 }
3213
3214 // Apply any Generic device class data
3215 uint8 basicMapping = 0;
3216 map<uint8,GenericDeviceClass*>::iterator git = s_genericDeviceClasses.find( _generic );
3217 if( git != s_genericDeviceClasses.end() )
3218 {
3219 GenericDeviceClass* genericDeviceClass = git->second;
3220 m_type = genericDeviceClass->GetLabel();
3221
3222 Log::Write( LogLevel_Info, m_nodeId, " Generic device Class (0x%.2x) - %s", m_generic, m_type.c_str() );
3223
3224 // Add the mandatory command classes for this generic class type
3225 AddMandatoryCommandClasses( genericDeviceClass->GetMandatoryCommandClasses() );
3226
3227 // Get the command class that COMMAND_CLASS_BASIC maps to.
3228 basicMapping = genericDeviceClass->GetBasicMapping();
3229
3230 // Apply any Specific device class data
3231 if( DeviceClass* specificDeviceClass = genericDeviceClass->GetSpecificDeviceClass( _specific ) )
3232 {
3233 m_type = specificDeviceClass->GetLabel();
3234
3235 Log::Write( LogLevel_Info, m_nodeId, " Specific device class (0x%.2x) - %s", m_specific, m_type.c_str() );
3236
3237 // Add the mandatory command classes for this specific class type
3238 AddMandatoryCommandClasses( specificDeviceClass->GetMandatoryCommandClasses() );
3239
3240 if( specificDeviceClass->GetBasicMapping() )
3241 {
3242 // Override the generic device class basic mapping with the specific device class one.

Callers

nothing calls this directly

Calls 14

WriteFunction · 0.85
findMethod · 0.80
GetBasicMappingMethod · 0.80
SetMappingMethod · 0.80
endMethod · 0.45
c_strMethod · 0.45
GetLabelMethod · 0.45
SetInstanceMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected