From 8881bb03a3b9c57cde93122f03a9486c5b0285f2 Mon Sep 17 00:00:00 2001 From: NADAL Jean-Baptiste Date: Sat, 21 May 2016 12:36:15 +0200 Subject: [PATCH] Add Skeleton for the Devices Tree :) --- src/domod/builders/cmake/CMakeLists.txt | 14 ++- src/domod/src/devices/Device.cpp | 52 ++++++++ src/domod/src/devices/Device.h | 45 +++++++ src/domod/src/devices/Devices.cpp | 111 ++++++++++++++++++ src/domod/src/devices/Devices.h | 58 +++++++++ src/domod/src/devices/LightDevice.cpp | 52 ++++++++ src/domod/src/devices/LightDevice.h | 46 ++++++++ src/domod/src/devices/ShutterDevice.cpp | 52 ++++++++ src/domod/src/devices/ShutterDevice.h | 46 ++++++++ src/domod/src/devices/SprinklerDevice.cpp | 52 ++++++++ src/domod/src/devices/SprinklerDevice.h | 46 ++++++++ src/domod/src/main.cpp | 6 +- src/domod/src/models/Devices.cpp | 3 +- src/domod/src/models/Devices.h | 1 + src/domod/src/timers/Event.cpp | 16 +-- src/domod/src/timers/Event.h | 6 +- src/domod/src/timers/Timers.cpp | 16 +-- src/domod/src/timers/Timers.h | 4 +- src/domod/src/ubus/capabilities_lights.cpp | 10 +- src/domod/src/ubus/capabilities_shutters.cpp | 6 +- .../src/ubus/capabilities_sprinklers.cpp | 10 +- src/domod/src/ubus/speach_command.cpp | 4 +- 22 files changed, 612 insertions(+), 44 deletions(-) create mode 100644 src/domod/src/devices/Device.cpp create mode 100644 src/domod/src/devices/Device.h create mode 100644 src/domod/src/devices/Devices.cpp create mode 100644 src/domod/src/devices/Devices.h create mode 100644 src/domod/src/devices/LightDevice.cpp create mode 100644 src/domod/src/devices/LightDevice.h create mode 100644 src/domod/src/devices/ShutterDevice.cpp create mode 100644 src/domod/src/devices/ShutterDevice.h create mode 100644 src/domod/src/devices/SprinklerDevice.cpp create mode 100644 src/domod/src/devices/SprinklerDevice.h diff --git a/src/domod/builders/cmake/CMakeLists.txt b/src/domod/builders/cmake/CMakeLists.txt index b967e39d..09816bf1 100644 --- a/src/domod/builders/cmake/CMakeLists.txt +++ b/src/domod/builders/cmake/CMakeLists.txt @@ -14,18 +14,22 @@ set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wextra -pedantic -Werror=strict-aliasing" file( GLOB_RECURSE source_files - ../../src/main.cpp + ../../src/timers/Timers.cpp + ../../src/timers/Event.cpp + ../../src/timers/Clock.cpp + ../../src/devices/Devices.cpp + ../../src/devices/Device.cpp + ../../src/devices/LightDevice.cpp + ../../src/devices/ShutterDevice.cpp + ../../src/devices/SprinklerDevice.cpp ../../src/ubus/capabilities.cpp ../../src/ubus/capabilities_lights.cpp ../../src/ubus/capabilities_shutters.cpp ../../src/ubus/capabilities_sprinklers.cpp ../../src/ubus/speach_command.cpp - ../../src/models/Devices.cpp ../../src/helpers/Tokenizer.cpp ../../src/helpers/Strings.cpp - ../../src/timers/Timers.cpp - ../../src/timers/Event.cpp - ../../src/timers/Clock.cpp + ../../src/main.cpp ) add_executable ( diff --git a/src/domod/src/devices/Device.cpp b/src/domod/src/devices/Device.cpp new file mode 100644 index 00000000..361daccf --- /dev/null +++ b/src/domod/src/devices/Device.cpp @@ -0,0 +1,52 @@ +/*! + * Device.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: 20/05/2016 + * + */ + + + +/*------------------------------- INCLUDES ----------------------------------*/ + +#include + +#include "devices/Device.h" + + +/*! ---------------------------------------------------------------------------- + * @fn Device + * + * @brief Constructor of the Device Object. + */ +Device::Device (void) +{ +} + + +/*! ---------------------------------------------------------------------------- + * @fn Device + * + * @brief Destructor of the Device Object. + */ +Device::~Device (void) +{ +} diff --git a/src/domod/src/devices/Device.h b/src/domod/src/devices/Device.h new file mode 100644 index 00000000..bd59d843 --- /dev/null +++ b/src/domod/src/devices/Device.h @@ -0,0 +1,45 @@ +/*! + * Device.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: 20/05/2016 + * + */ + +#ifndef _DEVICE_H +#define _DEVICE_H + +/*------------------------------- INCLUDES ----------------------------------*/ + + +/*---------------------------------- Deps -----------------------------------*/ + + +/*--------------------------------- CLASS ----------------------------------*/ + +class Device { + +public: + Device (void); + virtual ~Device (void); +}; + + +#endif /* _DEVICE_H */ diff --git a/src/domod/src/devices/Devices.cpp b/src/domod/src/devices/Devices.cpp new file mode 100644 index 00000000..9096fdb7 --- /dev/null +++ b/src/domod/src/devices/Devices.cpp @@ -0,0 +1,111 @@ +/*! + * Devices.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: 20/05/2016 + * + */ + +/*------------------------------- INCLUDES ----------------------------------*/ + +#include + +#include "devices/Devices.h" + + +/*! ---------------------------------------------------------------------------- + * @fn Devices + * + * @brief Constructor of the Devices Managagers. + */ +Devices::Devices (std::string aPath): +mFilePath (aPath) +{ +} + + +/*! ---------------------------------------------------------------------------- + * @fn ~Devices + * + * @brief Destructor of the Devices Managagers. + */ +Devices::~Devices (void) +{ +} + + +/*! ---------------------------------------------------------------------------- + * @fn load + * + * @brief Load the Devices from the Json File. + */ +int Devices::load (void) +{ + return 0; +} + + +/* + + "Lights" : { + "speach_name": "lumière", + "data": [ + { + "id": 1, + "name": "Bureau JB", + "speach_name": "bureau", + "zone": "", + "state": true, + "sender": 12797322, + "interruptor": 0 + }, + { + "id": 2, + "name": "Salon", + "speach_name": "salon", + "zone": "", + "state": false, + "sender": 12797322, + "interruptor": 1 + }, + { + "id": 3, + "name": "Sapin", + "speach_name": "sapin", + "zone": "", + "state": false, + "sender": 12797322, + "interruptor": 2 + } + ] + }, + +*/ + + +/*! ---------------------------------------------------------------------------- + * @fn save + * + * @brief Save the Devices from the Json File. + */ +int Devices::save (void) +{ + return 0; +} diff --git a/src/domod/src/devices/Devices.h b/src/domod/src/devices/Devices.h new file mode 100644 index 00000000..0dc8c302 --- /dev/null +++ b/src/domod/src/devices/Devices.h @@ -0,0 +1,58 @@ +/*! + * Devices.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: 20/05/2016 + * + */ + +#ifndef _DEVICES_H +#define _DEVICES_H + +/*------------------------------- INCLUDES ----------------------------------*/ + +#include +#include + +#include "devices/Device.h" + +#include + +/*---------------------------------- Deps -----------------------------------*/ + + +/*--------------------------------- CLASS ----------------------------------*/ + +class Devices { + +public: + Devices (std::string aPath); + ~Devices (void); + + int load (void); + int save (void); + +private: + std::string mFilePath; + std::map mDevices; +}; + + +#endif /* _DEVICES_H */ diff --git a/src/domod/src/devices/LightDevice.cpp b/src/domod/src/devices/LightDevice.cpp new file mode 100644 index 00000000..b893a2fd --- /dev/null +++ b/src/domod/src/devices/LightDevice.cpp @@ -0,0 +1,52 @@ +/*! + * LightDevice.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: 20/05/2016 + * + */ + + + +/*------------------------------- INCLUDES ----------------------------------*/ + +#include + +#include "devices/LightDevice.h" + + +/*! ---------------------------------------------------------------------------- + * @fn LightDevice + * + * @brief Constructor of the LightDevice Object. + */ +LightDevice::LightDevice (void) : Device() +{ +} + + +/*! ---------------------------------------------------------------------------- + * @fn LightDevice + * + * @brief Destructor of the Device Object. + */ +LightDevice::~LightDevice (void) +{ +} diff --git a/src/domod/src/devices/LightDevice.h b/src/domod/src/devices/LightDevice.h new file mode 100644 index 00000000..ff92e114 --- /dev/null +++ b/src/domod/src/devices/LightDevice.h @@ -0,0 +1,46 @@ +/*! + * LightDevice.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: 20/05/2016 + * + */ + +#ifndef _LIGHT_DEVICE_H +#define _LIGHT_DEVICE_H + +/*------------------------------- INCLUDES ----------------------------------*/ + +#include "devices/Device.h" + +/*---------------------------------- Deps -----------------------------------*/ + + +/*--------------------------------- CLASS ----------------------------------*/ + +class LightDevice : public Device { + +public: + LightDevice (void); + ~LightDevice (void); +}; + + +#endif /* _LIGHT_DEVICE_H */ diff --git a/src/domod/src/devices/ShutterDevice.cpp b/src/domod/src/devices/ShutterDevice.cpp new file mode 100644 index 00000000..24baf490 --- /dev/null +++ b/src/domod/src/devices/ShutterDevice.cpp @@ -0,0 +1,52 @@ +/*! + * ShutterDevice.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: 20/05/2016 + * + */ + + + +/*------------------------------- INCLUDES ----------------------------------*/ + +#include + +#include "devices/ShutterDevice.h" + + +/*! ---------------------------------------------------------------------------- + * @fn ShutterDevice + * + * @brief Constructor of the ShutterDevice Object. + */ +ShutterDevice::ShutterDevice (void) : Device() +{ +} + + +/*! ---------------------------------------------------------------------------- + * @fn ShutterDevice + * + * @brief Destructor of the Device Object. + */ +ShutterDevice::~ShutterDevice (void) +{ +} diff --git a/src/domod/src/devices/ShutterDevice.h b/src/domod/src/devices/ShutterDevice.h new file mode 100644 index 00000000..090ac3b7 --- /dev/null +++ b/src/domod/src/devices/ShutterDevice.h @@ -0,0 +1,46 @@ +/*! + * ShutterDevice.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: 20/05/2016 + * + */ + +#ifndef _SHUTTER_DEVICE_H +#define _SHUTTER_DEVICE_H + +/*------------------------------- INCLUDES ----------------------------------*/ + +#include "devices/Device.h" + +/*---------------------------------- Deps -----------------------------------*/ + + +/*--------------------------------- CLASS ----------------------------------*/ + +class ShutterDevice : public Device { + +public: + ShutterDevice (void); + ~ShutterDevice (void); +}; + + +#endif /* _SHUTTER_DEVICE_H */ diff --git a/src/domod/src/devices/SprinklerDevice.cpp b/src/domod/src/devices/SprinklerDevice.cpp new file mode 100644 index 00000000..190888a9 --- /dev/null +++ b/src/domod/src/devices/SprinklerDevice.cpp @@ -0,0 +1,52 @@ +/*! + * SprinklerDevice.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: 20/05/2016 + * + */ + + + +/*------------------------------- INCLUDES ----------------------------------*/ + +#include + +#include "devices/SprinklerDevice.h" + + +/*! ---------------------------------------------------------------------------- + * @fn SprinklerDevice + * + * @brief Constructor of the SprinklerDevice Object. + */ +SprinklerDevice::SprinklerDevice (void) : Device() +{ +} + + +/*! ---------------------------------------------------------------------------- + * @fn ~SprinklerDevice + * + * @brief Destructor of the Device Object. + */ +SprinklerDevice::~SprinklerDevice (void) +{ +} diff --git a/src/domod/src/devices/SprinklerDevice.h b/src/domod/src/devices/SprinklerDevice.h new file mode 100644 index 00000000..c48dde63 --- /dev/null +++ b/src/domod/src/devices/SprinklerDevice.h @@ -0,0 +1,46 @@ +/*! + * SprinklerDevice.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: 20/05/2016 + * + */ + +#ifndef _SPRINKLER_DEVICE_H +#define _SPRINKLER_DEVICE_H + +/*------------------------------- INCLUDES ----------------------------------*/ + +#include "devices/Device.h" + +/*---------------------------------- Deps -----------------------------------*/ + + +/*--------------------------------- CLASS ----------------------------------*/ + +class SprinklerDevice : public Device { + +public: + SprinklerDevice (void); + ~SprinklerDevice (void); +}; + + +#endif /* _SPRINKLER_DEVICE_H */ diff --git a/src/domod/src/main.cpp b/src/domod/src/main.cpp index e85f4b69..b66a4cfe 100644 --- a/src/domod/src/main.cpp +++ b/src/domod/src/main.cpp @@ -39,7 +39,7 @@ extern "C" { #include "ubus/speach_command.h" #include "timers/Timers.h" -#include "models/Devices.h" +#include "devices/Devices.h" /*--------------------------------- GLOBALS ---------------------------------*/ @@ -109,7 +109,7 @@ int main (void) Devices theDevices (theDevicePath); - if (theDevices.Load() != 0) { + if (theDevices.load() != 0) { return -1; } @@ -130,7 +130,7 @@ int main (void) /* Setup the Timers. */ Timers theTimers (theTimerPath, &theDevices); - if (theTimers.Load() != 0) { + if (theTimers.load() != 0) { return -1; } diff --git a/src/domod/src/models/Devices.cpp b/src/domod/src/models/Devices.cpp index 8d6aa7af..cb510eed 100644 --- a/src/domod/src/models/Devices.cpp +++ b/src/domod/src/models/Devices.cpp @@ -23,7 +23,8 @@ * */ - +#error deprecated + /*------------------------------- INCLUDES ----------------------------------*/ #include diff --git a/src/domod/src/models/Devices.h b/src/domod/src/models/Devices.h index 5230568c..8ed2fb56 100644 --- a/src/domod/src/models/Devices.h +++ b/src/domod/src/models/Devices.h @@ -23,6 +23,7 @@ * */ +#error deprecated #ifndef _MODELS_DEVICES_H #define _MODELS_DEVICES_H diff --git a/src/domod/src/timers/Event.cpp b/src/domod/src/timers/Event.cpp index 801c9892..fa6a2f56 100644 --- a/src/domod/src/timers/Event.cpp +++ b/src/domod/src/timers/Event.cpp @@ -57,11 +57,11 @@ Event::~Event (void) /*! ---------------------------------------------------------------------------- - * @fn Load + * @fn load_from_json * * @brief Load Event Object. */ -int Event::Load (Json::Value anElem) +int Event::load_from_json (Json::Value anElem) { std::size_t theSeparator; std::string::size_type sz; // alias of size_t @@ -90,11 +90,11 @@ int Event::Load (Json::Value anElem) /*! ---------------------------------------------------------------------------- - * @fn Save + * @fn to_json * - * @brief Save Event Object. + * @brief Export Event Object as JSON Object. */ -Json::Value Event::Save (void) const +Json::Value Event::to_json (void) const { Json::Value aResult(Json::objectValue); @@ -112,11 +112,11 @@ Json::Value Event::Save (void) const /*! ---------------------------------------------------------------------------- - * @fn Load + * @fn dump * - * @brief Load Event Object. + * @brief dump the Event Object. */ -void Event::Dump (void) +void Event::dump (void) { fprintf (stdout, "Timer Event:\n"); fprintf (stdout, "=========== \n"); diff --git a/src/domod/src/timers/Event.h b/src/domod/src/timers/Event.h index 1543c131..2e01ccba 100644 --- a/src/domod/src/timers/Event.h +++ b/src/domod/src/timers/Event.h @@ -44,10 +44,10 @@ public: Event (void); ~Event (void); - int Load (Json::Value anElem); - Json::Value Save (void) const; + int load_from_json (Json::Value anElem); + Json::Value to_json (void) const; - void Dump (void); + void dump (void); /* Getter */ bool isActive (void) const; diff --git a/src/domod/src/timers/Timers.cpp b/src/domod/src/timers/Timers.cpp index 095187ef..e8d0fc28 100644 --- a/src/domod/src/timers/Timers.cpp +++ b/src/domod/src/timers/Timers.cpp @@ -33,7 +33,7 @@ #include -#include "models/Devices.h" +#include "devices/Devices.h" #include "timers/Timers.h" #include "timers/Clock.h" @@ -65,11 +65,11 @@ Timers::~Timers (void) /*! ---------------------------------------------------------------------------- - * @fn Load + * @fn load * * @brief Load the Timer Managers. */ -int Timers::Load (void) +int Timers::load (void) { Json::Reader theReader; Json::Value theRoot; @@ -86,7 +86,7 @@ int Timers::Load (void) /* Create the Objects.. */ for (Json::Value& theElement : theRoot["timers"]) { Event theEvent; - if (theEvent.Load (theElement) == 0) { + if (theEvent.load_from_json (theElement) == 0) { mTimers.push_back (theEvent); } @@ -99,11 +99,11 @@ int Timers::Load (void) /*! ---------------------------------------------------------------------------- - * @fn Expire + * @fn save * - * @brief Method Call when the Timer has expired. + * @brief Method to save the Timers Object into a Json File. */ -int Timers::Save (void) +int Timers::save (void) { Json::StyledStreamWriter theWriter; std::vector::iterator timer_evt; @@ -111,7 +111,7 @@ int Timers::Save (void) for(timer_evt = mTimers.begin(); timer_evt != mTimers.end(); timer_evt++) { - timers_json.append ((*timer_evt).Save()); + timers_json.append ((*timer_evt).to_json()); } theRoot["timers"] = timers_json; diff --git a/src/domod/src/timers/Timers.h b/src/domod/src/timers/Timers.h index efb8af00..df84d76e 100644 --- a/src/domod/src/timers/Timers.h +++ b/src/domod/src/timers/Timers.h @@ -49,8 +49,8 @@ public: int Expire (void); - int Load (void); - int Save (void); + int load (void); + int save (void); private: Devices *mDevices; diff --git a/src/domod/src/ubus/capabilities_lights.cpp b/src/domod/src/ubus/capabilities_lights.cpp index e5ad3936..012a6c8e 100644 --- a/src/domod/src/ubus/capabilities_lights.cpp +++ b/src/domod/src/ubus/capabilities_lights.cpp @@ -31,7 +31,7 @@ extern "C" { #include -#include "models/Devices.h" +#include "devices/Devices.h" #include "capabilities_lights.h" @@ -84,11 +84,11 @@ int CapabilitiesLights::Get (struct ubus_context *aCtx, struct ubus_request_data struct blob_buf theBuf = {0}; blob_buf_init (&theBuf, 0); - +/* TODO blobmsg_add_json_from_string (&theBuf, mDevices->get("Lights").c_str()); theResult = ubus_send_reply (aCtx, aReq, theBuf.head); - +*/ blob_buf_free (&theBuf); return theResult; @@ -149,7 +149,7 @@ int CapabilitiesLights::Post (struct ubus_context *aCtx, struct ubus_request_dat theID = theRoot["id"].asInt(); theState = theRoot["state"].asBool(); - +/* TODO theElement = mDevices->get("Lights", theID); theElement["state"] = theState; @@ -157,7 +157,7 @@ int CapabilitiesLights::Post (struct ubus_context *aCtx, struct ubus_request_dat mDevices->set("Lights", theID, theElement); } - +*/ theOutput["Lights"] = theElement; blob_buf_init (&theBuf, 0); diff --git a/src/domod/src/ubus/capabilities_shutters.cpp b/src/domod/src/ubus/capabilities_shutters.cpp index 4e8a5c3c..c3b35b61 100644 --- a/src/domod/src/ubus/capabilities_shutters.cpp +++ b/src/domod/src/ubus/capabilities_shutters.cpp @@ -29,7 +29,7 @@ extern "C" { #include } -#include "models/Devices.h" +#include "devices/Devices.h" #include "capabilities_shutters.h" @@ -90,9 +90,9 @@ int CapabilitiesShutters::Get (struct ubus_context *aCtx, struct ubus_request_da struct blob_buf theBuf = {0}; blob_buf_init (&theBuf, 0); - + /* TODO blobmsg_add_json_from_string (&theBuf, mDevices->get("Shutters").c_str()); - + */ theResult = ubus_send_reply (aCtx, aReq, theBuf.head); blob_buf_free (&theBuf); diff --git a/src/domod/src/ubus/capabilities_sprinklers.cpp b/src/domod/src/ubus/capabilities_sprinklers.cpp index 65b74a5e..357cc8b5 100644 --- a/src/domod/src/ubus/capabilities_sprinklers.cpp +++ b/src/domod/src/ubus/capabilities_sprinklers.cpp @@ -31,7 +31,7 @@ extern "C" { #include -#include "models/Devices.h" +#include "devices/Devices.h" #include "capabilities_sprinklers.h" @@ -84,9 +84,9 @@ int CapabilitiesSprinklers::Get (struct ubus_context *aCtx, struct ubus_request_ struct blob_buf theBuf = {0}; blob_buf_init (&theBuf, 0); - +/*TODO blobmsg_add_json_from_string (&theBuf, mDevices->get("Sprinklers").c_str()); - +*/ theResult = ubus_send_reply (aCtx, aReq, theBuf.head); blob_buf_free (&theBuf); @@ -149,7 +149,7 @@ int CapabilitiesSprinklers::Post (struct ubus_context *aCtx, struct ubus_request theID = theRoot["id"].asInt(); theState = theRoot["state"].asBool(); - +/* theElement = mDevices->get("Sprinklers", theID); theElement["state"] = theState; @@ -157,7 +157,7 @@ int CapabilitiesSprinklers::Post (struct ubus_context *aCtx, struct ubus_request mDevices->set ("Sprinklers", theID, theElement); } - +*/ theOutput["Sprinklers"] = theElement; blob_buf_init (&theBuf, 0); diff --git a/src/domod/src/ubus/speach_command.cpp b/src/domod/src/ubus/speach_command.cpp index ad85b56d..003bdd28 100644 --- a/src/domod/src/ubus/speach_command.cpp +++ b/src/domod/src/ubus/speach_command.cpp @@ -33,7 +33,7 @@ extern "C" { #include -#include "models/Devices.h" +#include "devices/Devices.h" #include "helpers/Tokenizer.h" #include "helpers/Strings.h" @@ -155,6 +155,7 @@ int SpeachCommand::AnalyseAndExecute (std::string aCommand) return -1; } } +/* TODO else if (theSM == 1) { theCapability = s.GetToken(); @@ -174,6 +175,7 @@ int SpeachCommand::AnalyseAndExecute (std::string aCommand) return -3; } } +*/ theSM++; }