示例#1
0
void NodeMonitorHandlerTest::updatedDS(const std::string& control_unit_uid,
                                       int dataset_type,
                                       MapDatasetKeyValues& dataset_key_values) {
    LAPP_ << boost::str(boost::format("updatedDS: dataset type %1%")%getDatasetDesc(dataset_type));
    switch (dataset_type) {
        case chaos::DataPackCommonKey::DPCK_DATASET_TYPE_OUTPUT: {
            if(dataset_key_values.count(chaos::DataPackCommonKey::DPCK_TIMESTAMP)) {
                CDataVariant variant = dataset_key_values[chaos::DataPackCommonKey::DPCK_TIMESTAMP];
                LAPP_ << variant.asInt64();
            }
            break;
        }
            
        default:
            break;
    }
}
示例#2
0
bool AttributeValue::setValue(const CDataVariant& attribute_value,
                              bool tag_has_changed) {
    //if(type != attribute_value.getType()) return false;
    switch (attribute_value.getType()) {
        case DataType::TYPE_BOOLEAN: {
             if(!grow(sizeof(bool))) return false;
            bool bv = attribute_value.asBool();
            //copy string to buffer
            std::memcpy(value_buffer,
                        &bv,
                        sizeof(bool));
            break;
        }
        case DataType::TYPE_INT32: {
            if(!grow(sizeof(int32_t))) return false;
            int32_t i32v = attribute_value.asInt32();
            //copy string to buffer
            std::memcpy(value_buffer,
                        &i32v,
                        sizeof(int32_t));
            break;
        }
        case DataType::TYPE_INT64: {
            if(!grow(sizeof(int64_t))) return false;
            int64_t i64v = attribute_value.asInt64();
            //copy string to buffer
            std::memcpy(value_buffer,
                        &i64v,
                        sizeof(int64_t));
            break;
        }
        case DataType::TYPE_DOUBLE: {
            if(!grow(sizeof(double))) return false;
            double dv = attribute_value.asDouble();
            //copy string to buffer
            std::memcpy(value_buffer,
                        &dv,
                        sizeof(double));
            break;
        }
        case DataType::TYPE_CLUSTER:
        case DataType::TYPE_STRING: {
            const std::string value = attribute_value.asString();
            if(!grow((uint32_t)value.size())) return false;
            //copy string to buffer
            std::memcpy(value_buffer,
                        value.c_str(),
                        value.size());
            break;
        }
            
        case DataType::TYPE_BYTEARRAY:{
            const CDataBuffer * byte_array_value = attribute_value.asCDataBuffer();
            if(!grow(byte_array_value->getBufferSize())) return false;
            //copy buffer to buffer
            std::memcpy(value_buffer,
                        byte_array_value->getBuffer(),
                        byte_array_value->getBufferSize());
            break;
        }
        default:
            break;
    }
    
    //set the relative field for set has changed
    if(tag_has_changed) sharedBitmapChangedAttribute->set(index);
    return true;
}