----------------------------------------------------------------------------- Read the static device class data from the device_classes.xml file -----------------------------------------------------------------------------
| 3519 | // Read the static device class data from the device_classes.xml file |
| 3520 | //----------------------------------------------------------------------------- |
| 3521 | void Node::ReadDeviceClasses |
| 3522 | ( |
| 3523 | ) |
| 3524 | { |
| 3525 | // Load the XML document that contains the device class information |
| 3526 | string configPath; |
| 3527 | Options::Get()->GetOptionAsString( "ConfigPath", &configPath ); |
| 3528 | |
| 3529 | string filename = configPath + string("device_classes.xml"); |
| 3530 | |
| 3531 | TiXmlDocument doc; |
| 3532 | if( !doc.LoadFile( filename.c_str(), TIXML_ENCODING_UTF8 ) ) |
| 3533 | { |
| 3534 | Log::Write( LogLevel_Info, "Failed to load device_classes.xml" ); |
| 3535 | Log::Write( LogLevel_Info, "Check that the config path provided when creating the Manager points to the correct location." ); |
| 3536 | return; |
| 3537 | } |
| 3538 | doc.SetUserData((void *)filename.c_str()); |
| 3539 | TiXmlElement const* deviceClassesElement = doc.RootElement(); |
| 3540 | |
| 3541 | // Read the basic and generic device classes |
| 3542 | TiXmlElement const* child = deviceClassesElement->FirstChildElement(); |
| 3543 | while( child ) |
| 3544 | { |
| 3545 | char const* str = child->Value(); |
| 3546 | if( str ) |
| 3547 | { |
| 3548 | char const* keyStr = child->Attribute( "key" ); |
| 3549 | if( keyStr ) |
| 3550 | { |
| 3551 | char* pStop; |
| 3552 | /* we do a short here, as they key can be a DeviceType Key which is short */ |
| 3553 | uint16_t key = (uint16)strtol( keyStr, &pStop, 16 ); |
| 3554 | |
| 3555 | if( !strcmp( str, "Generic" ) ) |
| 3556 | { |
| 3557 | s_genericDeviceClasses[(uint8_t)(key & 0xFF)] = new GenericDeviceClass( child ); |
| 3558 | } |
| 3559 | else if( !strcmp( str, "Basic" ) ) |
| 3560 | { |
| 3561 | char const* label = child->Attribute( "label" ); |
| 3562 | if( label ) |
| 3563 | { |
| 3564 | s_basicDeviceClasses[(uint8_t)(key & 0xFF)] = label; |
| 3565 | } |
| 3566 | } |
| 3567 | else if( !strcmp( str, "Role" ) ) |
| 3568 | { |
| 3569 | s_roleDeviceClasses[(uint8_t)(key & 0xFF)] = new DeviceClass( child ); |
| 3570 | } |
| 3571 | else if( !strcmp( str, "DeviceType" ) ) |
| 3572 | { |
| 3573 | s_deviceTypeClasses[key] = new DeviceClass( child ); |
| 3574 | } |
| 3575 | else if (!strcmp( str, "NodeType" ) ) |
| 3576 | { |
| 3577 | s_nodeTypes[(uint8_t)(key & 0xFF)] = new DeviceClass( child ); |
| 3578 | } |
nothing calls this directly
no test coverage detected