From e4f6a1c0dd06e3cbceb45f8e8ee86f3a02c1e4ba Mon Sep 17 00:00:00 2001 From: Tom Schmidt Date: Fri, 2 Sep 2016 18:53:15 +0200 Subject: [PATCH 1/3] gen --- .../src/domain/valoplus/adressableRgbLed.h | 25 --------- .../valoplus/adressableRgbLedJsonService.h | 48 ----------------- firmware/src/domain/valoplus/channelElement.h | 12 ----- .../src/domain/valoplus/controllableElement.h | 14 ----- firmware/src/domain/valoplus/device.h | 25 --------- firmware/src/domain/valoplus/group.h | 19 ------- .../src/domain/valoplus/groupJsonService.h | 44 --------------- firmware/src/domain/valoplus/master.h | 35 ------------ .../src/domain/valoplus/masterJsonService.h | 54 ------------------- firmware/src/domain/valoplus/rgbLed.h | 24 --------- .../src/domain/valoplus/rgbLedJsonService.h | 48 ----------------- firmware/src/domain/valoplus/singleColorLed.h | 18 ------- .../valoplus/singleColorLedJsonService.h | 44 --------------- firmware/src/domain/valoplus/slave.h | 32 ----------- .../src/domain/valoplus/slaveJsonService.h | 52 ------------------ firmware/src/domain/valoplus/state.h | 13 ----- .../domain/valoplus/stateAdressableRgbLed.h | 17 ------ .../stateAdressableRgbLedJsonService.h | 44 --------------- 18 files changed, 568 deletions(-) delete mode 100644 firmware/src/domain/valoplus/adressableRgbLed.h delete mode 100644 firmware/src/domain/valoplus/adressableRgbLedJsonService.h delete mode 100644 firmware/src/domain/valoplus/channelElement.h delete mode 100644 firmware/src/domain/valoplus/controllableElement.h delete mode 100644 firmware/src/domain/valoplus/device.h delete mode 100644 firmware/src/domain/valoplus/group.h delete mode 100644 firmware/src/domain/valoplus/groupJsonService.h delete mode 100644 firmware/src/domain/valoplus/master.h delete mode 100644 firmware/src/domain/valoplus/masterJsonService.h delete mode 100644 firmware/src/domain/valoplus/rgbLed.h delete mode 100644 firmware/src/domain/valoplus/rgbLedJsonService.h delete mode 100644 firmware/src/domain/valoplus/singleColorLed.h delete mode 100644 firmware/src/domain/valoplus/singleColorLedJsonService.h delete mode 100644 firmware/src/domain/valoplus/slave.h delete mode 100644 firmware/src/domain/valoplus/slaveJsonService.h delete mode 100644 firmware/src/domain/valoplus/state.h delete mode 100644 firmware/src/domain/valoplus/stateAdressableRgbLed.h delete mode 100644 firmware/src/domain/valoplus/stateAdressableRgbLedJsonService.h diff --git a/firmware/src/domain/valoplus/adressableRgbLed.h b/firmware/src/domain/valoplus/adressableRgbLed.h deleted file mode 100644 index 1826790..0000000 --- a/firmware/src/domain/valoplus/adressableRgbLed.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef TEST_ADRESSABLERGBLED_H -#define TEST_ADRESSABLERGBLED_H - -#include -#include -#include - -class AdressableRgbLed : ChannelElement { - private: - std::string name; - StateAdressableRgbLed stateAdressableRgbLed; - int channelId; - int ledCount; - public: - std::string getName() { return this->name; } - StateAdressableRgbLed getStateAdressableRgbLed() { return this->stateAdressableRgbLed; } - int getChannelId() { return this->channelId; } - int getLedCount() { return this->ledCount; } - void setName(std::string name) { this->name = name; } - void setStateAdressableRgbLed(StateAdressableRgbLed stateAdressableRgbLed) { this->stateAdressableRgbLed = stateAdressableRgbLed; } - void setChannelId(int channelId) { this->channelId = channelId; } - void setLedCount(int ledCount) { this->ledCount = ledCount; } -}; - -#endif //TEST_ADRESSABLERGBLED_H diff --git a/firmware/src/domain/valoplus/adressableRgbLedJsonService.h b/firmware/src/domain/valoplus/adressableRgbLedJsonService.h deleted file mode 100644 index 182562f..0000000 --- a/firmware/src/domain/valoplus/adressableRgbLedJsonService.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef TEST_ADRESSABLERGBLEDJSONSERVICE_H -#define TEST_ADRESSABLERGBLEDJSONSERVICE_H - -#include -#include -#include - -class AdressableRgbLedJsonService { -private: - -public: - char* toJson(AdressableRgbLed obj) { - StaticJsonBuffer<200> jsonBuffer; - JsonObject& root = jsonBuffer.createObject(); - - root("name", obj.getName()); - root("stateAdressableRgbLed", obj.getStateAdressableRgbLed()); - root("channelId", obj.getChannelId()); - root("ledCount", obj.getLedCount()); - - JsonObject& links = root.createNestedObject("_links"); - - JsonObject& self1 = links.createNestedObject("self"); - self1.set("href", "/adressableRgbLeds/" + obj.getId()); - JsonObject& self2 = links.createNestedObject("adressableRgbLed"); - self2.set("href", "/adressableRgbLeds/" + obj.getId()); - - char buffer[root.measureLength()]; - root.printTo(buffer, sizeof(buffer)); - return buffer; - } - - AdressableRgbLed fromJson(String json) { - StaticJsonBuffer<200> jsonBuffer; - JsonObject& root = jsonBuffer.parseObject(json); - - AdressableRgbLed result = AdressableRgbLed(); - - result.setName(root("name")); - result.setStateAdressableRgbLed(root("stateAdressableRgbLed")); - result.setChannelId(root("channelId")); - result.setLedCount(root("ledCount")); - - return result; - } -}; - -#endif //TEST_ADRESSABLERGBLEDJSONSERVICE_H diff --git a/firmware/src/domain/valoplus/channelElement.h b/firmware/src/domain/valoplus/channelElement.h deleted file mode 100644 index 6236ace..0000000 --- a/firmware/src/domain/valoplus/channelElement.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef TEST_CHANNELELEMENT_H -#define TEST_CHANNELELEMENT_H - -#include - -class ChannelElement : ControllableElement { - private: - - public: -}; - -#endif //TEST_CHANNELELEMENT_H diff --git a/firmware/src/domain/valoplus/controllableElement.h b/firmware/src/domain/valoplus/controllableElement.h deleted file mode 100644 index 8f8b45c..0000000 --- a/firmware/src/domain/valoplus/controllableElement.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef TEST_CONTROLLABLEELEMENT_H -#define TEST_CONTROLLABLEELEMENT_H - -#include - -class ControllableElement { - private: - - public: - virtual std::string getName()= 0; - virtual void setName(std::string name)= 0; -}; - -#endif //TEST_CONTROLLABLEELEMENT_H diff --git a/firmware/src/domain/valoplus/device.h b/firmware/src/domain/valoplus/device.h deleted file mode 100644 index bdd9ca8..0000000 --- a/firmware/src/domain/valoplus/device.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef TEST_DEVICE_H -#define TEST_DEVICE_H - -#include -#include -#include -#include - -class Device : ControllableElement { - private: - - public: - virtual std::string getIp()= 0; - virtual std::string getKey()= 0; - virtual int getMaxChannel()= 0; - virtual bool getIsConfigured()= 0; - virtual std::vector getElements()= 0; - virtual void setIp(std::string ip)= 0; - virtual void setKey(std::string key)= 0; - virtual void setMaxChannel(int maxChannel)= 0; - virtual void setIsConfigured(bool isConfigured)= 0; - virtual void setElements(std::vector elements)= 0; -}; - -#endif //TEST_DEVICE_H diff --git a/firmware/src/domain/valoplus/group.h b/firmware/src/domain/valoplus/group.h deleted file mode 100644 index 4dc97f2..0000000 --- a/firmware/src/domain/valoplus/group.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef TEST_GROUP_H -#define TEST_GROUP_H - -#include -#include -#include - -class Group : ControllableElement { - private: - std::string name; - std::vector members; - public: - std::string getName() { return this->name; } - std::vector getMembers() { return this->members; } - void setName(std::string name) { this->name = name; } - void setMembers(std::vector members) { this->members = members; } -}; - -#endif //TEST_GROUP_H diff --git a/firmware/src/domain/valoplus/groupJsonService.h b/firmware/src/domain/valoplus/groupJsonService.h deleted file mode 100644 index c2327d2..0000000 --- a/firmware/src/domain/valoplus/groupJsonService.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef TEST_GROUPJSONSERVICE_H -#define TEST_GROUPJSONSERVICE_H - -#include -#include -#include - -class GroupJsonService { -private: - -public: - char* toJson(Group obj) { - StaticJsonBuffer<200> jsonBuffer; - JsonObject& root = jsonBuffer.createObject(); - - root("name", obj.getName()); - root("members", obj.getMembers()); - - JsonObject& links = root.createNestedObject("_links"); - - JsonObject& self1 = links.createNestedObject("self"); - self1.set("href", "/groups/" + obj.getId()); - JsonObject& self2 = links.createNestedObject("group"); - self2.set("href", "/groups/" + obj.getId()); - - char buffer[root.measureLength()]; - root.printTo(buffer, sizeof(buffer)); - return buffer; - } - - Group fromJson(String json) { - StaticJsonBuffer<200> jsonBuffer; - JsonObject& root = jsonBuffer.parseObject(json); - - Group result = Group(); - - result.setName(root("name")); - result.setMembers(root("members")); - - return result; - } -}; - -#endif //TEST_GROUPJSONSERVICE_H diff --git a/firmware/src/domain/valoplus/master.h b/firmware/src/domain/valoplus/master.h deleted file mode 100644 index d58be17..0000000 --- a/firmware/src/domain/valoplus/master.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef TEST_MASTER_H -#define TEST_MASTER_H - -#include -#include -#include -#include - -class Master : Device { - private: - std::string name; - std::string ip; - std::string key; - int maxChannel; - bool isConfigured; - std::vector elements; - std::string password; - public: - std::string getName() { return this->name; } - std::string getIp() { return this->ip; } - std::string getKey() { return this->key; } - int getMaxChannel() { return this->maxChannel; } - bool getIsConfigured() { return this->isConfigured; } - std::vector getElements() { return this->elements; } - std::string getPassword() { return this->password; } - void setName(std::string name) { this->name = name; } - void setIp(std::string ip) { this->ip = ip; } - void setKey(std::string key) { this->key = key; } - void setMaxChannel(int maxChannel) { this->maxChannel = maxChannel; } - void setIsConfigured(bool isConfigured) { this->isConfigured = isConfigured; } - void setElements(std::vector elements) { this->elements = elements; } - void setPassword(std::string password) { this->password = password; } -}; - -#endif //TEST_MASTER_H diff --git a/firmware/src/domain/valoplus/masterJsonService.h b/firmware/src/domain/valoplus/masterJsonService.h deleted file mode 100644 index 4b9072f..0000000 --- a/firmware/src/domain/valoplus/masterJsonService.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef TEST_MASTERJSONSERVICE_H -#define TEST_MASTERJSONSERVICE_H - -#include -#include -#include - -class MasterJsonService { -private: - -public: - char* toJson(Master obj) { - StaticJsonBuffer<200> jsonBuffer; - JsonObject& root = jsonBuffer.createObject(); - - root("name", obj.getName()); - root("ip", obj.getIp()); - root("key", obj.getKey()); - root("maxChannel", obj.getMaxChannel()); - root("isConfigured", obj.getIsConfigured()); - root("elements", obj.getElements()); - root("password", obj.getPassword()); - - JsonObject& links = root.createNestedObject("_links"); - - JsonObject& self1 = links.createNestedObject("self"); - self1.set("href", "/masters/" + obj.getId()); - JsonObject& self2 = links.createNestedObject("master"); - self2.set("href", "/masters/" + obj.getId()); - - char buffer[root.measureLength()]; - root.printTo(buffer, sizeof(buffer)); - return buffer; - } - - Master fromJson(String json) { - StaticJsonBuffer<200> jsonBuffer; - JsonObject& root = jsonBuffer.parseObject(json); - - Master result = Master(); - - result.setName(root("name")); - result.setIp(root("ip")); - result.setKey(root("key")); - result.setMaxChannel(root("maxChannel")); - result.setIsConfigured(root("isConfigured")); - result.setElements(root("elements")); - result.setPassword(root("password")); - - return result; - } -}; - -#endif //TEST_MASTERJSONSERVICE_H diff --git a/firmware/src/domain/valoplus/rgbLed.h b/firmware/src/domain/valoplus/rgbLed.h deleted file mode 100644 index 32f4894..0000000 --- a/firmware/src/domain/valoplus/rgbLed.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef TEST_RGBLED_H -#define TEST_RGBLED_H - -#include -#include - -class RgbLed : ChannelElement { - private: - std::string name; - int channelIdRed; - int channelIdGreen; - int channelIdBlue; - public: - std::string getName() { return this->name; } - int getChannelIdRed() { return this->channelIdRed; } - int getChannelIdGreen() { return this->channelIdGreen; } - int getChannelIdBlue() { return this->channelIdBlue; } - void setName(std::string name) { this->name = name; } - void setChannelIdRed(int channelIdRed) { this->channelIdRed = channelIdRed; } - void setChannelIdGreen(int channelIdGreen) { this->channelIdGreen = channelIdGreen; } - void setChannelIdBlue(int channelIdBlue) { this->channelIdBlue = channelIdBlue; } -}; - -#endif //TEST_RGBLED_H diff --git a/firmware/src/domain/valoplus/rgbLedJsonService.h b/firmware/src/domain/valoplus/rgbLedJsonService.h deleted file mode 100644 index 64f08bc..0000000 --- a/firmware/src/domain/valoplus/rgbLedJsonService.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef TEST_RGBLEDJSONSERVICE_H -#define TEST_RGBLEDJSONSERVICE_H - -#include -#include -#include - -class RgbLedJsonService { -private: - -public: - char* toJson(RgbLed obj) { - StaticJsonBuffer<200> jsonBuffer; - JsonObject& root = jsonBuffer.createObject(); - - root("name", obj.getName()); - root("channelIdRed", obj.getChannelIdRed()); - root("channelIdGreen", obj.getChannelIdGreen()); - root("channelIdBlue", obj.getChannelIdBlue()); - - JsonObject& links = root.createNestedObject("_links"); - - JsonObject& self1 = links.createNestedObject("self"); - self1.set("href", "/rgbLeds/" + obj.getId()); - JsonObject& self2 = links.createNestedObject("rgbLed"); - self2.set("href", "/rgbLeds/" + obj.getId()); - - char buffer[root.measureLength()]; - root.printTo(buffer, sizeof(buffer)); - return buffer; - } - - RgbLed fromJson(String json) { - StaticJsonBuffer<200> jsonBuffer; - JsonObject& root = jsonBuffer.parseObject(json); - - RgbLed result = RgbLed(); - - result.setName(root("name")); - result.setChannelIdRed(root("channelIdRed")); - result.setChannelIdGreen(root("channelIdGreen")); - result.setChannelIdBlue(root("channelIdBlue")); - - return result; - } -}; - -#endif //TEST_RGBLEDJSONSERVICE_H diff --git a/firmware/src/domain/valoplus/singleColorLed.h b/firmware/src/domain/valoplus/singleColorLed.h deleted file mode 100644 index d32ef6a..0000000 --- a/firmware/src/domain/valoplus/singleColorLed.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef TEST_SINGLECOLORLED_H -#define TEST_SINGLECOLORLED_H - -#include -#include - -class SingleColorLed : ChannelElement { - private: - std::string name; - int channelId; - public: - std::string getName() { return this->name; } - int getChannelId() { return this->channelId; } - void setName(std::string name) { this->name = name; } - void setChannelId(int channelId) { this->channelId = channelId; } -}; - -#endif //TEST_SINGLECOLORLED_H diff --git a/firmware/src/domain/valoplus/singleColorLedJsonService.h b/firmware/src/domain/valoplus/singleColorLedJsonService.h deleted file mode 100644 index 341f093..0000000 --- a/firmware/src/domain/valoplus/singleColorLedJsonService.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef TEST_SINGLECOLORLEDJSONSERVICE_H -#define TEST_SINGLECOLORLEDJSONSERVICE_H - -#include -#include -#include - -class SingleColorLedJsonService { -private: - -public: - char* toJson(SingleColorLed obj) { - StaticJsonBuffer<200> jsonBuffer; - JsonObject& root = jsonBuffer.createObject(); - - root("name", obj.getName()); - root("channelId", obj.getChannelId()); - - JsonObject& links = root.createNestedObject("_links"); - - JsonObject& self1 = links.createNestedObject("self"); - self1.set("href", "/singleColorLeds/" + obj.getId()); - JsonObject& self2 = links.createNestedObject("singleColorLed"); - self2.set("href", "/singleColorLeds/" + obj.getId()); - - char buffer[root.measureLength()]; - root.printTo(buffer, sizeof(buffer)); - return buffer; - } - - SingleColorLed fromJson(String json) { - StaticJsonBuffer<200> jsonBuffer; - JsonObject& root = jsonBuffer.parseObject(json); - - SingleColorLed result = SingleColorLed(); - - result.setName(root("name")); - result.setChannelId(root("channelId")); - - return result; - } -}; - -#endif //TEST_SINGLECOLORLEDJSONSERVICE_H diff --git a/firmware/src/domain/valoplus/slave.h b/firmware/src/domain/valoplus/slave.h deleted file mode 100644 index 7caf60f..0000000 --- a/firmware/src/domain/valoplus/slave.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef TEST_SLAVE_H -#define TEST_SLAVE_H - -#include -#include -#include -#include - -class Slave : Device { - private: - std::string name; - std::string ip; - std::string key; - int maxChannel; - bool isConfigured; - std::vector elements; - public: - std::string getName() { return this->name; } - std::string getIp() { return this->ip; } - std::string getKey() { return this->key; } - int getMaxChannel() { return this->maxChannel; } - bool getIsConfigured() { return this->isConfigured; } - std::vector getElements() { return this->elements; } - void setName(std::string name) { this->name = name; } - void setIp(std::string ip) { this->ip = ip; } - void setKey(std::string key) { this->key = key; } - void setMaxChannel(int maxChannel) { this->maxChannel = maxChannel; } - void setIsConfigured(bool isConfigured) { this->isConfigured = isConfigured; } - void setElements(std::vector elements) { this->elements = elements; } -}; - -#endif //TEST_SLAVE_H diff --git a/firmware/src/domain/valoplus/slaveJsonService.h b/firmware/src/domain/valoplus/slaveJsonService.h deleted file mode 100644 index e4caebe..0000000 --- a/firmware/src/domain/valoplus/slaveJsonService.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef TEST_SLAVEJSONSERVICE_H -#define TEST_SLAVEJSONSERVICE_H - -#include -#include -#include - -class SlaveJsonService { -private: - -public: - char* toJson(Slave obj) { - StaticJsonBuffer<200> jsonBuffer; - JsonObject& root = jsonBuffer.createObject(); - - root("name", obj.getName()); - root("ip", obj.getIp()); - root("key", obj.getKey()); - root("maxChannel", obj.getMaxChannel()); - root("isConfigured", obj.getIsConfigured()); - root("elements", obj.getElements()); - - JsonObject& links = root.createNestedObject("_links"); - - JsonObject& self1 = links.createNestedObject("self"); - self1.set("href", "/slaves/" + obj.getId()); - JsonObject& self2 = links.createNestedObject("slave"); - self2.set("href", "/slaves/" + obj.getId()); - - char buffer[root.measureLength()]; - root.printTo(buffer, sizeof(buffer)); - return buffer; - } - - Slave fromJson(String json) { - StaticJsonBuffer<200> jsonBuffer; - JsonObject& root = jsonBuffer.parseObject(json); - - Slave result = Slave(); - - result.setName(root("name")); - result.setIp(root("ip")); - result.setKey(root("key")); - result.setMaxChannel(root("maxChannel")); - result.setIsConfigured(root("isConfigured")); - result.setElements(root("elements")); - - return result; - } -}; - -#endif //TEST_SLAVEJSONSERVICE_H diff --git a/firmware/src/domain/valoplus/state.h b/firmware/src/domain/valoplus/state.h deleted file mode 100644 index 7658d4b..0000000 --- a/firmware/src/domain/valoplus/state.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef TEST_STATE_H -#define TEST_STATE_H - - -class State { - private: - - public: - virtual bool getActive()= 0; - virtual void setActive(bool active)= 0; -}; - -#endif //TEST_STATE_H diff --git a/firmware/src/domain/valoplus/stateAdressableRgbLed.h b/firmware/src/domain/valoplus/stateAdressableRgbLed.h deleted file mode 100644 index 4e62553..0000000 --- a/firmware/src/domain/valoplus/stateAdressableRgbLed.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef TEST_STATEADRESSABLERGBLED_H -#define TEST_STATEADRESSABLERGBLED_H - -#include - -class StateAdressableRgbLed : State { - private: - bool active; - int brightness; - public: - bool getActive() { return this->active; } - int getBrightness() { return this->brightness; } - void setActive(bool active) { this->active = active; } - void setBrightness(int brightness) { this->brightness = brightness; } -}; - -#endif //TEST_STATEADRESSABLERGBLED_H diff --git a/firmware/src/domain/valoplus/stateAdressableRgbLedJsonService.h b/firmware/src/domain/valoplus/stateAdressableRgbLedJsonService.h deleted file mode 100644 index b98ee9a..0000000 --- a/firmware/src/domain/valoplus/stateAdressableRgbLedJsonService.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef TEST_STATEADRESSABLERGBLEDJSONSERVICE_H -#define TEST_STATEADRESSABLERGBLEDJSONSERVICE_H - -#include -#include -#include - -class StateAdressableRgbLedJsonService { -private: - -public: - char* toJson(StateAdressableRgbLed obj) { - StaticJsonBuffer<200> jsonBuffer; - JsonObject& root = jsonBuffer.createObject(); - - root("active", obj.getActive()); - root("brightness", obj.getBrightness()); - - JsonObject& links = root.createNestedObject("_links"); - - JsonObject& self1 = links.createNestedObject("self"); - self1.set("href", "/stateAdressableRgbLeds/" + obj.getId()); - JsonObject& self2 = links.createNestedObject("stateAdressableRgbLed"); - self2.set("href", "/stateAdressableRgbLeds/" + obj.getId()); - - char buffer[root.measureLength()]; - root.printTo(buffer, sizeof(buffer)); - return buffer; - } - - StateAdressableRgbLed fromJson(String json) { - StaticJsonBuffer<200> jsonBuffer; - JsonObject& root = jsonBuffer.parseObject(json); - - StateAdressableRgbLed result = StateAdressableRgbLed(); - - result.setActive(root("active")); - result.setBrightness(root("brightness")); - - return result; - } -}; - -#endif //TEST_STATEADRESSABLERGBLEDJSONSERVICE_H From 092b056006fa296c1161e9d62aa962ba388e8705 Mon Sep 17 00:00:00 2001 From: Tom Schmidt Date: Fri, 2 Sep 2016 18:53:53 +0200 Subject: [PATCH 2/3] gen --- .../src/domain/valoplus/AdressableRgbLed.h | 25 +++++++++ .../valoplus/AdressableRgbLedJsonService.h | 48 +++++++++++++++++ firmware/src/domain/valoplus/ChannelElement.h | 12 +++++ .../src/domain/valoplus/ControllableElement.h | 14 +++++ firmware/src/domain/valoplus/Device.h | 25 +++++++++ firmware/src/domain/valoplus/Group.h | 19 +++++++ .../src/domain/valoplus/GroupJsonService.h | 44 +++++++++++++++ firmware/src/domain/valoplus/Master.h | 35 ++++++++++++ .../src/domain/valoplus/MasterJsonService.h | 54 +++++++++++++++++++ firmware/src/domain/valoplus/RgbLed.h | 24 +++++++++ .../src/domain/valoplus/RgbLedJsonService.h | 48 +++++++++++++++++ firmware/src/domain/valoplus/SingleColorLed.h | 18 +++++++ .../valoplus/SingleColorLedJsonService.h | 44 +++++++++++++++ firmware/src/domain/valoplus/Slave.h | 32 +++++++++++ .../src/domain/valoplus/SlaveJsonService.h | 52 ++++++++++++++++++ firmware/src/domain/valoplus/State.h | 13 +++++ .../domain/valoplus/StateAdressableRgbLed.h | 17 ++++++ .../StateAdressableRgbLedJsonService.h | 44 +++++++++++++++ 18 files changed, 568 insertions(+) create mode 100644 firmware/src/domain/valoplus/AdressableRgbLed.h create mode 100644 firmware/src/domain/valoplus/AdressableRgbLedJsonService.h create mode 100644 firmware/src/domain/valoplus/ChannelElement.h create mode 100644 firmware/src/domain/valoplus/ControllableElement.h create mode 100644 firmware/src/domain/valoplus/Device.h create mode 100644 firmware/src/domain/valoplus/Group.h create mode 100644 firmware/src/domain/valoplus/GroupJsonService.h create mode 100644 firmware/src/domain/valoplus/Master.h create mode 100644 firmware/src/domain/valoplus/MasterJsonService.h create mode 100644 firmware/src/domain/valoplus/RgbLed.h create mode 100644 firmware/src/domain/valoplus/RgbLedJsonService.h create mode 100644 firmware/src/domain/valoplus/SingleColorLed.h create mode 100644 firmware/src/domain/valoplus/SingleColorLedJsonService.h create mode 100644 firmware/src/domain/valoplus/Slave.h create mode 100644 firmware/src/domain/valoplus/SlaveJsonService.h create mode 100644 firmware/src/domain/valoplus/State.h create mode 100644 firmware/src/domain/valoplus/StateAdressableRgbLed.h create mode 100644 firmware/src/domain/valoplus/StateAdressableRgbLedJsonService.h diff --git a/firmware/src/domain/valoplus/AdressableRgbLed.h b/firmware/src/domain/valoplus/AdressableRgbLed.h new file mode 100644 index 0000000..1826790 --- /dev/null +++ b/firmware/src/domain/valoplus/AdressableRgbLed.h @@ -0,0 +1,25 @@ +#ifndef TEST_ADRESSABLERGBLED_H +#define TEST_ADRESSABLERGBLED_H + +#include +#include +#include + +class AdressableRgbLed : ChannelElement { + private: + std::string name; + StateAdressableRgbLed stateAdressableRgbLed; + int channelId; + int ledCount; + public: + std::string getName() { return this->name; } + StateAdressableRgbLed getStateAdressableRgbLed() { return this->stateAdressableRgbLed; } + int getChannelId() { return this->channelId; } + int getLedCount() { return this->ledCount; } + void setName(std::string name) { this->name = name; } + void setStateAdressableRgbLed(StateAdressableRgbLed stateAdressableRgbLed) { this->stateAdressableRgbLed = stateAdressableRgbLed; } + void setChannelId(int channelId) { this->channelId = channelId; } + void setLedCount(int ledCount) { this->ledCount = ledCount; } +}; + +#endif //TEST_ADRESSABLERGBLED_H diff --git a/firmware/src/domain/valoplus/AdressableRgbLedJsonService.h b/firmware/src/domain/valoplus/AdressableRgbLedJsonService.h new file mode 100644 index 0000000..182562f --- /dev/null +++ b/firmware/src/domain/valoplus/AdressableRgbLedJsonService.h @@ -0,0 +1,48 @@ +#ifndef TEST_ADRESSABLERGBLEDJSONSERVICE_H +#define TEST_ADRESSABLERGBLEDJSONSERVICE_H + +#include +#include +#include + +class AdressableRgbLedJsonService { +private: + +public: + char* toJson(AdressableRgbLed obj) { + StaticJsonBuffer<200> jsonBuffer; + JsonObject& root = jsonBuffer.createObject(); + + root("name", obj.getName()); + root("stateAdressableRgbLed", obj.getStateAdressableRgbLed()); + root("channelId", obj.getChannelId()); + root("ledCount", obj.getLedCount()); + + JsonObject& links = root.createNestedObject("_links"); + + JsonObject& self1 = links.createNestedObject("self"); + self1.set("href", "/adressableRgbLeds/" + obj.getId()); + JsonObject& self2 = links.createNestedObject("adressableRgbLed"); + self2.set("href", "/adressableRgbLeds/" + obj.getId()); + + char buffer[root.measureLength()]; + root.printTo(buffer, sizeof(buffer)); + return buffer; + } + + AdressableRgbLed fromJson(String json) { + StaticJsonBuffer<200> jsonBuffer; + JsonObject& root = jsonBuffer.parseObject(json); + + AdressableRgbLed result = AdressableRgbLed(); + + result.setName(root("name")); + result.setStateAdressableRgbLed(root("stateAdressableRgbLed")); + result.setChannelId(root("channelId")); + result.setLedCount(root("ledCount")); + + return result; + } +}; + +#endif //TEST_ADRESSABLERGBLEDJSONSERVICE_H diff --git a/firmware/src/domain/valoplus/ChannelElement.h b/firmware/src/domain/valoplus/ChannelElement.h new file mode 100644 index 0000000..6236ace --- /dev/null +++ b/firmware/src/domain/valoplus/ChannelElement.h @@ -0,0 +1,12 @@ +#ifndef TEST_CHANNELELEMENT_H +#define TEST_CHANNELELEMENT_H + +#include + +class ChannelElement : ControllableElement { + private: + + public: +}; + +#endif //TEST_CHANNELELEMENT_H diff --git a/firmware/src/domain/valoplus/ControllableElement.h b/firmware/src/domain/valoplus/ControllableElement.h new file mode 100644 index 0000000..8f8b45c --- /dev/null +++ b/firmware/src/domain/valoplus/ControllableElement.h @@ -0,0 +1,14 @@ +#ifndef TEST_CONTROLLABLEELEMENT_H +#define TEST_CONTROLLABLEELEMENT_H + +#include + +class ControllableElement { + private: + + public: + virtual std::string getName()= 0; + virtual void setName(std::string name)= 0; +}; + +#endif //TEST_CONTROLLABLEELEMENT_H diff --git a/firmware/src/domain/valoplus/Device.h b/firmware/src/domain/valoplus/Device.h new file mode 100644 index 0000000..bdd9ca8 --- /dev/null +++ b/firmware/src/domain/valoplus/Device.h @@ -0,0 +1,25 @@ +#ifndef TEST_DEVICE_H +#define TEST_DEVICE_H + +#include +#include +#include +#include + +class Device : ControllableElement { + private: + + public: + virtual std::string getIp()= 0; + virtual std::string getKey()= 0; + virtual int getMaxChannel()= 0; + virtual bool getIsConfigured()= 0; + virtual std::vector getElements()= 0; + virtual void setIp(std::string ip)= 0; + virtual void setKey(std::string key)= 0; + virtual void setMaxChannel(int maxChannel)= 0; + virtual void setIsConfigured(bool isConfigured)= 0; + virtual void setElements(std::vector elements)= 0; +}; + +#endif //TEST_DEVICE_H diff --git a/firmware/src/domain/valoplus/Group.h b/firmware/src/domain/valoplus/Group.h new file mode 100644 index 0000000..4dc97f2 --- /dev/null +++ b/firmware/src/domain/valoplus/Group.h @@ -0,0 +1,19 @@ +#ifndef TEST_GROUP_H +#define TEST_GROUP_H + +#include +#include +#include + +class Group : ControllableElement { + private: + std::string name; + std::vector members; + public: + std::string getName() { return this->name; } + std::vector getMembers() { return this->members; } + void setName(std::string name) { this->name = name; } + void setMembers(std::vector members) { this->members = members; } +}; + +#endif //TEST_GROUP_H diff --git a/firmware/src/domain/valoplus/GroupJsonService.h b/firmware/src/domain/valoplus/GroupJsonService.h new file mode 100644 index 0000000..c2327d2 --- /dev/null +++ b/firmware/src/domain/valoplus/GroupJsonService.h @@ -0,0 +1,44 @@ +#ifndef TEST_GROUPJSONSERVICE_H +#define TEST_GROUPJSONSERVICE_H + +#include +#include +#include + +class GroupJsonService { +private: + +public: + char* toJson(Group obj) { + StaticJsonBuffer<200> jsonBuffer; + JsonObject& root = jsonBuffer.createObject(); + + root("name", obj.getName()); + root("members", obj.getMembers()); + + JsonObject& links = root.createNestedObject("_links"); + + JsonObject& self1 = links.createNestedObject("self"); + self1.set("href", "/groups/" + obj.getId()); + JsonObject& self2 = links.createNestedObject("group"); + self2.set("href", "/groups/" + obj.getId()); + + char buffer[root.measureLength()]; + root.printTo(buffer, sizeof(buffer)); + return buffer; + } + + Group fromJson(String json) { + StaticJsonBuffer<200> jsonBuffer; + JsonObject& root = jsonBuffer.parseObject(json); + + Group result = Group(); + + result.setName(root("name")); + result.setMembers(root("members")); + + return result; + } +}; + +#endif //TEST_GROUPJSONSERVICE_H diff --git a/firmware/src/domain/valoplus/Master.h b/firmware/src/domain/valoplus/Master.h new file mode 100644 index 0000000..d58be17 --- /dev/null +++ b/firmware/src/domain/valoplus/Master.h @@ -0,0 +1,35 @@ +#ifndef TEST_MASTER_H +#define TEST_MASTER_H + +#include +#include +#include +#include + +class Master : Device { + private: + std::string name; + std::string ip; + std::string key; + int maxChannel; + bool isConfigured; + std::vector elements; + std::string password; + public: + std::string getName() { return this->name; } + std::string getIp() { return this->ip; } + std::string getKey() { return this->key; } + int getMaxChannel() { return this->maxChannel; } + bool getIsConfigured() { return this->isConfigured; } + std::vector getElements() { return this->elements; } + std::string getPassword() { return this->password; } + void setName(std::string name) { this->name = name; } + void setIp(std::string ip) { this->ip = ip; } + void setKey(std::string key) { this->key = key; } + void setMaxChannel(int maxChannel) { this->maxChannel = maxChannel; } + void setIsConfigured(bool isConfigured) { this->isConfigured = isConfigured; } + void setElements(std::vector elements) { this->elements = elements; } + void setPassword(std::string password) { this->password = password; } +}; + +#endif //TEST_MASTER_H diff --git a/firmware/src/domain/valoplus/MasterJsonService.h b/firmware/src/domain/valoplus/MasterJsonService.h new file mode 100644 index 0000000..4b9072f --- /dev/null +++ b/firmware/src/domain/valoplus/MasterJsonService.h @@ -0,0 +1,54 @@ +#ifndef TEST_MASTERJSONSERVICE_H +#define TEST_MASTERJSONSERVICE_H + +#include +#include +#include + +class MasterJsonService { +private: + +public: + char* toJson(Master obj) { + StaticJsonBuffer<200> jsonBuffer; + JsonObject& root = jsonBuffer.createObject(); + + root("name", obj.getName()); + root("ip", obj.getIp()); + root("key", obj.getKey()); + root("maxChannel", obj.getMaxChannel()); + root("isConfigured", obj.getIsConfigured()); + root("elements", obj.getElements()); + root("password", obj.getPassword()); + + JsonObject& links = root.createNestedObject("_links"); + + JsonObject& self1 = links.createNestedObject("self"); + self1.set("href", "/masters/" + obj.getId()); + JsonObject& self2 = links.createNestedObject("master"); + self2.set("href", "/masters/" + obj.getId()); + + char buffer[root.measureLength()]; + root.printTo(buffer, sizeof(buffer)); + return buffer; + } + + Master fromJson(String json) { + StaticJsonBuffer<200> jsonBuffer; + JsonObject& root = jsonBuffer.parseObject(json); + + Master result = Master(); + + result.setName(root("name")); + result.setIp(root("ip")); + result.setKey(root("key")); + result.setMaxChannel(root("maxChannel")); + result.setIsConfigured(root("isConfigured")); + result.setElements(root("elements")); + result.setPassword(root("password")); + + return result; + } +}; + +#endif //TEST_MASTERJSONSERVICE_H diff --git a/firmware/src/domain/valoplus/RgbLed.h b/firmware/src/domain/valoplus/RgbLed.h new file mode 100644 index 0000000..32f4894 --- /dev/null +++ b/firmware/src/domain/valoplus/RgbLed.h @@ -0,0 +1,24 @@ +#ifndef TEST_RGBLED_H +#define TEST_RGBLED_H + +#include +#include + +class RgbLed : ChannelElement { + private: + std::string name; + int channelIdRed; + int channelIdGreen; + int channelIdBlue; + public: + std::string getName() { return this->name; } + int getChannelIdRed() { return this->channelIdRed; } + int getChannelIdGreen() { return this->channelIdGreen; } + int getChannelIdBlue() { return this->channelIdBlue; } + void setName(std::string name) { this->name = name; } + void setChannelIdRed(int channelIdRed) { this->channelIdRed = channelIdRed; } + void setChannelIdGreen(int channelIdGreen) { this->channelIdGreen = channelIdGreen; } + void setChannelIdBlue(int channelIdBlue) { this->channelIdBlue = channelIdBlue; } +}; + +#endif //TEST_RGBLED_H diff --git a/firmware/src/domain/valoplus/RgbLedJsonService.h b/firmware/src/domain/valoplus/RgbLedJsonService.h new file mode 100644 index 0000000..64f08bc --- /dev/null +++ b/firmware/src/domain/valoplus/RgbLedJsonService.h @@ -0,0 +1,48 @@ +#ifndef TEST_RGBLEDJSONSERVICE_H +#define TEST_RGBLEDJSONSERVICE_H + +#include +#include +#include + +class RgbLedJsonService { +private: + +public: + char* toJson(RgbLed obj) { + StaticJsonBuffer<200> jsonBuffer; + JsonObject& root = jsonBuffer.createObject(); + + root("name", obj.getName()); + root("channelIdRed", obj.getChannelIdRed()); + root("channelIdGreen", obj.getChannelIdGreen()); + root("channelIdBlue", obj.getChannelIdBlue()); + + JsonObject& links = root.createNestedObject("_links"); + + JsonObject& self1 = links.createNestedObject("self"); + self1.set("href", "/rgbLeds/" + obj.getId()); + JsonObject& self2 = links.createNestedObject("rgbLed"); + self2.set("href", "/rgbLeds/" + obj.getId()); + + char buffer[root.measureLength()]; + root.printTo(buffer, sizeof(buffer)); + return buffer; + } + + RgbLed fromJson(String json) { + StaticJsonBuffer<200> jsonBuffer; + JsonObject& root = jsonBuffer.parseObject(json); + + RgbLed result = RgbLed(); + + result.setName(root("name")); + result.setChannelIdRed(root("channelIdRed")); + result.setChannelIdGreen(root("channelIdGreen")); + result.setChannelIdBlue(root("channelIdBlue")); + + return result; + } +}; + +#endif //TEST_RGBLEDJSONSERVICE_H diff --git a/firmware/src/domain/valoplus/SingleColorLed.h b/firmware/src/domain/valoplus/SingleColorLed.h new file mode 100644 index 0000000..d32ef6a --- /dev/null +++ b/firmware/src/domain/valoplus/SingleColorLed.h @@ -0,0 +1,18 @@ +#ifndef TEST_SINGLECOLORLED_H +#define TEST_SINGLECOLORLED_H + +#include +#include + +class SingleColorLed : ChannelElement { + private: + std::string name; + int channelId; + public: + std::string getName() { return this->name; } + int getChannelId() { return this->channelId; } + void setName(std::string name) { this->name = name; } + void setChannelId(int channelId) { this->channelId = channelId; } +}; + +#endif //TEST_SINGLECOLORLED_H diff --git a/firmware/src/domain/valoplus/SingleColorLedJsonService.h b/firmware/src/domain/valoplus/SingleColorLedJsonService.h new file mode 100644 index 0000000..341f093 --- /dev/null +++ b/firmware/src/domain/valoplus/SingleColorLedJsonService.h @@ -0,0 +1,44 @@ +#ifndef TEST_SINGLECOLORLEDJSONSERVICE_H +#define TEST_SINGLECOLORLEDJSONSERVICE_H + +#include +#include +#include + +class SingleColorLedJsonService { +private: + +public: + char* toJson(SingleColorLed obj) { + StaticJsonBuffer<200> jsonBuffer; + JsonObject& root = jsonBuffer.createObject(); + + root("name", obj.getName()); + root("channelId", obj.getChannelId()); + + JsonObject& links = root.createNestedObject("_links"); + + JsonObject& self1 = links.createNestedObject("self"); + self1.set("href", "/singleColorLeds/" + obj.getId()); + JsonObject& self2 = links.createNestedObject("singleColorLed"); + self2.set("href", "/singleColorLeds/" + obj.getId()); + + char buffer[root.measureLength()]; + root.printTo(buffer, sizeof(buffer)); + return buffer; + } + + SingleColorLed fromJson(String json) { + StaticJsonBuffer<200> jsonBuffer; + JsonObject& root = jsonBuffer.parseObject(json); + + SingleColorLed result = SingleColorLed(); + + result.setName(root("name")); + result.setChannelId(root("channelId")); + + return result; + } +}; + +#endif //TEST_SINGLECOLORLEDJSONSERVICE_H diff --git a/firmware/src/domain/valoplus/Slave.h b/firmware/src/domain/valoplus/Slave.h new file mode 100644 index 0000000..7caf60f --- /dev/null +++ b/firmware/src/domain/valoplus/Slave.h @@ -0,0 +1,32 @@ +#ifndef TEST_SLAVE_H +#define TEST_SLAVE_H + +#include +#include +#include +#include + +class Slave : Device { + private: + std::string name; + std::string ip; + std::string key; + int maxChannel; + bool isConfigured; + std::vector elements; + public: + std::string getName() { return this->name; } + std::string getIp() { return this->ip; } + std::string getKey() { return this->key; } + int getMaxChannel() { return this->maxChannel; } + bool getIsConfigured() { return this->isConfigured; } + std::vector getElements() { return this->elements; } + void setName(std::string name) { this->name = name; } + void setIp(std::string ip) { this->ip = ip; } + void setKey(std::string key) { this->key = key; } + void setMaxChannel(int maxChannel) { this->maxChannel = maxChannel; } + void setIsConfigured(bool isConfigured) { this->isConfigured = isConfigured; } + void setElements(std::vector elements) { this->elements = elements; } +}; + +#endif //TEST_SLAVE_H diff --git a/firmware/src/domain/valoplus/SlaveJsonService.h b/firmware/src/domain/valoplus/SlaveJsonService.h new file mode 100644 index 0000000..e4caebe --- /dev/null +++ b/firmware/src/domain/valoplus/SlaveJsonService.h @@ -0,0 +1,52 @@ +#ifndef TEST_SLAVEJSONSERVICE_H +#define TEST_SLAVEJSONSERVICE_H + +#include +#include +#include + +class SlaveJsonService { +private: + +public: + char* toJson(Slave obj) { + StaticJsonBuffer<200> jsonBuffer; + JsonObject& root = jsonBuffer.createObject(); + + root("name", obj.getName()); + root("ip", obj.getIp()); + root("key", obj.getKey()); + root("maxChannel", obj.getMaxChannel()); + root("isConfigured", obj.getIsConfigured()); + root("elements", obj.getElements()); + + JsonObject& links = root.createNestedObject("_links"); + + JsonObject& self1 = links.createNestedObject("self"); + self1.set("href", "/slaves/" + obj.getId()); + JsonObject& self2 = links.createNestedObject("slave"); + self2.set("href", "/slaves/" + obj.getId()); + + char buffer[root.measureLength()]; + root.printTo(buffer, sizeof(buffer)); + return buffer; + } + + Slave fromJson(String json) { + StaticJsonBuffer<200> jsonBuffer; + JsonObject& root = jsonBuffer.parseObject(json); + + Slave result = Slave(); + + result.setName(root("name")); + result.setIp(root("ip")); + result.setKey(root("key")); + result.setMaxChannel(root("maxChannel")); + result.setIsConfigured(root("isConfigured")); + result.setElements(root("elements")); + + return result; + } +}; + +#endif //TEST_SLAVEJSONSERVICE_H diff --git a/firmware/src/domain/valoplus/State.h b/firmware/src/domain/valoplus/State.h new file mode 100644 index 0000000..7658d4b --- /dev/null +++ b/firmware/src/domain/valoplus/State.h @@ -0,0 +1,13 @@ +#ifndef TEST_STATE_H +#define TEST_STATE_H + + +class State { + private: + + public: + virtual bool getActive()= 0; + virtual void setActive(bool active)= 0; +}; + +#endif //TEST_STATE_H diff --git a/firmware/src/domain/valoplus/StateAdressableRgbLed.h b/firmware/src/domain/valoplus/StateAdressableRgbLed.h new file mode 100644 index 0000000..4e62553 --- /dev/null +++ b/firmware/src/domain/valoplus/StateAdressableRgbLed.h @@ -0,0 +1,17 @@ +#ifndef TEST_STATEADRESSABLERGBLED_H +#define TEST_STATEADRESSABLERGBLED_H + +#include + +class StateAdressableRgbLed : State { + private: + bool active; + int brightness; + public: + bool getActive() { return this->active; } + int getBrightness() { return this->brightness; } + void setActive(bool active) { this->active = active; } + void setBrightness(int brightness) { this->brightness = brightness; } +}; + +#endif //TEST_STATEADRESSABLERGBLED_H diff --git a/firmware/src/domain/valoplus/StateAdressableRgbLedJsonService.h b/firmware/src/domain/valoplus/StateAdressableRgbLedJsonService.h new file mode 100644 index 0000000..b98ee9a --- /dev/null +++ b/firmware/src/domain/valoplus/StateAdressableRgbLedJsonService.h @@ -0,0 +1,44 @@ +#ifndef TEST_STATEADRESSABLERGBLEDJSONSERVICE_H +#define TEST_STATEADRESSABLERGBLEDJSONSERVICE_H + +#include +#include +#include + +class StateAdressableRgbLedJsonService { +private: + +public: + char* toJson(StateAdressableRgbLed obj) { + StaticJsonBuffer<200> jsonBuffer; + JsonObject& root = jsonBuffer.createObject(); + + root("active", obj.getActive()); + root("brightness", obj.getBrightness()); + + JsonObject& links = root.createNestedObject("_links"); + + JsonObject& self1 = links.createNestedObject("self"); + self1.set("href", "/stateAdressableRgbLeds/" + obj.getId()); + JsonObject& self2 = links.createNestedObject("stateAdressableRgbLed"); + self2.set("href", "/stateAdressableRgbLeds/" + obj.getId()); + + char buffer[root.measureLength()]; + root.printTo(buffer, sizeof(buffer)); + return buffer; + } + + StateAdressableRgbLed fromJson(String json) { + StaticJsonBuffer<200> jsonBuffer; + JsonObject& root = jsonBuffer.parseObject(json); + + StateAdressableRgbLed result = StateAdressableRgbLed(); + + result.setActive(root("active")); + result.setBrightness(root("brightness")); + + return result; + } +}; + +#endif //TEST_STATEADRESSABLERGBLEDJSONSERVICE_H From 4b2db73e0055820c3ddcf51918c257c2f5f8e3af Mon Sep 17 00:00:00 2001 From: Tom Schmidt Date: Sun, 25 Sep 2016 21:05:59 +0200 Subject: [PATCH 3/3] - fix imports - add PersistentElement - add first Idea of PersistentService --- firmware/src/domain/core/PersistentElement.h | 15 ++++++++++++ firmware/src/domain/core/PersistentService.h | 24 +++++++++++++++++++ .../src/domain/valoplus/AdressableRgbLed.h | 6 ++--- .../valoplus/AdressableRgbLedJsonService.h | 6 ++--- firmware/src/domain/valoplus/ChannelElement.h | 4 ++-- .../src/domain/valoplus/ControllableElement.h | 3 ++- firmware/src/domain/valoplus/Device.h | 6 ++--- firmware/src/domain/valoplus/Group.h | 4 ++-- .../src/domain/valoplus/GroupJsonService.h | 6 ++--- firmware/src/domain/valoplus/Master.h | 6 ++--- .../src/domain/valoplus/MasterJsonService.h | 6 ++--- firmware/src/domain/valoplus/RgbLed.h | 4 ++-- .../src/domain/valoplus/RgbLedJsonService.h | 6 ++--- firmware/src/domain/valoplus/SingleColorLed.h | 4 ++-- .../valoplus/SingleColorLedJsonService.h | 6 ++--- firmware/src/domain/valoplus/Slave.h | 6 ++--- .../src/domain/valoplus/SlaveJsonService.h | 6 ++--- firmware/src/domain/valoplus/State.h | 3 ++- .../domain/valoplus/StateAdressableRgbLed.h | 4 ++-- .../StateAdressableRgbLedJsonService.h | 6 ++--- 20 files changed, 86 insertions(+), 45 deletions(-) create mode 100644 firmware/src/domain/core/PersistentElement.h create mode 100644 firmware/src/domain/core/PersistentService.h diff --git a/firmware/src/domain/core/PersistentElement.h b/firmware/src/domain/core/PersistentElement.h new file mode 100644 index 0000000..8a2f47d --- /dev/null +++ b/firmware/src/domain/core/PersistentElement.h @@ -0,0 +1,15 @@ +#ifndef ESP32_PERSISTENTELEMENT_H +#define ESP32_PERSISTENTELEMENT_H + +/** + * PersistentElements can be stored with the PersistentService + */ +class PersistentElement { +private: + int tableRow; +public: + int getTableRow() { return this->tableRow; } + void setTableRow(int tableRow) { this->tableRow = tableRow; } +}; + +#endif //ESP32_PERSISTENTELEMENT_H diff --git a/firmware/src/domain/core/PersistentService.h b/firmware/src/domain/core/PersistentService.h new file mode 100644 index 0000000..532fae1 --- /dev/null +++ b/firmware/src/domain/core/PersistentService.h @@ -0,0 +1,24 @@ +#ifndef ESP32_PERSISTSERVICE_H +#define ESP32_PERSISTSERVICE_H + +#include +#include "PersistentElement.h" + +/** + * This service is used to access and save elements in the storage. + * Each non abstract class will managed in his own class. Abstract types are read only (sorted by type if read as list) + */ +class PersistentService { +private: + +public: + virtual void save(PersistentElement elementToSave)= 0; + virtual void remove(PersistentElement elementToSave)= 0; + virtual void remove(std::string type, int id)= 0; + virtual PersistentElement get(std::string type)= 0; + virtual PersistentElement get(std::string type, int id)= 0; + + virtual void rearangeStorage()=0; +}; + +#endif //ESP32_PERSISTSERVICE_H diff --git a/firmware/src/domain/valoplus/AdressableRgbLed.h b/firmware/src/domain/valoplus/AdressableRgbLed.h index 1826790..66d7c27 100644 --- a/firmware/src/domain/valoplus/AdressableRgbLed.h +++ b/firmware/src/domain/valoplus/AdressableRgbLed.h @@ -1,11 +1,11 @@ #ifndef TEST_ADRESSABLERGBLED_H #define TEST_ADRESSABLERGBLED_H -#include +#include #include -#include +#include -class AdressableRgbLed : ChannelElement { +class AdressableRgbLed : public ChannelElement { private: std::string name; StateAdressableRgbLed stateAdressableRgbLed; diff --git a/firmware/src/domain/valoplus/AdressableRgbLedJsonService.h b/firmware/src/domain/valoplus/AdressableRgbLedJsonService.h index 182562f..232cf06 100644 --- a/firmware/src/domain/valoplus/AdressableRgbLedJsonService.h +++ b/firmware/src/domain/valoplus/AdressableRgbLedJsonService.h @@ -3,7 +3,7 @@ #include #include -#include +#include class AdressableRgbLedJsonService { private: @@ -21,9 +21,9 @@ class AdressableRgbLedJsonService { JsonObject& links = root.createNestedObject("_links"); JsonObject& self1 = links.createNestedObject("self"); - self1.set("href", "/adressableRgbLeds/" + obj.getId()); + self1.set("href", "/adressableRgbLeds/" + obj.getTableRow()); JsonObject& self2 = links.createNestedObject("adressableRgbLed"); - self2.set("href", "/adressableRgbLeds/" + obj.getId()); + self2.set("href", "/adressableRgbLeds/" + obj.getTableRow()); char buffer[root.measureLength()]; root.printTo(buffer, sizeof(buffer)); diff --git a/firmware/src/domain/valoplus/ChannelElement.h b/firmware/src/domain/valoplus/ChannelElement.h index 6236ace..79d4a9d 100644 --- a/firmware/src/domain/valoplus/ChannelElement.h +++ b/firmware/src/domain/valoplus/ChannelElement.h @@ -1,9 +1,9 @@ #ifndef TEST_CHANNELELEMENT_H #define TEST_CHANNELELEMENT_H -#include +#include -class ChannelElement : ControllableElement { +class ChannelElement : public ControllableElement { private: public: diff --git a/firmware/src/domain/valoplus/ControllableElement.h b/firmware/src/domain/valoplus/ControllableElement.h index 8f8b45c..5349930 100644 --- a/firmware/src/domain/valoplus/ControllableElement.h +++ b/firmware/src/domain/valoplus/ControllableElement.h @@ -1,9 +1,10 @@ #ifndef TEST_CONTROLLABLEELEMENT_H #define TEST_CONTROLLABLEELEMENT_H +#include #include -class ControllableElement { +class ControllableElement : public PersistentElement { private: public: diff --git a/firmware/src/domain/valoplus/Device.h b/firmware/src/domain/valoplus/Device.h index bdd9ca8..3046b45 100644 --- a/firmware/src/domain/valoplus/Device.h +++ b/firmware/src/domain/valoplus/Device.h @@ -1,12 +1,12 @@ #ifndef TEST_DEVICE_H #define TEST_DEVICE_H -#include +#include #include -#include #include +#include -class Device : ControllableElement { +class Device : public ControllableElement { private: public: diff --git a/firmware/src/domain/valoplus/Group.h b/firmware/src/domain/valoplus/Group.h index 4dc97f2..2805dd5 100644 --- a/firmware/src/domain/valoplus/Group.h +++ b/firmware/src/domain/valoplus/Group.h @@ -1,11 +1,11 @@ #ifndef TEST_GROUP_H #define TEST_GROUP_H +#include #include -#include #include -class Group : ControllableElement { +class Group : public ControllableElement { private: std::string name; std::vector members; diff --git a/firmware/src/domain/valoplus/GroupJsonService.h b/firmware/src/domain/valoplus/GroupJsonService.h index c2327d2..f5f7d2b 100644 --- a/firmware/src/domain/valoplus/GroupJsonService.h +++ b/firmware/src/domain/valoplus/GroupJsonService.h @@ -3,7 +3,7 @@ #include #include -#include +#include class GroupJsonService { private: @@ -19,9 +19,9 @@ class GroupJsonService { JsonObject& links = root.createNestedObject("_links"); JsonObject& self1 = links.createNestedObject("self"); - self1.set("href", "/groups/" + obj.getId()); + self1.set("href", "/groups/" + obj.getTableRow()); JsonObject& self2 = links.createNestedObject("group"); - self2.set("href", "/groups/" + obj.getId()); + self2.set("href", "/groups/" + obj.getTableRow()); char buffer[root.measureLength()]; root.printTo(buffer, sizeof(buffer)); diff --git a/firmware/src/domain/valoplus/Master.h b/firmware/src/domain/valoplus/Master.h index d58be17..9606952 100644 --- a/firmware/src/domain/valoplus/Master.h +++ b/firmware/src/domain/valoplus/Master.h @@ -1,12 +1,12 @@ #ifndef TEST_MASTER_H #define TEST_MASTER_H -#include #include -#include +#include #include +#include -class Master : Device { +class Master : public Device { private: std::string name; std::string ip; diff --git a/firmware/src/domain/valoplus/MasterJsonService.h b/firmware/src/domain/valoplus/MasterJsonService.h index 4b9072f..db7a4e2 100644 --- a/firmware/src/domain/valoplus/MasterJsonService.h +++ b/firmware/src/domain/valoplus/MasterJsonService.h @@ -3,7 +3,7 @@ #include #include -#include +#include class MasterJsonService { private: @@ -24,9 +24,9 @@ class MasterJsonService { JsonObject& links = root.createNestedObject("_links"); JsonObject& self1 = links.createNestedObject("self"); - self1.set("href", "/masters/" + obj.getId()); + self1.set("href", "/masters/" + obj.getTableRow()); JsonObject& self2 = links.createNestedObject("master"); - self2.set("href", "/masters/" + obj.getId()); + self2.set("href", "/masters/" + obj.getTableRow()); char buffer[root.measureLength()]; root.printTo(buffer, sizeof(buffer)); diff --git a/firmware/src/domain/valoplus/RgbLed.h b/firmware/src/domain/valoplus/RgbLed.h index 32f4894..2171a1c 100644 --- a/firmware/src/domain/valoplus/RgbLed.h +++ b/firmware/src/domain/valoplus/RgbLed.h @@ -1,10 +1,10 @@ #ifndef TEST_RGBLED_H #define TEST_RGBLED_H -#include #include +#include -class RgbLed : ChannelElement { +class RgbLed : public ChannelElement { private: std::string name; int channelIdRed; diff --git a/firmware/src/domain/valoplus/RgbLedJsonService.h b/firmware/src/domain/valoplus/RgbLedJsonService.h index 64f08bc..1c64d97 100644 --- a/firmware/src/domain/valoplus/RgbLedJsonService.h +++ b/firmware/src/domain/valoplus/RgbLedJsonService.h @@ -3,7 +3,7 @@ #include #include -#include +#include class RgbLedJsonService { private: @@ -21,9 +21,9 @@ class RgbLedJsonService { JsonObject& links = root.createNestedObject("_links"); JsonObject& self1 = links.createNestedObject("self"); - self1.set("href", "/rgbLeds/" + obj.getId()); + self1.set("href", "/rgbLeds/" + obj.getTableRow()); JsonObject& self2 = links.createNestedObject("rgbLed"); - self2.set("href", "/rgbLeds/" + obj.getId()); + self2.set("href", "/rgbLeds/" + obj.getTableRow()); char buffer[root.measureLength()]; root.printTo(buffer, sizeof(buffer)); diff --git a/firmware/src/domain/valoplus/SingleColorLed.h b/firmware/src/domain/valoplus/SingleColorLed.h index d32ef6a..fc611af 100644 --- a/firmware/src/domain/valoplus/SingleColorLed.h +++ b/firmware/src/domain/valoplus/SingleColorLed.h @@ -1,10 +1,10 @@ #ifndef TEST_SINGLECOLORLED_H #define TEST_SINGLECOLORLED_H -#include #include +#include -class SingleColorLed : ChannelElement { +class SingleColorLed : public ChannelElement { private: std::string name; int channelId; diff --git a/firmware/src/domain/valoplus/SingleColorLedJsonService.h b/firmware/src/domain/valoplus/SingleColorLedJsonService.h index 341f093..2702061 100644 --- a/firmware/src/domain/valoplus/SingleColorLedJsonService.h +++ b/firmware/src/domain/valoplus/SingleColorLedJsonService.h @@ -3,7 +3,7 @@ #include #include -#include +#include class SingleColorLedJsonService { private: @@ -19,9 +19,9 @@ class SingleColorLedJsonService { JsonObject& links = root.createNestedObject("_links"); JsonObject& self1 = links.createNestedObject("self"); - self1.set("href", "/singleColorLeds/" + obj.getId()); + self1.set("href", "/singleColorLeds/" + obj.getTableRow()); JsonObject& self2 = links.createNestedObject("singleColorLed"); - self2.set("href", "/singleColorLeds/" + obj.getId()); + self2.set("href", "/singleColorLeds/" + obj.getTableRow()); char buffer[root.measureLength()]; root.printTo(buffer, sizeof(buffer)); diff --git a/firmware/src/domain/valoplus/Slave.h b/firmware/src/domain/valoplus/Slave.h index 7caf60f..e4a489f 100644 --- a/firmware/src/domain/valoplus/Slave.h +++ b/firmware/src/domain/valoplus/Slave.h @@ -1,12 +1,12 @@ #ifndef TEST_SLAVE_H #define TEST_SLAVE_H -#include #include -#include +#include #include +#include -class Slave : Device { +class Slave : public Device { private: std::string name; std::string ip; diff --git a/firmware/src/domain/valoplus/SlaveJsonService.h b/firmware/src/domain/valoplus/SlaveJsonService.h index e4caebe..942d975 100644 --- a/firmware/src/domain/valoplus/SlaveJsonService.h +++ b/firmware/src/domain/valoplus/SlaveJsonService.h @@ -3,7 +3,7 @@ #include #include -#include +#include class SlaveJsonService { private: @@ -23,9 +23,9 @@ class SlaveJsonService { JsonObject& links = root.createNestedObject("_links"); JsonObject& self1 = links.createNestedObject("self"); - self1.set("href", "/slaves/" + obj.getId()); + self1.set("href", "/slaves/" + obj.getTableRow()); JsonObject& self2 = links.createNestedObject("slave"); - self2.set("href", "/slaves/" + obj.getId()); + self2.set("href", "/slaves/" + obj.getTableRow()); char buffer[root.measureLength()]; root.printTo(buffer, sizeof(buffer)); diff --git a/firmware/src/domain/valoplus/State.h b/firmware/src/domain/valoplus/State.h index 7658d4b..0acfdf7 100644 --- a/firmware/src/domain/valoplus/State.h +++ b/firmware/src/domain/valoplus/State.h @@ -1,8 +1,9 @@ #ifndef TEST_STATE_H #define TEST_STATE_H +#include -class State { +class State : public PersistentElement { private: public: diff --git a/firmware/src/domain/valoplus/StateAdressableRgbLed.h b/firmware/src/domain/valoplus/StateAdressableRgbLed.h index 4e62553..d1c753b 100644 --- a/firmware/src/domain/valoplus/StateAdressableRgbLed.h +++ b/firmware/src/domain/valoplus/StateAdressableRgbLed.h @@ -1,9 +1,9 @@ #ifndef TEST_STATEADRESSABLERGBLED_H #define TEST_STATEADRESSABLERGBLED_H -#include +#include -class StateAdressableRgbLed : State { +class StateAdressableRgbLed : public State { private: bool active; int brightness; diff --git a/firmware/src/domain/valoplus/StateAdressableRgbLedJsonService.h b/firmware/src/domain/valoplus/StateAdressableRgbLedJsonService.h index b98ee9a..d4c9b48 100644 --- a/firmware/src/domain/valoplus/StateAdressableRgbLedJsonService.h +++ b/firmware/src/domain/valoplus/StateAdressableRgbLedJsonService.h @@ -3,7 +3,7 @@ #include #include -#include +#include class StateAdressableRgbLedJsonService { private: @@ -19,9 +19,9 @@ class StateAdressableRgbLedJsonService { JsonObject& links = root.createNestedObject("_links"); JsonObject& self1 = links.createNestedObject("self"); - self1.set("href", "/stateAdressableRgbLeds/" + obj.getId()); + self1.set("href", "/stateAdressableRgbLeds/" + obj.getTableRow()); JsonObject& self2 = links.createNestedObject("stateAdressableRgbLed"); - self2.set("href", "/stateAdressableRgbLeds/" + obj.getId()); + self2.set("href", "/stateAdressableRgbLeds/" + obj.getTableRow()); char buffer[root.measureLength()]; root.printTo(buffer, sizeof(buffer));