From 61c5514ce19ce3d537a55acc10c93e6550b981c2 Mon Sep 17 00:00:00 2001
From: athatheocsd <athatheo@csd.auth.gr>
Date: Wed, 26 Dec 2018 20:53:20 +0200
Subject: [PATCH] Updated MessageParser::execute function Added test basics

---
 inc/Message.hpp                     |  2 ++
 inc/MessageParser.hpp               | 11 +++++++++++
 inc/Services/EventActionService.hpp |  7 +------
 src/MessageParser.cpp               |  3 ---
 src/Services/EventActionService.cpp |  2 +-
 5 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/inc/Message.hpp b/inc/Message.hpp
index 0d4aa67d..f42b7a3c 100644
--- a/inc/Message.hpp
+++ b/inc/Message.hpp
@@ -20,6 +20,8 @@ class Message;
  */
 class Message {
 public:
+	Message (){}
+
 	enum PacketType {
 		TM = 0, // Telemetry
 		TC = 1 // Telecommand
diff --git a/inc/MessageParser.hpp b/inc/MessageParser.hpp
index 9de268e4..a8cbaa4c 100644
--- a/inc/MessageParser.hpp
+++ b/inc/MessageParser.hpp
@@ -37,6 +37,17 @@ public:
 	 */
 	Message parse(uint8_t * data, uint32_t length);
 
+	/**
+	 * @todo: elaborate on this comment
+	 * Create a message so that a string can be parsed
+	 */
+	Message parseTC(String<256> data, ){
+		Message message;
+		message.packetType = Message::TC;
+		parseTC(data, 15, message);
+		return message;
+	}
+
 private:
 	/**
 	 * Parse the ECSS Telecommand packet secondary header
diff --git a/inc/Services/EventActionService.hpp b/inc/Services/EventActionService.hpp
index 22f94e49..a355be1d 100644
--- a/inc/Services/EventActionService.hpp
+++ b/inc/Services/EventActionService.hpp
@@ -97,7 +97,7 @@ public:
 	 * Custom function that is called right after an event takes place, to initiate
 	 * the execution of the action
 	 */
-	void execute(Message &message);
+	void executeAction(Message &message);
 
 	/**
 	 * Setter for event-action function status
@@ -105,11 +105,6 @@ public:
 	void setEventActionFunctionStatus(EventActionFunctionStatus e) {
 		eventActionFunctionStatus = e;
 	}
-
-	/**
-	 * The purpose of this instance is to access the execute function
-	 */
-	 static EventActionService instance;
 };
 
 #endif //ECSS_SERVICES_EVENTACTIONSERVICE_HPP
diff --git a/src/MessageParser.cpp b/src/MessageParser.cpp
index f9b0394c..b27ee179 100644
--- a/src/MessageParser.cpp
+++ b/src/MessageParser.cpp
@@ -8,7 +8,6 @@
 
 TestService TestService::instance;
 RequestVerificationService RequestVerificationService::instance;
-EventActionService EventActionService::instance;
 
 void MessageParser::execute(Message &message) {
 	switch (message.serviceType) {
@@ -18,8 +17,6 @@ void MessageParser::execute(Message &message) {
 		case 17:
 			TestService::instance.execute(message);
 			break;
-		case 19:
-			EventActionService::instance.execute(message);
 		default:
 			// cout is very bad for embedded systems
 			std::cout << "This service hasn't been implemented yet or it doesn't exist";
diff --git a/src/Services/EventActionService.cpp b/src/Services/EventActionService.cpp
index 497d3aa8..51fb0750 100644
--- a/src/Services/EventActionService.cpp
+++ b/src/Services/EventActionService.cpp
@@ -170,7 +170,7 @@ void EventActionService::disableEventActionFunction(Message message) {
 		setEventActionFunctionStatus(EventActionFunctionStatus::disabledFunction);
 	}
 }
-
+// Should I use the name execute here instead of executeAction?
 void EventActionService::execute(Message &message) {
 	// Custom function
 	if (eventActionFunctionStatus == enabledFunction) {
-- 
GitLab