rename some class
This commit is contained in:
3
.vscode/c_cpp_properties.json
vendored
3
.vscode/c_cpp_properties.json
vendored
@@ -31,7 +31,8 @@
|
|||||||
"${workspaceRoot}/_builds/x86_64_domo-debug/cross/usr/x86_64-buildroot-linux-gnu/sysroot/usr/include",
|
"${workspaceRoot}/_builds/x86_64_domo-debug/cross/usr/x86_64-buildroot-linux-gnu/sysroot/usr/include",
|
||||||
"${workspaceRoot}/_builds/x86_64_domo-debug/cross/opt/ext-toolchain/x86_64-buildroot-linux-gnu/include/c++/5.4.0",
|
"${workspaceRoot}/_builds/x86_64_domo-debug/cross/opt/ext-toolchain/x86_64-buildroot-linux-gnu/include/c++/5.4.0",
|
||||||
"${workspaceRoot}/_builds/x86_64_domo-debug/cross/opt/ext-toolchain/x86_64-buildroot-linux-gnu/include/c++/5.4.0/x86_64-buildroot-linux-gnu",
|
"${workspaceRoot}/_builds/x86_64_domo-debug/cross/opt/ext-toolchain/x86_64-buildroot-linux-gnu/include/c++/5.4.0/x86_64-buildroot-linux-gnu",
|
||||||
"${workspaceRoot}/_builds/x86_64_domo-debug/cross/opt/ext-toolchain/lib/gcc/x86_64-buildroot-linux-gnu/5.4.0/include"
|
"${workspaceRoot}/_builds/x86_64_domo-debug/cross/opt/ext-toolchain/lib/gcc/x86_64-buildroot-linux-gnu/5.4.0/include",
|
||||||
|
"${workspaceFolder}/src/lib/libubus-cpp/include"
|
||||||
],
|
],
|
||||||
"defines": [],
|
"defines": [],
|
||||||
"intelliSenseMode": "clang-x64",
|
"intelliSenseMode": "clang-x64",
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ file(
|
|||||||
source_files
|
source_files
|
||||||
${workspaceRoot}/src/lib/libubus-cpp/src/ubus-call.cpp
|
${workspaceRoot}/src/lib/libubus-cpp/src/ubus-call.cpp
|
||||||
${workspaceRoot}/src/lib/libubus-cpp/src/ubus-object.cpp
|
${workspaceRoot}/src/lib/libubus-cpp/src/ubus-object.cpp
|
||||||
${workspaceRoot}/src/lib/libubus-cpp/src/ubus-timer.cpp
|
${workspaceRoot}/src/lib/libubus-cpp/src/uloop-timer.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(
|
add_library(
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _UBUS_TIMER_H
|
#ifndef _ULOOP_TIMER_H
|
||||||
#define _UBUS_TIMER_H
|
#define _ULOOP_TIMER_H
|
||||||
|
|
||||||
/*------------------------------- INCLUDES ----------------------------------*/
|
/*------------------------------- INCLUDES ----------------------------------*/
|
||||||
|
|
||||||
@@ -39,23 +39,25 @@ extern "C" {
|
|||||||
|
|
||||||
/*--------------------------------- CLASS ----------------------------------*/
|
/*--------------------------------- CLASS ----------------------------------*/
|
||||||
|
|
||||||
class UBusTimer : public uloop_timeout {
|
class ULoopTimer : public uloop_timeout {
|
||||||
|
|
||||||
// Disable copy construction and copy assignement
|
// Disable copy construction and copy assignement
|
||||||
UBusTimer (const UBusTimer&);
|
ULoopTimer (const ULoopTimer&);
|
||||||
UBusTimer &operator=(const UBusTimer&);
|
ULoopTimer &operator=(const ULoopTimer&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UBusTimer (void);
|
ULoopTimer (void);
|
||||||
virtual ~UBusTimer (void);
|
virtual ~ULoopTimer (void);
|
||||||
|
|
||||||
virtual int Expire (void);
|
virtual int expire (void);
|
||||||
int Start (unsigned int aTimerValue, bool aRepeat = false);
|
int start (unsigned int a_timer_value, bool a_is_repeated = false);
|
||||||
int Tick (void);
|
int stop (void);
|
||||||
|
|
||||||
|
int tick (void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mRepeat;
|
bool m_is_repeated;
|
||||||
uint16_t mTimerValue;
|
uint16_t m_timer_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _UBUS_TIMER_H */
|
#endif /* _ULOOP_TIMER_H */
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#include "ubus-cpp/ubus-timer.h"
|
#include "ubus-cpp/uloop-timer.h"
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
@@ -35,60 +35,73 @@
|
|||||||
*
|
*
|
||||||
* @brief Callback used when a Timer has expired.
|
* @brief Callback used when a Timer has expired.
|
||||||
*/
|
*/
|
||||||
static void timer_callback (struct uloop_timeout *aTimeout)
|
static void timer_callback (struct uloop_timeout *a_timeout)
|
||||||
{
|
{
|
||||||
UBusTimer *aTmp = static_cast<UBusTimer *>(aTimeout);
|
ULoopTimer *the_timer = static_cast<ULoopTimer *>(a_timeout);
|
||||||
aTmp->Tick();
|
|
||||||
|
the_timer->tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn UBusTimer
|
* @fn ULoopTimer
|
||||||
*
|
*
|
||||||
* @brief Constructor of the Timer UBUS Object.
|
* @brief Constructor of the Uloop Timer Object.
|
||||||
*/
|
*/
|
||||||
UBusTimer::UBusTimer (void)
|
ULoopTimer::ULoopTimer (void)
|
||||||
{
|
{
|
||||||
// Uloop Timer Init.
|
// Uloop Timer Init.
|
||||||
cb = timer_callback;
|
cb = timer_callback;
|
||||||
pending = 0;
|
pending = 0;
|
||||||
|
|
||||||
// UBus Timer.
|
// UBus Timer.
|
||||||
mRepeat = false;
|
m_is_repeated = false;
|
||||||
mTimerValue = 0;
|
m_timer_value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn ~UBusTimer
|
* @fn ~ULoopTimer
|
||||||
*
|
*
|
||||||
* @brief Destructor of the Timer UBUS Object.
|
* @brief Destructor of the Ullop Timer Object.
|
||||||
*/
|
*/
|
||||||
UBusTimer::~UBusTimer (void)
|
ULoopTimer::~ULoopTimer (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn Start the Timer
|
* @fn start
|
||||||
*
|
* @param aTimerValue is the amount of time (in milliseconds) before the timer
|
||||||
|
* expires.
|
||||||
* @brief Start the Timer object.
|
* @brief Start the Timer object.
|
||||||
*/
|
*/
|
||||||
int UBusTimer::Start (unsigned int aTimerValue, bool aRepeat)
|
int ULoopTimer::start (unsigned int a_timer_value, bool a_is_repeated)
|
||||||
{
|
{
|
||||||
mTimerValue = aTimerValue;
|
m_timer_value = a_timer_value;
|
||||||
mRepeat = aRepeat;
|
m_is_repeated = a_is_repeated;
|
||||||
|
|
||||||
return uloop_timeout_set (this, mTimerValue);
|
return uloop_timeout_set (this, m_timer_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn Expire
|
* @fn stop
|
||||||
|
*
|
||||||
|
* @brief Stop the Timer object.
|
||||||
|
*/
|
||||||
|
int ULoopTimer::stop (void)
|
||||||
|
{
|
||||||
|
return uloop_timeout_cancel (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! ----------------------------------------------------------------------------
|
||||||
|
* @fn expire
|
||||||
*
|
*
|
||||||
* @brief Method Should be overrided.
|
* @brief Method Should be overrided.
|
||||||
*/
|
*/
|
||||||
int UBusTimer::Expire (void)
|
int ULoopTimer::expire (void)
|
||||||
{
|
{
|
||||||
//fprintf (stderr, "UBusTimer::Expire\n");
|
//fprintf (stderr, "UBusTimer::Expire\n");
|
||||||
return 0;
|
return 0;
|
||||||
@@ -96,18 +109,16 @@ int UBusTimer::Expire (void)
|
|||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn Tick
|
* @fn tick
|
||||||
*
|
*
|
||||||
* @brief Method called when the Timer has expired.
|
* @brief Method called when the Timer has expired.
|
||||||
*/
|
*/
|
||||||
int UBusTimer::Tick (void)
|
int ULoopTimer::tick (void)
|
||||||
{
|
{
|
||||||
//fprintf (stderr, "UBusTimer::Tick\n");
|
// fprintf (stderr, "UBusTimer::Tick\n");
|
||||||
|
|
||||||
Expire ();
|
if (m_is_repeated == true)
|
||||||
|
uloop_timeout_set (this, m_timer_value);
|
||||||
|
|
||||||
if (mRepeat == true)
|
return expire ();
|
||||||
uloop_timeout_set (this, mTimerValue);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
@@ -15,13 +15,16 @@ file(
|
|||||||
GLOB_RECURSE
|
GLOB_RECURSE
|
||||||
source_files
|
source_files
|
||||||
${workspaceRoot}/src/prog/domod/src/main.cpp
|
${workspaceRoot}/src/prog/domod/src/main.cpp
|
||||||
|
${workspaceRoot}/src/prog/domod/src/devices/device.cpp
|
||||||
|
${workspaceRoot}/src/prog/domod/src/devices/devices.cpp
|
||||||
|
${workspaceRoot}/src/prog/domod/src/timers/event.cpp
|
||||||
|
${workspaceRoot}/src/prog/domod/src/ubus/timers.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# $ENV{SRC_DIR}/src/prog/domod/src/timers/Timers.cpp
|
# $ENV{SRC_DIR}/src/prog/domod/src/timers/Timers.cpp
|
||||||
# $ENV{SRC_DIR}/src/prog/domod/src/timers/Event.cpp
|
|
||||||
# $ENV{SRC_DIR}/src/prog/domod/src/timers/Clock.cpp
|
# $ENV{SRC_DIR}/src/prog/domod/src/timers/Clock.cpp
|
||||||
# $ENV{SRC_DIR}/src/prog/domod/src/devices/Devices.cpp
|
#
|
||||||
# $ENV{SRC_DIR}/src/prog/domod/src/devices/Device.cpp
|
|
||||||
# $ENV{SRC_DIR}/src/prog/domod/src/devices/LightDevice.cpp
|
# $ENV{SRC_DIR}/src/prog/domod/src/devices/LightDevice.cpp
|
||||||
# $ENV{SRC_DIR}/src/prog/domod/src/devices/ShutterDevice.cpp
|
# $ENV{SRC_DIR}/src/prog/domod/src/devices/ShutterDevice.cpp
|
||||||
# $ENV{SRC_DIR}/src/prog/domod/src/devices/SprinklerDevice.cpp
|
# $ENV{SRC_DIR}/src/prog/domod/src/devices/SprinklerDevice.cpp
|
||||||
@@ -33,10 +36,8 @@ file(
|
|||||||
# $ENV{SRC_DIR}/src/prog/domod/src/ubus/capabilities_shutters.cpp
|
# $ENV{SRC_DIR}/src/prog/domod/src/ubus/capabilities_shutters.cpp
|
||||||
# $ENV{SRC_DIR}/src/prog/domod/src/ubus/capabilities_sprinklers.cpp
|
# $ENV{SRC_DIR}/src/prog/domod/src/ubus/capabilities_sprinklers.cpp
|
||||||
# $ENV{SRC_DIR}/src/prog/domod/src/ubus/speach_command.cpp
|
# $ENV{SRC_DIR}/src/prog/domod/src/ubus/speach_command.cpp
|
||||||
# $ENV{SRC_DIR}/src/prog/domod/src/ubus/timers.cpp
|
|
||||||
# $ENV{SRC_DIR}/src/prog/domod/src/helpers/Tokenizer.cpp
|
# $ENV{SRC_DIR}/src/prog/domod/src/helpers/Tokenizer.cpp
|
||||||
# $ENV{SRC_DIR}/src/prog/domod/src/helpers/Strings.cpp
|
# $ENV{SRC_DIR}/src/prog/domod/src/helpers/Strings.cpp
|
||||||
# $ENV{SRC_DIR}/src/prog/domod/src/main.cpp
|
|
||||||
#)
|
#)
|
||||||
|
|
||||||
add_executable (domod ${source_files})
|
add_executable (domod ${source_files})
|
||||||
|
|||||||
@@ -27,7 +27,9 @@
|
|||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#include "devices/Device.h"
|
#include <json-c/json.h>
|
||||||
|
|
||||||
|
#include "devices/device.h"
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
@@ -51,11 +53,11 @@ Device::~Device (void)
|
|||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn load_from_json
|
* @fn from_json
|
||||||
*
|
*
|
||||||
* @brief Load LightDevice Object From a Json Object.
|
* @brief Load Device Object From a Json Object stringified.
|
||||||
*/
|
*/
|
||||||
int Device::load_from_json (Json::Value anElem)
|
int Device::from_json (const std::string &a_json)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Device::load_from_json...\n");
|
fprintf(stderr, "Device::load_from_json...\n");
|
||||||
return 0;
|
return 0;
|
||||||
@@ -65,11 +67,9 @@ int Device::load_from_json (Json::Value anElem)
|
|||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn to_json
|
* @fn to_json
|
||||||
*
|
*
|
||||||
* @brief Export LightDevice Object as JSON Object.
|
* @brief Export Device Object as JSON Object.
|
||||||
*/
|
*/
|
||||||
Json::Value Device::to_json (bool bDataOnly) const
|
struct json_object *Device::to_json (void) const
|
||||||
{
|
{
|
||||||
Json::Value theResult;
|
return NULL;
|
||||||
fprintf(stderr, "Device::to_json...\n");
|
|
||||||
return theResult;
|
|
||||||
}
|
}
|
||||||
@@ -30,10 +30,9 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <jsoncpp/json.h>
|
/*------------------------------ DEPENDENCIES -------------------------------*/
|
||||||
|
|
||||||
/*---------------------------------- Deps -----------------------------------*/
|
|
||||||
|
|
||||||
|
struct json_object;
|
||||||
|
|
||||||
/*--------------------------------- CLASS ----------------------------------*/
|
/*--------------------------------- CLASS ----------------------------------*/
|
||||||
|
|
||||||
@@ -43,8 +42,8 @@ public:
|
|||||||
Device (void);
|
Device (void);
|
||||||
virtual ~Device (void);
|
virtual ~Device (void);
|
||||||
|
|
||||||
virtual int load_from_json (Json::Value anElem);
|
virtual int from_json (const std::string &a_json);
|
||||||
virtual Json::Value to_json (bool bDataOnly = false) const;
|
virtual struct json_object *to_json (void) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string mspeach_name;
|
std::string mspeach_name;
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#include "devices/SprinklerDevice.h"
|
#include "devices/sprinkler-device.h"
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
@@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "devices/Sprinkler.h"
|
#include "devices/sprinkler.h"
|
||||||
#include "devices/Device.h"
|
#include "devices/device.h"
|
||||||
|
|
||||||
/*---------------------------------- Deps -----------------------------------*/
|
/*---------------------------------- Deps -----------------------------------*/
|
||||||
|
|
||||||
@@ -37,6 +37,9 @@ extern "C" {
|
|||||||
#include <libubus.h>
|
#include <libubus.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "timers/timers.h"
|
||||||
|
#include "devices/devices.h"
|
||||||
|
|
||||||
/*-------------------------------- DEFINES ---------------------------------*/
|
/*-------------------------------- DEFINES ---------------------------------*/
|
||||||
|
|
||||||
#define k_dir_sep '/'
|
#define k_dir_sep '/'
|
||||||
@@ -117,11 +120,27 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
int the_ret = 0;
|
int the_ret = 0;
|
||||||
std::string the_config_path;
|
std::string the_config_path;
|
||||||
|
|
||||||
struct ubus_context *the_ctx = NULL;
|
struct ubus_context *the_ctx = NULL;
|
||||||
|
|
||||||
/* Get the Path of the binary to load configs. */
|
/* Get the Path of the binary to load configs. */
|
||||||
the_config_path = get_config_path(argv[0]);
|
the_config_path = get_config_path(argv[0]);
|
||||||
printf ("config path: %s\n", the_config_path.c_str());
|
printf ("config path: %s\n", the_config_path.c_str());
|
||||||
|
|
||||||
|
/* Setup the devices. */
|
||||||
|
Devices the_devices(the_config_path + "/Devices.json");
|
||||||
|
if (theDevices.load() != 0) {
|
||||||
|
fprintf(stderr, "Failed to load devices.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Setup the Timers. */
|
||||||
|
Timers the_timers(the_config_path + "/Timers.json", &the_devices);
|
||||||
|
if (the_timers.load() != 0) {
|
||||||
|
fprintf(stderr, "Failed to load timers.\n");
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Setup the Ubus context. */
|
/* Setup the Ubus context. */
|
||||||
|
|||||||
@@ -31,10 +31,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <jsoncpp/json.h>
|
#include <ubus-cpp/uloop-timer.h>
|
||||||
|
|
||||||
#include "ubus-cpp/UBusTimer.h"
|
#include "timers/event.h"
|
||||||
#include "timers/Event.h"
|
|
||||||
|
|
||||||
/*---------------------------------- Deps -----------------------------------*/
|
/*---------------------------------- Deps -----------------------------------*/
|
||||||
|
|
||||||
@@ -42,13 +41,13 @@ class Devices;
|
|||||||
|
|
||||||
/*--------------------------------- CLASS ----------------------------------*/
|
/*--------------------------------- CLASS ----------------------------------*/
|
||||||
|
|
||||||
class Timers : public UBusTimer {
|
class Timers : public ULoopTimer {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Timers (std::string aPath, Devices *aDevice);
|
Timers (const std::string &a_path, Devices *a_device);
|
||||||
~Timers (void);
|
~Timers (void);
|
||||||
|
|
||||||
int Expire (void);
|
int expire (void);
|
||||||
|
|
||||||
int load (void);
|
int load (void);
|
||||||
int save (void);
|
int save (void);
|
||||||
Reference in New Issue
Block a user