1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #include "BMISensorResource.h"
24 BMISensorResource::BMISensorResource()
26 m_pBMISensor = new BMISensor();
29 BMISensorResource::~BMISensorResource()
34 void BMISensorResource::handleSetAttributesRequest(
35 const RCSResourceAttributes &value)
37 BundleResource::setAttributes(value);
40 RCSResourceAttributes BMISensorResource::handleGetAttributesRequest()
42 return BundleResource::getAttributes();
45 void BMISensorResource::executeLogic()
47 std::string strBMIResult;
49 if (m_pBMISensor->executeBMISensorLogic(&m_mapInputData, &strBMIResult) != -1)
50 setAttribute("BMIresult", RCSResourceAttributes::Value(strBMIResult.c_str()));
53 void BMISensorResource::onUpdatedInputResource(const std::string attributeName,
54 std::vector<RCSResourceAttributes::Value> values)
56 // remove all existing data
57 m_mapInputData.clear();
59 if (!attributeName.compare("weight"))
60 m_mapInputData.insert(std::make_pair("weight", values.back().toString()));
62 if (!attributeName.compare("height"))
63 m_mapInputData.insert(std::make_pair("height", values.back().toString()));