Skip to content
Snippets Groups Projects
Commit 2d74207f authored by athatheocsd's avatar athatheocsd
Browse files

Added Features

parent 9b78c519
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "Service.hpp" #include "Service.hpp"
#include "MessageParser.hpp" #include "MessageParser.hpp"
#include "etl/String.hpp" #include "etl/String.hpp"
#include <bitset>
/** /**
* Implementation of ST[19] event-action Service * Implementation of ST[19] event-action Service
...@@ -22,6 +23,7 @@ ...@@ -22,6 +23,7 @@
class EventActionService : public Service { class EventActionService : public Service {
private: private:
uint8_t eventActionFunctionStatus; // Indicates if actions are enabled uint8_t eventActionFunctionStatus; // Indicates if actions are enabled
std::bitset<256> stateOfEventAction;
struct EventActionDefinition { struct EventActionDefinition {
uint8_t empty = 1; // 1 means empty, 0 means full uint8_t empty = 1; // 1 means empty, 0 means full
uint16_t applicationId = 0; uint16_t applicationId = 0;
...@@ -35,6 +37,7 @@ public: ...@@ -35,6 +37,7 @@ public:
EventActionService() { EventActionService() {
serviceType = 19; serviceType = 19;
eventActionFunctionStatus = enabledFunction; eventActionFunctionStatus = enabledFunction;
stateOfEventAction.set();
} }
/** /**
......
...@@ -86,8 +86,23 @@ void EventActionService::enableEventActionDefinitions(Message message) { ...@@ -86,8 +86,23 @@ void EventActionService::enableEventActionDefinitions(Message message) {
if (message.messageType == 4 && message.packetType == Message::TC && message.serviceType if (message.messageType == 4 && message.packetType == Message::TC && message.serviceType
== 19) { == 19) {
uint16_t N = message.readUint16(); uint16_t N = message.readUint16();
uint8_t index = 0;
uint8_t flag = 0; // used as boolean 0 is false, 1 is true
for (uint16_t i = 0; i < N; i++) { for (uint16_t i = 0; i < N; i++) {
uint16_t applicationID = message.readEnum16();
uint16_t eventDefinitionID = message.readEnum16();
while (eventActionDefinitionArray[index].applicationId != applicationID ||
eventActionDefinitionArray[index].eventDefinitionID != eventDefinitionID){
if (index == 255){ // 255 should be changed depending on size of the array
flag = 1;
break;
}
index++;
}
if (flag == 0){ // Found
stateOfEventAction[index] = 1;
}
index = 0;
} }
} }
...@@ -98,10 +113,24 @@ void EventActionService::disableEventActionDefinitions(Message message) { ...@@ -98,10 +113,24 @@ void EventActionService::disableEventActionDefinitions(Message message) {
if (message.messageType == 5 && message.packetType == Message::TC && message.serviceType if (message.messageType == 5 && message.packetType == Message::TC && message.serviceType
== 19) { == 19) {
uint16_t N = message.readUint16(); uint16_t N = message.readUint16();
uint8_t index = 0;
uint8_t flag = 0; // used as boolean 0 is false, 1 is true
for (uint16_t i = 0; i < N; i++) { for (uint16_t i = 0; i < N; i++) {
uint16_t applicationID = message.readEnum16();
uint16_t eventDefinitionID = message.readEnum16();
while (eventActionDefinitionArray[index].applicationId != applicationID ||
eventActionDefinitionArray[index].eventDefinitionID != eventDefinitionID){
if (index == 255){ // 255 should be changed depending on size of the array
flag = 1;
break;
}
index++;
}
if (flag == 0){ // Found
stateOfEventAction[index] = 0;
}
index = 0;
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment