From 7ff883936f7d8865c00ee00710efe733ff30d959 Mon Sep 17 00:00:00 2001 From: Mika Laitio Date: Wed, 15 Aug 2012 01:52:13 +0300 Subject: [PATCH] device list read fixes - changes required by api changes - fix for the device list handling in cases that sensor device does not have any data to return. (only the config file) Signed-off-by: Mika Laitio --- src_client/DeviceManagerClient.cc | 28 ++++++++++++++-------------- src_server/DeviceManagerServer.cc | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src_client/DeviceManagerClient.cc b/src_client/DeviceManagerClient.cc index fb4e62e..b318d88 100644 --- a/src_client/DeviceManagerClient.cc +++ b/src_client/DeviceManagerClient.cc @@ -73,7 +73,6 @@ DataRange *DeviceManagerClient::parse_device_data_msg(BusMessage *msg_param, data_str = msg_param->get_string_parameter(RSP__GET_LATEST_DATA__VALUE, err_flg); data = Data::parse_string(data_str); ret_val = new DataRange(data); - log_info("date: %s\n", data->get_date().to_string().c_str()); log_debug("latest data\n"); data->printout(); @@ -140,7 +139,7 @@ list *DeviceManagerClient::parse_device_list_msg(BusMessage *msg_param key << RSP__DEVICE_LIST__ID << ii; id = msg_param->get_string_parameter(key.str(), err_flg); if (*err_flg != PLP_OK) { - log_error("Failed to parse device id\n"); + log_error("Failed to parse device id.\n"); break; } @@ -148,7 +147,7 @@ list *DeviceManagerClient::parse_device_list_msg(BusMessage *msg_param key << RSP__DEVICE_LIST__NAME << ii; name = msg_param->get_string_parameter(key.str(), err_flg); if (*err_flg != PLP_OK) { - log_error("Failed to parse device name\n"); + log_error("Failed to parse name for the device: %s\n", id.c_str()); break; } @@ -156,7 +155,7 @@ list *DeviceManagerClient::parse_device_list_msg(BusMessage *msg_param key << RSP__DEVICE_LIST__TYPE << ii; type = msg_param->get_string_parameter(key.str(), err_flg); if (*err_flg != PLP_OK) { - log_error("Failed to parse device type\n"); + log_error("Failed to parse type for the device: %s\n", id.c_str()); break; } @@ -164,7 +163,7 @@ list *DeviceManagerClient::parse_device_list_msg(BusMessage *msg_param key << RSP__DEVICE_LIST__LF_STATE << ii; state_i = msg_param->get_int_parameter(key.str(), err_flg); if (*err_flg != PLP_OK) { - log_error("Failed to parse device's life cycle state\n"); + log_error("Failed to parse life cycle state for the device: %s\n", id.c_str()); break; } state = (EnumDeviceLifeCycleStatus)state_i; @@ -172,16 +171,17 @@ list *DeviceManagerClient::parse_device_list_msg(BusMessage *msg_param key.str(""); key << RSP__DEVICE_LIST__DATA << ii; datastr = msg_param->get_string_parameter(key.str(), err_flg); - if (*err_flg != PLP_OK) { - log_error("Failed to parse device's data\n"); - break; + if (*err_flg == PLP_OK) { + data = Data::parse_string(datastr); + if (data == NULL) { + log_error("Failed to parse data items for the device: %s\n", id.c_str()); + *err_flg = PLP_ERR; + break; + } } - - data = Data::parse_string(datastr); - if (data == NULL) { - log_error("Failed to parse device's data items.\n"); - *err_flg = PLP_ERR; - break; + else { + log_error("No data available for the device: %s\n", id.c_str()); + data = new Data(0); } dev = new DeviceData(id, type, name, state, data); ret_val->push_back(dev); diff --git a/src_server/DeviceManagerServer.cc b/src_server/DeviceManagerServer.cc index 3eb8a01..052234b 100644 --- a/src_server/DeviceManagerServer.cc +++ b/src_server/DeviceManagerServer.cc @@ -200,7 +200,7 @@ void DeviceManagerServer::get_latest_data(BusMessage *msg_req_param, if (dev != NULL) { sensor = dynamic_cast(dev); if (sensor != NULL) { - reader = sensor->get_device_data(); + reader = sensor->get_datareader(); decode_data_to_busmessage(ret_val, reader); } } -- 2.41.1