rename generic-dio to oultet dio
This commit is contained in:
@@ -3,29 +3,29 @@
|
|||||||
{
|
{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"name": "Bureau JB",
|
"name": "Bureau JB",
|
||||||
"speach_name": "bureau",
|
"speech_name": "bureau",
|
||||||
"zone": "",
|
"zone": "",
|
||||||
"state": true,
|
"state": true,
|
||||||
"sender": 12797322,
|
"sender": 12797322,
|
||||||
"interruptor": 0
|
"switch": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"name": "Salon",
|
"name": "Salon",
|
||||||
"speach_name": "salon",
|
"speech_name": "salon",
|
||||||
"zone": "",
|
"zone": "",
|
||||||
"state": false,
|
"state": false,
|
||||||
"sender": 12797322,
|
"sender": 12797322,
|
||||||
"interruptor": 1
|
"switch": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 3,
|
"id": 3,
|
||||||
"name": "Sapin",
|
"name": "Sapin",
|
||||||
"speach_name": "sapin",
|
"speech_name": "sapin",
|
||||||
"zone": "",
|
"zone": "",
|
||||||
"state": false,
|
"state": false,
|
||||||
"sender": 12797322,
|
"sender": 12797322,
|
||||||
"interruptor": 2
|
"switch": 2
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"shutters": [
|
"shutters": [
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
"zone": "",
|
"zone": "",
|
||||||
"state": true,
|
"state": true,
|
||||||
"sender": 14997046,
|
"sender": 14997046,
|
||||||
"interruptor": 12,
|
"switch": 12,
|
||||||
"speed_up": 20,
|
"speed_up": 20,
|
||||||
"speed_down": 18
|
"speed_down": 18
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ file(
|
|||||||
${workspaceRoot}/src/prog/domod/src/devices/devices-manager.cpp
|
${workspaceRoot}/src/prog/domod/src/devices/devices-manager.cpp
|
||||||
${workspaceRoot}/src/prog/domod/src/devices/devices-collection.cpp
|
${workspaceRoot}/src/prog/domod/src/devices/devices-collection.cpp
|
||||||
${workspaceRoot}/src/prog/domod/src/devices/device.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/sprinkler.cpp
|
||||||
${workspaceRoot}/src/prog/domod/src/devices/shutter.cpp
|
${workspaceRoot}/src/prog/domod/src/devices/shutter.cpp
|
||||||
|
|
||||||
|
|||||||
@@ -42,12 +42,11 @@
|
|||||||
/* common */
|
/* common */
|
||||||
#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_speech_name "speech_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_switch "switch"
|
||||||
|
|
||||||
|
|
||||||
/* shutter */
|
/* shutter */
|
||||||
#define k_entry_speed_up "speed_up"
|
#define k_entry_speed_up "speed_up"
|
||||||
|
|||||||
@@ -80,9 +80,9 @@ int Device::from_json(struct json_object *a_node)
|
|||||||
m_name = json_object_get_string(the_value_node);
|
m_name = json_object_get_string(the_value_node);
|
||||||
}
|
}
|
||||||
// speech_name
|
// 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
|
// 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))
|
||||||
@@ -121,7 +121,7 @@ int Device::to_json(struct json_object *a_node) const
|
|||||||
// name
|
// name
|
||||||
json_object_object_add(a_node, k_entry_name, json_object_new_string(m_name.c_str()));
|
json_object_object_add(a_node, k_entry_name, json_object_new_string(m_name.c_str()));
|
||||||
// speach_name
|
// 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
|
// state
|
||||||
json_object_object_add(a_node, k_entry_state, json_object_new_boolean(m_state));
|
json_object_object_add(a_node, k_entry_state, json_object_new_boolean(m_state));
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class Device
|
|||||||
protected:
|
protected:
|
||||||
uint16_t m_id;
|
uint16_t m_id;
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
std::string m_speach_name;
|
std::string m_speech_name;
|
||||||
bool m_state;
|
bool m_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "domo.h"
|
#include "domo.h"
|
||||||
|
|
||||||
#include "generic-dio.h"
|
#include "outlet-dio.h"
|
||||||
#include "shutter.h"
|
#include "shutter.h"
|
||||||
#include "sprinkler.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);
|
the_len = json_object_array_length(a_node);
|
||||||
for (int i = 0; i < the_len; i++)
|
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_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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*!
|
/*!
|
||||||
* generic-dio.cpp
|
* outlet-dio.cpp
|
||||||
*
|
*
|
||||||
* Copyright (c) 2016-2018, NADAL Jean-Baptiste. All rights reserved.
|
* Copyright (c) 2016-2018, NADAL Jean-Baptiste. All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -33,33 +33,33 @@
|
|||||||
|
|
||||||
#include "domo.h"
|
#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
|
* @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;
|
int the_result;
|
||||||
struct json_object *the_value_node;
|
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);
|
m_sender = json_object_get_int(the_value_node);
|
||||||
}
|
}
|
||||||
// interruptor
|
// switch
|
||||||
if (json_object_object_get_ex(a_node, k_entry_interruptor, &the_value_node))
|
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;
|
return 0;
|
||||||
@@ -90,9 +90,9 @@ int GenericDio::from_json(struct json_object *a_node)
|
|||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn to_json
|
* @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;
|
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.
|
* @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);
|
Device::to_json(a_node);
|
||||||
|
|
||||||
// zone
|
// zone
|
||||||
json_object_object_add(a_node, k_entry_zone, json_object_new_string(m_zone.c_str()));
|
json_object_object_add(a_node, k_entry_zone, json_object_new_string(m_zone.c_str()));
|
||||||
// sender
|
// sender
|
||||||
json_object_object_add(a_node, k_entry_sender, json_object_new_int(m_sender));
|
json_object_object_add(a_node, k_entry_sender, json_object_new_int(m_sender));
|
||||||
// interruptor
|
// switch
|
||||||
json_object_object_add(a_node, k_entry_interruptor, json_object_new_int(m_interruptor));
|
json_object_object_add(a_node, k_entry_switch, json_object_new_int(m_switch));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*!
|
/*!
|
||||||
* generic-dio.h
|
* outlet-dio.h
|
||||||
*
|
*
|
||||||
* Copyright (c) 2016-2018, NADAL Jean-Baptiste. All rights reserved.
|
* Copyright (c) 2016-2018, NADAL Jean-Baptiste. All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -23,8 +23,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _LIGHT_H
|
#ifndef _OUTLET_DIO_H
|
||||||
#define _LIGHT_H
|
#define _OUTLET_DIO_H
|
||||||
|
|
||||||
/*------------------------------- INCLUDES ----------------------------------*/
|
/*------------------------------- INCLUDES ----------------------------------*/
|
||||||
|
|
||||||
@@ -36,11 +36,11 @@ struct json_object;
|
|||||||
|
|
||||||
/*--------------------------------- CLASS ----------------------------------*/
|
/*--------------------------------- CLASS ----------------------------------*/
|
||||||
|
|
||||||
class GenericDio : public Device
|
class OutletDio : public Device
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GenericDio(void);
|
OutletDio(void);
|
||||||
~GenericDio(void);
|
~OutletDio(void);
|
||||||
|
|
||||||
virtual int from_json(struct json_object *a_node);
|
virtual int from_json(struct json_object *a_node);
|
||||||
virtual struct json_object *to_json(void) const;
|
virtual struct json_object *to_json(void) const;
|
||||||
@@ -56,7 +56,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
std::string m_zone;
|
std::string m_zone;
|
||||||
uint32_t m_sender;
|
uint32_t m_sender;
|
||||||
uint8_t m_interruptor;
|
uint8_t m_switch;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _LIGHT_H */
|
#endif /* _OUTLET_DIO_H */
|
||||||
@@ -64,7 +64,7 @@ int Shutter::from_json(struct json_object *a_node)
|
|||||||
int the_result;
|
int the_result;
|
||||||
struct json_object *the_value_node;
|
struct json_object *the_value_node;
|
||||||
|
|
||||||
the_result = GenericDio::from_json(a_node);
|
the_result = OutletDio::from_json(a_node);
|
||||||
if (the_result < 0)
|
if (the_result < 0)
|
||||||
return the_result;
|
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
|
int Shutter::to_json(struct json_object *a_node) const
|
||||||
{
|
{
|
||||||
// Get Generic Dio fields
|
// Get Generic Dio fields
|
||||||
GenericDio::to_json(a_node);
|
OutletDio::to_json(a_node);
|
||||||
|
|
||||||
// speed up
|
// speed up
|
||||||
json_object_object_add(a_node, k_entry_speed_up, json_object_new_int(m_speed_up));
|
json_object_object_add(a_node, k_entry_speed_up, json_object_new_int(m_speed_up));
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
/*------------------------------- INCLUDES ----------------------------------*/
|
/*------------------------------- INCLUDES ----------------------------------*/
|
||||||
|
|
||||||
#include "generic-dio.h"
|
#include "outlet-dio.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ struct json_object;
|
|||||||
|
|
||||||
/*--------------------------------- CLASS ----------------------------------*/
|
/*--------------------------------- CLASS ----------------------------------*/
|
||||||
|
|
||||||
class Shutter : public GenericDio
|
class Shutter : public OutletDio
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Shutter(void);
|
Shutter(void);
|
||||||
|
|||||||
Reference in New Issue
Block a user