DESERT 4.0.0
UWMdriver Class Referenceabstract

#include <uwmdriver.h>

Inheritance diagram for UWMdriver:
Inheritance graph
Collaboration diagram for UWMdriver:
Collaboration graph

Public Member Functions

 UWMdriver (UWMPhy_modem *)
 
 ~UWMdriver ()
 
virtual void modemSetID ()=0
 
virtual void start ()=0
 
virtual void stop ()=0
 
virtual void modemTx ()=0
 
virtual modem_state_t updateStatus ()=0
 
void setID (int ID_)
 
void resetModemStatus ()
 
void updateTx (int, std::string)
 
void updateRx (int, int, std::string)
 
int getID ()
 
modem_state_t getStatus ()
 
std::string getRxPayload ()
 
int getSrc ()
 
int getDstPktRx ()
 
log_level_t getDebug ()
 
void setModemID (bool set)
 
bool getModemID ()
 
void setResetModemQueue (bool reset_m_queue)
 
bool getResetModemQueue ()
 
log_level_t getLogLevel ()
 
std::string getLogFile ()
 
void printOnLog (log_level_t log_level, std::string module, std::string message)
 
 UWMdriver (UWMPhy_modem *)
 
 ~UWMdriver ()
 
virtual void modemSetID ()=0
 
virtual void start ()=0
 
virtual void stop ()=0
 
virtual void modemTx ()=0
 
virtual modem_state_t updateStatus ()=0
 
void setID (int ID_)
 
void resetModemStatus ()
 
void updateTx (int, std::string)
 
void updateRx (int, int, std::string)
 
int getID ()
 
modem_state_t getStatus ()
 
std::string getRxPayload ()
 
int getSrc ()
 
int getDstPktRx ()
 
log_level_t getDebug ()
 
void setModemID (bool set)
 
bool getModemID ()
 
void setResetModemQueue (bool reset_m_queue)
 
bool getResetModemQueue ()
 
log_level_t getLogLevel ()
 
std::string getLogFile ()
 
void printOnLog (log_level_t log_level, std::string module, std::string message)
 

Protected Member Functions

void setConnections (UWMinterpreter *, UWMconnector *)
 
virtual void modemTxManager ()=0
 
void setConnections (UWMinterpreter *, UWMconnector *)
 
virtual void modemTxManager ()=0
 

Protected Attributes

UWMPhy_modempmModem
 
UWMinterpreterpmInterpreter
 
UWMconnectorpmConnector
 
int ID
 
modem_state_t status
 
std::string payload_tx
 
int dest
 
std::string payload_rx
 
int src
 
int dstPktRx
 
bool SetModemID
 
int debug_
 
std::ofstream outLog
 
bool ResetModemQueue
 

Detailed Description

The class needed by UWMPhy_modem to handle the different transmissions cases and corresponding protocol messages to be generated according to the tcl-user choices and modem firmware, respectively. This class contains all the basic functions needed to drive modem in transmitting/receiving messages. NOTE: this class must be inherited and extended to implement any specific modem driver.

Constructor & Destructor Documentation

◆ UWMdriver() [1/2]

UWMdriver::UWMdriver ( UWMPhy_modem pmModem_)

Class constructor.

Parameters
pmModem_pointer to the UWMPhy_modem object to link with this UWMdriver object.

References debug_, dest, UWMPhy_modem::getDebug(), UWMPhy_modem::getID(), ID, MODEM_IDLE, payload_rx, payload_tx, pmConnector, pmInterpreter, pmModem, SetModemID, src, and status.

Here is the call graph for this function:

◆ ~UWMdriver() [1/2]

UWMdriver::~UWMdriver ( )

Class destructor.

◆ UWMdriver() [2/2]

UWMdriver::UWMdriver ( UWMPhy_modem )

Class constructor.

Parameters
pmModem_pointer to the UWMPhy_modem object to link with this UWMdriver object.

◆ ~UWMdriver() [2/2]

UWMdriver::~UWMdriver ( )

Class destructor.

Member Function Documentation

◆ getDebug() [1/2]

log_level_t UWMdriver::getDebug ( )
inline

Method to return the flag used to enable debug messages.

Returns
UWMPhy_modem::debug_

References debug_.

◆ getDebug() [2/2]

log_level_t UWMdriver::getDebug ( )
inline

Method to return the flag used to enable debug messages.

Returns
UWMPhy_modem::debug_

References debug_.

Referenced by UWMinterpreter::UWMinterpreter().

◆ getDstPktRx() [1/2]

int UWMdriver::getDstPktRx ( )
inline

Method to access to the ID of the destination of the last packet acoustically received. NOTE: This function should be used by the UWMcodec object linked to this UWMdriver (and contained in the UWMPhy_modem object pointed by pmModem) to recover the orginal NS-Miracle to be sent to the above protocol layers of the simulator.

Returns
UWMdriver::dstPktRx.

References dstPktRx.

◆ getDstPktRx() [2/2]

int UWMdriver::getDstPktRx ( )
inline

Method to access to the ID of the destination of the last packet acoustically received. NOTE: This function should be used by the UWMcodec object linked to this UWMdriver (and contained in the UWMPhy_modem object pointed by pmModem) to recover the orginal NS-Miracle to be sent to the above protocol layers of the simulator.

Returns
UWMdriver::dstPktRx.

References dstPktRx.

◆ getID() [1/2]

int UWMdriver::getID ( )
inline

Method to return modem ID.

Returns
UWMdriver::ID.

References ID.

◆ getID() [2/2]

int UWMdriver::getID ( )
inline

Method to return modem ID.

Returns
UWMdriver::ID.

References ID.

◆ getLogFile() [1/2]

std::string UWMdriver::getLogFile ( )

Method to return the name of the disk-fiel used to print the log messages.

Returns
UWMPhy_modem::logFile

◆ getLogFile() [2/2]

std::string UWMdriver::getLogFile ( )

Method to return the name of the disk-fiel used to print the log messages.

Returns
UWMPhy_modem::logFile

References UWMPhy_modem::getLogFile(), and pmModem.

Here is the call graph for this function:

◆ getLogLevel() [1/2]

log_level_t UWMdriver::getLogLevel ( )

Method to return the flag used to enable the printing of log messages in UWMPhy_modem::logFile.

Returns
UWMPhy_modem::log_

◆ getLogLevel() [2/2]

log_level_t UWMdriver::getLogLevel ( )

Method to return the flag used to enable the printing of log messages in UWMPhy_modem::logFile.

Returns
UWMPhy_modem::log_

References UWMPhy_modem::getLogLevel(), and pmModem.

Here is the call graph for this function:

◆ getModemID() [1/2]

bool UWMdriver::getModemID ( )
inline
Returns
true if the interface sets the modem ID

References SetModemID.

◆ getModemID() [2/2]

bool UWMdriver::getModemID ( )
inline
Returns
true if the interface sets the modem ID

References SetModemID.

◆ getResetModemQueue() [1/2]

bool UWMdriver::getResetModemQueue ( )
inline

References ResetModemQueue.

◆ getResetModemQueue() [2/2]

bool UWMdriver::getResetModemQueue ( )
inline

References ResetModemQueue.

◆ getRxPayload() [1/2]

std::string UWMdriver::getRxPayload ( )
inline

Method to access to the payload of the last packet acoustically received. NOTE: This function should be used by the UWMcodec object linked to this UWMdriver (and contained in the UWMPhy_modem object pointed by pmModem) to recover the orginal NS-Miracle to be sent to the above protocol layers of the simulator.

Returns
UWMdriver::payload_rx.

References payload_rx.

◆ getRxPayload() [2/2]

std::string UWMdriver::getRxPayload ( )
inline

Method to access to the payload of the last packet acoustically received. NOTE: This function should be used by the UWMcodec object linked to this UWMdriver (and contained in the UWMPhy_modem object pointed by pmModem) to recover the orginal NS-Miracle to be sent to the above protocol layers of the simulator.

Returns
UWMdriver::payload_rx.

References payload_rx.

Referenced by UWMPhy_modem::endRx().

◆ getSrc() [1/2]

int UWMdriver::getSrc ( )
inline

Method to access to the ID of the source of the last packet acoustically received. NOTE: This function should be used by the UWMcodec object linked to this UWMdriver (and contained in the UWMPhy_modem object pointed by pmModem) to recover the orginal NS-Miracle to be sent to the above protocol layers of the simulator.

Returns
UWMdriver::src.

References src.

◆ getSrc() [2/2]

int UWMdriver::getSrc ( )
inline

Method to access to the ID of the source of the last packet acoustically received. NOTE: This function should be used by the UWMcodec object linked to this UWMdriver (and contained in the UWMPhy_modem object pointed by pmModem) to recover the orginal NS-Miracle to be sent to the above protocol layers of the simulator.

Returns
UWMdriver::src.

References src.

◆ getStatus() [1/2]

modem_state_t UWMdriver::getStatus ( )
inline

Method to return the modem's status.

Returns
UWMdriver::status.

References status.

◆ getStatus() [2/2]

modem_state_t UWMdriver::getStatus ( )
inline

Method to return the modem's status.

Returns
UWMdriver::status.

References status.

Referenced by MS2C_Evo_lowlev::check_modem(), and UWMPhy_modem::recv().

◆ modemSetID() [1/2]

virtual void UWMdriver::modemSetID ( )
pure virtual

Implemented in MdriverS2C_Evo_lowlev.

◆ modemSetID() [2/2]

virtual void UWMdriver::modemSetID ( )
pure virtual

Implemented in MdriverS2C_Evo_lowlev.

◆ modemTx() [1/2]

virtual void UWMdriver::modemTx ( )
pure virtual

Method to notify to the driver that there is a packet to be sent via modem. NOTE: when this function is called (by an UWMPhy_modem object), the driver's status must be set to TX_ and the packet must be sent immediately to the modem.

Implemented in MdriverS2C_Evo_lowlev.

◆ modemTx() [2/2]

virtual void UWMdriver::modemTx ( )
pure virtual

Method to notify to the driver that there is a packet to be sent via modem. NOTE: when this function is called (by an UWMPhy_modem object), the driver's status must be set to TX_ and the packet must be sent immediately to the modem.

Implemented in MdriverS2C_Evo_lowlev.

Referenced by UWMPhy_modem::startTx().

◆ modemTxManager() [1/2]

virtual void UWMdriver::modemTxManager ( )
protectedpure virtual

Method to manage modem to host and host to modem communications. This method has to handle the different transmissions cases and corresponding protocol messages to be generated according to the tcl-user choices and modem firmware, respectively.

Implemented in MdriverS2C_Evo_lowlev.

◆ modemTxManager() [2/2]

virtual void UWMdriver::modemTxManager ( )
protectedpure virtual

Method to manage modem to host and host to modem communications. This method has to handle the different transmissions cases and corresponding protocol messages to be generated according to the tcl-user choices and modem firmware, respectively.

Implemented in MdriverS2C_Evo_lowlev.

◆ printOnLog() [1/2]

void UWMdriver::printOnLog ( log_level_t  log_level,
std::string  module,
std::string  message 
)

◆ printOnLog() [2/2]

◆ resetModemStatus() [1/2]

void UWMdriver::resetModemStatus ( )

Method to reset the modem status. NOTE: this function should be used by the UWMPhy_modem object linked to this UWMdriver (the one pointed by pmModem) to reset the status to _IDLE after the processing of a received packet or to abort a given ongoing reception process.

Parameters
[out]status(i.e., the member UWMdriver::status), changed to IDLE_.

◆ resetModemStatus() [2/2]

void UWMdriver::resetModemStatus ( )

Method to reset the modem status. NOTE: this function should be used by the UWMPhy_modem object linked to this UWMdriver (the one pointed by pmModem) to reset the status to _IDLE after the processing of a received packet or to abort a given ongoing reception process.

Parameters
[out]status(i.e., the member UWMdriver::status), changed to IDLE_.

References MODEM_IDLE, and status.

Referenced by UWMPhy_modem::endRx(), and UWMPhy_modem::recv().

◆ setConnections() [1/2]

void UWMdriver::setConnections ( UWMinterpreter ,
UWMconnector  
)
protected

Link connector. This method must be used by any derived class D of UWDriver to link the members pmInterpreter and pmConnector of UWMdriver to the corresponding derived objects contained in D.

See also
: e.g. MdriverS2C_EvoLogics
Parameters
[in]pmInterpreter_pointer to a UWMinterpreter object
[in]pmConnector_pointer to an UWMconnector object
[out]pmInterpreter(i.e., the member UWMPhy_modem::pmInterpreter)
[out]pmConnector(i.e., the member UWMPhy_modem::pmConnector)

◆ setConnections() [2/2]

void UWMdriver::setConnections ( UWMinterpreter pmInterpreter_,
UWMconnector pmConnector_ 
)
protected

Link connector. This method must be used by any derived class D of UWDriver to link the members pmInterpreter and pmConnector of UWMdriver to the corresponding derived objects contained in D.

See also
: e.g. MdriverS2C_EvoLogics
Parameters
[in]pmInterpreter_pointer to a UWMinterpreter object
[in]pmConnector_pointer to an UWMconnector object
[out]pmInterpreter(i.e., the member UWMPhy_modem::pmInterpreter)
[out]pmConnector(i.e., the member UWMPhy_modem::pmConnector)

References UWMPhy_modem::getQueueLength(), pmConnector, pmInterpreter, pmModem, and UWMconnector::setDriverQueueLength().

Referenced by MdriverS2C_Evo_lowlev::MdriverS2C_Evo_lowlev().

Here is the call graph for this function:

◆ setID() [1/2]

void UWMdriver::setID ( int  ID_)
inline

Method to change the modem ID. This method is called by the UWMPhy_modem object linked to this UWMdriver (the one pointed by pmModem).

Parameters
[in]IDthe ID that must be assigned to the modem.
[out]ID(i.e., the member UWMdriver::ID), changed to ID_.

References ID.

◆ setID() [2/2]

void UWMdriver::setID ( int  ID_)
inline

Method to change the modem ID. This method is called by the UWMPhy_modem object linked to this UWMdriver (the one pointed by pmModem).

Parameters
[in]IDthe ID that must be assigned to the modem.
[out]ID(i.e., the member UWMdriver::ID), changed to ID_.

References ID.

Referenced by UWMPhy_modem::start().

◆ setModemID() [1/2]

void UWMdriver::setModemID ( bool  set)
inline
Parameters
settrue if the interface has to set the modem ID

References SetModemID.

◆ setModemID() [2/2]

void UWMdriver::setModemID ( bool  set)
inline
Parameters
settrue if the interface has to set the modem ID

References SetModemID.

Referenced by UWMPhy_modem::start().

◆ setResetModemQueue() [1/2]

void UWMdriver::setResetModemQueue ( bool  reset_m_queue)
inline

References ResetModemQueue.

◆ setResetModemQueue() [2/2]

void UWMdriver::setResetModemQueue ( bool  reset_m_queue)
inline

References ResetModemQueue.

Referenced by DropTimer::expire().

◆ start() [1/2]

virtual void UWMdriver::start ( )
pure virtual

Driver starter. This method starts the driver performing all the needed operations to open an host-modem connection.

Implemented in MdriverS2C_Evo_lowlev.

◆ start() [2/2]

virtual void UWMdriver::start ( )
pure virtual

Driver starter. This method starts the driver performing all the needed operations to open an host-modem connection.

Implemented in MdriverS2C_Evo_lowlev.

Referenced by UWMPhy_modem::start().

◆ stop() [1/2]

virtual void UWMdriver::stop ( )
pure virtual

Driver stopper. This method should be used before stopping the simulation. It closes and, if needed, resets all the opened files and ports.

Implemented in MdriverS2C_Evo_lowlev.

◆ stop() [2/2]

virtual void UWMdriver::stop ( )
pure virtual

Driver stopper. This method should be used before stopping the simulation. It closes and, if needed, resets all the opened files and ports.

Implemented in MdriverS2C_Evo_lowlev.

Referenced by UWMPhy_modem::stop().

◆ updateRx() [1/2]

void UWMdriver::updateRx ( int  ,
int  ,
std::string   
)

Method to write in UWMdriver::payload_rx, UWMdriver::src and UWMdriver::dstPktRx. NOTE: This method should be used by an UWMinterpreter object linked to this UWMdriver (and contained in the UWMPhy_modem object pointed by pmModem)

Parameters
[in]sthe ID of the modem that sent the last received packet.
[in]dthe ID of the modem that is the destination of the last received packet.
[in]prxthe payload of the last packet acoustically received.
[out]src(i.e., the member UWMdriver::src), changed to s.
[out]dstPktRx(i.e., the member UWMdriver::dstPktRx), changed to d.
[out]payload_rx(i.e., the member UWMdriver::payload_rx), changed to prx.

◆ updateRx() [2/2]

void UWMdriver::updateRx ( int  s,
int  d,
std::string  prx 
)

Method to write in UWMdriver::payload_rx, UWMdriver::src and UWMdriver::dstPktRx. NOTE: This method should be used by an UWMinterpreter object linked to this UWMdriver (and contained in the UWMPhy_modem object pointed by pmModem)

Parameters
[in]sthe ID of the modem that sent the last received packet.
[in]dthe ID of the modem that is the destination of the last received packet.
[in]prxthe payload of the last packet acoustically received.
[out]src(i.e., the member UWMdriver::src), changed to s.
[out]dstPktRx(i.e., the member UWMdriver::dstPktRx), changed to d.
[out]payload_rx(i.e., the member UWMdriver::payload_rx), changed to prx.

References dstPktRx, payload_rx, and src.

Referenced by MinterpreterTEL::parse_TELEGRAM().

◆ updateStatus() [1/2]

virtual modem_state_t UWMdriver::updateStatus ( )
pure virtual

Method to update modem status. This method has to update the modem status according to the messages received from the modem/channel (e.g., after a check of the modem buffer's output). NOTE: This method may return after an arbitrary period if nothing has happened, but it must return immediately after a change of UWMdriver::status.

Returns
UWMdriver::status, the updated modem's status.

Implemented in MdriverS2C_Evo_lowlev.

◆ updateStatus() [2/2]

virtual modem_state_t UWMdriver::updateStatus ( )
pure virtual

Method to update modem status. This method has to update the modem status according to the messages received from the modem/channel (e.g., after a check of the modem buffer's output). NOTE: This method may return after an arbitrary period if nothing has happened, but it must return immediately after a change of UWMdriver::status.

Returns
UWMdriver::status, the updated modem's status.

Implemented in MdriverS2C_Evo_lowlev.

Referenced by MS2C_Evo_lowlev::check_modem().

◆ updateTx() [1/2]

void UWMdriver::updateTx ( int  ,
std::string   
)

Method to update the values of both UWMdriver::payload_tx and UWMdriver::dest. NOTE: This method should be used by an UWMcodec object linked to this UWMdriver (and contained in the UWMPhy_modem object pointed by pmModem)

Parameters
[in]dthe ID of the modem to which transmit the next packet.
[in]ptxthe payload of the modem packet to transmit acoustically.
[out]dest(i.e., the member UWMdriver::dest), changed to d.
[out]payload_tx(i.e., the member UWMdriver::payload_tx), changed to ptx.

◆ updateTx() [2/2]

void UWMdriver::updateTx ( int  d,
std::string  ptx 
)

Method to update the values of both UWMdriver::payload_tx and UWMdriver::dest. NOTE: This method should be used by an UWMcodec object linked to this UWMdriver (and contained in the UWMPhy_modem object pointed by pmModem)

Parameters
[in]dthe ID of the modem to which transmit the next packet.
[in]ptxthe payload of the modem packet to transmit acoustically.
[out]dest(i.e., the member UWMdriver::dest), changed to d.
[out]payload_tx(i.e., the member UWMdriver::payload_tx), changed to ptx.

References dest, and payload_tx.

Referenced by UWMPhy_modem::recv().

Member Data Documentation

◆ debug_

int UWMdriver::debug_
protected

Flag to enable debug mode (i.e., printing of debug messages) if set to 1

Referenced by getDebug(), and UWMdriver().

◆ dest

int UWMdriver::dest
protected

Variable where to save the destination ID of the next packet to send via modem. NOTE: an object of the class UWMcodec must write here after the host-to-modem demapping.

Referenced by updateTx(), and UWMdriver().

◆ dstPktRx

int UWMdriver::dstPktRx
protected

Variable where to save the destination ID of the last packet received via modem. NOTE: an object of the class UWMinterpreter must write here after a the parsing of a received data packet; instead, an object of the class UWMcodec reads here before the modem-to-host mapping.

Referenced by getDstPktRx(), and updateRx().

◆ ID

int UWMdriver::ID
protected

ID of the modem. NOTE: UWMdriver::ID (i.e., modem ID, hardware side) is set equal to UWMPhy_modem::ID (i.e., node ID, simulator side) (therefore when node ID transmits, it also coincides with the source ID).

See also
UWMPhy_modem::start(), UWMdriver::setID(int)

Referenced by getID(), setID(), and UWMdriver().

◆ outLog

std::ofstream UWMdriver::outLog
protected

output strem to print into a disk-file log messages. See UWMPhy_modem::logFile.

◆ payload_rx

std::string UWMdriver::payload_rx
protected

String where to save the payload of the last packet received via modem. NOTE: an object of the class UWMinterpreter must write here after a the parsing of a received data packet; instead, an object of the class UWMcodec reads here before the modem-to-host mapping.

Referenced by getRxPayload(), updateRx(), MdriverS2C_Evo_lowlev::updateStatus(), and UWMdriver().

◆ payload_tx

std::string UWMdriver::payload_tx
protected

String where to save the payload of the next packet to send via modem. NOTE: an object of the class UWMcodec must write here after the host-to-modem mapping.

Referenced by MdriverS2C_Evo_lowlev::modemTxManager(), updateTx(), and UWMdriver().

◆ pmConnector

UWMconnector * UWMdriver::pmConnector
protected

pointer to the object that handles the physical transmission and reception of acoustic packets

Referenced by setConnections(), and UWMdriver().

◆ pmInterpreter

UWMinterpreter * UWMdriver::pmInterpreter
protected

pointer to the object that builds/parses the necessary messages to make UWMdriver able to communicate with a real modem

Referenced by setConnections(), and UWMdriver().

◆ pmModem

UWMPhy_modem * UWMdriver::pmModem
protected

link to the UWMPhy_modem object that contains this driver

Referenced by getLogFile(), getLogLevel(), setConnections(), and UWMdriver().

◆ ResetModemQueue

bool UWMdriver::ResetModemQueue
protected

◆ SetModemID

bool UWMdriver::SetModemID
protected

Variable to decide whether the interface has to set the acoustic ID of the modem or not

Referenced by getModemID(), setModemID(), and UWMdriver().

◆ src

int UWMdriver::src
protected

Variable storing the source ID of the last packet received via modem. NOTE: an object of the class UWMinterpreter must write here after a the parsing of a received data packet; instead, an object of the class UWMcodec reads here before the modem-to-host mapping.

Referenced by getSrc(), updateRx(), and UWMdriver().

◆ status

modem_state_t UWMdriver::status
protected

Status of the driver's general state machine. Seven possible statuses = _IDLE, _TX, _RX , _IDLE_RX,_CFG, _TX_PAUSED and _TX_RX.

Referenced by getStatus(), MdriverS2C_Evo_lowlev::modemTx(), resetModemStatus(), MdriverS2C_Evo_lowlev::start(), MdriverS2C_Evo_lowlev::stop(), MdriverS2C_Evo_lowlev::updateStatus(), and UWMdriver().


The documentation for this class was generated from the following files: