timers is now complete. timer ubus model is in progress.
This commit is contained in:
@@ -29,7 +29,7 @@ file(
|
|||||||
${workspaceRoot}/src/prog/domod/src/ubus/capabilities_lights.cpp
|
${workspaceRoot}/src/prog/domod/src/ubus/capabilities_lights.cpp
|
||||||
${workspaceRoot}/src/prog/domod/src/ubus/capabilities_shutters.cpp
|
${workspaceRoot}/src/prog/domod/src/ubus/capabilities_shutters.cpp
|
||||||
${workspaceRoot}/src/prog/domod/src/ubus/capabilities_sprinklers.cpp
|
${workspaceRoot}/src/prog/domod/src/ubus/capabilities_sprinklers.cpp
|
||||||
#${workspaceRoot}/src/prog/domod/src/ubus/timers.cpp
|
${workspaceRoot}/src/prog/domod/src/ubus/timers.cpp
|
||||||
|
|
||||||
# Timers
|
# Timers
|
||||||
${workspaceRoot}/src/prog/domod/src/timers/timers-manager.cpp
|
${workspaceRoot}/src/prog/domod/src/timers/timers-manager.cpp
|
||||||
|
|||||||
@@ -136,22 +136,28 @@ int Event::from_json(struct json_object *a_node)
|
|||||||
*/
|
*/
|
||||||
struct json_object *Event::to_json(void) const
|
struct json_object *Event::to_json(void) const
|
||||||
{
|
{
|
||||||
#if 0
|
struct json_object *the_root_node;
|
||||||
Json::Value aResult(Json::objectValue);
|
|
||||||
|
|
||||||
aResult ["id"] = mID;
|
the_root_node = json_object_new_object();
|
||||||
|
|
||||||
aResult ["active"] = mActive;
|
// id
|
||||||
aResult ["device_id"] = mCapability + "/" + std::to_string(mDeviceID);
|
json_object_object_add(the_root_node, k_entry_id, json_object_new_int(m_id));
|
||||||
aResult ["action"] = mAction;
|
// 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));
|
||||||
|
// 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()));
|
||||||
|
|
||||||
aResult["recurrence"] = mRecurrence;
|
return the_root_node;
|
||||||
aResult["duration"] = mDuration;
|
|
||||||
|
|
||||||
aResult["start_time"] = std::to_string(mHour) + ":" + std::to_string(mMinute);
|
|
||||||
|
|
||||||
return aResult;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ const Event &TimerManager::get(uint16_t an_id)
|
|||||||
return (*the_timer_evt);
|
return (*the_timer_evt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//todo return something.
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -33,21 +33,19 @@ extern "C" {
|
|||||||
|
|
||||||
#include <json-c/json.h>
|
#include <json-c/json.h>
|
||||||
|
|
||||||
|
#include "timers/timers-manager.h"
|
||||||
#include "timers/timers.h"
|
|
||||||
|
|
||||||
#include "timers.h"
|
#include "timers.h"
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
using namespace UBus;
|
using namespace UBus;
|
||||||
|
|
||||||
static ObjectType gTimersModelUbus_types(
|
static ObjectType gTimersModelUbus_types(
|
||||||
"TimersModel",
|
"TimersModel",
|
||||||
Method("get", UBUS_CPP(TimersModel, Get)),
|
Method("get", UBUS_CPP(TimersModel, get)),
|
||||||
Method("delete", UBUS_CPP(TimersModel, Delete))
|
Method("delete", UBUS_CPP(TimersModel, del)));
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
@@ -55,33 +53,29 @@ static ObjectType gTimersModelUbus_types(
|
|||||||
*
|
*
|
||||||
* @brief Constructor of the Timer Objects.
|
* @brief Constructor of the Timer Objects.
|
||||||
*/
|
*/
|
||||||
TimersModel::TimersModel (Timers *aTimers) :
|
TimersModel::TimersModel(TimerManager *a_timer_manager) : UBusObject(gTimersModelUbus_types, "domo.timers"),
|
||||||
UBusObject (gTimersModelUbus_types, "domo.timers"),
|
m_timer_manager(a_timer_manager)
|
||||||
mTimers (aTimers)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn ~TimersModel
|
* @fn ~TimersModel
|
||||||
*
|
*
|
||||||
* @brief Destructor of the Timer Objects.
|
* @brief Destructor of the Timer Objects.
|
||||||
*/
|
*/
|
||||||
TimersModel::~TimersModel (void)
|
TimersModel::~TimersModel(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn Get
|
* @fn get
|
||||||
*
|
*
|
||||||
* @brief Get the List of timer objects.
|
* @brief Get the List of timer objects.
|
||||||
*/
|
*/
|
||||||
int TimersModel::Get (struct ubus_context *aCtx, struct ubus_request_data *aReq,
|
int TimersModel::get(struct ubus_context *a_ctx, struct ubus_request_data *a_req, struct blob_attr *a_msg)
|
||||||
struct blob_attr *aMsg)
|
|
||||||
{
|
{
|
||||||
int theResult = 0;
|
int the_result = 0;
|
||||||
|
#if 0
|
||||||
int theID = -1;
|
int theID = -1;
|
||||||
Json::Reader theReader;
|
Json::Reader theReader;
|
||||||
Json::StyledWriter theWriter;
|
Json::StyledWriter theWriter;
|
||||||
@@ -111,20 +105,19 @@ int TimersModel::Get (struct ubus_context *aCtx, struct ubus_request_data *aReq,
|
|||||||
theResult = ubus_send_reply (aCtx, aReq, theBuf.head);
|
theResult = ubus_send_reply (aCtx, aReq, theBuf.head);
|
||||||
|
|
||||||
blob_buf_free (&theBuf);
|
blob_buf_free (&theBuf);
|
||||||
|
#endif
|
||||||
return theResult;
|
return the_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn Delete
|
* @fn del
|
||||||
*
|
*
|
||||||
* @brief Delete a Timer Object.
|
* @brief Delete a Timer Object.
|
||||||
*/
|
*/
|
||||||
int TimersModel::Delete (struct ubus_context *aCtx, struct ubus_request_data *aReq,
|
int TimersModel::del(struct ubus_context *a_ctx, struct ubus_request_data *a_req, struct blob_attr *a_msg)
|
||||||
struct blob_attr *aMsg)
|
|
||||||
{
|
{
|
||||||
int theResult = 0;
|
int the_result = 0;
|
||||||
|
#if 0
|
||||||
Json::Reader theReader;
|
Json::Reader theReader;
|
||||||
Json::Value theRoot;
|
Json::Value theRoot;
|
||||||
int theID = -1;
|
int theID = -1;
|
||||||
@@ -147,6 +140,6 @@ int TimersModel::Delete (struct ubus_context *aCtx, struct ubus_request_data *aR
|
|||||||
printf ("Successfully removed.\n");
|
printf ("Successfully removed.\n");
|
||||||
//TODO SAVE and return OK.
|
//TODO SAVE and return OK.
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return theResult;
|
return the_result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
/*--------------------------------- Define ----------------------------------*/
|
/*--------------------------------- Define ----------------------------------*/
|
||||||
|
|
||||||
class Timers;
|
class TimerManager;
|
||||||
|
|
||||||
/*--------------------------------- CLASS ----------------------------------*/
|
/*--------------------------------- CLASS ----------------------------------*/
|
||||||
|
|
||||||
@@ -42,14 +42,14 @@ class TimersModel : public UBusObject
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TimersModel(Timers *aTimers);
|
TimersModel(TimerManager *a_timer_manager);
|
||||||
~TimersModel(void);
|
~TimersModel(void);
|
||||||
|
|
||||||
int get(struct ubus_context *, struct ubus_request_data *, struct blob_attr *);
|
int get(struct ubus_context *, struct ubus_request_data *, struct blob_attr *);
|
||||||
int del(struct ubus_context *, struct ubus_request_data *, struct blob_attr *);
|
int del(struct ubus_context *, struct ubus_request_data *, struct blob_attr *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Timers *m_timers;
|
TimerManager *m_timer_manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _UBUS_TIMERS_H */
|
#endif /* _UBUS_TIMERS_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user