The DtEntityStateRepWithTemperature is a new class that replaces the default VR-Link entity state repository in order to add storage for the new temperature attribute. In order to encode the temperature to an HLA attribute, new encoder, decoder, and checker functions are also required to be registered with VR-Link. Note that this example does not support publishing the new attribute to DIS. However this could be achieved using the VR-Link API to encode the temperature into a new attribute record in DIS 7. See the VR-Link API for more details. Additionally, VR-Forces state properties can also be used to easily add and publish new attributes for both HLA and DIS. Please see the addStateProperty example for more details.
State Repository Header file:
#pragma once
#if DtHLA
#include <stdio.h>
#include <vl/entityPublisher.h>
#include <vl/reflectedEntityList.h>
{
public:
{
}
{
}
public:
protected:
};
{
}
{
}
{
DtEntityStateRepository::printData();
}
{
}
{
if (copy)
{
}
else
{
}
}
{
public:
{
DtWarn << "Constructing" << std::endl;
}
{
DtWarn << "Destructing" << std::endl;
}
protected:
{
DtEntityPublisher::setStateRepCreator((DtEntityPublisher::DtStateRepCreator)
}
{
DtReflectedEntity::setStateRepCreator((DtReflectedEntity::DtStateRepCreator)
}
};
#endif
Header file for encoder, decoder, and checker functions as well as FOM mapper configuration:
#pragma once
#if DtHLA
#include <vl/fomMapper.h>
RTI::AttributeHandleValuePairSet* avList,
RTI::AttributeHandle handle);
const RTI::AttributeHandleValuePairSet& avlist,
int pairSetIndex);
#endif
Implementation for encoder, decoder, and checker functions as well as FOM mapper configuration:
#if DtHLA
#include <vl/stateEncoderFactory.h>
#include <vl/stateDecoderFactory.h>
{
mapper->stateEncoderFactory()->addAttributeEncoder(
"BaseEntity.PhysicalEntity", "Temperature",
mapper->stateDecoderFactory()->addAttributeDecoder(
"BaseEntity.PhysicalEntity", "Temperature",
mapper->stateEncoderFactory()->addAttributeChecker(
"BaseEntity.PhysicalEntity", "Temperature",
}
{
}
RTI::AttributeHandleValuePairSet* avList,
RTI::AttributeHandle handle)
{
DtNetFloat64 netVal(temperature);
avList->add(handle, (char*)&netVal, sizeof(DtNetFloat64));
}
const RTI::AttributeHandleValuePairSet& avlist,
int pairSetIndex)
{
DtNetFloat64 netVal;
RTI::ULong length = 0;
avlist.getValue(pairSetIndex, (char*)&netVal, length);
}
{
}
#endif