36 if (ll_string ==
"ERR") {
40 if (ll_string ==
"INFO") {
44 if (ll_string ==
"DBG") {
88 bind(
"debug_", (
int *) &
debug_);
89 bind(
"period_", (
double *) &
period);
108 (double) (std::chrono::duration_cast<std::chrono::milliseconds>(
109 std::chrono::system_clock::now().time_since_epoch())
116 std::string ll_descriptor =
"";
119 outLog << std::setprecision(15) << left << ll_descriptor <<
"::["
120 << timestamp <<
"]::[" << NOW <<
"]::" <<
module << "("
121 << modemID << ")::" << message << endl;
129 Tcl &tcl = Tcl::instance();
132 if (!strcmp(argv[1],
"start")) {
136 if (!strcmp(argv[1],
"stop")) {
140 }
else if (argc == 3) {
141 if (!strcmp(argv[1],
"setModemAddress")) {
145 if (!strcmp(argv[1],
"setLogSuffix")) {
149 if (!strcmp(argv[1],
"setLogLevel")) {
150 std::string log_lv = argv[2];
154 std::cout <<
"setLogLevel::INVALID_LOGLEVEL" << std::endl;
159 return MPhy::command(argc, argv);
UwModem * pmModem
Pointer to an UwModem object.
virtual void expire(Event *e)
Method to handle the expiration of a given event.
LogLevel
Enum representing the amount of logs being generated ERROR: only errors will be generated INFO : gene...
std::string log_suffix
Possibility to insert a log suffix.
static bool string2log(const std::string &ll_string, LogLevel &ll)
Method that converts a string representing the loglevel into the enum type of loglevel.
std::string modem_address
String containing the address needed to connect to the device In case of socket, it may be expressed ...
UwModem()
UwModem constructor.
virtual void stop()=0
Method that stops the driver operations.
std::queue< ModemEvent > event_q
Queue of events that are scheduled for NS2 to execute (callbacks)
static bool log2string(LogLevel ll, std::string &ll_string)
Method that converts an enum type of the loglevel into the string representing it.
bool log_is_open
Flag to check if log file has already be opened.
virtual void start()=0
Method that starts the driver operations.
void checkEvent()
Method to check if any event from real world has to go to ns.
int MAX_READ_BYTES
Maximum number of bytes to be read by a single dump of data.
int debug_
Usual debug value that chooses the debug level through Tcl interface.
CheckTimer * checkTimer
Pointer to an object to schedule the "check-modem" events.
LogLevel loglevel_
Log level on file, from ERROR (0) to DEBUG (2) in UwEvoLogicsS2CModem::logFile.
void printOnLog(LogLevel log_level, string module, string message)
Function that, given the appropriate level of log, prints to the set log file the provided log messag...
virtual ~UwModem()
UwModem destructor.
unsigned int DATA_BUFFER_LEN
Size of the buffer that holds data.
virtual void endTx(Packet *p)
Method that ends a packet transmission.
std::ofstream outLog
output strem to print into a disk-file log messages.
virtual int command(int argc, const char *const *argv)
Tcl command interpreter: Method that maps Tcl commands into C++ methods.
int modemID
Number used for identification purposes: not specified.
double period
Checking period of the modem's buffer.
LogLevel getLogLevel()
Method to return the flag used to enable the printing of log messages in UwEvoLogicsS2CModem::logFile...
std::string getLogFile()
Method to return the name of the file where to log messages.
std::function< void(UwModem &, Packet *p)> f
Header of the main class that implements the general interface between DESERT and real acoustic modem...