Пример #1
0
/*---------------------------------------------------------------------------------
 
 ---------------------------------------------------------------------------------*/
void AttributeValue::writeToCDataWrapper(CDataWrapper& data_wrapper) {
    switch(type) {
        case chaos::DataType::TYPE_BYTEARRAY:{
            switch(sub_type.size()) {
                case 1:
                    data_wrapper.addBinaryValue(name, sub_type[0], (const char *)value_buffer, size);
                    break;
                    
                default:
                    data_wrapper.addBinaryValue(name, (const char *)value_buffer, size);
                    break;
            }
            break;
        }
        case chaos::DataType::TYPE_CLUSTER:{

            data_wrapper.addCSDataValue(name,cdvalue);
            break;
        }
        case chaos::DataType::TYPE_STRING:{
            unsigned long str_len = value_buffer?std::strlen((const char *)value_buffer):0;
            str_len = (str_len>=size?size:str_len);
            data_wrapper.addStringValue(name, (str_len?std::string(static_cast<const char*>(value_buffer), str_len):""));
            break;
        }
            
        case chaos::DataType::TYPE_BOOLEAN:{
            data_wrapper.addBoolValue(name, *getValuePtr<bool>());
            break;
        }
            
        case chaos::DataType::TYPE_DOUBLE:{
            data_wrapper.addDoubleValue(name, *getValuePtr<double>());
            break;
        }
            
        case chaos::DataType::TYPE_INT32:{
            data_wrapper.addInt32Value(name, *getValuePtr<int32_t>());
            break;
        }
            
        case chaos::DataType::TYPE_INT64:{
            data_wrapper.addInt64Value(name, *getValuePtr<int64_t>());
            break;
        }
        default:
            break;
    }
}
Пример #2
0
//------------------------------------
int DeviceMessageChannel::setAttributeValue(CDataWrapper& attributesValues,
                                            bool noWait,
                                            int32_t millisec_to_wait) {
    //create the pack
    attributesValues.addStringValue(NodeDefinitionKey::NODE_UNIQUE_ID, device_network_address->device_id);
    if(noWait){
        sendMessage(device_network_address->node_id, ControlUnitNodeDomainAndActionRPC::CONTROL_UNIT_APPLY_INPUT_DATASET_ATTRIBUTE_CHANGE_SET, &attributesValues);
    } else {
        auto_ptr<CDataWrapper> initResult(sendRequest(device_network_address->node_id,
                                                      ControlUnitNodeDomainAndActionRPC::CONTROL_UNIT_APPLY_INPUT_DATASET_ATTRIBUTE_CHANGE_SET,
                                                      &attributesValues,
                                                      millisec_to_wait));
    }
    setOnline(!CHAOS_IS_RPC_SERVER_OFFLINE(getLastErrorCode()));
    return getLastErrorCode();
}
Пример #3
0
void StringHealtMetric::addMetricToCD(CDataWrapper& data) {
    data.addStringValue(name, value);
}