endpoint including temperature and distance sensors
Dependencies: mbed mbedConnectorInterface mbedEndpointNetwork TrashSensors
Fork of TempAndDistTest by
resource/MaxDistanceResource.h@10:338191178cbf, 2015-05-18 (annotated)
- Committer:
- coyotebush
- Date:
- Mon May 18 00:44:59 2015 +0000
- Revision:
- 10:338191178cbf
max distance
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
coyotebush | 10:338191178cbf | 1 | #ifndef MAX_DISTANCE_RESOURCE_H |
coyotebush | 10:338191178cbf | 2 | #define MAX_DISTANCE_RESOURCE_H |
coyotebush | 10:338191178cbf | 3 | |
coyotebush | 10:338191178cbf | 4 | #include "DynamicResource.h" |
coyotebush | 10:338191178cbf | 5 | #include "hcsr04.h" |
coyotebush | 10:338191178cbf | 6 | |
coyotebush | 10:338191178cbf | 7 | class MaxDistanceResource : public DynamicResource { |
coyotebush | 10:338191178cbf | 8 | public: |
coyotebush | 10:338191178cbf | 9 | MaxDistanceResource(const Logger *logger, const char *name, HCSR04 *sensor, const bool observable = false) |
coyotebush | 10:338191178cbf | 10 | : DynamicResource(logger, name, "MaxDistanceResource", SN_GRS_GET_ALLOWED, observable), sensor(sensor) |
coyotebush | 10:338191178cbf | 11 | {} |
coyotebush | 10:338191178cbf | 12 | |
coyotebush | 10:338191178cbf | 13 | virtual string get() |
coyotebush | 10:338191178cbf | 14 | { |
coyotebush | 10:338191178cbf | 15 | char buf[10]; |
coyotebush | 10:338191178cbf | 16 | snprintf(buf, 10, "%0.2f", sensor->get_max_dist_cm()); |
coyotebush | 10:338191178cbf | 17 | return string(buf); |
coyotebush | 10:338191178cbf | 18 | } |
coyotebush | 10:338191178cbf | 19 | private: |
coyotebush | 10:338191178cbf | 20 | HCSR04 *sensor; |
coyotebush | 10:338191178cbf | 21 | }; |
coyotebush | 10:338191178cbf | 22 | |
coyotebush | 10:338191178cbf | 23 | #endif |