-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bart Wesselink
committed
Jun 16, 2022
1 parent
07aa403
commit 372bf6b
Showing
19 changed files
with
368 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...llerdsl/src/nl/tue/robotsupervisorycontrollerdsl/generator/cpp/logging/LogGenerator.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package nl.tue.robotsupervisorycontrollerdsl.generator.cpp.logging | ||
|
||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class LogGenerator { | ||
def compileImports()''' | ||
#include <iostream> | ||
#include <fstream> | ||
''' | ||
|
||
def compileFields()''' | ||
std::ofstream logging_out_file; | ||
std::ofstream logging_in_file; | ||
''' | ||
def compileFunctions()''' | ||
std::string logging_time_human() { | ||
std::time_t rawtime; | ||
char buffer[80]; | ||
|
||
std::time (&rawtime); | ||
auto local = std::localtime(&rawtime); | ||
|
||
std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", local); | ||
std::string output(buffer); | ||
|
||
return output; | ||
} | ||
|
||
std::string logging_time_machine() { | ||
std::time_t rawtime; | ||
char buffer[80]; | ||
|
||
std::time (&rawtime); | ||
auto local = std::localtime(&rawtime); | ||
|
||
std::strftime(buffer, sizeof(buffer), "%Y_%m_%d_%H_%M_%S", local); | ||
std::string output(buffer); | ||
|
||
return output; | ||
} | ||
|
||
void start_logging() { | ||
logging_out_file.open("node_out_" + logging_time_machine() + ".log"); | ||
logging_in_file.open("node_in_" + logging_time_machine() + ".log"); | ||
} | ||
|
||
void write_to_incoming_log(std::string value) { | ||
logging_out_file << "[" << logging_time_human() << "] "<< value << std::endl; | ||
} | ||
|
||
void write_to_outgoing_log(std::string value) { | ||
logging_out_file << "[" << logging_time_human() << "] "<< value << std::endl; | ||
} | ||
''' | ||
def compileInitialization()''' | ||
this->start_logging(); | ||
''' | ||
def compileDestruction()''' | ||
logging_in_file.close(); | ||
logging_out_file.close(); | ||
''' | ||
} |
24 changes: 24 additions & 0 deletions
24
...l/src/nl/tue/robotsupervisorycontrollerdsl/generator/cpp/logging/LogOutputConverter.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package nl.tue.robotsupervisorycontrollerdsl.generator.cpp.logging | ||
|
||
import nl.tue.robotsupervisorycontrollerdsl.robotSupervisoryControllerDSL.Message | ||
import javax.inject.Singleton | ||
import nl.tue.robotsupervisorycontrollerdsl.generator.common.naming.DefaultIdentifierNamer | ||
import javax.inject.Inject | ||
import nl.tue.robotsupervisorycontrollerdsl.robotSupervisoryControllerDSL.Service | ||
import nl.tue.robotsupervisorycontrollerdsl.robotSupervisoryControllerDSL.Action | ||
|
||
@Singleton | ||
class LogOutputConverter { | ||
@Inject DefaultIdentifierNamer namer | ||
|
||
dispatch def responseOutput(Message entity)'''Response from message «entity.name» (identifier «namer.name(entity)») ''' | ||
dispatch def responseOutput(Service entity)'''Response from service «entity.name» (identifier «namer.name(entity)») ''' | ||
dispatch def responseOutput(Action entity)'''Response from action «entity.name» (identifier «namer.name(entity)») ''' | ||
|
||
dispatch def requestOutput(Message entity)'''Request to message «entity.name» (identifier «namer.name(entity)») ''' | ||
dispatch def requestOutput(Service entity)'''Request to service «entity.name» (identifier «namer.name(entity)») ''' | ||
dispatch def requestOutput(Action entity)'''Request to action «entity.name» (identifier «namer.name(entity)») ''' | ||
|
||
def feedbackOutput(Action entity)'''Feedback from action «entity.name» (identifier «namer.name(entity)») ''' | ||
def cancelOutput(Action entity)'''Cancelling action «entity.name» (identifier «namer.name(entity)») ''' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.