[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[certi-cvs] applications/HLA_TestsSuite test_TRTCCallbacks....
From: |
certi-cvs |
Subject: |
[certi-cvs] applications/HLA_TestsSuite test_TRTCCallbacks.... |
Date: |
Thu, 15 Oct 2009 16:12:40 +0000 |
CVSROOT: /sources/certi
Module name: applications
Changes by: Eric NOULARD <erk> 09/10/15 16:12:39
Modified files:
HLA_TestsSuite : test_TRTCCallbacks.fed test_TRTCCallbacks.cc
Log message:
Prepare TRTCCallbacks to validate bug fixe for
bug #27595: Late arriving federate (re)starts federation from timestamp
0
to be continued. (not finished [yet])
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/test_TRTCCallbacks.fed?cvsroot=certi&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/test_TRTCCallbacks.cc?cvsroot=certi&r1=1.4&r2=1.5
Patches:
Index: test_TRTCCallbacks.fed
===================================================================
RCS file: /sources/certi/applications/HLA_TestsSuite/test_TRTCCallbacks.fed,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- test_TRTCCallbacks.fed 5 May 2008 15:55:09 -0000 1.2
+++ test_TRTCCallbacks.fed 15 Oct 2009 16:12:39 -0000 1.3
@@ -19,6 +19,10 @@
(Class ObjectRoot
(Attribute privilegeToDelete reliable timestamp)
(Class RTIprivate)
+ (Class UpdateMe
+ (Attribute PingMe reliable timestamp)
+ (Attribute Counter reliable timestamp)
+ )
)
)
(Interactions
Index: test_TRTCCallbacks.cc
===================================================================
RCS file: /sources/certi/applications/HLA_TestsSuite/test_TRTCCallbacks.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- test_TRTCCallbacks.cc 11 Jul 2008 14:57:08 -0000 1.4
+++ test_TRTCCallbacks.cc 15 Oct 2009 16:12:39 -0000 1.5
@@ -7,6 +7,8 @@
#include <memory>
#include <string>
#include <cstdlib>
+#include <vector>
+#include <HLAtypesIEEE1516.hh>
using std::string;
using std::cout;
@@ -22,15 +24,42 @@
string federationName;
string fedFile;
bool creator;
- bool TIMEREGENABLED, TIMECONENABLED;
+ bool TIME_REGULATION_ENABLED, TIME_CONSTRAINED_ENABLED;
+ bool TIME_ADVANCE_GRANT;
+ typedef struct UpdateMeH {
+ RTI::ObjectClassHandle och_updateMe;
+ RTI::AttributeHandle ah_pingMe;
+ RTI::AttributeHandle ah_counter;
+ } UpdateMeH_t;
+
+ UpdateMeH_t umoh;
+ typedef struct UpdateMeObject {
+ RTI::ObjectHandle oh_updateMe;
+ libhla::HLAdata<libhla::HLAinteger64LE> pingMe;
+ libhla::HLAdata<libhla::HLAinteger64LE> counter;
+ } UpdateMeObject_t;
+
+ std::vector<UpdateMeObject_t> umo;
+ RTIfedTime mytime;
+ RTIfedTime myLookahead;
public:
TRTCCallbacksFed(void) {
+ UpdateMeObject_t initVal;
federationName = "TestTRTCCallbacks";
fedFile = "test_TRTCCallbacks.fed";
creator = false;
- TIMEREGENABLED = false;
- TIMECONENABLED = false;
+ TIME_REGULATION_ENABLED = false;
+ TIME_CONSTRAINED_ENABLED = false;
+ umo.reserve(MAX_FEDERATES);
+ *(initVal.pingMe) = 0;
+ *(initVal.counter) = 0;
+ umo[0] = initVal;
+ // initial simulation time is 0
+ mytime.setZero();
+ myLookahead.setZero();
+ // initial [default lookahead is 1.0]
+ myLookahead = myLookahead + RTIfedTime(1.0);
};
virtual ~TRTCCallbacksFed() throw (RTI::FederateInternalError) {
@@ -39,23 +68,24 @@
int
main(void) {
this->create_and_join();
+ this->getHandles();
if (creator) {
cout << "Press ENTER to start execution ..." << endl;
getchar();
this->enableTimeReg();
- while (!TIMEREGENABLED) this->tickRTI();
- TIMEREGENABLED=false;
+ while (!TIME_REGULATION_ENABLED) this->tickRTI();
+ TIME_REGULATION_ENABLED=false;
this->enableTimeCon();
- while (!TIMECONENABLED) this->tickRTI();
- TIMECONENABLED=false;
+ while (!TIME_CONSTRAINED_ENABLED) this->tickRTI();
+ TIME_CONSTRAINED_ENABLED=false;
} else {
this->enableTimeReg();
- while (!TIMEREGENABLED) this->tickRTI();
- TIMEREGENABLED=false;
+ while (!TIME_REGULATION_ENABLED) this->tickRTI();
+ TIME_REGULATION_ENABLED=false;
this->enableTimeCon();
- while (!TIMECONENABLED) this->tickRTI();
- TIMECONENABLED=false;
+ while (!TIME_CONSTRAINED_ENABLED) this->tickRTI();
+ TIME_CONSTRAINED_ENABLED=false;
}
this->resign_and_destroy();
return 0;
@@ -134,6 +164,90 @@
}
}
+ void getHandles() {
+ // get object class handle
+ try {
+ umoh.och_updateMe =
+ rtiamb.getObjectClassHandle("UpdateMe");
+ } catch ( RTI::Exception &e ) {
+ cerr << "RTI exception: " << e._name << " ["
+ << (e._reason ? e._reason :
"undefined") << "]." << endl;
+ } catch ( ... ) {
+ cerr << "Error: Unknown non-RTI exception." << endl;
+ }
+
+ // get attribute handles
+ try {
+ umoh.ah_pingMe =
+
rtiamb.getAttributeHandle("PingMe",umoh.och_updateMe);
+ umoh.ah_counter =
+
rtiamb.getAttributeHandle("Counter",umoh.och_updateMe);
+ } catch ( RTI::Exception &e ) {
+ cerr << "RTI exception: " << e._name << " ["
+ << (e._reason ? e._reason :
"undefined") << "]." << endl;
+ } catch ( ... ) {
+ cerr << "Error: Unknown non-RTI exception." << endl;
+ }
+ }
+
+ void publishAndRegister() {
+ auto_ptr<RTI::AttributeHandleSet>
+ attributes(RTI::AttributeHandleSetFactory::create(2));
+
+ attributes->add(umoh.ah_pingMe);
+ attributes->add(umoh.ah_counter);
+
+ try {
+ rtiamb.publishObjectClass(umoh.och_updateMe,
*attributes);
+ } catch ( RTI::Exception &e ) {
+ cerr << "RTI exception: " << e._name << " ["
+ << (e._reason ? e._reason :
"undefined") << "]." << endl;
+ } catch ( ... ) {
+ cerr << "Error: unknown non-RTI exception." << endl;
+ }
+ attributes->empty();
+
+ // Register My Object instance
+ try {
+ umo[0].oh_updateMe =
rtiamb.registerObjectInstance(umoh.och_updateMe);
+ } catch ( RTI::Exception &e ) {
+ cerr << "RTI exception: " << e._name << " ["
+ << (e._reason ? e._reason :
"undefined") << "]." << endl;
+ } catch ( ... ) {
+ cerr << "Error: unknown non-RTI exception." << endl;
+ }
+ } /* end of publishAndRegister */
+
+ /**
+ * Send update attribute values.
+ * @param ts true if the UAV is timestamped false otherwise
+ */
+ void UAV(bool ts) {
+
+
+ auto_ptr<RTI::AttributeHandleValuePairSet>
+
+ ahvps(RTI::AttributeSetFactory::create(2));
+ ahvps->add(umoh.ah_counter, umo[0].counter.data(),
umo[0].counter.size());
+ ahvps->add(umoh.ah_pingMe, umo[0].pingMe.data(),
umo[0].pingMe.size());
+
+ try {
+ if (ts) {
+
rtiamb.updateAttributeValues(umo[0].oh_updateMe, *ahvps,mytime+myLookahead,
"upd");
+ }
+ else {
+
rtiamb.updateAttributeValues(umo[0].oh_updateMe, *ahvps,"upd");
+ }
+ } catch ( RTI::Exception &e ) {
+ cerr << "RTI exception: " << e._name << " ["
+ << (e._reason ? e._reason :
"undefined") << "]." << endl;
+ } catch ( ... ) {
+ cerr << "Error: unknown non-RTI exception." << endl;
+ }
+
+ ahvps->empty();
+ } /* end of UAV */
+
void
enableTimeReg(void) {
try {
@@ -182,6 +296,20 @@
}
}
+ void
+ advanceTime(double time) {
+ try {
+ rtiamb.timeAdvanceRequest(RTIfedTime(time));
+ } catch ( RTI::Exception &e ) {
+ cerr << "RTI exception: " << e._name << " ["
+ << (e._reason ? e._reason :
"undefined") << "]." << endl;
+ } catch ( ... ) {
+ cerr << "Error: unknown non-RTI exception." << endl;
+ }
+ while (!TIME_ADVANCE_GRANT) this->tickRTI();
+ TIME_ADVANCE_GRANT = false;
+ }
+
/* Federate Ambassador services */
void
timeRegulationEnabled(const RTI::FedTime& theTime)
@@ -190,7 +318,7 @@
RTI::FederateInternalError) {
cout << "Time Regulation Enabled, press ENTER to continue..." << endl;
cout << static_cast<RTIfedTime>(theTime).getTime() << endl;
- TIMEREGENABLED = true;
+ TIME_REGULATION_ENABLED = true;
getchar();
}
@@ -201,7 +329,7 @@
RTI::FederateInternalError) {
cout << "Time Constrained Enabled, press ENTER to continue..." << endl;
cout << static_cast<RTIfedTime>(theTime).getTime() << endl;
- TIMECONENABLED = true;
+ TIME_CONSTRAINED_ENABLED = true;
getchar();
}
- [certi-cvs] applications/HLA_TestsSuite test_TRTCCallbacks....,
certi-cvs <=