Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gen #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions firmware/src/domain/core/PersistentElement.h
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions firmware/src/domain/core/PersistentService.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef ESP32_PERSISTSERVICE_H
#define ESP32_PERSISTSERVICE_H

#include <string>
#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
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef TEST_ADRESSABLERGBLED_H
#define TEST_ADRESSABLERGBLED_H

#include <domain/valoplus/channelElement.h>
#include <domain/valoplus/StateAdressableRgbLed.h>
#include <string>
#include <domain/valoplus/stateAdressableRgbLed.h>
#include <domain/valoplus/ChannelElement.h>

class AdressableRgbLed : ChannelElement {
class AdressableRgbLed : public ChannelElement {
private:
std::string name;
StateAdressableRgbLed stateAdressableRgbLed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <Arduino.h>
#include <ArduinoJson.h>
#include <domain/valoplus/adressableRgbLed.h>
#include <domain/valoplus/AdressableRgbLed.h>

class AdressableRgbLedJsonService {
private:
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef TEST_CHANNELELEMENT_H
#define TEST_CHANNELELEMENT_H

#include <domain/valoplus/controllableElement.h>
#include <domain/valoplus/ControllableElement.h>

class ChannelElement : ControllableElement {
class ChannelElement : public ControllableElement {
private:

public:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#ifndef TEST_CONTROLLABLEELEMENT_H
#define TEST_CONTROLLABLEELEMENT_H

#include <domain/core/PersistentElement.h>
#include <string>

class ControllableElement {
class ControllableElement : public PersistentElement {
private:

public:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#ifndef TEST_DEVICE_H
#define TEST_DEVICE_H

#include <domain/valoplus/channelElement.h>
#include <domain/valoplus/ControllableElement.h>
#include <string>
#include <domain/valoplus/controllableElement.h>
#include <vector>
#include <domain/valoplus/ChannelElement.h>

class Device : ControllableElement {
class Device : public ControllableElement {
private:

public:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef TEST_GROUP_H
#define TEST_GROUP_H

#include <domain/valoplus/ControllableElement.h>
#include <string>
#include <domain/valoplus/controllableElement.h>
#include <vector>

class Group : ControllableElement {
class Group : public ControllableElement {
private:
std::string name;
std::vector<ControllableElement> members;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <Arduino.h>
#include <ArduinoJson.h>
#include <domain/valoplus/group.h>
#include <domain/valoplus/Group.h>

class GroupJsonService {
private:
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#ifndef TEST_MASTER_H
#define TEST_MASTER_H

#include <domain/valoplus/channelElement.h>
#include <string>
#include <domain/valoplus/device.h>
#include <domain/valoplus/Device.h>
#include <vector>
#include <domain/valoplus/ChannelElement.h>

class Master : Device {
class Master : public Device {
private:
std::string name;
std::string ip;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <Arduino.h>
#include <ArduinoJson.h>
#include <domain/valoplus/master.h>
#include <domain/valoplus/Master.h>

class MasterJsonService {
private:
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef TEST_RGBLED_H
#define TEST_RGBLED_H

#include <domain/valoplus/channelElement.h>
#include <string>
#include <domain/valoplus/ChannelElement.h>

class RgbLed : ChannelElement {
class RgbLed : public ChannelElement {
private:
std::string name;
int channelIdRed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <Arduino.h>
#include <ArduinoJson.h>
#include <domain/valoplus/rgbLed.h>
#include <domain/valoplus/RgbLed.h>

class RgbLedJsonService {
private:
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef TEST_SINGLECOLORLED_H
#define TEST_SINGLECOLORLED_H

#include <domain/valoplus/channelElement.h>
#include <string>
#include <domain/valoplus/ChannelElement.h>

class SingleColorLed : ChannelElement {
class SingleColorLed : public ChannelElement {
private:
std::string name;
int channelId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <Arduino.h>
#include <ArduinoJson.h>
#include <domain/valoplus/singleColorLed.h>
#include <domain/valoplus/SingleColorLed.h>

class SingleColorLedJsonService {
private:
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#ifndef TEST_SLAVE_H
#define TEST_SLAVE_H

#include <domain/valoplus/channelElement.h>
#include <string>
#include <domain/valoplus/device.h>
#include <domain/valoplus/Device.h>
#include <vector>
#include <domain/valoplus/ChannelElement.h>

class Slave : Device {
class Slave : public Device {
private:
std::string name;
std::string ip;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <Arduino.h>
#include <ArduinoJson.h>
#include <domain/valoplus/slave.h>
#include <domain/valoplus/Slave.h>

class SlaveJsonService {
private:
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#ifndef TEST_STATE_H
#define TEST_STATE_H

#include <domain/core/PersistentElement.h>

class State {
class State : public PersistentElement {
private:

public:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef TEST_STATEADRESSABLERGBLED_H
#define TEST_STATEADRESSABLERGBLED_H

#include <domain/valoplus/state.h>
#include <domain/valoplus/State.h>

class StateAdressableRgbLed : State {
class StateAdressableRgbLed : public State {
private:
bool active;
int brightness;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <Arduino.h>
#include <ArduinoJson.h>
#include <domain/valoplus/stateAdressableRgbLed.h>
#include <domain/valoplus/StateAdressableRgbLed.h>

class StateAdressableRgbLedJsonService {
private:
Expand All @@ -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));
Expand Down