rename generic-dio to oultet dio

This commit is contained in:
jbnadal
2018-05-07 11:02:53 +02:00
parent a8fd8415ae
commit 20cee78636
10 changed files with 49 additions and 50 deletions

View File

@@ -3,29 +3,29 @@
{
"id": 1,
"name": "Bureau JB",
"speach_name": "bureau",
"speech_name": "bureau",
"zone": "",
"state": true,
"sender": 12797322,
"interruptor": 0
"switch": 0
},
{
"id": 2,
"name": "Salon",
"speach_name": "salon",
"speech_name": "salon",
"zone": "",
"state": false,
"sender": 12797322,
"interruptor": 1
"switch": 1
},
{
"id": 3,
"name": "Sapin",
"speach_name": "sapin",
"speech_name": "sapin",
"zone": "",
"state": false,
"sender": 12797322,
"interruptor": 2
"switch": 2
}
],
"shutters": [
@@ -35,7 +35,7 @@
"zone": "",
"state": true,
"sender": 14997046,
"interruptor": 12,
"switch": 12,
"speed_up": 20,
"speed_down": 18
}

View File

@@ -20,7 +20,7 @@ file(
${workspaceRoot}/src/prog/domod/src/devices/devices-manager.cpp
${workspaceRoot}/src/prog/domod/src/devices/devices-collection.cpp
${workspaceRoot}/src/prog/domod/src/devices/device.cpp
${workspaceRoot}/src/prog/domod/src/devices/generic-dio.cpp
${workspaceRoot}/src/prog/domod/src/devices/outlet-dio.cpp
${workspaceRoot}/src/prog/domod/src/devices/sprinkler.cpp
${workspaceRoot}/src/prog/domod/src/devices/shutter.cpp

View File

@@ -42,12 +42,11 @@
/* common */
#define k_entry_id "id"
#define k_entry_name "name"
#define k_entry_speach_name "speach_name"
#define k_entry_speech_name "speech_name"
#define k_entry_zone "zone"
#define k_entry_state "state"
#define k_entry_sender "sender"
#define k_entry_interruptor "interruptor"
#define k_entry_switch "switch"
/* shutter */
#define k_entry_speed_up "speed_up"

View File

@@ -80,9 +80,9 @@ int Device::from_json(struct json_object *a_node)
m_name = json_object_get_string(the_value_node);
}
// speech_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_speech_name, &the_value_node))
{
m_speach_name = json_object_get_string(the_value_node);
m_speech_name = json_object_get_string(the_value_node);
}
// state
if (json_object_object_get_ex(a_node, k_entry_state, &the_value_node))
@@ -121,7 +121,7 @@ int Device::to_json(struct json_object *a_node) const
// name
json_object_object_add(a_node, k_entry_name, json_object_new_string(m_name.c_str()));
// speach_name
json_object_object_add(a_node, k_entry_speach_name, json_object_new_string(m_speach_name.c_str()));
json_object_object_add(a_node, k_entry_speech_name, json_object_new_string(m_speech_name.c_str()));
// state
json_object_object_add(a_node, k_entry_state, json_object_new_boolean(m_state));

View File

@@ -53,7 +53,7 @@ class Device
protected:
uint16_t m_id;
std::string m_name;
std::string m_speach_name;
std::string m_speech_name;
bool m_state;
};

View File

@@ -32,7 +32,7 @@
#include "domo.h"
#include "generic-dio.h"
#include "outlet-dio.h"
#include "shutter.h"
#include "sprinkler.h"
@@ -255,11 +255,11 @@ int DevicesManager::load_lights(struct json_object *a_node)
the_len = json_object_array_length(a_node);
for (int i = 0; i < the_len; i++)
{
GenericDio* the_light = new GenericDio;
OutletDio* the_outlet = new OutletDio;
the_light_node = json_object_array_get_idx(a_node, i);
the_light->from_json(the_light_node);
the_outlet->from_json(the_light_node);
m_lights.add(the_light);
m_lights.add(the_outlet);
}
}

View File

@@ -1,5 +1,5 @@
/*!
* generic-dio.cpp
* outlet-dio.cpp
*
* Copyright (c) 2016-2018, NADAL Jean-Baptiste. All rights reserved.
*
@@ -33,33 +33,33 @@
#include "domo.h"
#include "generic-dio.h"
#include "outlet-dio.h"
/*! ----------------------------------------------------------------------------
* @fn GenericDio
* @fn OutletDio
*
* @brief Constructor of the Light Object.
* @brief Constructor of the Outlet Dio Object.
*/
GenericDio::GenericDio(void)
OutletDio::OutletDio(void)
{
}
/*! ----------------------------------------------------------------------------
* @fn ~Light
* @fn ~OutletDio
*
* @brief Destructor of the Light Object.
* @brief Destructor of the Outlet Dio Object.
*/
GenericDio::~GenericDio(void)
OutletDio::~OutletDio(void)
{
}
/*! ----------------------------------------------------------------------------
* @fn from_json
*
* @brief Load a Light Element from a Json Entry.
* @brief Load a Outlet Element from a Json Entry.
*/
int GenericDio::from_json(struct json_object *a_node)
int OutletDio::from_json(struct json_object *a_node)
{
int the_result;
struct json_object *the_value_node;
@@ -78,10 +78,10 @@ int GenericDio::from_json(struct json_object *a_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))
// switch
if (json_object_object_get_ex(a_node, k_entry_switch, &the_value_node))
{
m_interruptor = json_object_get_int(the_value_node);
m_switch = json_object_get_int(the_value_node);
}
return 0;
@@ -90,9 +90,9 @@ int GenericDio::from_json(struct json_object *a_node)
/*! ----------------------------------------------------------------------------
* @fn to_json
*
* @brief Return Light Object as a Json Object.
* @brief Return Outlet Dio Object as a Json Object.
*/
struct json_object *GenericDio::to_json(void) const
struct json_object *OutletDio::to_json(void) const
{
struct json_object *the_root_node;
@@ -108,17 +108,17 @@ struct json_object *GenericDio::to_json(void) const
*
* @brief Export Device Object as JSON Object without creating a node.
*/
int GenericDio::to_json(struct json_object *a_node) const
int OutletDio::to_json(struct json_object *a_node) const
{
// Get DEvices fields
// Get Devices fields
Device::to_json(a_node);
// zone
json_object_object_add(a_node, k_entry_zone, json_object_new_string(m_zone.c_str()));
// sender
json_object_object_add(a_node, k_entry_sender, json_object_new_int(m_sender));
// interruptor
json_object_object_add(a_node, k_entry_interruptor, json_object_new_int(m_interruptor));
// switch
json_object_object_add(a_node, k_entry_switch, json_object_new_int(m_switch));
return 0;
}

View File

@@ -1,5 +1,5 @@
/*!
* generic-dio.h
* outlet-dio.h
*
* Copyright (c) 2016-2018, NADAL Jean-Baptiste. All rights reserved.
*
@@ -23,8 +23,8 @@
*
*/
#ifndef _LIGHT_H
#define _LIGHT_H
#ifndef _OUTLET_DIO_H
#define _OUTLET_DIO_H
/*------------------------------- INCLUDES ----------------------------------*/
@@ -36,11 +36,11 @@ struct json_object;
/*--------------------------------- CLASS ----------------------------------*/
class GenericDio : public Device
class OutletDio : public Device
{
public:
GenericDio(void);
~GenericDio(void);
OutletDio(void);
~OutletDio(void);
virtual int from_json(struct json_object *a_node);
virtual struct json_object *to_json(void) const;
@@ -56,7 +56,7 @@ protected:
private:
std::string m_zone;
uint32_t m_sender;
uint8_t m_interruptor;
uint8_t m_switch;
};
#endif /* _LIGHT_H */
#endif /* _OUTLET_DIO_H */

View File

@@ -64,7 +64,7 @@ int Shutter::from_json(struct json_object *a_node)
int the_result;
struct json_object *the_value_node;
the_result = GenericDio::from_json(a_node);
the_result = OutletDio::from_json(a_node);
if (the_result < 0)
return the_result;
@@ -106,7 +106,7 @@ struct json_object *Shutter::to_json(void) const
int Shutter::to_json(struct json_object *a_node) const
{
// Get Generic Dio fields
GenericDio::to_json(a_node);
OutletDio::to_json(a_node);
// speed up
json_object_object_add(a_node, k_entry_speed_up, json_object_new_int(m_speed_up));

View File

@@ -28,7 +28,7 @@
/*------------------------------- INCLUDES ----------------------------------*/
#include "generic-dio.h"
#include "outlet-dio.h"
#include <string>
@@ -38,7 +38,7 @@ struct json_object;
/*--------------------------------- CLASS ----------------------------------*/
class Shutter : public GenericDio
class Shutter : public OutletDio
{
public:
Shutter(void);