wip Add Action
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
"start_time": "17:30",
|
||||
"recurrence": 1
|
||||
},
|
||||
"sequence": [
|
||||
"actions": [
|
||||
{
|
||||
"device_id": "sprinkler/7",
|
||||
"state": true,
|
||||
@@ -29,7 +29,7 @@
|
||||
"start_time": "21:48",
|
||||
"recurrence": 0
|
||||
},
|
||||
"sequence": [
|
||||
"actions": [
|
||||
{
|
||||
"device_id": "light/7",
|
||||
"state": true,
|
||||
@@ -45,7 +45,7 @@
|
||||
"start_time": "09:00",
|
||||
"recurrence": 0
|
||||
},
|
||||
"sequence": [
|
||||
"actions": [
|
||||
[
|
||||
{
|
||||
"device_id": "shutters/1",
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"start_time": "17:30",
|
||||
"recurrence": 1
|
||||
},
|
||||
"sequence": [
|
||||
"actions": [
|
||||
{
|
||||
"device_id": "sprinkler/7",
|
||||
"state": true,
|
||||
@@ -29,7 +29,7 @@
|
||||
"start_time": "21:48",
|
||||
"recurrence": 0
|
||||
},
|
||||
"sequence": [
|
||||
"actions": [
|
||||
{
|
||||
"device_id": "light/7",
|
||||
"state": true,
|
||||
@@ -45,7 +45,7 @@
|
||||
"start_time": "09:00",
|
||||
"recurrence": 0
|
||||
},
|
||||
"sequence": [
|
||||
"actions": [
|
||||
[
|
||||
{
|
||||
"device_id": "shutters/1",
|
||||
|
||||
@@ -34,6 +34,7 @@ file(
|
||||
# Timers
|
||||
${workspaceRoot}/src/prog/domod/src/sequences/sequences-manager.cpp
|
||||
${workspaceRoot}/src/prog/domod/src/sequences/sequence.cpp
|
||||
${workspaceRoot}/src/prog/domod/src/sequences/timer.cpp
|
||||
${workspaceRoot}/src/prog/domod/src/sequences/action.cpp
|
||||
${workspaceRoot}/src/prog/domod/src/sequences/clock.cpp
|
||||
)
|
||||
|
||||
@@ -53,8 +53,13 @@
|
||||
#define k_entry_speed_up "speed_up"
|
||||
#define k_entry_speed_down "speed_down"
|
||||
|
||||
|
||||
/* Timer */
|
||||
|
||||
/* sequence */
|
||||
#define k_entry_active "active"
|
||||
#define k_entry_start_time "start_time"
|
||||
#define k_entry_recurrence "recurrence"
|
||||
#define k_entry_timer "timer"
|
||||
#define k_entry_device_id "device_id"
|
||||
#define k_entry_duration "duration"
|
||||
#define k_entry_actions "actions"
|
||||
|
||||
#endif /* _DOMO_H */
|
||||
@@ -31,31 +31,18 @@
|
||||
|
||||
#include "domo.h"
|
||||
|
||||
#include "sequences/action.h"
|
||||
#include "action.h"
|
||||
|
||||
/*------------------------------- DEFINES ----------------------------------*/
|
||||
|
||||
#define k_entry_active "active"
|
||||
#define k_entry_device_id "device_id"
|
||||
#define k_entry_start_time "start_time"
|
||||
|
||||
#define k_entry_recurrence "recurrence"
|
||||
#define k_entry_duration "duration"
|
||||
#define k_entry_action "action"
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn Action
|
||||
*
|
||||
* @brief Constructor of Action Object.
|
||||
*/
|
||||
Action::Action(void) : m_active(false),
|
||||
m_id(0),
|
||||
m_device_id(0),
|
||||
m_hour(0),
|
||||
m_minute(0),
|
||||
m_recurrence(0),
|
||||
m_duration(0),
|
||||
m_in_progress(false)
|
||||
Action::Action(void) : m_device_id(0),
|
||||
m_state(false),
|
||||
m_duration(0)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
@@ -77,16 +64,6 @@ int Action::from_json(struct json_object *a_node)
|
||||
{
|
||||
struct json_object *the_value_node;
|
||||
|
||||
// id
|
||||
if (json_object_object_get_ex(a_node, k_entry_id, &the_value_node))
|
||||
{
|
||||
m_id = json_object_get_int(the_value_node);
|
||||
}
|
||||
// active
|
||||
if (json_object_object_get_ex(a_node, k_entry_active, &the_value_node))
|
||||
{
|
||||
m_active = json_object_get_boolean(the_value_node);
|
||||
}
|
||||
// device_id
|
||||
if (json_object_object_get_ex(a_node, k_entry_device_id, &the_value_node))
|
||||
{
|
||||
@@ -98,22 +75,11 @@ int Action::from_json(struct json_object *a_node)
|
||||
m_capability = the_id_elem.substr(0, the_separator);
|
||||
m_device_id = std::stoi(the_id_elem.substr(the_separator + 1));
|
||||
}
|
||||
// start time
|
||||
if (json_object_object_get_ex(a_node, k_entry_start_time, &the_value_node))
|
||||
{
|
||||
std::size_t the_separator;
|
||||
std::string the_start_time;
|
||||
the_start_time = json_object_get_string(the_value_node);
|
||||
the_separator = the_start_time.find_last_of(":");
|
||||
|
||||
m_hour = std::stoi(the_start_time.substr(0, the_separator));
|
||||
m_minute = std::stoi(the_start_time.substr(the_separator + 1));
|
||||
}
|
||||
|
||||
// recurrence
|
||||
if (json_object_object_get_ex(a_node, k_entry_recurrence, &the_value_node))
|
||||
// state
|
||||
if (json_object_object_get_ex(a_node, k_entry_state, &the_value_node))
|
||||
{
|
||||
m_recurrence = json_object_get_int(the_value_node);
|
||||
m_state = json_object_get_boolean(the_value_node);
|
||||
}
|
||||
|
||||
// duration
|
||||
@@ -122,12 +88,6 @@ int Action::from_json(struct json_object *a_node)
|
||||
m_duration = json_object_get_int(the_value_node);
|
||||
}
|
||||
|
||||
// action
|
||||
if (json_object_object_get_ex(a_node, k_entry_action, &the_value_node))
|
||||
{
|
||||
m_action = json_object_get_string(the_value_node);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -142,22 +102,15 @@ struct json_object *Action::to_json(void) const
|
||||
|
||||
the_root_node = json_object_new_object();
|
||||
|
||||
// id
|
||||
json_object_object_add(the_root_node, k_entry_id, json_object_new_int(m_id));
|
||||
// active
|
||||
json_object_object_add(the_root_node, k_entry_active, json_object_new_boolean(m_active));
|
||||
// device_id
|
||||
std::string the_device_id = m_capability + "/" + std::to_string(m_device_id);
|
||||
json_object_object_add(the_root_node, k_entry_device_id, json_object_new_string(the_device_id.c_str()));
|
||||
// action
|
||||
json_object_object_add(the_root_node, k_entry_action, json_object_new_string(m_action.c_str()));
|
||||
// recurrence
|
||||
json_object_object_add(the_root_node, k_entry_recurrence, json_object_new_int(m_recurrence));
|
||||
|
||||
// state
|
||||
json_object_object_add(the_root_node, k_entry_active, json_object_new_boolean(m_state));
|
||||
|
||||
// duration
|
||||
json_object_object_add(the_root_node, k_entry_duration, json_object_new_int(m_duration));
|
||||
//start_time
|
||||
std::string the_start_time = std::to_string(m_hour) + ":" + std::to_string(m_minute);
|
||||
json_object_object_add(the_root_node, k_entry_start_time, json_object_new_string(the_start_time.c_str()));
|
||||
|
||||
return the_root_node;
|
||||
}
|
||||
@@ -167,30 +120,34 @@ struct json_object *Action::to_json(void) const
|
||||
*
|
||||
* @brief Start the Action.
|
||||
*/
|
||||
#if 0
|
||||
int Action::start(DevicesManager *a_device_manager)
|
||||
{
|
||||
set_in_progress(true);
|
||||
|
||||
return a_device_manager->set_state(m_capability, m_device_id, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn stop
|
||||
*
|
||||
* @brief Stop the Action.
|
||||
*/
|
||||
#if 0
|
||||
int Action::stop(DevicesManager *a_device_manager)
|
||||
{
|
||||
set_in_progress(false);
|
||||
|
||||
return a_device_manager->set_state(m_capability, m_device_id, false);
|
||||
}
|
||||
|
||||
#endif
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn dump
|
||||
*
|
||||
* @brief dump the Event Object.
|
||||
*/
|
||||
#if 0
|
||||
void Action::dump(void)
|
||||
{
|
||||
fprintf(stdout, "Timer Event:\n");
|
||||
@@ -204,15 +161,16 @@ void Action::dump(void)
|
||||
fprintf(stdout, " - duration: %d\n", m_duration);
|
||||
fprintf(stdout, " - action: %s\n", m_action.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn is_active
|
||||
* @fn get_device_id
|
||||
*
|
||||
* @brief return true if the Timer event is active.
|
||||
* @brief return the Device ID of the Event.
|
||||
*/
|
||||
bool Action::is_active(void) const
|
||||
uint16_t Action::get_device_id(void) const
|
||||
{
|
||||
return m_active;
|
||||
return m_device_id;
|
||||
}
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
@@ -226,53 +184,13 @@ const std::string &Action::get_capability(void) const
|
||||
}
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn get_id
|
||||
* @fn get_state
|
||||
*
|
||||
* @brief return the ID of the Event.
|
||||
* @brief return the state for this action.
|
||||
*/
|
||||
uint16_t Action::get_id(void) const
|
||||
bool Action::get_state(void) const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn get_device_id
|
||||
*
|
||||
* @brief return the Device ID of the Event.
|
||||
*/
|
||||
uint16_t Action::get_device_id(void) const
|
||||
{
|
||||
return m_device_id;
|
||||
}
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn get_hour
|
||||
*
|
||||
* @brief Return the Hour of the Event.
|
||||
*/
|
||||
uint8_t Action::get_hour(void) const
|
||||
{
|
||||
return m_hour;
|
||||
}
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn get_minute
|
||||
*
|
||||
* @brief Return the Minute of the Event.
|
||||
*/
|
||||
uint8_t Action::get_minute(void) const
|
||||
{
|
||||
return m_minute;
|
||||
}
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn getRecurrence
|
||||
*
|
||||
* @brief Return the Recurrency of the Event.
|
||||
*/
|
||||
uint16_t Action::get_recurrence(void) const
|
||||
{
|
||||
return m_recurrence;
|
||||
return m_state;
|
||||
}
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
@@ -285,16 +203,7 @@ uint16_t Action::get_duration(void) const
|
||||
return m_duration;
|
||||
}
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn get_action
|
||||
*
|
||||
* @brief Return the Action of the Event.
|
||||
*/
|
||||
const std::string &Action::get_action(void) const
|
||||
{
|
||||
return m_action;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn is_in_progress
|
||||
*
|
||||
@@ -314,3 +223,4 @@ void Action::set_in_progress(bool a_state)
|
||||
{
|
||||
m_in_progress = a_state;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -46,37 +46,29 @@ class Action
|
||||
int from_json(struct json_object *a_node);
|
||||
struct json_object *to_json(void) const;
|
||||
|
||||
int start(DevicesManager *a_device_manager);
|
||||
int stop(DevicesManager *a_device_manager);
|
||||
//int start(DevicesManager *a_device_manager);
|
||||
//int stop(DevicesManager *a_device_manager);
|
||||
|
||||
void dump(void);
|
||||
//void dump(void);
|
||||
|
||||
/* Getter */
|
||||
bool is_active(void) const;
|
||||
const std::string &get_capability(void) const;
|
||||
uint16_t get_id(void) const;
|
||||
uint16_t get_device_id(void) const;
|
||||
uint8_t get_hour(void) const;
|
||||
uint8_t get_minute(void) const;
|
||||
uint16_t get_recurrence(void) const;
|
||||
const std::string &get_capability(void) const;
|
||||
bool get_state(void) const;
|
||||
uint16_t get_duration(void) const;
|
||||
const std::string &get_action(void) const;
|
||||
bool is_in_progress(void) const;
|
||||
|
||||
//bool is_in_progress(void) const;
|
||||
|
||||
/* Setter */
|
||||
void set_in_progress(bool a_state);
|
||||
//void set_in_progress(bool a_state);
|
||||
|
||||
private:
|
||||
bool m_active;
|
||||
std::string m_capability;
|
||||
uint16_t m_id;
|
||||
uint16_t m_device_id;
|
||||
uint8_t m_hour;
|
||||
uint8_t m_minute;
|
||||
uint16_t m_recurrence;
|
||||
std::string m_capability;
|
||||
bool m_state;
|
||||
uint16_t m_duration;
|
||||
std::string m_action;
|
||||
bool m_in_progress;
|
||||
|
||||
//bool m_in_progress;
|
||||
};
|
||||
|
||||
#endif /* _EVENT_H */
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "sequences/clock.h"
|
||||
#include "clock.h"
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn Clock
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
*
|
||||
* @brief Constructor of the Sequence Object.
|
||||
*/
|
||||
Sequence::Sequence(void)
|
||||
Sequence::Sequence(void) : m_id(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -70,6 +70,29 @@ int Sequence::from_json(struct json_object *a_node)
|
||||
m_name = json_object_get_string(the_value_node);
|
||||
}
|
||||
|
||||
// timer
|
||||
if (json_object_object_get_ex(a_node, k_entry_timer, &the_value_node))
|
||||
{
|
||||
m_timer.from_json(the_value_node);
|
||||
}
|
||||
|
||||
// actions
|
||||
if (json_object_object_get_ex(a_node, k_entry_actions, &the_value_node) && (json_object_get_type(the_value_node) == json_type_array))
|
||||
{
|
||||
int the_len;
|
||||
struct json_object *the_action_node;
|
||||
|
||||
the_len = json_object_array_length(the_value_node);
|
||||
for (int i = 0; i < the_len; i++)
|
||||
{
|
||||
Action the_action;
|
||||
the_action_node = json_object_array_get_idx(the_value_node, i);
|
||||
the_action.from_json(the_action_node);
|
||||
|
||||
m_actions.push_back(the_action);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -80,15 +103,29 @@ int Sequence::from_json(struct json_object *a_node)
|
||||
*/
|
||||
struct json_object *Sequence::to_json(void) const
|
||||
{
|
||||
struct json_object *the_root_node;
|
||||
std::vector<Action>::iterator the_action_it;
|
||||
struct json_object *the_root_node, *the_action_array_node;
|
||||
|
||||
the_root_node = json_object_new_object();
|
||||
|
||||
// id
|
||||
json_object_object_add(the_root_node, k_entry_id, json_object_new_int(m_id));
|
||||
|
||||
// name
|
||||
json_object_object_add(the_root_node, k_entry_name, json_object_new_string(m_name.c_str()));
|
||||
|
||||
// timer
|
||||
json_object_object_add(the_root_node, k_entry_timer, m_timer.to_json());
|
||||
|
||||
// actions
|
||||
the_action_array_node = json_object_new_array();
|
||||
json_object_object_add(the_root_node, k_entry_actions, the_action_array_node);
|
||||
#if 0
|
||||
for (the_action_it = m_actions.begin(); the_action_it != m_actions.end(); the_action_it++)
|
||||
{
|
||||
//json_object_array_add(the_action_array_node, (*the_action_it).to_json());
|
||||
}
|
||||
#endif
|
||||
return the_root_node;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,11 @@
|
||||
/*------------------------------- INCLUDES ----------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "sequences/action.h"
|
||||
|
||||
#include "sequences/timer.h"
|
||||
|
||||
/*---------------------------------- Deps -----------------------------------*/
|
||||
|
||||
@@ -51,6 +56,8 @@ public:
|
||||
private:
|
||||
uint16_t m_id;
|
||||
std::string m_name;
|
||||
Timer m_timer;
|
||||
std::vector<Action> m_actions;
|
||||
};
|
||||
|
||||
#endif /* _SEQUENCE_H */
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "domo.h"
|
||||
|
||||
#include "sequences/sequences-manager.h"
|
||||
#include "sequences-manager.h"
|
||||
|
||||
//#define k60s 60000
|
||||
#define k60s 2000
|
||||
|
||||
155
src/prog/domod/src/sequences/timer.cpp
Normal file
155
src/prog/domod/src/sequences/timer.cpp
Normal file
@@ -0,0 +1,155 @@
|
||||
/*!
|
||||
* timer.cpp
|
||||
*
|
||||
* Copyright (c) 2016-2018, NADAL Jean-Baptiste. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* @Author: NADAL Jean-Baptiste
|
||||
* @Date: 11/04/2018
|
||||
*
|
||||
*/
|
||||
|
||||
/*------------------------------- INCLUDES ----------------------------------*/
|
||||
|
||||
#include <json-c/json.h>
|
||||
|
||||
#include "domo.h"
|
||||
|
||||
#include "timer.h"
|
||||
|
||||
/*------------------------------- DEFINES ----------------------------------*/
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn Timer
|
||||
*
|
||||
* @brief Constructor of Timer Object.
|
||||
*/
|
||||
Timer::Timer(void) : m_active(false),
|
||||
m_hour(0),
|
||||
m_minute(0),
|
||||
m_recurrence(0)
|
||||
{
|
||||
}
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn ~Timer
|
||||
*
|
||||
* @brief Destructor of Timer Object.
|
||||
*/
|
||||
Timer::~Timer(void)
|
||||
{
|
||||
}
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn from_json
|
||||
*
|
||||
* @brief Load Timer Object.
|
||||
*/
|
||||
int Timer::from_json(struct json_object *a_node)
|
||||
{
|
||||
struct json_object *the_value_node;
|
||||
|
||||
// active
|
||||
if (json_object_object_get_ex(a_node, k_entry_active, &the_value_node))
|
||||
{
|
||||
m_active = json_object_get_boolean(the_value_node);
|
||||
}
|
||||
|
||||
// start time
|
||||
if (json_object_object_get_ex(a_node, k_entry_start_time, &the_value_node))
|
||||
{
|
||||
std::size_t the_separator;
|
||||
std::string the_start_time;
|
||||
the_start_time = json_object_get_string(the_value_node);
|
||||
the_separator = the_start_time.find_last_of(":");
|
||||
|
||||
m_hour = std::stoi(the_start_time.substr(0, the_separator));
|
||||
m_minute = std::stoi(the_start_time.substr(the_separator + 1));
|
||||
}
|
||||
|
||||
// recurrence
|
||||
if (json_object_object_get_ex(a_node, k_entry_recurrence, &the_value_node))
|
||||
{
|
||||
m_recurrence = json_object_get_int(the_value_node);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn to_json
|
||||
*
|
||||
* @brief Export Timer Object as JSON Object.
|
||||
*/
|
||||
struct json_object *Timer::to_json(void) const
|
||||
{
|
||||
struct json_object *the_root_node;
|
||||
|
||||
the_root_node = json_object_new_object();
|
||||
|
||||
// active
|
||||
json_object_object_add(the_root_node, k_entry_active, json_object_new_boolean(m_active));
|
||||
|
||||
//start_time
|
||||
std::string the_start_time = std::to_string(m_hour) + ":" + std::to_string(m_minute);
|
||||
json_object_object_add(the_root_node, k_entry_start_time, json_object_new_string(the_start_time.c_str()));
|
||||
|
||||
// recurrence
|
||||
json_object_object_add(the_root_node, k_entry_recurrence, json_object_new_int(m_recurrence));
|
||||
|
||||
return the_root_node;
|
||||
}
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn is_active
|
||||
*
|
||||
* @brief return true if the Timer is active.
|
||||
*/
|
||||
bool Timer::is_active(void) const
|
||||
{
|
||||
return m_active;
|
||||
}
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn get_hour
|
||||
*
|
||||
* @brief Return the Hour of the Timer.
|
||||
*/
|
||||
uint8_t Timer::get_hour(void) const
|
||||
{
|
||||
return m_hour;
|
||||
}
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn get_minute
|
||||
*
|
||||
* @brief Return the Minute of the Timer.
|
||||
*/
|
||||
uint8_t Timer::get_minute(void) const
|
||||
{
|
||||
return m_minute;
|
||||
}
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn get_recurrence
|
||||
*
|
||||
* @brief Return the Recurrency of the Timer.
|
||||
*/
|
||||
uint16_t Timer::get_recurrence(void) const
|
||||
{
|
||||
return m_recurrence;
|
||||
}
|
||||
60
src/prog/domod/src/sequences/timer.h
Normal file
60
src/prog/domod/src/sequences/timer.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*!
|
||||
* timer.h
|
||||
*
|
||||
* Copyright (c) 2016-2018, NADAL Jean-Baptiste. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*
|
||||
* @Author: NADAL Jean-Baptiste
|
||||
* @Date: 11/04/2018
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _TIMER_H
|
||||
#define _TIMER_H
|
||||
|
||||
/*------------------------------- INCLUDES ----------------------------------*/
|
||||
|
||||
#include <string>
|
||||
|
||||
/*---------------------------------- Deps -----------------------------------*/
|
||||
|
||||
struct json_object;
|
||||
|
||||
/*--------------------------------- CLASS ----------------------------------*/
|
||||
|
||||
class Timer
|
||||
{
|
||||
public:
|
||||
Timer(void);
|
||||
~Timer(void);
|
||||
|
||||
int from_json(struct json_object *a_node);
|
||||
struct json_object *to_json(void) const;
|
||||
|
||||
bool is_active(void) const;
|
||||
uint8_t get_hour(void) const;
|
||||
uint8_t get_minute(void) const;
|
||||
uint16_t get_recurrence(void) const;
|
||||
|
||||
private:
|
||||
bool m_active;
|
||||
uint8_t m_hour;
|
||||
uint8_t m_minute;
|
||||
uint16_t m_recurrence;
|
||||
};
|
||||
|
||||
#endif /* _TIMER_H */
|
||||
Reference in New Issue
Block a user