Add Skeleton for the Devices Tree :)
This commit is contained in:
@@ -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 (
|
||||
|
||||
52
src/domod/src/devices/Device.cpp
Normal file
52
src/domod/src/devices/Device.cpp
Normal file
@@ -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 <cstdio>
|
||||
|
||||
#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)
|
||||
{
|
||||
}
|
||||
45
src/domod/src/devices/Device.h
Normal file
45
src/domod/src/devices/Device.h
Normal file
@@ -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 */
|
||||
111
src/domod/src/devices/Devices.cpp
Normal file
111
src/domod/src/devices/Devices.cpp
Normal file
@@ -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 <cstdio>
|
||||
|
||||
#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;
|
||||
}
|
||||
58
src/domod/src/devices/Devices.h
Normal file
58
src/domod/src/devices/Devices.h
Normal file
@@ -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 <string>
|
||||
#include <map>
|
||||
|
||||
#include "devices/Device.h"
|
||||
|
||||
#include <jsoncpp/json.h>
|
||||
|
||||
/*---------------------------------- Deps -----------------------------------*/
|
||||
|
||||
|
||||
/*--------------------------------- CLASS ----------------------------------*/
|
||||
|
||||
class Devices {
|
||||
|
||||
public:
|
||||
Devices (std::string aPath);
|
||||
~Devices (void);
|
||||
|
||||
int load (void);
|
||||
int save (void);
|
||||
|
||||
private:
|
||||
std::string mFilePath;
|
||||
std::map<std::string, Device> mDevices;
|
||||
};
|
||||
|
||||
|
||||
#endif /* _DEVICES_H */
|
||||
52
src/domod/src/devices/LightDevice.cpp
Normal file
52
src/domod/src/devices/LightDevice.cpp
Normal file
@@ -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 <cstdio>
|
||||
|
||||
#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)
|
||||
{
|
||||
}
|
||||
46
src/domod/src/devices/LightDevice.h
Normal file
46
src/domod/src/devices/LightDevice.h
Normal file
@@ -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 */
|
||||
52
src/domod/src/devices/ShutterDevice.cpp
Normal file
52
src/domod/src/devices/ShutterDevice.cpp
Normal file
@@ -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 <cstdio>
|
||||
|
||||
#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)
|
||||
{
|
||||
}
|
||||
46
src/domod/src/devices/ShutterDevice.h
Normal file
46
src/domod/src/devices/ShutterDevice.h
Normal file
@@ -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 */
|
||||
52
src/domod/src/devices/SprinklerDevice.cpp
Normal file
52
src/domod/src/devices/SprinklerDevice.cpp
Normal file
@@ -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 <cstdio>
|
||||
|
||||
#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)
|
||||
{
|
||||
}
|
||||
46
src/domod/src/devices/SprinklerDevice.h
Normal file
46
src/domod/src/devices/SprinklerDevice.h
Normal file
@@ -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 */
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#error deprecated
|
||||
|
||||
/*------------------------------- INCLUDES ----------------------------------*/
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#error deprecated
|
||||
|
||||
#ifndef _MODELS_DEVICES_H
|
||||
#define _MODELS_DEVICES_H
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <vector>
|
||||
|
||||
|
||||
#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<Event>::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;
|
||||
|
||||
@@ -49,8 +49,8 @@ public:
|
||||
|
||||
int Expire (void);
|
||||
|
||||
int Load (void);
|
||||
int Save (void);
|
||||
int load (void);
|
||||
int save (void);
|
||||
|
||||
private:
|
||||
Devices *mDevices;
|
||||
|
||||
@@ -31,7 +31,7 @@ extern "C" {
|
||||
|
||||
#include <ubuscpp/UBusCall.h>
|
||||
|
||||
#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);
|
||||
|
||||
@@ -29,7 +29,7 @@ extern "C" {
|
||||
#include <libubox/blobmsg_json.h>
|
||||
}
|
||||
|
||||
#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);
|
||||
|
||||
@@ -31,7 +31,7 @@ extern "C" {
|
||||
|
||||
#include <ubuscpp/UBusCall.h>
|
||||
|
||||
#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);
|
||||
|
||||
@@ -33,7 +33,7 @@ extern "C" {
|
||||
|
||||
#include <ubuscpp/UBusCall.h>
|
||||
|
||||
#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++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user