Home / Data Monitor / Annex C
Page options

Annex C


Protocol objects are xxx_vars, where xxx is the protocol. And xxx_vars are complex_var. In the case of the RM protocol, there are 3 message type – rm_var, rm_message_var, rm_data_var.

 

In order to add logging ability, we could subclass them and add a function call to a log the message. For the RM protocol, this should be a possible implementation:

 

class datamon_rm_var : public rm_var

{

public:

RUNTIME_TYPE(datamon_rm_var)

      virtual int extract(int len, unsigned char *buf);

}

 

int datamon_rm_var::extract(int len, unsigned char *buf)

{

      DataMonitorLogger::write(len, buf, getName(), rtti());

      complex_var::extract(len, buf);

}

 

class datamon_rm_message_var : public rm_message_var

{

public:

RUNTIME_TYPE(datamon_rm_message_var)

      virtual int extract(int len, unsigned char *buf);

}

 

int datamon_rm_message_var::extract(int len, unsigned char *buf)

{

      DataMonitorLogger::write(len, buf, getName(), rtti());

      complex_var::extract(len, buf);

}

 

class datamon_rm_data_var : public rm_data_var

{

public:

      RUNTIME_TYPE(datamon_rm_data_var)

      virtual int extract(int len, unsigned char *buf);

}

 

int datamon_rm_data_var::extract(int len, unsigned char *buf)

{

      DataMonitorLogger::write(len, buf, getName(), rtti());

      complex_var::extract(len, buf);

}

 

This method allows other protocol vars to access the Data Monitor’s logging system easily. The logger needs additional information about the data it is logging, namely, an identifier for the packet type, and a runtime-type identifier to help locate the plugin that will assist in the playback.

 

Data Monitor will initialize message plugins during startup to identify the rtti of message protocol classes its factory is capable of instantiating, and handling. During playback, it will use the rtti from the log file to determine which plugin to forward the data. The plugin will then route the message to the extract method of the instance with the matching identifier.

 

During playback mode, DataMonitorLogger::write will return without doing anything. This will allow the extract methods to be used in both realtime mode and playback mode.

 

    Post a comment

    Your Name or E-mail ID (mandatory)

     

    Note: Your comment will be published after approval of the owner.

    No Attachments Found. Click here to upload new file.




     RSS of this page

    Author: Guest   Version: 1.0   Last Edited By: Guest   Modified: 12 Jan 2009