Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / service / soft-sensor-manager / SampleApp / linux / HeightSensorApp / include / HeightSensorApp.h
1 /******************************************************************
2  *
3  * Copyright 2015 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  * HeightSensorApp.h
22  */
23
24 #ifndef HEIGHTSENSORAPP_H_
25 #define HEIGHTSENSORAPP_H_
26
27 #include <functional>
28 #include <pthread.h>
29 #include "OCPlatform.h"
30 #include "OCApi.h"
31
32 using namespace OC;
33 using namespace std;
34
35 #include <string>
36 #include <cstdlib>
37
38 #define COAP_IP                 "0.0.0.0"
39 #define COAP_PORT               0
40 #define COAP_MODE               ModeType::Server
41 #define COAP_SRVTYPE        ServiceType::InProc
42
43 #define COAP_TYPE_NAME          "SSManager.Sensor"
44
45 //  testing case
46 #define INTERVAL_FOR_CHECK          4   // seconds
47 #define INTERVAL_FOR_MEASUREMENT    3   // seconds
48 #define INIT_VAL                    1   // default value
49 #define DIFF_VAL                    0.02   // default value
50
51
52
53 // Forward declaring the entityHandler
54
55 class HeightResource
56 {
57     public:
58         /// Access this property from a TB client
59 //        int m_humid;
60 //        int m_temp;
61         double m_height;
62         std::string m_resourceUri;
63         std::vector<std::string> m_resourceTypes;
64         std::vector<std::string> m_resourceInterfaces;
65         OCResourceHandle m_resourceHandle;
66         OCRepresentation m_resourceRep;
67         ObservationIds m_interestedObservers;
68
69     public:
70         /// Constructor
71         HeightResource() :
72             /*m_humid(0), m_temp(0), */ m_height(0), m_resourceHandle(0)
73         {
74             m_resourceUri = "/Thing_HeightSensor";
75             m_resourceTypes.push_back(COAP_TYPE_NAME);
76             m_resourceInterfaces.push_back(DEFAULT_INTERFACE);
77
78             printf("Running thing as %s\n", m_resourceUri.c_str());
79             m_resourceRep.setUri(m_resourceUri);
80             m_resourceRep.setResourceTypes(m_resourceTypes);
81             m_resourceRep.setResourceInterfaces(m_resourceInterfaces);
82         }
83
84         ~HeightResource()
85         {
86         }
87
88         void registerResource();
89
90         OCResourceHandle getHandle();
91
92         void setResourceRepresentation(OCRepresentation &rep);
93
94         OCRepresentation getResourceRepresentation();
95 };
96
97 #endif /* THINGRESOURCESERVER_H_ */