WIP...
This commit is contained in:
@@ -50,3 +50,27 @@ Device::Device (void)
|
|||||||
Device::~Device (void)
|
Device::~Device (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! ----------------------------------------------------------------------------
|
||||||
|
* @fn load_from_json
|
||||||
|
*
|
||||||
|
* @brief Load LightDevice Object From a Json Object.
|
||||||
|
*/
|
||||||
|
int Device::load_from_json (Json::Value anElem)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! ----------------------------------------------------------------------------
|
||||||
|
* @fn to_json
|
||||||
|
*
|
||||||
|
* @brief Export LightDevice Object as JSON Object.
|
||||||
|
*/
|
||||||
|
Json::Value Device::to_json (void) const
|
||||||
|
{
|
||||||
|
Json::Value theResult;
|
||||||
|
|
||||||
|
return theResult;
|
||||||
|
}
|
||||||
|
|||||||
@@ -28,7 +28,8 @@
|
|||||||
|
|
||||||
/*------------------------------- INCLUDES ----------------------------------*/
|
/*------------------------------- INCLUDES ----------------------------------*/
|
||||||
|
|
||||||
|
#include <jsoncpp/json.h>
|
||||||
|
|
||||||
/*---------------------------------- Deps -----------------------------------*/
|
/*---------------------------------- Deps -----------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
@@ -39,6 +40,9 @@ class Device {
|
|||||||
public:
|
public:
|
||||||
Device (void);
|
Device (void);
|
||||||
virtual ~Device (void);
|
virtual ~Device (void);
|
||||||
|
|
||||||
|
virtual int load_from_json (Json::Value anElem);
|
||||||
|
virtual Json::Value to_json (void) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,10 @@
|
|||||||
|
|
||||||
#include <jsoncpp/json.h>
|
#include <jsoncpp/json.h>
|
||||||
|
|
||||||
|
#include "devices/LightDevice.h"
|
||||||
|
#include "devices/ShutterDevice.h"
|
||||||
|
#include "devices/SprinklerDevice.h"
|
||||||
|
|
||||||
#include "devices/Devices.h"
|
#include "devices/Devices.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -64,7 +68,7 @@ int Devices::load (void)
|
|||||||
Json::Reader theReader;
|
Json::Reader theReader;
|
||||||
Json::Value theRoot;
|
Json::Value theRoot;
|
||||||
std::ifstream theDevicesFile (mFilePath.c_str());
|
std::ifstream theDevicesFile (mFilePath.c_str());
|
||||||
|
fprintf (stderr, "Devices::load...\n");
|
||||||
/* Load and Parse the Json File. */
|
/* Load and Parse the Json File. */
|
||||||
if (!theReader.parse (theDevicesFile, theRoot)) {
|
if (!theReader.parse (theDevicesFile, theRoot)) {
|
||||||
|
|
||||||
@@ -72,7 +76,22 @@ int Devices::load (void)
|
|||||||
mFilePath.c_str());
|
mFilePath.c_str());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
//TODO
|
|
||||||
|
/* Open Lights. */
|
||||||
|
LightDevice theLights;
|
||||||
|
theLights.load_from_json (theRoot["Lights"]);
|
||||||
|
mDevices["Lights"] = theLights;
|
||||||
|
|
||||||
|
/* Open Shutters. */
|
||||||
|
ShutterDevice theShutters;
|
||||||
|
theShutters.load_from_json (theRoot["Shutters"]);
|
||||||
|
mDevices["Shutters"] = theShutters;
|
||||||
|
|
||||||
|
/* Open Sprinklers. */
|
||||||
|
SprinklerDevice theSprinklers;
|
||||||
|
theSprinklers.load_from_json (theRoot["Sprinklers"]);
|
||||||
|
mDevices["Sprinklers"] = theSprinklers;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,3 +50,53 @@ LightDevice::LightDevice (void) : Device()
|
|||||||
LightDevice::~LightDevice (void)
|
LightDevice::~LightDevice (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! ----------------------------------------------------------------------------
|
||||||
|
* @fn load_from_json
|
||||||
|
*
|
||||||
|
* @brief Load LightDevice Object From a Json Object.
|
||||||
|
*/
|
||||||
|
int LightDevice::load_from_json (Json::Value anElem)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "LightDevice::load_from_json\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! ----------------------------------------------------------------------------
|
||||||
|
* @fn to_json
|
||||||
|
*
|
||||||
|
* @brief Export LightDevice Object as JSON Object.
|
||||||
|
*/
|
||||||
|
Json::Value LightDevice::to_json (void) const
|
||||||
|
{
|
||||||
|
fprintf (stderr, "LightDevice::to_json\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
int Timers::load (void)
|
||||||
|
{
|
||||||
|
Json::Reader theReader;
|
||||||
|
Json::Value theRoot;
|
||||||
|
std::ifstream theTimerFile (mTimersPath.c_str());
|
||||||
|
|
||||||
|
if (!theReader.parse (theTimerFile, theRoot)) {
|
||||||
|
|
||||||
|
fprintf (stderr, "Failed to parse the Timers File (%s).\n",
|
||||||
|
mTimersPath.c_str());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Json::Value& theElement : theRoot["timers"]) {
|
||||||
|
Event theEvent;
|
||||||
|
if (theEvent.load_from_json (theElement) == 0) {
|
||||||
|
|
||||||
|
mTimers.push_back (theEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Start (k60s, true);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}*/
|
||||||
|
|||||||
@@ -44,7 +44,10 @@ class LightDevice : public Device {
|
|||||||
public:
|
public:
|
||||||
LightDevice (void);
|
LightDevice (void);
|
||||||
~LightDevice (void);
|
~LightDevice (void);
|
||||||
|
|
||||||
|
int load_from_json (Json::Value anElem);
|
||||||
|
Json::Value to_json (void) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string mspeach_name;
|
std::string mspeach_name;
|
||||||
std::vector <Light> mLights;
|
std::vector <Light> mLights;
|
||||||
|
|||||||
Reference in New Issue
Block a user