The Interface Content example demonstrates the following:
- How to create a new interface content message
- How to install the interface content message in the factory
- How to send and receive the new interface content message
Creating a New Type of Interface Message
The Interface Content example creates a new type of VRF interface message class MyInterfaceContent which demonstrates how to send and receive interface content messages.
Since this example is loaded as a plugin, it can be used in conjunction with the released VR-Forces application.
How to Run the Example
Usage
In the Launcher, click the Plug-ins button to bring up the Plug-ins Selection dialog. Enable the plugin.
To view the new behavior:
-
Start VR-Forces GUI and SIM.
-
There is no need to load an existing or create a new scenario.
-
A new menu item - 'Send Interface Content Message...' will be created under the Simulation menu.
-
Type in a message in the displayed Interface Content dialog, and press OK button to send the message.
-
The SIM will receive the message and send an acknowledgement to the GUI.
-
Upon receipt, both SIM and GUI will print a message to their console windows.
Classes
Plugin Entry Points
#include <vlutil/vlPrint.h>
#include <vl/exerciseConn.h>
static DtSimulationAddress theSimulationAddress;
static int theOutgoingMessageNumber = 0;
extern "C" {
{
{
}
else if (ifMsg->
sender() == theSimulationAddress)
{
}
else if (theSimManager)
{
DtInfo("messageCallback received MyInterfaceContent:\n");
DtInfo("--------------------------------------------\n");
DtInfo("%s\n", output.string());
response = "Server Response (";
response += theSimulationAddress.string();
response += "): Received: ";
msg.setMessage(response);
msg.setNumber(myContent->
number());
msg.setAck(true);
}
}
{
public:
virtual ~DtPingCommand() override { };
{
messageToSend = "Test message from (";
messageToSend += theSimulationAddress.string();
messageToSend += "): Sending Text: ";
messageToSend += parameters;
return true;
}
return "Send a message with the given text.";
};
virtual bool showInHelp()
const override {
return true; };
};
static DtPingCommand* thePingCommand = new DtPingCommand();
{
delete thePingCommand;
thePingCommand = nullptr;
}
{
info.
pluginDescription =
"This is an example of how to add a new interface message in the VRF back-end.";
}
{
return true;
}
{
thePingCommand);
return true;
}
}