VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Interface Content

The Interface Content example demonstrates the following:

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

To view the new behavior:

  1. Start vrfSim.
  2. Start vrfGui.

A menu item to send the interface content message will be created under the Simulation menu. Type in a message. The back-end will receive the message and send an acknowledgement to the front-end

Classes

MyInterfaceContentThe interface content message.

Plugin Entry Points

/*******************************************************************************
** Copyright (c) 2003 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
/*******************************************************************************
** $RCSfile: plugin.cxx,v $ $Revision: 1.3 $ $State: Exp $
*******************************************************************************/
//Example includes
//VR-Forces includes
//VR-Forces includes
#include "vrfcgf/cgf.h"
//VR-Link includes
#include <vlutil/vlPrint.h>
#include <vl/exerciseConn.h>
static DtSimulationAddress theSimulationAddress;
static DtSimManager* theSimManager = 0;
static int theOutgoingMessageNumber = 0;
extern "C" {
//Callback function to print out incoming messages
static void messageCallback(DtSimMessage* msg, void* usr)
{
MyInterfaceContent* myContent =
if (myContent->ack())
{
//Don't send out a response as this could cause an infinite loop.
}
else if (ifMsg->sender() == theSimulationAddress)
{
//Don't send out a response to a message you sent.
}
else if (theSimManager)
{
DtString output;
myContent->printDataToString(output);
DtInfo("messageCallback received MyInterfaceContent:\n");
DtInfo("--------------------------------------------\n");
DtInfo("%s\n", output.string());
//Now, send out ack with receipt string
//Send a test message
DtString response;
response = "Server Response (";
response += theSimulationAddress.string();
response += "): Received: ";
response += myContent->message();
msg.setMessage(response);
msg.setNumber(myContent->number());
msg.setAck(true);
theSimManager->createAndDeliverMessage(DtSimSendToAll, msg);
}
}
class DtPingCommand : public DtConsoleCommand
{
~DtPingCommand() { };
//Execute the command.
//\return True on success of the command.
virtual bool execute(const DtString& parameters)
{
DtString messageToSend;
messageToSend = "Test message from (";
messageToSend += theSimulationAddress.string();
messageToSend += "): Sending Text: ";
messageToSend += parameters;
msg.setMessage(messageToSend);
msg.setNumber(theOutgoingMessageNumber++);
msg.setAck(false);
theSimManager->createAndDeliverMessage(DtSimSendToAll, msg);
return true;
}
//\return Some help text for the command.
virtual DtString help(const DtString& parameters)
{
return "Send a message with the given text.";
};
//\return True if this command should show up in the help list.
//If false, than this command will not be presented to the user.
virtual bool showInHelp() const { return true; };
};
static DtPingCommand* thePingCommand = new DtPingCommand();
{
info.pluginName = "interfaceContentSim";
info.pluginDescription = "This is an example of how to add a new interface message in the VRF back-end.";
info.pluginVersion = "1.00";
info.pluginCreator = "MAK Technologies";
info.pluginCreatorEmail = "sales@mak.com";
info.pluginContactWebPage = "www.mak.com";
info.pluginContactMailingAddress = "150 Cambridge Park Drive 3rd Floor - Cambridge, MA 02140 USA";
info.pluginContactPhone = "(617) 876 8085";
}
DT_VRF_DLL_PLUGIN bool DtInitializeVrfPlugin(DtCgf* cgf)
{
//Register the creator for MyInterfaceContentType with the
//DtInterfaceContentFactory
cgf->factoryManager()->interfaceContentFactory()->addCreatorFcn(
return true;
}
//Now that everything is initialized, send out a test message
DT_VRF_DLL_PLUGIN bool DtPostInitializeVrfPlugin(DtCgf* cgf)
{
//Register for callbacks on MyInterfaceContent with the
//DtVrfMessageInterface
MyInterfaceContentType, messageCallback, NULL);
theSimulationAddress = cgf->exerciseConn()->applicationId();
theSimManager = cgf->simManager();
thePingCommand);
return true;
}
}

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)