wip on shutters
This commit is contained in:
@@ -31,45 +31,49 @@
|
|||||||
|
|
||||||
#include "devices/device.h"
|
#include "devices/device.h"
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn Device
|
* @fn Device
|
||||||
*
|
*
|
||||||
* @brief Constructor of the Device Object.
|
* @brief Constructor of the Device Object.
|
||||||
*/
|
*/
|
||||||
Device::Device (void)
|
Device::Device(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn Device
|
* @fn Device
|
||||||
*
|
*
|
||||||
* @brief Destructor of the Device Object.
|
* @brief Destructor of the Device Object.
|
||||||
*/
|
*/
|
||||||
Device::~Device (void)
|
Device::~Device(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn from_json
|
* @fn from_json
|
||||||
*
|
*
|
||||||
* @brief Load Device Object From a Json Object stringified.
|
* @brief Load Device Object From a Json Object stringified.
|
||||||
*/
|
*/
|
||||||
int Device::from_json (struct json_object *a_node)
|
int Device::from_json(struct json_object *a_node)
|
||||||
{
|
{
|
||||||
|
struct json_object *the_value_node;
|
||||||
fprintf(stderr, "Device::load_from_json...\n");
|
fprintf(stderr, "Device::load_from_json...\n");
|
||||||
|
|
||||||
|
// speach name
|
||||||
|
if (json_object_object_get_ex(a_node, k_entry_speach_name, &the_value_node))
|
||||||
|
{
|
||||||
|
m_speach_name = json_object_get_string(the_value_node);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn to_json
|
* @fn to_json
|
||||||
*
|
*
|
||||||
* @brief Export Device Object as JSON Object.
|
* @brief Export Device Object as JSON Object.
|
||||||
*/
|
*/
|
||||||
struct json_object *Device::to_json (void) const
|
struct json_object *Device::to_json(void) const
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,11 @@
|
|||||||
|
|
||||||
struct json_object;
|
struct json_object;
|
||||||
|
|
||||||
|
/*------------------------------- DEFINES ----------------------------------*/
|
||||||
|
|
||||||
|
#define k_entry_speach_name "speach_name"
|
||||||
|
#define k_entry_data "data"
|
||||||
|
|
||||||
/*--------------------------------- CLASS ----------------------------------*/
|
/*--------------------------------- CLASS ----------------------------------*/
|
||||||
|
|
||||||
class Device
|
class Device
|
||||||
|
|||||||
@@ -77,16 +77,19 @@ int DevicesManager::load(void)
|
|||||||
if (json_object_object_get_ex(the_root_node, kLightEntry, &the_value_node))
|
if (json_object_object_get_ex(the_root_node, kLightEntry, &the_value_node))
|
||||||
{
|
{
|
||||||
printf(" On a des Lights.\n");
|
printf(" On a des Lights.\n");
|
||||||
|
m_lights.from_json(the_value_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json_object_object_get_ex(the_root_node, kShutterEntry, &the_value_node))
|
if (json_object_object_get_ex(the_root_node, kShutterEntry, &the_value_node))
|
||||||
{
|
{
|
||||||
printf(" On a des shutters.\n");
|
printf(" On a des shutters.\n");
|
||||||
|
m_shutters.from_json(the_value_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json_object_object_get_ex(the_root_node, kSprinklerEntry, &the_value_node))
|
if (json_object_object_get_ex(the_root_node, kSprinklerEntry, &the_value_node))
|
||||||
{
|
{
|
||||||
printf(" On a des sprintkler.\n");
|
printf(" On a des sprintkler.\n");
|
||||||
|
m_sprinklers.from_json(the_value_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clean the json object. */
|
/* Clean the json object. */
|
||||||
|
|||||||
@@ -33,9 +33,6 @@
|
|||||||
|
|
||||||
#include "devices/light-device.h"
|
#include "devices/light-device.h"
|
||||||
|
|
||||||
#define k_entry_speach_name "speach_name"
|
|
||||||
#define k_entry_data "data"
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn LightDevice
|
* @fn LightDevice
|
||||||
*
|
*
|
||||||
@@ -61,17 +58,15 @@ LightDevice::~LightDevice(void)
|
|||||||
*/
|
*/
|
||||||
int LightDevice::from_json(struct json_object *a_node)
|
int LightDevice::from_json(struct json_object *a_node)
|
||||||
{
|
{
|
||||||
struct json_object *the_value_node, *the_data_node;
|
struct json_object *the_data_node;
|
||||||
fprintf(stderr, "LightDevice::load_from_json\n");
|
fprintf(stderr, "LightDevice::load_from_json\n");
|
||||||
|
|
||||||
// speach name
|
// speach name
|
||||||
if (json_object_object_get_ex(a_node, k_entry_speach_name, &the_value_node)) {
|
Device::from_json(a_node);
|
||||||
|
|
||||||
m_speach_name = json_object_get_string(the_value_node);
|
|
||||||
}
|
|
||||||
// Get Light
|
// Get Light
|
||||||
else if (json_object_object_get_ex(a_node, k_entry_data, &the_data_node) && (json_object_get_type(the_data_node) == json_type_array)) {
|
if (json_object_object_get_ex(a_node, k_entry_data, &the_data_node) && (json_object_get_type(the_data_node) == json_type_array))
|
||||||
|
{
|
||||||
int the_len;
|
int the_len;
|
||||||
struct json_object *the_light_node;
|
struct json_object *the_light_node;
|
||||||
|
|
||||||
@@ -82,7 +77,7 @@ int LightDevice::from_json(struct json_object *a_node)
|
|||||||
the_light_node = json_object_array_get_idx(the_data_node, i);
|
the_light_node = json_object_array_get_idx(the_data_node, i);
|
||||||
the_light.from_json(the_light_node);
|
the_light.from_json(the_light_node);
|
||||||
|
|
||||||
m_lights.push_back (the_light);
|
m_lights.push_back(the_light);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,8 +102,8 @@ struct json_object *LightDevice::to_json(void)
|
|||||||
// data
|
// data
|
||||||
json_object_object_add(the_root_node, k_entry_data, the_data_node);
|
json_object_object_add(the_root_node, k_entry_data, the_data_node);
|
||||||
|
|
||||||
|
for (the_light_it = m_lights.begin(); the_light_it != m_lights.end(); the_light_it++)
|
||||||
for (the_light_it = m_lights.begin(); the_light_it != m_lights.end(); the_light_it++) {
|
{
|
||||||
json_object_array_add(the_data_node, (*the_light_it).to_json());
|
json_object_array_add(the_data_node, (*the_light_it).to_json());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,85 +33,88 @@
|
|||||||
|
|
||||||
#include "devices/light.h"
|
#include "devices/light.h"
|
||||||
|
|
||||||
|
/*------------------------------- DEFINES ----------------------------------*/
|
||||||
|
|
||||||
#define k_entry_id "id"
|
#define k_entry_id "id"
|
||||||
#define k_entry_name "name"
|
#define k_entry_name "name"
|
||||||
#define k_entry_speach_name "speach_name"
|
#define k_entry_speach_name "speach_name"
|
||||||
#define k_entry_zone "zone"
|
#define k_entry_zone "zone"
|
||||||
#define k_entry_state "state"
|
#define k_entry_state "state"
|
||||||
#define k_entry_sender "sender"
|
#define k_entry_sender "sender"
|
||||||
#define k_entry_interruptor "interruptor"
|
#define k_entry_interruptor "interruptor"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn Light
|
* @fn Light
|
||||||
*
|
*
|
||||||
* @brief Constructor of the Light Object.
|
* @brief Constructor of the Light Object.
|
||||||
*/
|
*/
|
||||||
Light::Light (void)
|
Light::Light(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn ~Light
|
* @fn ~Light
|
||||||
*
|
*
|
||||||
* @brief Destructor of the Light Object.
|
* @brief Destructor of the Light Object.
|
||||||
*/
|
*/
|
||||||
Light::~Light (void)
|
Light::~Light(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn from_json
|
* @fn from_json
|
||||||
*
|
*
|
||||||
* @brief Load a Light Element from a Json Entry.
|
* @brief Load a Light Element from a Json Entry.
|
||||||
*/
|
*/
|
||||||
int Light::from_json (struct json_object *a_node)
|
int Light::from_json(struct json_object *a_node)
|
||||||
{
|
{
|
||||||
struct json_object *the_value_node;
|
struct json_object *the_value_node;
|
||||||
|
|
||||||
// id
|
// id
|
||||||
if (json_object_object_get_ex(a_node, k_entry_id, &the_value_node)) {
|
if (json_object_object_get_ex(a_node, k_entry_id, &the_value_node))
|
||||||
|
{
|
||||||
m_id = json_object_get_int(the_value_node);
|
m_id = json_object_get_int(the_value_node);
|
||||||
}
|
}
|
||||||
// name
|
// name
|
||||||
if (json_object_object_get_ex(a_node, k_entry_name, &the_value_node)) {
|
if (json_object_object_get_ex(a_node, k_entry_name, &the_value_node))
|
||||||
|
{
|
||||||
m_name = json_object_get_string(the_value_node);
|
m_name = json_object_get_string(the_value_node);
|
||||||
}
|
}
|
||||||
// speach_name
|
// speach_name
|
||||||
if (json_object_object_get_ex(a_node, k_entry_speach_name, &the_value_node)) {
|
if (json_object_object_get_ex(a_node, k_entry_speach_name, &the_value_node))
|
||||||
|
{
|
||||||
m_speach_name = json_object_get_string(the_value_node);
|
m_speach_name = json_object_get_string(the_value_node);
|
||||||
}
|
}
|
||||||
// zone
|
// zone
|
||||||
if (json_object_object_get_ex(a_node, k_entry_zone, &the_value_node)) {
|
if (json_object_object_get_ex(a_node, k_entry_zone, &the_value_node))
|
||||||
|
{
|
||||||
m_zone = json_object_get_string(the_value_node);
|
m_zone = json_object_get_string(the_value_node);
|
||||||
}
|
}
|
||||||
// state
|
// state
|
||||||
if (json_object_object_get_ex(a_node, k_entry_state, &the_value_node)) {
|
if (json_object_object_get_ex(a_node, k_entry_state, &the_value_node))
|
||||||
|
{
|
||||||
m_state = json_object_get_boolean(the_value_node);
|
m_state = json_object_get_boolean(the_value_node);
|
||||||
}
|
}
|
||||||
// sender
|
// sender
|
||||||
if (json_object_object_get_ex(a_node, k_entry_sender, &the_value_node)) {
|
if (json_object_object_get_ex(a_node, k_entry_sender, &the_value_node))
|
||||||
|
{
|
||||||
m_sender = json_object_get_int(the_value_node);
|
m_sender = json_object_get_int(the_value_node);
|
||||||
}
|
}
|
||||||
// interruptor
|
// interruptor
|
||||||
if (json_object_object_get_ex(a_node, k_entry_interruptor, &the_value_node)) {
|
if (json_object_object_get_ex(a_node, k_entry_interruptor, &the_value_node))
|
||||||
|
{
|
||||||
m_interruptor = json_object_get_int(the_value_node);
|
m_interruptor = json_object_get_int(the_value_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn to_json
|
* @fn to_json
|
||||||
*
|
*
|
||||||
* @brief Return Light Object as a Json Object.
|
* @brief Return Light Object as a Json Object.
|
||||||
*/
|
*/
|
||||||
struct json_object *Light::to_json (void) const
|
struct json_object *Light::to_json(void) const
|
||||||
{
|
{
|
||||||
struct json_object *the_root_node;
|
struct json_object *the_root_node;
|
||||||
|
|
||||||
@@ -135,40 +138,37 @@ struct json_object *Light::to_json (void) const
|
|||||||
return the_root_node;
|
return the_root_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn update
|
* @fn update
|
||||||
*
|
*
|
||||||
* @brief Update the Light State.
|
* @brief Update the Light State.
|
||||||
*/
|
*/
|
||||||
int Light::update (bool a_state)
|
int Light::update(bool a_state)
|
||||||
{
|
{
|
||||||
if (m_state == a_state)
|
if (m_state == a_state)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
m_state = a_state;
|
m_state = a_state;
|
||||||
|
|
||||||
return send_state ();
|
return send_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn get_id
|
* @fn get_id
|
||||||
*
|
*
|
||||||
* @brief Return the ID of the Light.
|
* @brief Return the ID of the Light.
|
||||||
*/
|
*/
|
||||||
uint16_t Light::get_id (void)
|
uint16_t Light::get_id(void)
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn sendState
|
* @fn sendState
|
||||||
*
|
*
|
||||||
* @brief Send the Curent State of the Light.
|
* @brief Send the Curent State of the Light.
|
||||||
*/
|
*/
|
||||||
int Light::send_state (void)
|
int Light::send_state(void)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
UBusCall theCmd;
|
UBusCall theCmd;
|
||||||
|
|||||||
@@ -23,64 +23,72 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------- INCLUDES ----------------------------------*/
|
/*------------------------------- INCLUDES ----------------------------------*/
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
#include <json-c/json.h>
|
||||||
|
|
||||||
#include "devices/shutter-device.h"
|
#include "devices/shutter-device.h"
|
||||||
|
|
||||||
|
/*! ----------------------------------------------------------------------------
|
||||||
|
* @fn ShutterDevice
|
||||||
|
*
|
||||||
|
* @brief Constructor of the Shutter Device Object.
|
||||||
|
*/
|
||||||
|
ShutterDevice::ShutterDevice(void) : Device()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn ShutterDevice
|
* @fn ShutterDevice
|
||||||
*
|
*
|
||||||
* @brief Constructor of the ShutterDevice Object.
|
* @brief Destructor of the Shutter Device Object.
|
||||||
*/
|
*/
|
||||||
ShutterDevice::ShutterDevice (void) : Device()
|
ShutterDevice::~ShutterDevice(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
|
||||||
* @fn ShutterDevice
|
|
||||||
*
|
|
||||||
* @brief Destructor of the Device Object.
|
|
||||||
*/
|
|
||||||
ShutterDevice::~ShutterDevice (void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn from_json
|
* @fn from_json
|
||||||
*
|
*
|
||||||
* @brief Load ShutterDevice Object From a Json Object.
|
* @brief Load ShutterDevice Object From a Json Object.
|
||||||
*/
|
*/
|
||||||
int ShutterDevice::from_json (struct json_object *a_node)
|
int ShutterDevice::from_json(struct json_object *a_node)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "ShutterDevice::load_from_json\n");
|
struct json_object *the_data_node;
|
||||||
#if 0
|
fprintf(stderr, "ShutterDevice::load_from_json\n");
|
||||||
mspeach_name = anElem["speach_name"].asString();
|
|
||||||
|
|
||||||
for (Json::Value& theElement : anElem["data"]) {
|
// speach name
|
||||||
Shutter theShutter;
|
Device::from_json(a_node);
|
||||||
if (theShutter.load_from_json (theElement) == 0) {
|
|
||||||
|
|
||||||
mShutter.push_back (theShutter);
|
// Get Shutter
|
||||||
|
if (json_object_object_get_ex(a_node, k_entry_data, &the_data_node) && (json_object_get_type(the_data_node) == json_type_array))
|
||||||
|
{
|
||||||
|
|
||||||
|
int the_len;
|
||||||
|
struct json_object *the_shutter_node;
|
||||||
|
|
||||||
|
the_len = json_object_array_length(the_data_node);
|
||||||
|
for (int i = 0; i < the_len; i++)
|
||||||
|
{
|
||||||
|
Shutter the_shutter;
|
||||||
|
the_shutter_node = json_object_array_get_idx(the_data_node, i);
|
||||||
|
the_shutter.from_json(the_shutter_node);
|
||||||
|
|
||||||
|
m_shutters.push_back(the_shutter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn to_json
|
* @fn to_json
|
||||||
*
|
*
|
||||||
* @brief Export ShutterDevice Object as JSON Object.
|
* @brief Export ShutterDevice Object as JSON Object.
|
||||||
*/
|
*/
|
||||||
struct json_object *ShutterDevice::to_json (void)
|
struct json_object *ShutterDevice::to_json(void)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
Json::Value theResult;
|
Json::Value theResult;
|
||||||
@@ -104,24 +112,22 @@ struct json_object *ShutterDevice::to_json (void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! ----------------------------------------------------------------------------
|
||||||
|
* @fn set
|
||||||
|
*
|
||||||
|
* @brief set the new Shutter state.
|
||||||
|
*/
|
||||||
|
int ShutterDevice::set(struct json_object *a_node)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn set
|
* @fn set
|
||||||
*
|
*
|
||||||
* @brief set the new Shutter state.
|
* @brief set the new Shutter state.
|
||||||
*/
|
*/
|
||||||
int ShutterDevice::set (struct json_object *a_node)
|
int ShutterDevice::set(int an_id, bool a_state)
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
|
||||||
* @fn set
|
|
||||||
*
|
|
||||||
* @brief set the new Shutter state.
|
|
||||||
*/
|
|
||||||
int ShutterDevice::set (int an_id, bool a_state)
|
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class ShutterDevice : public Device
|
|||||||
int set(int an_id, bool a_state);
|
int set(int an_id, bool a_state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Shutter> m_shutter;
|
std::vector<Shutter> m_shutters;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _SHUTTER_DEVICE_H */
|
#endif /* _SHUTTER_DEVICE_H */
|
||||||
|
|||||||
@@ -27,10 +27,24 @@
|
|||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
#include <json-c/json.h>
|
||||||
|
|
||||||
#include <ubus-cpp/ubus-call.h>
|
#include <ubus-cpp/ubus-call.h>
|
||||||
|
|
||||||
#include "devices/shutter.h"
|
#include "devices/shutter.h"
|
||||||
|
|
||||||
|
/*------------------------------- DEFINES ----------------------------------*/
|
||||||
|
|
||||||
|
#define k_entry_id "id"
|
||||||
|
#define k_entry_name "name"
|
||||||
|
#define k_entry_speach_name "speach_name"
|
||||||
|
#define k_entry_zone "zone"
|
||||||
|
#define k_entry_state "state"
|
||||||
|
#define k_entry_sender "sender"
|
||||||
|
#define k_entry_interruptor "interruptor"
|
||||||
|
#define k_entry_speed_up "speed_up"
|
||||||
|
#define k_entry_speed_down "speed_down"
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn Shutter
|
* @fn Shutter
|
||||||
*
|
*
|
||||||
@@ -56,17 +70,54 @@ Shutter::~Shutter(void)
|
|||||||
*/
|
*/
|
||||||
int Shutter::from_json(struct json_object *a_node)
|
int Shutter::from_json(struct json_object *a_node)
|
||||||
{
|
{
|
||||||
#if 0
|
struct json_object *the_value_node;
|
||||||
mID = anElem["id"].asInt();
|
// TODO: Should shared with Light.
|
||||||
mName = anElem["name"].asString();
|
// id
|
||||||
mSpeach_name = anElem["speach_name"].asString();
|
if (json_object_object_get_ex(a_node, k_entry_id, &the_value_node))
|
||||||
mZone = anElem["zone"].asString();
|
{
|
||||||
mState = anElem["state"].asBool();
|
m_id = json_object_get_int(the_value_node);
|
||||||
mSender = anElem["sender"].asInt();
|
}
|
||||||
mInterruptor = anElem["interruptor"].asInt();
|
// name
|
||||||
mSpeed_up = anElem["speed_up"].asInt();
|
if (json_object_object_get_ex(a_node, k_entry_name, &the_value_node))
|
||||||
mSpeed_down = anElem["speed_down"].asInt();
|
{
|
||||||
#endif
|
m_name = json_object_get_string(the_value_node);
|
||||||
|
}
|
||||||
|
// speach_name
|
||||||
|
if (json_object_object_get_ex(a_node, k_entry_speach_name, &the_value_node))
|
||||||
|
{
|
||||||
|
m_speach_name = json_object_get_string(the_value_node);
|
||||||
|
}
|
||||||
|
// zone
|
||||||
|
if (json_object_object_get_ex(a_node, k_entry_zone, &the_value_node))
|
||||||
|
{
|
||||||
|
m_zone = json_object_get_string(the_value_node);
|
||||||
|
}
|
||||||
|
// state
|
||||||
|
if (json_object_object_get_ex(a_node, k_entry_state, &the_value_node))
|
||||||
|
{
|
||||||
|
m_state = json_object_get_boolean(the_value_node);
|
||||||
|
}
|
||||||
|
// sender
|
||||||
|
if (json_object_object_get_ex(a_node, k_entry_sender, &the_value_node))
|
||||||
|
{
|
||||||
|
m_sender = json_object_get_int(the_value_node);
|
||||||
|
}
|
||||||
|
// interruptor
|
||||||
|
if (json_object_object_get_ex(a_node, k_entry_interruptor, &the_value_node))
|
||||||
|
{
|
||||||
|
m_interruptor = json_object_get_int(the_value_node);
|
||||||
|
}
|
||||||
|
// speed up
|
||||||
|
if (json_object_object_get_ex(a_node, k_entry_speed_up, &the_value_node))
|
||||||
|
{
|
||||||
|
m_speed_up = json_object_get_int(the_value_node);
|
||||||
|
}
|
||||||
|
// speed down
|
||||||
|
if (json_object_object_get_ex(a_node, k_entry_speed_down, &the_value_node))
|
||||||
|
{
|
||||||
|
m_speed_down = json_object_get_int(the_value_node);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,21 +128,30 @@ int Shutter::from_json(struct json_object *a_node)
|
|||||||
*/
|
*/
|
||||||
struct json_object *Shutter::to_json(void) const
|
struct json_object *Shutter::to_json(void) const
|
||||||
{
|
{
|
||||||
#if 0
|
struct json_object *the_root_node;
|
||||||
Json::Value aResult(Json::objectValue);
|
|
||||||
fprintf (stderr, "Shutter::to_json\n");
|
the_root_node = json_object_new_object();
|
||||||
aResult["id"] = mID;
|
|
||||||
aResult["name"] = mName;
|
// id
|
||||||
aResult["zone"] = mZone;
|
json_object_object_add(the_root_node, k_entry_id, json_object_new_int(m_id));
|
||||||
aResult["state"] = mState;
|
// name
|
||||||
aResult["sender"] = mSender;
|
json_object_object_add(the_root_node, k_entry_name, json_object_new_string(m_name.c_str()));
|
||||||
aResult["interruptor"] = mInterruptor;
|
// speach_name
|
||||||
aResult["speed_up"] = mSpeed_up;
|
json_object_object_add(the_root_node, k_entry_speach_name, json_object_new_string(m_speach_name.c_str()));
|
||||||
aResult["speed_down"] = mSpeed_down;
|
// zone
|
||||||
aResult["speach_name"] = mSpeach_name;
|
json_object_object_add(the_root_node, k_entry_zone, json_object_new_string(m_zone.c_str()));
|
||||||
|
// state
|
||||||
return aResult;
|
json_object_object_add(the_root_node, k_entry_state, json_object_new_boolean(m_state));
|
||||||
#endif
|
// sender
|
||||||
|
json_object_object_add(the_root_node, k_entry_sender, json_object_new_int(m_sender));
|
||||||
|
// interruptor
|
||||||
|
json_object_object_add(the_root_node, k_entry_interruptor, json_object_new_int(m_interruptor));
|
||||||
|
// speed up
|
||||||
|
json_object_object_add(the_root_node, k_entry_speed_up, json_object_new_int(m_speed_up));
|
||||||
|
// speed down
|
||||||
|
json_object_object_add(the_root_node, k_entry_speed_down, json_object_new_int(m_speed_down));
|
||||||
|
|
||||||
|
return the_root_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user