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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
22 * This file contains the exported symbol.
25 #include "DiscomfortIndexSensor.h"
31 #include "OCAndroid.h"
34 using namespace DiscomfortIndexSensorName;
36 DiscomfortIndexSensor::DiscomfortIndexSensor()
40 m_discomfortIndex = "";
43 DiscomfortIndexSensor::~DiscomfortIndexSensor()
48 int DiscomfortIndexSensor::executeDISensorLogic(std::map<std::string, std::string> *pInputData,
51 std::cout << "[DiscomfortIndexSensor] DiscomfortIndexSensor::" << __func__ << " is called."
56 m_temperature = pInputData->at("temperature");
57 m_humidity = pInputData->at("humidity");
59 if ((result = makeDiscomfortIndex()) != SUCCESS)
61 std::cout << "Error : makeDiscomfortIndex() result = " << result << std::endl;
65 (*pOutput) = m_discomfortIndex;
71 * Calculation of DiscomfortIndex with TEMP&HUMI.
73 DIResult DiscomfortIndexSensor::makeDiscomfortIndex()
75 int DILevel = (int) ERROR;
78 int t = std::stoi(m_temperature);
79 int h = std::stoi(m_humidity);
80 double F = (9.0 * (double) t) / 5.0 + 32.0;
82 // calculation of discomfortIndex
83 dDI = F - (F - 58.0) * (double)((100 - h) * 55) / 10000.0;
85 std::cout << "Discomfort level : " << dDI << ", Temperature :" << t << ", Humidity :" << h <<
88 std::cout << "[result] Discomfort Index : " << m_discomfortIndex << std::endl;
91 DILevel = (int)ALL_DISCOMPORT;
92 std::cout << "DI : " << DILevel << " : All person discomfort. : " << dDI
97 DILevel = (int)HALF_DISCOMPORT;
98 std::cout << "DI : " << DILevel << " : Half of person discomfort. : " << dDI
101 else if (dDI >= 68.0)
103 DILevel = (int)LITTLE_DISCOMPORT;
104 std::cout << "DI : " << DILevel << " : A little person discomfort. : " << dDI
109 DILevel = (int)ALL_COMPORT;
110 std::cout << "DI : " << DILevel << " : All person comfort. : " << dDI
114 std::cout << std::endl;
116 m_discomfortIndex = std::to_string(DILevel);