Troubleshooting
Problem
How can the encode and decode functionality of class be tested in IBM Rational Rose RealTime?
Resolving The Problem
To verify the encode function of a class, output the class via the Log service using the following operation on a Log port:
void log( const void *, const RTObject_class * );
For example, assuming the class name is "ClassA", the following would work:
ClassA a;
// Set a's attributes.
log.log(&a, &RTType_ClassA);
This will print the encoded string to the output window. The string can now be verified manually to ensure that all the necessary data is present.
To verify the decode function of a class, inject a message on a port probe containing the data in string form. (The string form of the data can be obtained using the Log service, see above.)
If an inject of the message, causes a "SYSTEM ERROR - Target Detected Protocol Error", then there is a good chance that either the data is being specified incorrectly in the data field of the inject message or the data is not being decoded properly. The data field should contain the exact same text that would appear if an instance of the class were to be output with the Log service.
An alternative method to test the encode and decode functions, that does not require any user interaction, is to call the encode and decode functions directly. Attached to this technote is a model with a helper class, AsciiEncoderDecoder, and a test capsule that makes direct calls to the encode and decode functions. See the Documentation field of the AsciiEncoderDecoder class' specification for information on how to use the encode and decode functions.
The model file 24378_AsciiEncoderDecoderSimpleModel.rtmdl has an example of how to use this class. This model has been tested using the following configurations:
NT40T.x86-VisualC++-6.0
SUN5T.sparc-gnu-2.8.1
The 24378_AsciiEncoderDecoder.rtptl file is provided so that the AsciiEncoderDecoder class can be easily imported into other models. (In your model right click on the Logical View package, select File... and Import..., navigate to the location of the 24378_AsciiEncoderDecoder.rtptl file, select it and click Open.)
Note to Connexis Users: The methods described in this solution use the ASCII encoding scheme. A class that is sent between two processes using Connexis can be encoded and decoded using either the ASCII or CDR encoding scheme. If the CDR (Common Data Representation) encoding scheme is used, then the methods outlined in this solution do not completely duplicate how the class will be encoded and decoded with Connexis. However, for debugging purposes, it is probably sufficient to use the ASCII encoding and decoding tests.
For more information on topics covered in this technote, see the following online documentation sections:
C++ Reference > Services Library Class Reference > Log
Toolset Guide > Running and Debugging > Probes
Toolset Guide > Running and Debugging > Inject Window
C++ Reference > Model Properties Reference > Type Descriptors
C++ Reference > Services Library Class Reference > RTObject_class
For background information regarding the encode and decode functionality of a class, see Solution 1161855.
Related Information
Historical Number
24378
Was this topic helpful?
Document Information
More support for:
Rational Rose RealTime
Software version:
2002, 2003
Document number:
330425
Modified date:
16 June 2018
UID
swg21135770