vsTASKER 7 User Manual
×
Menu
Index

Packet Code

 
Packet Code
1

Declarations

1. Declarations
Put in this panel all data you want to add in the current Packet. Public data is used to generate the Dyn-UI so, consider carefully what you put in the Public: data section.
It is also good to define all the methods that will be called from any other objects (logics, components, etc.) since the object will be instanciated once and easily accessible:
 
// Packet name: View_0
// Method defined in View_0 : mySetup()
// how to call it:
 
   cici.View_0->mySetup();
 
 
Consider the Packet as a C++ Class which will instanciate only one object.
No constructor and destructor should be added here. Use instead the Initialization panel.
2

Initialization

2. Initialization
This part is called automatically at instantiation (INIT), when Packet is created using new, or every time the object is RESET and finally at destruction (CLEAN) using delete.
It is a good practice to put in the RESET part whatever must be reinitialized at reset. There is no break after INIT to allow the RESET part to be processed after INIT, at Socket creation time.
 
3

Methods

3. Methods
Put here all the Packet methods declared in the Declaration section.
 
4

Runtime

4. Runtime
This part is called by tic(Event*). It is an automatic routine of the Packet so, all data of the Packet can be accessed here.
  • Senders: if triggering mode is Cycle on Event, use event of type Event*. if Cycle at set, no argument is available. Use scen() to get the data you need.
i.e: to send a request for position,
do:         
if (entity) {
        CigiPositionReqV3 positionReq;
        positionReq.SetObjectID(entity->getId());
        positionReq.SetObjectClass(CigiBasePositionReq::Entity);
        positionReq.SetUpdateMode(CigiBasePositionReq::OneShot);
        positionReq.SetCoordSys(CigiBasePositionReq::Geodetic);
        // Enqueue the position request
        *mgr->transmitter << positionReq;
}
 
  • Receivers: Use getEvent()->data of type MsgData* and cast it according to the type of data you are expected on this packet:
    i.e: for a message type: CIGI_POSITION_RESP_PACKET_ID_V3
    do:
response = (CigiPositionRespV3 *) getEvent()->data;
printf("CigiPositionResp received\n"
            "\tObject id:      %d\n"
            "\tArtPart id:     %d\n", response->GetObjectID(), response->GetArtPartID());