Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / service / soft-sensor-manager / SoftSensorPlugin / DiscomfortIndexSensor / include / DiscomfortIndexSensor.h
1 /******************************************************************
2  *
3  * Copyright 2014 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  ******************************************************************/
20
21 /*
22  * DiscomfortIndexSensor.h
23  */
24
25 #ifndef DISCOMFORTINDEXSENSOR_H_
26 #define DISCOMFORTINDEXSENSOR_H_
27
28 /**
29  * This header file is included to define _EXPORT_.
30  */
31 #include "SSMModelDefinition.h"
32
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37 INTERFACE_DECLSPEC void InitializeContext(ICtxDelegate *pDelegate);
38 #ifdef __cplusplus
39 }
40 ;
41 #endif
42
43 namespace DiscomfortIndexSensorName
44 {
45 #define PHYSICAL_EA 2
46
47     typedef struct _physicalInput_
48     {
49         char *m_thingName;
50         int m_inputNum;
51         void *m_pInputStruct;
52     } physicalInput;
53
54     typedef enum
55     {
56         SUCCESS = 0, ERROR, ALL_DISCOMPORT, HALF_DISCOMPORT, LITTLE_DISCOMPORT, ALL_COMPORT
57     } DIResult;
58
59     class DiscomfortIndexSensor: public ICtxEvent
60     {
61         private:
62
63             static physicalInput s_PHYSICAL_SOFTSENSORs[PHYSICAL_EA];
64
65             class InValue
66             {
67                 public:
68                     std::string m_timestamp; // .
69                     std::string m_discomfortIndex; // Discomfort Index. ( 2 ~ 5 )
70                     std::string m_humidity; // relative humidity.
71                     std::string m_temperature; // celsius temperature.
72             };
73
74             InValue m_DI[PHYSICAL_EA];
75             InValue m_result;
76
77             int runLogic(std::vector< ContextData > &contextDataList);
78
79         public:
80             DiscomfortIndexSensor();
81
82             void onCtxEvent(enum CTX_EVENT_TYPE eventType, std::vector< ContextData > contextDataList);
83
84             DIResult getInput(std::vector< ContextData > &contextDataList, InValue *data);
85             DIResult makeDiscomfortIndex(InValue *data);
86             ContextData setOutput(int property_count, InValue *data);
87
88             friend void INTERFACE_DECLSPEC initializeContext(ICtxDelegate *pDelegate);
89     };
90 }
91 ;
92
93 #endif /* DISCOMFORTINDEXSENSOR_H_ */