Add UBusTimer Object. And Add a Test of it into Domo program.
This commit is contained in:
@@ -23,6 +23,7 @@ file(
|
||||
../../src/models/Devices.cpp
|
||||
../../src/helpers/Tokenizer.cpp
|
||||
../../src/helpers/Strings.cpp
|
||||
../../src/Timers.cpp
|
||||
)
|
||||
|
||||
add_executable (
|
||||
|
||||
@@ -38,6 +38,7 @@ extern "C" {
|
||||
#include "ubus/capabilities_sprinklers.h"
|
||||
#include "ubus/speach_command.h"
|
||||
|
||||
#include "timers/Timers.h"
|
||||
#include "models/Devices.h"
|
||||
|
||||
/*--------------------------------- GLOBALS ---------------------------------*/
|
||||
@@ -85,11 +86,19 @@ static struct ubus_context *setupUbus (void)
|
||||
int main (void)
|
||||
{
|
||||
int theRet = 0;
|
||||
char *theWritePath;
|
||||
std::string thePath;
|
||||
|
||||
Timers theTimers;
|
||||
struct ubus_context *theCtx = NULL;
|
||||
|
||||
thePath = getenv ("DOMO_WRITE_PATH");
|
||||
theWritePath = getenv ("DOMO_WRITE_PATH");
|
||||
if (theWritePath == NULL) {
|
||||
|
||||
fprintf (stderr, "you should export DOMO_WRITE_PATH. with the Path of data.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
thePath = theWritePath;
|
||||
thePath += "/Devices.json";
|
||||
|
||||
//printf ("DOMO PATH: %s\n", thePath.c_str());
|
||||
@@ -114,6 +123,9 @@ int main (void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Setup the Timers. */
|
||||
theTimers.Setup ();
|
||||
|
||||
/* Add the UBus to the model exposed. */
|
||||
ubus_add_object (theCtx, &theCapabilities);
|
||||
ubus_add_object (theCtx, &theCapLights);
|
||||
|
||||
78
src/domod/src/timers/Timers.cpp
Normal file
78
src/domod/src/timers/Timers.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/*!
|
||||
* Timers.cpp
|
||||
*
|
||||
* Copyright (c) 2016, 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: 17/05/2016
|
||||
*
|
||||
*/
|
||||
|
||||
/*------------------------------- INCLUDES ----------------------------------*/
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "timers/Timers.h"
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn Timers
|
||||
*
|
||||
* @brief Constructor of the Timers Managagers.
|
||||
*/
|
||||
Timers::Timers (void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn Devices
|
||||
*
|
||||
* @brief Destructors of the Timer Managers.
|
||||
*/
|
||||
Timers::~Timers (void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn Devices
|
||||
*
|
||||
* @brief Destructors of the Timer Managers.
|
||||
*/
|
||||
int Timers::Setup (void)
|
||||
{
|
||||
Start (2000, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*! ----------------------------------------------------------------------------
|
||||
* @fn Expire
|
||||
*
|
||||
* @brief Method Call when the Timer has expired.
|
||||
*/
|
||||
int Timers::Expire (void)
|
||||
{
|
||||
fprintf (stderr, "Domo::Timers::Expire\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
48
src/domod/src/timers/Timers.h
Normal file
48
src/domod/src/timers/Timers.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*!
|
||||
* Timers.h
|
||||
*
|
||||
* Copyright (c) 2016, 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: 17/05/2016
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _TIMERS_H
|
||||
#define _TIMERS_H
|
||||
|
||||
/*------------------------------- INCLUDES ----------------------------------*/
|
||||
|
||||
#include "ubuscpp/UBusTimer.h"
|
||||
|
||||
class Timers : public UBusTimer {
|
||||
|
||||
public:
|
||||
Timers (void);
|
||||
~Timers (void);
|
||||
|
||||
int Expire (void);
|
||||
|
||||
int Setup (void);
|
||||
|
||||
private:
|
||||
UBusTimer mTest;
|
||||
};
|
||||
|
||||
|
||||
#endif /* _TIMERS_H */
|
||||
@@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 2.8.11)
|
||||
|
||||
project(ui)
|
||||
|
||||
add_custom_target(ui ALL)
|
||||
#add_custom_target(ui ALL)
|
||||
add_custom_target(ui)
|
||||
|
||||
add_custom_command(TARGET ui PRE_BUILD
|
||||
COMMAND mkdir -p ${CMAKE_SOURCE_DIR}/build/html
|
||||
|
||||
Reference in New Issue
Block a user