Skip to content

Commit 54734ad

Browse files
committed
still integration
1 parent e61b024 commit 54734ad

4 files changed

Lines changed: 13 additions & 14 deletions

File tree

Inc/HALAL/Services/Time/Time.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public :
130130
uint16_t year;
131131

132132
string serialize() const {
133-
return "counter: " + to_string(counter) + ",second: " + to_string(second) + ",minute: " + to_string(minute) + ",hour: " + to_string(hour) + ",day: " + to_string(day) + ",month: " + to_string(month) + ",year: " + to_string(year);
133+
return "\"counter\": " + to_string(counter) + ",\"second\": " + to_string(second) + ",\"minute\": " + to_string(minute) + ",\"hour\": " + to_string(hour) + ",\"day\": " + to_string(day) + ",\"month\": " + to_string(month) + ",\"year\": " + to_string(year);
134134
}
135135

136136
static size_t get_string_size(const RTCData& to_serialize){

Inc/ST-LIB_HIGH/Protections/Boundary.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ template<class Type, ProtectionType Protector> struct Boundary;
3333
template<class Type>
3434
struct Boundary<Type, BELOW> : public BoundaryInterface{
3535
static constexpr ProtectionType Protector = BELOW;
36-
static constexpr const char* format = "\"type\": LOWER_BOUND, \"data\": { \"value\": %s, \"bound\": %s }";
36+
static constexpr const char* format = "\"type\": \"LOWER_BOUND\", \"data\": { \"value\": %s, \"bound\": %s }";
3737
Type* src = nullptr;
3838
Type boundary;
3939
Boundary(Type boundary): boundary(boundary){};
@@ -55,7 +55,7 @@ struct Boundary<Type, BELOW> : public BoundaryInterface{
5555
template<class Type>
5656
struct Boundary<Type, ABOVE> : public BoundaryInterface{
5757
static constexpr ProtectionType Protector = ABOVE;
58-
static constexpr const char* format = "\"type\": UPPER_BOUND, \"data\": { \"value\": %s, \"bound\": %s }";
58+
static constexpr const char* format = "\"type\": \"UPPER_BOUND\", \"data\": { \"value\": %s, \"bound\": %s }";
5959
Type* src = nullptr;
6060
Type boundary;
6161
Boundary(Type boundary): boundary(boundary){};
@@ -77,7 +77,7 @@ struct Boundary<Type, ABOVE> : public BoundaryInterface{
7777
template<class Type>
7878
struct Boundary<Type, EQUALS> : public BoundaryInterface{
7979
static constexpr ProtectionType Protector = EQUALS;
80-
static constexpr const char* format = "\"type\": EQUALS, \"data\": { \"value\": %s, \"bound\": %s }";
80+
static constexpr const char* format = "\"type\": \"EQUALS\", \"data\": { \"value\": %s, \"bound\": %s }";
8181
Type* src = nullptr;
8282
Type boundary;
8383
Boundary(Type boundary): boundary(boundary){};
@@ -99,7 +99,7 @@ struct Boundary<Type, EQUALS> : public BoundaryInterface{
9999
template<class Type>
100100
struct Boundary<Type, NOT_EQUALS> : public BoundaryInterface{
101101
static constexpr ProtectionType Protector = NOT_EQUALS;
102-
static constexpr const char* format = "\"type\": NOT_EQUALS, \"data\": { \"value\": %s, \"bound\": %s }";
102+
static constexpr const char* format = "\"type\": \"NOT_EQUALS\", \"data\": { \"value\": %s, \"bound\": %s }";
103103
Type* src = nullptr;
104104
Type boundary;
105105
Boundary(Type boundary): boundary(boundary){};
@@ -121,7 +121,7 @@ struct Boundary<Type, NOT_EQUALS> : public BoundaryInterface{
121121
template<class Type>
122122
struct Boundary<Type, OUT_OF_RANGE> : public BoundaryInterface{
123123
static constexpr ProtectionType Protector = OUT_OF_RANGE;
124-
static constexpr const char* format = "\"type\": OUT_OF_BOUNDS, \"data\": { \"value\": %s, \"bounds\": [%s, %s] }";
124+
static constexpr const char* format = "\"type\": \"OUT_OF_BOUNDS\", \"data\": { \"value\": %s, \"bounds\": [%s, %s] }";
125125
Type* src = nullptr;
126126
Type lower_boundary, upper_boundary;
127127
Boundary(Type lower_boundary, Type upper_boundary): lower_boundary(lower_boundary), upper_boundary(upper_boundary){};
@@ -143,7 +143,7 @@ struct Boundary<Type, OUT_OF_RANGE> : public BoundaryInterface{
143143
template<>
144144
struct Boundary<void, ERROR_HANDLER> : public BoundaryInterface{
145145
static constexpr ProtectionType Protector = ERROR_HANDLER;
146-
static constexpr const char* format = "\"type\": ERROR_HANDLER, \"data\": %s ";
146+
static constexpr const char* format = "\"type\": \"ERROR_HANDLER\", \"data\": %s ";
147147
Boundary() = default;
148148
bool check_bounds() override{
149149
return ErrorHandlerModel::error_triggered;
@@ -160,7 +160,7 @@ struct Boundary<void, ERROR_HANDLER> : public BoundaryInterface{
160160
template<>
161161
struct Boundary<double, TIME_ACCUMULATION> : public BoundaryInterface{
162162
static constexpr ProtectionType Protector = TIME_ACCUMULATION;
163-
static constexpr const char* format = "\"type\": TIME_ACCUMULATION, \"data\": { \"value\": %s, \"bound\": %s,\"timelimit\": %s }";
163+
static constexpr const char* format = "\"type\": \"TIME_ACCUMULATION\", \"data\": { \"value\": %s, \"bound\": %s,\"timelimit\": %s }";
164164
double* src = nullptr;
165165
double bound;
166166
float time_limit;
@@ -220,7 +220,7 @@ struct Boundary<double, TIME_ACCUMULATION> : public BoundaryInterface{
220220
template<>
221221
struct Boundary<float, TIME_ACCUMULATION> : public BoundaryInterface{
222222
static constexpr ProtectionType Protector = TIME_ACCUMULATION;
223-
static constexpr const char* format = "\"type\": TIME_ACCUMULATION, \"data\": { \"value\": %s, \"bound\": %s,\"timelimit\": %s }";
223+
static constexpr const char* format = "\"type\": \"TIME_ACCUMULATION\", \"data\": { \"value\": %s, \"bound\": %s,\"timelimit\": %s }";
224224
float* src = nullptr;
225225
float bound;
226226
float time_limit;

Inc/ST-LIB_HIGH/Protections/Notification.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ class Notification : public Order{
1515
message_size_t tx_message_size;
1616
string rx_message;
1717
uint8_t* buffer = nullptr;
18-
static constexpr size_t null_length = 1;
1918
OrderProtocol* received_socket = nullptr;
2019
public:
21-
Notification(uint16_t packet_id,void(*callback)() ,string message) : id(packet_id), callback(callback),tx_message(message), tx_message_size(message.size() + null_length){
20+
Notification(uint16_t packet_id,void(*callback)() ,string message) : id(packet_id), callback(callback),tx_message(message), tx_message_size(message.size()){
2221
Order::orders[id] = this;
2322
Packet::packets[id] = this;
2423
}
@@ -49,13 +48,13 @@ class Notification : public Order{
4948

5049
memcpy(buffer,&id,sizeof(id));
5150
memcpy(buffer + sizeof(id), &tx_message_size, sizeof(tx_message_size));
52-
memcpy(buffer+sizeof(id)+sizeof(tx_message_size),tx_message.c_str(), tx_message.size() + null_length);
51+
memcpy(buffer+sizeof(id)+sizeof(tx_message_size),tx_message.c_str(), tx_message.size());
5352
return buffer;
5453
}
5554

5655
void notify(string message){
5756
tx_message = message;
58-
tx_message_size = message.size() + null_length;
57+
tx_message_size = message.size();
5958
notify();
6059
}
6160

Inc/ST-LIB_HIGH/Protections/Protection.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ enum FaultType{
1111

1212
class Protection{
1313
private:
14-
static constexpr const char* format = "\"protection\" : {\"name\":%s, %s}";
14+
static constexpr const char* format = "\"protection\" : {\"name\":\"%s\", %s}";
1515
char* name = nullptr;
1616
vector<unique_ptr<BoundaryInterface>> boundaries;
1717
BoundaryInterface* jumped_protection = nullptr;

0 commit comments

Comments
 (0)