VR-Forces 4.0.4 Class Documentation
Interface Content Message

The MyInterfaceContent is a subclass of DtSimInterfaceContent that is used send interface content messages that can contain any type of information.

When creating the network structure that represents the interface content message, it is important to remember to align it along an 8 byte boundry


Header file:

/*******************************************************************************
** Copyright (c) 2004 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
/*******************************************************************************
** $RCSfile: myInterfaceContent.h,v $ $Revision: 1.7 $ $State: Exp $
*******************************************************************************/

#ifndef MyInterfaceContent_H_
#define MyInterfaceContent_H_

//VR-Forces includes
#include <vrfExtProtocol/ifaceCont.h>
#include <vrfExtProtocol/msgTypes.h>

//VR-Link includes
#include <vlutil/vlString.h>
#include <vlutil/vlNetTypes.h>

//Class MyInterfaceContent
//This is an example of a DtSimInterfaceContent subclass which can be
//used to send a message from one DtVrfMessageInterface to another
//which consists of a string and a number.
                                          //8 bytes total

//To prevent conflicts with existing VR-Forces messages, increment custom
//messages starting at MIN_USER_INTERFACE_MESSAGE_TYPE as defined in
//msgTypes.h.
const int MyInterfaceContentType = MIN_USER_INTERFACE_MESSAGE_TYPE + 1;
 
class MyInterfaceContent : public DtSimInterfaceContent
{
public:

   //default constructor
   MyInterfaceContent();

   //destructor
   virtual ~MyInterfaceContent();

   //copy constructor
   MyInterfaceContent(const MyInterfaceContent& orig);

   //assignment operator
   MyInterfaceContent& operator=(const MyInterfaceContent& orig);

   //Returns the type of interface content (MyInterfaceContentType as defined
   //above).
   virtual int type() const;

   //Calls the copy constructor to create a clone
   virtual DtSimInterfaceContent * clone() const;

   //Set the message string 
   virtual const DtString & message() const;
   
   //Get the message string 
   virtual void setMessage(const DtString & message);

   //Set the number 
   virtual unsigned int number() const;
   
   //Get the number 
   virtual void setNumber(unsigned int number);   

   //See if this is an acknowledgement 
   virtual bool ack() const;
   
   //Set if this is an acknowledgement
   virtual void setAck(bool);   
   
   //Returns the size of the full network representation padded to an 8-byte
   //boundary.
   virtual int netRepSize() const;

   //Fills in the message from the network buffer
   virtual bool setFromNet(const char* contentBuffer, 
      unsigned contentSize);

   //Fills in the network buffer with the message contents
   virtual bool setToNet();

   //Prints the formatted contents of the message into the given string
   virtual void printDataToString(DtString& str);

   //Static creator function which gets registered with the 
   //DtInterfaceContentFactory
   static DtSimInterfaceContent* creator();

protected:
   DtString myMessage;
   DtU32 myNumber;
   bool myAck;
};

#endif

How to Run

This example demonstrates how add a new kind of interface content message.

Usage

Select Settings, Plugins... and on the Plugins Editor page, use the combo box at the top of the page to select the plug-in. Then enable the Load Plugin checkbox and re-start VR-Forces.

To view the new behavior:

  1. Start vrfSim. Watch the console and wait until the parameter database has been loaded.
    1. Start vrfGui.

The vrfGui application creates and sends a new kind of interface content message. Both vrfGui and vrfSim receive the message and display its contents in their console windows (message content includes the phrase 'Testing from interfaceContentGui').


Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)