To publish, the local (FedItem) data must be copied to the Attribute/Parameter name.
Using the following formalism, vsTASKER will preprocess the code and generate the correct C++ code.
"name", where name is the one of the Attribute/Parameter.
<- preprocess symbol
(type) &variable; local variable holding the data to publish.
All attributes will be published when the Object FedItem is called.
Most of the time, several Attributes will not need to be updated because the value has not changed enough.
For CPU load control, you can define a Boolean to force or not the publication of the Attribute.
Declaration in the FedItem Object:
struct {
struct {
WCoord current;
bool update;
} pos;
} local;
|
Code in the FedItem Object:
if (entity->pos.distanceTo2D(local.pos.old) < 10) {
local.pos.update = true;
local.pos.current = entity->pos;
}
else local.pos.update = false;
|
Code in the FedItem Object Attribute:
if (local.pos.update) {
"entityPos" <- local.pos.current;
}
|
When subscribing to HLA, data coming from the RTI must be stored locally before being used at the Object/Interaction code.
This is done using the preprocess symbol <-
x local variable that will receive the data. Must be of the correct type to avoid runtime error with the memcpy.
<- preprocess symbol
vsTASKER allows user to manually publish Object Attributes or Interactions Parameters using the runtime window of each publishing FedItem.
The generated code works fine for simple types (string, integer, float, double, long...) but when it get to complex ones, user must deactivate the Automatic mode and do the coding itself.
It is not difficult as it consist of getting the character string entered by the user in the
Dyn-UI and copy it to the proper FedItem data.
The publishing is done right after.
Above is the Runtime FedItem window for a publisher.
here, the Position string will be received in the variable value and will contain: 11,22 (as entered by the user).
local variable is automatically set by vsTASKER when a DataModel is associated with the FedItem.
So:
strGetWord(1, "11,22) -> 11
|
and:
strGetWord(2, "11,22") -> 22
|