Skip to content

Commit

Permalink
Merge pull request #63 from genesfa/main
Browse files Browse the repository at this point in the history
Improve documentation
  • Loading branch information
Bl4d3s committed Dec 21, 2021
2 parents e52bf05 + 567e547 commit 87cbbc0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 56 deletions.
87 changes: 37 additions & 50 deletions Sim_To_DuT_Interface/Sim_Communication/SimComHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ namespace sim_interface {
* Constructor: Create a new handler.
* @param interface A pointer to communicate with the interface.
* @param config System configuration.
* @param socketSimPub_: Create socket for publishing messages to simulation
* @param socketSimSub_: Create socket for subscribing messages from simulation
* @param socketSimSubConfig_: Create socket for subscribing xml-configuration from simulation
* socketSimPub_: Create socket for publishing messages to simulation
* socketSimSub_: Create socket for subscribing messages from simulation
* socketSimSubConfig_: Create socket for subscribing xml-configuration from simulation
*
* Configure sockets with the addresses from the config
* @param context_recConfig: Defines the context of the zmq socket for the xml-Configuration
* context_recConfig: Defines the context of the zmq socket for the xml-Configuration
* Set the sockets to subscriber sockets and listen to any String
*
* Open connecting of the sockets:
Expand All @@ -74,31 +74,31 @@ namespace sim_interface {

/**
* Asynchronous sending of events to simulation.
* @param logSimEvent: For Logging the SimEvents
* @param simEvent: An event that should be sent to the simulation.
* @param simEventMap: A variable Map for events to the Simulation
* logSimEvent: For Logging the SimEvents
* simEventMap: A variable Map for events to the Simulation
* adding keys and values to the simEventMap
* @param simEventsStringStream: output stringstream for publishing
* @param archiveSimEvent: put the stringstream into the output text archive
* simEventsStringStream: output stringstream for publishing
* archiveSimEvent: put the stringstream into the output text archive
* write the Map to the archive
* @param simEventData: Convert simEventsStringStream into a string
* @param msgToSend: preparing zmq:message type for publishing
* simEventData: Convert simEventsStringStream into a string
* msgToSend: preparing zmq:message type for publishing
* Send message via socket and start logger for event
*/
void sendEventToSim(const SimEvent &simEvent);

/**
* Starts the handler to asynchronously receive incoming events.
* while loop: ends, if the thread was stopped
* @param replySimData: zmq message, which contains serialized data from the simulation
* replySimData: zmq message, which contains serialized data from the simulation
* Receive the serialized simulation data e.g. Speed with exception-handling
* If receiving is failed, unbind and disconnect the sockets
* Start logging
* @param bufSimData: Buffer with the serialized string
* @param inputSimData: Convert the buffer into a string
* @param archiveStreamSimData: for writing the inputSimData
* @param archiveSimData: input text archive for writing the inputSimData stringstream
* @param receiveMapSimData: variable map with operations and value e.g. speed 13.05
* bufSimData: Buffer with the serialized string
* inputSimData: Convert the buffer into a string
* archiveStreamSimData: for writing the inputSimData
* archiveSimData: input text archive for writing the inputSimData stringstream
* receiveMapSimData: variable map with operations and value e.g. speed 13.05
* writing the archive into the map with exception handling
* start logging, if writing failed
* for each loop: run through element from the receiveMapSimData
Expand All @@ -108,20 +108,20 @@ namespace sim_interface {
void receive();

/**
* @param replyConfig: zmq message, which contains serialized data from the xml-config
* replyConfig: zmq message, which contains serialized data from the xml-config
* Receive the serialized data from the xml-config with exception-handling
* If receiving is failed, unbind and disconnect the sockets
* Start logging
* @param bufConfig: Buffer with the serialized string from the xml-config
* @param tree: Property tree for deserialize the xml-config
* @param convertedSimConfigBuffer: output stringstream for converting the buffer
* @param SimConfigString: convert the output stringstream to a string
* bufConfig: Buffer with the serialized string from the xml-config
* tree: Property tree for deserialize the xml-config
* convertedSimConfigBuffer: output stringstream for converting the buffer
* SimConfigString: convert the output stringstream to a string
* With these parameters parsing the XML into the property tree.
* If parsing is failed, unbind and disconnect the sockets
* Start logging
*
* @param connectorTypes: create String for copmaring the names of the connectortypes
* @param xmlWriterSettings: preparing an xml writer with property tree
* connectorTypes: create String for copmaring the names of the connectortypes
* xmlWriterSettings: preparing an xml writer with property tree
*
* for each loop: run through each value type in a xml-file and get every value in connectors tags
* save the classtype of the xml attribute into the connectorTypes string for comparing
Expand All @@ -130,12 +130,12 @@ namespace sim_interface {
* The principle of the deserializing for the three connector are working very similar
* Exception handling and logging
* The principle will be explained with RESTDummyConnector:
* @param restXMLStringStream: stringstream for writing the xml file
* restXMLStringStream: stringstream for writing the xml file
* writing the xml file with these parameters
* @param restXMLString: Convert the stringstream to a string
* restXMLString: Convert the stringstream to a string
* replace not needed tags in the xml-file to make it shorter
* @param restConnectorConfig: Create Pointer from type RESTConnectorConfig
* @param xmliStringStream: Convert the string to a input stringstream for deserialization
* restConnectorConfig: Create Pointer from type RESTConnectorConfig
* xmliStringStream: Convert the string to a input stringstream for deserialization
* Deserialize the received RESTDummyConnector from xml-config
* Create RestConnector object and put it in the queue of the DuTToSim
* Add it to the interface
Expand All @@ -145,7 +145,7 @@ namespace sim_interface {
void getConfig();

/**
* @param connectorType: numeration for the various connectorType
* connectorType: numeration for the various connectorType
* RESTDummyConnector
* CANConnector
* V2XConnector
Expand Down Expand Up @@ -198,28 +198,15 @@ namespace sim_interface {
*/
void sendEventToInterface(const SimEvent &simEvent);

/**
* Create zmq sockets for Publisher and Subscrribe
* @param socketSimSub: Socket for Interface subscriber
* @param socketSimPub: Socket for Interface publisher
* @param socketSimSubConfig_: Socket for Interface subscriber for the configuration
* @param socketSimAddressPub: String for the address socket for publisher to simulation
* @param socketSimAddressSub: String for the address socket for subsriber from simulation
* @param socketSimAddressReceiverConfig: String for the address socket for subscriber for xml-Configuration from simulation
* @param simComHandlerThread: Thread for receiving simulation data
* @param stopThread: boolean for start/stop the thread
* @param SimToDuTInterface: Pointer form object SimToDuTInterface for adding connectors
*/

zmq::socket_t socketSimSub_;
zmq::socket_t socketSimPub_;
zmq::socket_t socketSimSubConfig_;
std::string socketSimAddressSub;
std::string socketSimAddressPub;
std::string socketSimAddressReceiverConfig;
std::thread simComHandlerThread;
bool stopThread = true;
SimToDuTInterface *interface;
zmq::socket_t socketSimSub_; /**< Socket for Interface subscriber */
zmq::socket_t socketSimPub_; /**< Socket for Interface publisher */
zmq::socket_t socketSimSubConfig_; /**< Socket for Interface subscriber for the configuration */
std::string socketSimAddressSub; /**< String for the address socket for subscriber from simulation. */
std::string socketSimAddressPub; /**< String for the address socket for publisher to simulation. */
std::string socketSimAddressReceiverConfig; /**< String for the address socket for subscriber for xml-Configuration from simulation. */
std::thread simComHandlerThread; /**< Thread for receiving simulation data. */
bool stopThread = true; /**< boolean for starting/stopping the thread. */
SimToDuTInterface *interface; /**< Pointer form object SimToDuTInterface for adding connectors. */
};
}

Expand Down
12 changes: 6 additions & 6 deletions Sim_To_DuT_Interface/Utility/ConfigSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ namespace sim_interface {
class ConfigSerializer {
public:
/**
* @param T: Templates for any type, so that the following methods can be used by them
* T: Templates for any type, so that the following methods can be used by them
* method:deserialize
* @param ifs: address of an input stringstream
* @param objName: address of name of a object
* @param obj: pointer of any type of object
*
* if: when the input string stream is available
* exception handling: catching archive exception and start InterfaceLogger:
* @param iss: create an input stringstream
* @param ia: create an xml input archive with the input stringstream and no header
* iss: create an input stringstream
* ia: create an xml input archive with the input stringstream and no header
* deserialize the object
* catch the exception if the deserialisation failed and start logging
* else: start logging:
Expand All @@ -97,15 +97,15 @@ namespace sim_interface {
}

/**
* @param T: Templates for any type, so that the following methods can be used by them
* T: Templates for any type, so that the following methods can be used by them
* method:serialize
* @param objName: address of a string --> name of the object
* @param file: address of a string --> file
* @param obj: pointer of any type of object
*
* @param ofs: create an output file stream
* ofs: create an output file stream
* if: when the output file stream is available
* @param oa: create an xml output archive with the output stringstream and no header
* oa: create an xml output archive with the output stringstream and no header
* serialize now the object in the outputarchive and close file
* else: start logging
*/
Expand Down

0 comments on commit 87cbbc0

Please sign in to comment.