From da681b8715c2f37f4ee7e1a6dbe9475dcff74d59 Mon Sep 17 00:00:00 2001
From: kongr45gpen <electrovesta@gmail.com>
Date: Sat, 10 Aug 2019 13:41:13 +0300
Subject: [PATCH] Remove more non-static usages of the MessageParser

---
 inc/Services/TimeBasedSchedulingService.hpp | 2 --
 src/Services/EventActionService.cpp         | 3 +--
 src/Services/TimeBasedSchedulingService.cpp | 6 +++---
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/inc/Services/TimeBasedSchedulingService.hpp b/inc/Services/TimeBasedSchedulingService.hpp
index cc7e119a..e3a6b772 100644
--- a/inc/Services/TimeBasedSchedulingService.hpp
+++ b/inc/Services/TimeBasedSchedulingService.hpp
@@ -54,8 +54,6 @@ private:
 	 */
 	bool executionFunctionStatus = false; // True indicates "enabled" and False "disabled" state
 
-	MessageParser msgParser; // Parse TC packets
-
 	/**
 	 * @brief Request identifier of the received packet
 	 *
diff --git a/src/Services/EventActionService.cpp b/src/Services/EventActionService.cpp
index 26e67d0d..bd06114d 100644
--- a/src/Services/EventActionService.cpp
+++ b/src/Services/EventActionService.cpp
@@ -180,8 +180,7 @@ void EventActionService::executeAction(uint16_t eventID) {
 		auto range = eventActionDefinitionMap.equal_range(eventID);
 		for (auto& element = range.first; element != range.second; ++element) {
 			if (element->second.enabled) {
-				MessageParser messageParser;
-				Message message = messageParser.parseECSSTC(element->second.request);
+				Message message = MessageParser::parseECSSTC(element->second.request);
 				MessageParser::execute(message);
 			}
 		}
diff --git a/src/Services/TimeBasedSchedulingService.cpp b/src/Services/TimeBasedSchedulingService.cpp
index d917585e..d381318e 100644
--- a/src/Services/TimeBasedSchedulingService.cpp
+++ b/src/Services/TimeBasedSchedulingService.cpp
@@ -49,7 +49,7 @@ void TimeBasedSchedulingService::insertActivities(Message& request) {
 			// Get the TC packet request
 			uint8_t requestData[ECSS_TC_REQUEST_STRING_SIZE] = {0};
 			request.readString(requestData, ECSS_TC_REQUEST_STRING_SIZE);
-			Message receivedTCPacket = msgParser.parseECSSTC(requestData);
+			Message receivedTCPacket = MessageParser::parseECSSTC(requestData);
 			ScheduledActivity newActivity; // Create the new activity
 
 			// Assign the attributes to the newly created activity
@@ -168,7 +168,7 @@ void TimeBasedSchedulingService::detailReportAllActivities(Message& request) {
 		// todo: append sub-schedule and group ID if they are defined
 
 		report.appendUint32(activity.requestReleaseTime);
-		report.appendString(msgParser.composeECSS(activity.request));
+		report.appendString(MessageParser::composeECSS(activity.request));
 	}
 	storeMessage(report); // Save the report
 }
@@ -209,7 +209,7 @@ void TimeBasedSchedulingService::detailReportActivitiesByID(Message& request) {
 	report.appendUint16(static_cast<uint16_t>(matchedActivities.size()));
 	for (auto& match : matchedActivities) {
 		report.appendUint32(match.requestReleaseTime); // todo: Replace with the time parser
-		report.appendString(msgParser.composeECSS(match.request));
+		report.appendString(MessageParser::composeECSS(match.request));
 	}
 	storeMessage(report); // Save the report
 }
-- 
GitLab