MeshProtocolSimulator
1.0.0
|
Public Member Functions | |
bool | begin (const JSONSettings &settings, std::string path) |
Begins simulation logging. More... | |
void | terminate () |
Terminates logging and closes file. Output file "status" property will be set to "terminated". More... | |
void | end (int errorCode, std::string errorText) |
Ends logging and closes file. Output file "status" property will be set to "success" or "error" depends on error code. More... | |
void | exceptionEnd (int errorCode, std::string errorText) |
Ends logging and closes file. Output file "status" property will be set to "success" or "exception" depends on error code. More... | |
void | end () |
Ends logging and closes file. Output file "status" property will be set to "success". More... | |
void | logMessageTransmit (RawMessage &message) |
Logs message transmission to output log file. More... | |
void | logMessageReceive (MeshMAC node, std::chrono::nanoseconds receiveTime, RawMessage &message, float RSSI) |
Logs message receiving to output log file. More... | |
void | logReceiveInterference (MeshMAC node, std::chrono::nanoseconds simulationTime, MeshMAC sender_node1, uint64_t sender_node1_UID, float rssi1, MeshMAC sender_node2, uint64_t sender_node2_UID, float rssi2) |
Logs receive interference (two nodes sends simultaneously and message cannot be received by "node") to output log file. More... | |
void | logTransmitInterference (MeshMAC node, uint64_t node_UID, std::chrono::nanoseconds simulationTime, MeshMAC sender_node, uint64_t sender_node_UID, float RSSI) |
Logs transmit interference (one node is sending message and another wants to send him message) to output log file. More... | |
void | logMessageLost (MeshMAC sender, MeshMAC receiver, uint64_t node_UID, std::chrono::nanoseconds simulationTime, float RSSI) |
Logs lost message due to bad link quality to output log file. More... | |
void | logAPLReceived (MeshMAC node, MeshMAC sender_node, std::chrono::nanoseconds simulationTime, char *messageData, size_t length) |
Logs application layer received message to output log file. More... | |
void | logTableChange (MeshMAC node, std::string &descriptor, TableChangeType changeType, std::chrono::nanoseconds simulationTime, const char *data, size_t length) |
Logs application layer received message to output log file. More... | |
Static Public Member Functions | |
static std::string | EncodeSpecialCharacters (const char *text, size_t inLength) |
Encodes special characters in json string value. Escaped characters are '', '\f', ' ', '\r', '\t', '\', '"', '\0'. More... | |
static std::string | EncodeSpecialCharacters (std::string &text) |
Encodes special characters in json string value. Escaped characters are '', '\f', ' ', '\r', '\t', '\', '"', '\0'. More... | |
static std::string | GetCurrentTimeISO8601 () |
Gets current pc time and converts it to ISO 8601. More... | |
Public Attributes | |
std::string | version = "0.0.1" |
Emulator version. | |
Protected Attributes | |
bool | beginCalled = false |
std::chrono::steady_clock::time_point | simulationStartTime |
std::ofstream | outFile |
bool | anyLogWritten = false |
bool JSONLogsWriter::begin | ( | const JSONSettings & | settings, |
std::string | path | ||
) |
Begins simulation logging.
settings | Initial simulation settings. Those settings has to be validated before passing here. |
path | Path, where will be output JSON file stored. |
|
static |
Encodes special characters in json string value. Escaped characters are '', '\f', '
', '\r', '\t', '\', '"', '\0'.
text | Text to check. |
inLength | Count of characters in text. |
|
inlinestatic |
Encodes special characters in json string value. Escaped characters are '', '\f', '
', '\r', '\t', '\', '"', '\0'.
text | Text to check. |
void JSONLogsWriter::end | ( | ) |
Ends logging and closes file. Output file "status" property will be set to "success".
void JSONLogsWriter::end | ( | int | errorCode, |
std::string | errorText | ||
) |
Ends logging and closes file. Output file "status" property will be set to "success" or "error" depends on error code.
errorCode | Error code. When set to 0, "status" property will be set to "success". |
errorText | Text, that describes an error, that happened. Igored when errorCode is 0. |
void JSONLogsWriter::exceptionEnd | ( | int | errorCode, |
std::string | errorText | ||
) |
Ends logging and closes file. Output file "status" property will be set to "success" or "exception" depends on error code.
errorCode | Error code. When set to 0, "status" property will be set to "success". |
errorText | Text, that describes an exception, that happened. Igored when errorCode is 0. |
|
static |
Gets current pc time and converts it to ISO 8601.
void JSONLogsWriter::logAPLReceived | ( | MeshMAC | node, |
MeshMAC | sender_node, | ||
std::chrono::nanoseconds | simulationTime, | ||
char * | messageData, | ||
size_t | length | ||
) |
Logs application layer received message to output log file.
node | MAC address of node, which received message. |
sender_node | MAC address of node, the data was received from. |
simulationTime | Simulation time, when message was received by application layer. |
messageData | Data, which was received. |
length | Length of message data. |
void JSONLogsWriter::logMessageLost | ( | MeshMAC | sender, |
MeshMAC | receiver, | ||
uint64_t | node_UID, | ||
std::chrono::nanoseconds | simulationTime, | ||
float | RSSI | ||
) |
Logs lost message due to bad link quality to output log file.
sender | MAC address of node, which sent message. |
receiver | MAC address of node, which cannot receive message. |
node_UID | Unique message identifier. |
simulationTime | Simulation time, when this issue happened. |
RSSI | RSSI value of message. |
void JSONLogsWriter::logMessageReceive | ( | MeshMAC | node, |
std::chrono::nanoseconds | receiveTime, | ||
RawMessage & | message, | ||
float | RSSI | ||
) |
Logs message receiving to output log file.
node | MAC address of node, which received message. |
receiveTime | Simulation time, when message was received by node. |
message | Received message. |
RSSI | RSSI value of received message. |
void JSONLogsWriter::logMessageTransmit | ( | RawMessage & | message | ) |
Logs message transmission to output log file.
message | Transmitted message. |
void JSONLogsWriter::logReceiveInterference | ( | MeshMAC | node, |
std::chrono::nanoseconds | simulationTime, | ||
MeshMAC | sender_node1, | ||
uint64_t | sender_node1_UID, | ||
float | rssi1, | ||
MeshMAC | sender_node2, | ||
uint64_t | sender_node2_UID, | ||
float | rssi2 | ||
) |
Logs receive interference (two nodes sends simultaneously and message cannot be received by "node") to output log file.
node | MAC address of node, which cannot receive message. |
simulationTime | Simulation time, when interference happened. |
sender_node1 | MAC address of first sender node, which caused interference. |
sender_node1_UID | First sender node's unique message identifier. |
rssi1 | RSSI value of first message. |
sender_node2 | MAC address of second sender node, which caused interference. |
sender_node2_UID | Second sender node's unique message identifier. |
rssi2 | RSSI value of second message. |
void JSONLogsWriter::logTableChange | ( | MeshMAC | node, |
std::string & | descriptor, | ||
TableChangeType | changeType, | ||
std::chrono::nanoseconds | simulationTime, | ||
const char * | data, | ||
size_t | length | ||
) |
Logs application layer received message to output log file.
node | MAC address of node, which table was changed. |
descriptor | Table descriptor. |
changeType | Type of change. |
simulationTime | Simulation time, when table change happened. |
data | Data of change. |
length | Length of data. |
void JSONLogsWriter::logTransmitInterference | ( | MeshMAC | node, |
uint64_t | node_UID, | ||
std::chrono::nanoseconds | simulationTime, | ||
MeshMAC | sender_node, | ||
uint64_t | sender_node_UID, | ||
float | RSSI | ||
) |
Logs transmit interference (one node is sending message and another wants to send him message) to output log file.
node | MAC address of node, which cannot receive message, because it is already sending message. |
node_UID | Sender node's unique message identifier. |
simulationTime | Simulation time, when interference happened. |
sender_node | MAC address of sender node, which caused interference. |
sender_node_UID | Sender node's unique message identifier. |
RSSI | RSSI value of first sent message. |
void JSONLogsWriter::terminate | ( | ) |
Terminates logging and closes file. Output file "status" property will be set to "terminated".