[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
applications/HLA_Tutorial DisplayServiceExplana...
From: |
certi-cvs |
Subject: |
applications/HLA_Tutorial DisplayServiceExplana... |
Date: |
Wed, 28 Nov 2007 16:47:30 +0000 |
CVSROOT: /sources/certi
Module name: applications
Changes by: Christian Stenzel <approx> 07/11/28 16:47:30
Modified files:
HLA_Tutorial : DisplayServiceExplanation.cc
DisplayServiceExplanation.hh
DisplayServiceMessages.hh
DisplayServiceMessages.hh.in
GenerateMessagesHeader.cmake
controllerFederate.cc processFederate.cc
Log message:
New texts added. The tutorial is now complete, some explanations still
need
further improvements in grammar, style (linguistic stuff).
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_Tutorial/DisplayServiceExplanation.cc?cvsroot=certi&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_Tutorial/DisplayServiceExplanation.hh?cvsroot=certi&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_Tutorial/DisplayServiceMessages.hh?cvsroot=certi&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_Tutorial/DisplayServiceMessages.hh.in?cvsroot=certi&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_Tutorial/GenerateMessagesHeader.cmake?cvsroot=certi&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_Tutorial/controllerFederate.cc?cvsroot=certi&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_Tutorial/processFederate.cc?cvsroot=certi&r1=1.5&r2=1.6
Patches:
Index: DisplayServiceExplanation.cc
===================================================================
RCS file:
/sources/certi/applications/HLA_Tutorial/DisplayServiceExplanation.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- DisplayServiceExplanation.cc 6 Nov 2007 18:04:49 -0000 1.4
+++ DisplayServiceExplanation.cc 28 Nov 2007 16:47:30 -0000 1.5
@@ -13,7 +13,7 @@
/* private methods */
void
DisplayServiceExplanation::getKeyFromCmdLine(void) {
- std::cout << "\n\n>> Press any key to resume <<" << std::endl;
+ std::cout << "\n>> Press any key to resume <<" << std::endl;
char pressedKey;
std::cin.get(pressedKey);
}
@@ -79,6 +79,71 @@
this->getKeyFromCmdLine();
}
+void
+DisplayServiceExplanation::dispPublishObjectClass(void) {
+ system(DS_CLEAR_CONSOLE_COMMAND);
+ std::cout << DS_MSG_PUBLISH_OBJECT_CLASS << std::endl;
+ std::cout << std::endl;
+ std::cout << DS_MSG_PUBLISH_OBJECT_CLASS_SRC << std::endl;
+ this->getKeyFromCmdLine();
+}
+
+void
+DisplayServiceExplanation::dispSubscribeToObjectClass(void) {
+ system(DS_CLEAR_CONSOLE_COMMAND);
+ std::cout << DS_MSG_SUBSCRIBE_TO_OBJECT_CLASS << std::endl;
+ std::cout << std::endl;
+ std::cout << DS_MSG_SUBSCRIBE_TO_OBJECT_CLASS_SRC << std::endl;
+ this->getKeyFromCmdLine();
+}
+
+/* Object Management - RTI services */
+
+void
+DisplayServiceExplanation::dispObjectManagement(void) {
+ system(DS_CLEAR_CONSOLE_COMMAND);
+ std::cout << DS_MSG_OBJECT_MANAGEMENT << std::endl;
+ this->getKeyFromCmdLine();
+}
+
+void
+DisplayServiceExplanation::dispRegisterObjectInstance(void) {
+ system(DS_CLEAR_CONSOLE_COMMAND);
+ std::cout << DS_MSG_REGISTER_OBJECT_INSTANCE << std::endl;
+ std::cout << std::endl;
+ std::cout << DS_MSG_REGISTER_OBJECT_INSTANCE_SRC << std::endl;
+ this->getKeyFromCmdLine();
+}
+
+void
+DisplayServiceExplanation::dispUpdateAttributeValues(void) {
+ system(DS_CLEAR_CONSOLE_COMMAND);
+ std::cout << DS_MSG_UPDATE_ATTRIBUTE_VALUES << std::endl;
+ std::cout << std::endl;
+ std::cout << DS_MSG_UPDATE_ATTRIBUTE_VALUES_SRC << std::endl;
+ this->getKeyFromCmdLine();
+}
+
+/* Object Management - Federate services */
+
+void
+DisplayServiceExplanation::dispDiscoverObjectInstance(void) {
+ system(DS_CLEAR_CONSOLE_COMMAND);
+ std::cout << DS_MSG_DISCOVER_OBJECT_INSTANCE << std::endl;
+ std::cout << std::endl;
+ std::cout << DS_MSG_DISCOVER_OBJECT_INSTANCE_SRC << std::endl;
+ this->getKeyFromCmdLine();
+}
+
+void
+DisplayServiceExplanation::dispReflectAttributeValues(void) {
+ system(DS_CLEAR_CONSOLE_COMMAND);
+ std::cout << DS_MSG_REFLECT_ATTRIBUTE_VALUES << std::endl;
+ std::cout << std::endl;
+ std::cout << DS_MSG_REFLECT_ATTRIBUTE_VALUES_SRC << std::endl;
+ this->getKeyFromCmdLine();
+}
+
/* Ancillary Services */
void
@@ -98,3 +163,21 @@
std::cout << DS_MSG_GET_ATTRIBUTE_HANDLE_SRC << std::endl;
this->getKeyFromCmdLine();
}
+
+void
+DisplayServiceExplanation::dispAddToAttributeHandleSet(void) {
+ system(DS_CLEAR_CONSOLE_COMMAND);
+ std::cout << DS_MSG_ADD_TO_ATTRIBUTE_HANDLE_SET << std::endl;
+ std::cout << std::endl;
+ std::cout << DS_MSG_ADD_TO_ATTRIBUTE_HANDLE_SET_SRC << std::endl;
+ this->getKeyFromCmdLine();
+}
+
+void
+DisplayServiceExplanation::dispTick(void) {
+ system(DS_CLEAR_CONSOLE_COMMAND);
+ std::cout << DS_MSG_TICK << std::endl;
+ std::cout << std::endl;
+ std::cout << DS_MSG_TICK_SRC << std::endl;
+ this->getKeyFromCmdLine();
+}
Index: DisplayServiceExplanation.hh
===================================================================
RCS file:
/sources/certi/applications/HLA_Tutorial/DisplayServiceExplanation.hh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- DisplayServiceExplanation.hh 6 Nov 2007 18:04:49 -0000 1.3
+++ DisplayServiceExplanation.hh 28 Nov 2007 16:47:30 -0000 1.4
@@ -43,6 +43,31 @@
void
dispDeclarationManagement(void);
+ void
+ dispPublishObjectClass(void);
+
+ void
+ dispSubscribeToObjectClass(void);
+
+ /* Object Management - RTI services */
+
+ void
+ dispObjectManagement(void);
+
+ void
+ dispRegisterObjectInstance(void);
+
+ void
+ dispUpdateAttributeValues(void);
+
+ /* Object Management - Federate services */
+
+ void
+ dispDiscoverObjectInstance(void);
+
+ void
+ dispReflectAttributeValues(void);
+
/* Ancillary Services */
void
@@ -51,6 +76,12 @@
void
dispGetAttributeHandle(void);
+ void
+ dispAddToAttributeHandleSet(void);
+
+ void
+ dispTick(void);
+
};
#endif /* DISPLAY_SERVICE_EXPLANATION_H */
Index: DisplayServiceMessages.hh
===================================================================
RCS file: /sources/certi/applications/HLA_Tutorial/DisplayServiceMessages.hh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- DisplayServiceMessages.hh 26 Nov 2007 11:56:15 -0000 1.3
+++ DisplayServiceMessages.hh 28 Nov 2007 16:47:30 -0000 1.4
@@ -18,6 +18,8 @@
Object Management.\
"
+/* Federation Management - RTI services */
+
#define DS_MSG_FEDERATION_MANAGEMENT "\
Federation Management\n\n\
Services of this management area coordinate federation-wide activities \
@@ -72,21 +74,22 @@
#define DS_MSG_RESIGN_FEDERATION_EXECUTION "\
Federation Management -> Resign Federation Execution\n\n\
The RTI ambassador service resignFederationExecution is used by a federate \
-when leaving the federation. The required ResignAction parameter resolves
ownership of \
-any attributes owned by the federate. Allowed values are: RELEASE_ATTRIBUTES, \
-DELETE_OBJECT, DELETE_OBJECTS_AND_RELEASE_ATTRIBUTES (common practice),
NO_ACTION. \
+when leaving the federation. The required ResignAction parameter resolves \
+ownership of any attributes owned by the federate. Allowed values are: \
+RELEASE_ATTRIBUTES, DELETE_OBJECT, \
+DELETE_OBJECTS_AND_RELEASE_ATTRIBUTES (common practice), NO_ACTION. \
"
-#define DS_MSG_RESIGN_FEDERATION_EXECUTION_SRC "Example from file:
controllerFederate.cc\n457: /* resign federation execution */\n\
-458- try {\n\
-459- rtiAmb.resignFederationExecution(\n\
-460- RTI::DELETE_OBJECTS_AND_RELEASE_ATTRIBUTES);\n\
-461- } catch ( RTI::Exception &e ) {\n\
-462- cerr << \"RTI exception: \" << e._name << \" [\"\n\
-463- << (e._reason ? e._reason : \"undefined\") << \"].\" << endl;\n\
-464- } catch ( ... ) {\n\
-465- cerr << \"Error: unknown non-RTI exception.\" << endl;\n\
-466- }\n\
+#define DS_MSG_RESIGN_FEDERATION_EXECUTION_SRC "Example from file:
controllerFederate.cc\n468: /* resign federation execution */\n\
+469- try {\n\
+470- rtiAmb.resignFederationExecution(\n\
+471- RTI::DELETE_OBJECTS_AND_RELEASE_ATTRIBUTES);\n\
+472- } catch ( RTI::Exception &e ) {\n\
+473- cerr << \"RTI exception: \" << e._name << \" [\"\n\
+474- << (e._reason ? e._reason : \"undefined\") << \"].\" << endl;\n\
+475- } catch ( ... ) {\n\
+476- cerr << \"Error: unknown non-RTI exception.\" << endl;\n\
+477- }\n\
"
#define DS_MSG_DESTROY_FEDERATION_EXECUTION "\
@@ -96,25 +99,180 @@
execution. \
"
-#define DS_MSG_DESTROY_FEDERATION_EXECUTION_SRC "Example from file:
controllerFederate.cc\n470: /* destroy federation execution */\n\
-471- try {\n\
-472- rtiAmb.destroyFederationExecution(federationName.c_str());\n\
-473- } catch (RTI::FederatesCurrentlyJoined) {\n\
-474- cout << \"Federates currently joined.\" << endl;\n\
-475- } catch ( RTI::Exception &e ) {\n\
-476- cerr << \"RTI exception: \" << e._name << \" [\"\n\
-477- << (e._reason ? e._reason : \"undefined\") << \"].\" << endl;\n\
-478- } catch ( ... ) {\n\
-479- cerr << \"Error: unknown non-RTI exception.\" << endl;\n\
-480- }\n\
+#define DS_MSG_DESTROY_FEDERATION_EXECUTION_SRC "Example from file:
controllerFederate.cc\n481: /* destroy federation execution */\n\
+482- try {\n\
+483- rtiAmb.destroyFederationExecution(federationName.c_str());\n\
+484- } catch (RTI::FederatesCurrentlyJoined) {\n\
+485- cout << \"Federates currently joined.\" << endl;\n\
+486- } catch ( RTI::Exception &e ) {\n\
+487- cerr << \"RTI exception: \" << e._name << \" [\"\n\
+488- << (e._reason ? e._reason : \"undefined\") << \"].\" << endl;\n\
+489- } catch ( ... ) {\n\
+490- cerr << \"Error: unknown non-RTI exception.\" << endl;\n\
+491- }\n\
"
+/* Declaration Management - RTI services */
+
#define DS_MSG_DECLARATION_MANAGEMENT "\
Declaration Management\n\n \
+HLA communication relies on an implicit data exchange mechanism. That's why \
+federates have to declare their intention to generate or receive information \
+in their initialization phase according to their FOM resp. their SOM. \
+Declaration Management can also be regarded as interest management. \
+ "
+
+#define DS_MSG_PUBLISH_OBJECT_CLASS "\
+Declaration Management -> Publish Object Class\n\n \
+When invoking this service the federate announces that it can produce \
+information for the specified attributes within the AttributeHandleSet class \
+in its future execution. \
+ "
+
+#define DS_MSG_PUBLISH_OBJECT_CLASS_SRC "Example from file:
controllerFederate.cc\n324: /* publish u */\n\
+325- try {\n\
+326- rtiAmb.publishObjectClass(twoLevelContrID, *attrU);\n\
+327- } catch ( RTI::Exception &e ) {\n\
+328- cerr << \"RTI exception: \" << e._name << \" [\"\n\
+329- << (e._reason ? e._reason : \"undefined\") << \"].\" << endl;\n\
+330- } catch ( ... ) {\n\
+331- cerr << \"Error: unknown non-RTI exception.\" << endl;\n\
+332- }\n\
+"
+
+#define DS_MSG_SUBSCRIBE_TO_OBJECT_CLASS "\
+Declaration Management -> Subscribe To Object Class\n\n \
+When invoking this service the federate announces that it is interested in \
+receiving updates for the specified attributes within the AttributeHandleSet \
+class in its future execution. \
+ "
+
+#define DS_MSG_SUBSCRIBE_TO_OBJECT_CLASS_SRC "Example from file:
controllerFederate.cc\n336: /* subscribe to y */\n\
+337- try {\n\
+338- rtiAmb.subscribeObjectClassAttributes(twoLevelContrID, *attrY);\n\
+339- } catch ( RTI::Exception &e ) {\n\
+340- cerr << \"RTI exception: \" << e._name << \" [\"\n\
+341- << (e._reason ? e._reason : \"undefined\") << \"].\" << endl;\n\
+342- } catch ( ... ) {\n\
+343- cerr << \"Error: unknown non-RTI exception.\" << endl;\n\
+344- }\n\
+"
+
+/* Object Management - RTI services */
+
+#define DS_MSG_OBJECT_MANAGEMENT "\
+Object Management\n\n \
+This part of the interface specification deals with deletion, instanciation, \
+modification and registration of object instances. The necessary data exchange
\
+mechanisms, especially updating and reflecting attributes and sending and \
+receiving interactions are part of this management area. \
+ "
+
+#define DS_MSG_REGISTER_OBJECT_INSTANCE "\
+Object Management -> Register Object Instance\n\n \
+This service creates a new object instance. Other federates are informed \
+through the federate service discoverObjectInstance. \
+ "
+
+#define DS_MSG_REGISTER_OBJECT_INSTANCE_SRC "Example from file:
controllerFederate.cc\n352: /* register object */\n\
+353- RTI::ObjectHandle objInstID_u;\n\
+354-\n\
+355- try {\n\
+356- objInstID_u = rtiAmb.registerObjectInstance(twoLevelContrID,
\"u\");\n\
+357- } catch ( RTI::Exception &e ) {\n\
+358- cerr << \"RTI exception: \" << e._name << \" [\"\n\
+359- << (e._reason ? e._reason : \"undefined\") << \"].\" << endl;\n\
+360- } catch ( ... ) {\n\
+361- cerr << \"Error: unknown non-RTI exception.\" << endl;\n\
+362- }\n\
+"
+
+#define DS_MSG_UPDATE_ATTRIBUTE_VALUES "\
+Object Management -> Update Attribute Values\n\n \
+The federate informs interested federates about object updates. Interested \
+federates will receive the updates by a reflectAttributeValues callback. \
"
+#define DS_MSG_UPDATE_ATTRIBUTE_VALUES_SRC "Example from file:
controllerFederate.cc\n405: /* update attribute */\n\
+406- ahvps -> add(uID, (char*)&(u), sizeof(double));\n\
+407-\n\
+408- try {\n\
+409- rtiAmb.updateAttributeValues(objInstID_u, *ahvps, \"u\");\n\
+410- } catch ( RTI::Exception &e ) {\n\
+411- cerr << \"RTI exception: \" << e._name << \" [\"\n\
+412- << (e._reason ? e._reason : \"undefined\") << \"].\" <<
endl;\n\
+413- } catch ( ... ) {\n\
+414- cerr << \"Error: unknown non-RTI exception.\" << endl;\n\
+415- }\n\
+"
+
+/* Object Management - Federate services */
+
+#define DS_MSG_DISCOVER_OBJECT_INSTANCE "\
+Object Management -> Discover Object Instance\n\n \
+This federate service informs the federate of a new object instance. Federates
\
+are only informed about new objects if they have specified their interests in \
+a former subscription invocation. In this case, we are informed about a new \
+instance of the output variable y. \
+ "
+
+#define DS_MSG_DISCOVER_OBJECT_INSTANCE_SRC "Example from file:
controllerFederate.cc\n167: discoverObjectInstance (RTI::ObjectHandle
theObject,\n\
+168- RTI::ObjectClassHandle theObjectClass,\n\
+169- const char *theObjectName)\n\
+170- throw ( RTI::CouldNotDiscover,\n\
+171- RTI::ObjectClassNotKnown,\n\
+172- RTI::FederateInternalError) {\n\
+173- cout << \"discoverObjInst \" << theObjectName << endl;\n\
+174- if (!strcmp(theObjectName,\"y\")) {\n\
+175- discovY = true;\n\
+176- }\n\
+177- }\n\
+"
+
+#define DS_MSG_REFLECT_ATTRIBUTE_VALUES "\
+Object Management -> Reflect Attribute Values\n\n \
+This federate service informs the federate of new state updates for attributes
\
+it is currently interesting in. \
+ "
+
+#define DS_MSG_REFLECT_ATTRIBUTE_VALUES_SRC "Example from file:
controllerFederate.cc\n189: reflectAttributeValues (RTI::ObjectHandle
theObject,\n\
+190- const RTI::AttributeHandleValuePairSet&\n\
+191- theAttributes,\n\
+192- const char *theTag)\n\
+193- throw ( RTI::ObjectNotKnown,\n\
+194- RTI::AttributeNotKnown,\n\
+195- RTI::FederateOwnsAttributes,\n\
+196- RTI::FederateInternalError) {\n\
+197- RTI::ULong length;\n\
+198- char *attrValue;\n\
+199-\n\
+200- /*\n\
+201- * common implementation scheme is to iterate through the\n\
+202- * AttributeHandleValuePairSet.\n\
+203- */\n\
+204- for (unsigned int i=0; i<theAttributes.size(); i++) {\n\
+205-\n\
+206- RTI::AttributeHandle handle = theAttributes.getHandle(i);\n\
+207- length = theAttributes.getValueLength(i);\n\
+208- attrValue = new char[length];\n\
+209- theAttributes.getValue(i, attrValue, length);\n\
+210-\n\
+211- if (!strcmp(theTag,\"y\")) {\n\
+212- y = *(reinterpret_cast<double*>(attrValue));\n\
+213- newY = true;\n\
+214- }\n\
+215-\n\
+216- delete[] attrValue;\n\
+217- }\n\
+218- }\n\
+"
+
+/* Ancillary Services */
+
#define DS_MSG_GET_OBJECT_CLASS_HANDLE "\
Ancillary Service -> Get Object Class Handle\n\n \
+This service returns a numeric handle for the named object class \
+according to the FOM resp. SOM. \
"
#define DS_MSG_GET_OBJECT_CLASS_HANDLE_SRC "Example from file:
controllerFederate.cc\n277: /* get object class handle */\n\
@@ -132,6 +290,8 @@
#define DS_MSG_GET_ATTRIBUTE_HANDLE "\
Ancillary Service -> Get Attribute Handle\n\n \
+This service returns a numeric handle for the named attribute according to \
+the FOM resp. SOM. \
"
#define DS_MSG_GET_ATTRIBUTE_HANDLE_SRC "Example from file:
controllerFederate.cc\n291: /* get attribute handle */\n\
@@ -146,6 +306,44 @@
300- }\n\
"
+#define DS_MSG_ADD_TO_ATTRIBUTE_HANDLE_SET "\
+Ancillary Service -> Add attribute handles to attribute handle set\n\n \
+The code below shows how to add attributes to the AttributeHandleSet class. \
+ "
+
+#define DS_MSG_ADD_TO_ATTRIBUTE_HANDLE_SET_SRC "Example from file:
controllerFederate.cc\n313: /* add attribute handle to AttributeHandleSet
*/\n\
+314- auto_ptr<RTI::AttributeHandleSet>\n\
+315- attrU(RTI::AttributeHandleSetFactory::create(1));\n\
+316- auto_ptr<RTI::AttributeHandleSet>\n\
+317- attrY(RTI::AttributeHandleSetFactory::create(1));\n\
+318-\n\
+319- attrU->add(uID);\n\
+320- attrY->add(yID);\n\
+"
+
+#define DS_MSG_TICK "\
+Ancillary Service -> Tick\n\n \
+Tick is used to provide computation time to the LRC. Here we tick until we \
+get the discoverObjectInstance callback. \
+ "
+
+#define DS_MSG_TICK_SRC "Example from file: controllerFederate.cc\n367: /*
discover y */\n\
+368- cout << \"Wait for second federate.\" << endl;\n\
+369- while (!myFedAmb.getDiscoverY()) {\n\
+370-\n\
+371- try {\n\
+372- rtiAmb.tick();\n\
+373- } catch ( RTI::Exception &e ) {\n\
+374- cerr << \"RTI exception: \" << e._name << \" [\"\n\
+375- << (e._reason ? e._reason : \"undefined\") << \"].\" <<
endl;\n\
+376- } catch ( ... ) {\n\
+377- cerr << \"Error: unknown non-RTI exception.\" << endl;\n\
+378- }\n\
+379-\n\
+380- sleep(1);\n\
+381- }\n\
+382- myFedAmb.setDiscoverY(false);\n\
+"
#ifdef _WIN32
#define DS_CLEAR_CONSOLE_COMMAND "cls"
Index: DisplayServiceMessages.hh.in
===================================================================
RCS file:
/sources/certi/applications/HLA_Tutorial/DisplayServiceMessages.hh.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- DisplayServiceMessages.hh.in 6 Nov 2007 18:04:49 -0000 1.2
+++ DisplayServiceMessages.hh.in 28 Nov 2007 16:47:30 -0000 1.3
@@ -18,6 +18,8 @@
Object Management.\
"
+/* Federation Management - RTI services */
+
#define DS_MSG_FEDERATION_MANAGEMENT "\
Federation Management\n\n\
Services of this management area coordinate federation-wide activities \
@@ -48,9 +50,10 @@
#define DS_MSG_RESIGN_FEDERATION_EXECUTION "\
Federation Management -> Resign Federation Execution\n\n\
The RTI ambassador service resignFederationExecution is used by a federate \
-when leaving the federation. The required ResignAction parameter resolves
ownership of \
-any attributes owned by the federate. Allowed values are: RELEASE_ATTRIBUTES, \
-DELETE_OBJECT, DELETE_OBJECTS_AND_RELEASE_ATTRIBUTES (common practice),
NO_ACTION. \
+when leaving the federation. The required ResignAction parameter resolves \
+ownership of any attributes owned by the federate. Allowed values are: \
+RELEASE_ATTRIBUTES, DELETE_OBJECT, \
+DELETE_OBJECTS_AND_RELEASE_ATTRIBUTES (common practice), NO_ACTION. \
"
#define DS_MSG_RESIGN_FEDERATION_EXECUTION_SRC
"@DS_MSG_RESIGN_FEDERATION_EXECUTION_SRC@"
@@ -64,22 +67,112 @@
#define DS_MSG_DESTROY_FEDERATION_EXECUTION_SRC
"@DS_MSG_DESTROY_FEDERATION_EXECUTION_SRC@"
+/* Declaration Management - RTI services */
+
#define DS_MSG_DECLARATION_MANAGEMENT "\
Declaration Management\n\n \
+HLA communication relies on an implicit data exchange mechanism. That's why \
+federates have to declare their intention to generate or receive information \
+in their initialization phase according to their FOM resp. their SOM. \
+Declaration Management can also be regarded as interest management. \
+ "
+
+#define DS_MSG_PUBLISH_OBJECT_CLASS "\
+Declaration Management -> Publish Object Class\n\n \
+When invoking this service the federate announces that it can produce \
+information for the specified attributes within the AttributeHandleSet class \
+in its future execution. \
+ "
+
+#define DS_MSG_PUBLISH_OBJECT_CLASS_SRC "@DS_MSG_PUBLISH_OBJECT_CLASS_SRC@"
+
+#define DS_MSG_SUBSCRIBE_TO_OBJECT_CLASS "\
+Declaration Management -> Subscribe To Object Class\n\n \
+When invoking this service the federate announces that it is interested in \
+receiving updates for the specified attributes within the AttributeHandleSet \
+class in its future execution. \
+ "
+
+#define DS_MSG_SUBSCRIBE_TO_OBJECT_CLASS_SRC
"@DS_MSG_SUBSCRIBE_TO_OBJECT_CLASS_SRC@"
+
+/* Object Management - RTI services */
+
+#define DS_MSG_OBJECT_MANAGEMENT "\
+Object Management\n\n \
+This part of the interface specification deals with deletion, instanciation, \
+modification and registration of object instances. The necessary data exchange
\
+mechanisms, especially updating and reflecting attributes and sending and \
+receiving interactions are part of this management area. \
+ "
+
+#define DS_MSG_REGISTER_OBJECT_INSTANCE "\
+Object Management -> Register Object Instance\n\n \
+This service creates a new object instance. Other federates are informed \
+through the federate service discoverObjectInstance. \
+ "
+
+#define DS_MSG_REGISTER_OBJECT_INSTANCE_SRC
"@DS_MSG_REGISTER_OBJECT_INSTANCE_SRC@"
+
+#define DS_MSG_UPDATE_ATTRIBUTE_VALUES "\
+Object Management -> Update Attribute Values\n\n \
+The federate informs interested federates about object updates. Interested \
+federates will receive the updates by a reflectAttributeValues callback. \
+ "
+
+#define DS_MSG_UPDATE_ATTRIBUTE_VALUES_SRC
"@DS_MSG_UPDATE_ATTRIBUTE_VALUES_SRC@"
+
+/* Object Management - Federate services */
+
+#define DS_MSG_DISCOVER_OBJECT_INSTANCE "\
+Object Management -> Discover Object Instance\n\n \
+This federate service informs the federate of a new object instance. Federates
\
+are only informed about new objects if they have specified their interests in \
+a former subscription invocation. In this case, we are informed about a new \
+instance of the output variable y. \
+ "
+
+#define DS_MSG_DISCOVER_OBJECT_INSTANCE_SRC
"@DS_MSG_DISCOVER_OBJECT_INSTANCE_SRC@"
+
+#define DS_MSG_REFLECT_ATTRIBUTE_VALUES "\
+Object Management -> Reflect Attribute Values\n\n \
+This federate service informs the federate of new state updates for attributes
\
+it is currently interesting in. \
"
+#define DS_MSG_REFLECT_ATTRIBUTE_VALUES_SRC
"@DS_MSG_REFLECT_ATTRIBUTE_VALUES_SRC@"
+
+/* Ancillary Services */
+
#define DS_MSG_GET_OBJECT_CLASS_HANDLE "\
Ancillary Service -> Get Object Class Handle\n\n \
+This service returns a numeric handle for the named object class \
+according to the FOM resp. SOM. \
"
#define DS_MSG_GET_OBJECT_CLASS_HANDLE_SRC
"@DS_MSG_GET_OBJECT_CLASS_HANDLE_SRC@"
#define DS_MSG_GET_ATTRIBUTE_HANDLE "\
Ancillary Service -> Get Attribute Handle\n\n \
+This service returns a numeric handle for the named attribute according to \
+the FOM resp. SOM. \
"
#define DS_MSG_GET_ATTRIBUTE_HANDLE_SRC "@DS_MSG_GET_ATTRIBUTE_HANDLE_SRC@"
+#define DS_MSG_ADD_TO_ATTRIBUTE_HANDLE_SET "\
+Ancillary Service -> Add attribute handles to attribute handle set\n\n \
+The code below shows how to add attributes to the AttributeHandleSet class. \
+ "
+
+#define DS_MSG_ADD_TO_ATTRIBUTE_HANDLE_SET_SRC
"@DS_MSG_ADD_TO_ATTRIBUTE_HANDLE_SET_SRC@"
+
+#define DS_MSG_TICK "\
+Ancillary Service -> Tick\n\n \
+Tick is used to provide computation time to the LRC. Here we tick until we \
+get the discoverObjectInstance callback. \
+ "
+
+#define DS_MSG_TICK_SRC "@DS_MSG_TICK_SRC@"
#ifdef _WIN32
#define DS_CLEAR_CONSOLE_COMMAND "cls"
Index: GenerateMessagesHeader.cmake
===================================================================
RCS file:
/sources/certi/applications/HLA_Tutorial/GenerateMessagesHeader.cmake,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- GenerateMessagesHeader.cmake 6 Nov 2007 18:04:49 -0000 1.2
+++ GenerateMessagesHeader.cmake 28 Nov 2007 16:47:30 -0000 1.3
@@ -41,15 +41,25 @@
ENDMACRO(GREP_SOURCE SRC_FILE FROM_STRING FOR_NB_LINES VARNAME)
IF(UNIX)
- # federation management
+ # federation management - rti services
GREP_SOURCE(controllerFederate.cc "create federation execution" 12
DS_MSG_CREATE_FEDERATION_EXECUTION_SRC)
GREP_SOURCE(controllerFederate.cc "join federation execution" 10
DS_MSG_JOIN_FEDERATION_EXECUTION_SRC)
GREP_SOURCE(controllerFederate.cc "resign federation execution" 9
DS_MSG_RESIGN_FEDERATION_EXECUTION_SRC)
GREP_SOURCE(controllerFederate.cc "destroy federation execution" 10
DS_MSG_DESTROY_FEDERATION_EXECUTION_SRC)
- # declaration management
+ # declaration management - rti services
+ GREP_SOURCE(controllerFederate.cc "publish u" 8
DS_MSG_PUBLISH_OBJECT_CLASS_SRC)
+ GREP_SOURCE(controllerFederate.cc "subscribe to y" 8
DS_MSG_SUBSCRIBE_TO_OBJECT_CLASS_SRC)
+ # object management - rti services
+ GREP_SOURCE(controllerFederate.cc "register object" 10
DS_MSG_REGISTER_OBJECT_INSTANCE_SRC)
+ GREP_SOURCE(controllerFederate.cc "update attribute" 10
DS_MSG_UPDATE_ATTRIBUTE_VALUES_SRC)
+ # object management - federate services
+ GREP_SOURCE(controllerFederate.cc "discoverObjectInstance (RTI" 10
DS_MSG_DISCOVER_OBJECT_INSTANCE_SRC)
+ GREP_SOURCE(controllerFederate.cc "reflectAttributeValues (RTI" 29
DS_MSG_REFLECT_ATTRIBUTE_VALUES_SRC)
# ancillary services
GREP_SOURCE(controllerFederate.cc "get object class handle" 10
DS_MSG_GET_OBJECT_CLASS_HANDLE_SRC)
GREP_SOURCE(controllerFederate.cc "get attribute handle" 9
DS_MSG_GET_ATTRIBUTE_HANDLE_SRC)
+ GREP_SOURCE(controllerFederate.cc "add attribute handle" 7
DS_MSG_ADD_TO_ATTRIBUTE_HANDLE_SET_SRC)
+ GREP_SOURCE(controllerFederate.cc "discover y" 15 DS_MSG_TICK_SRC)
# Then we generate the header using var value replacement
CONFIGURE_FILE(DisplayServiceMessages.hh.in
${CMAKE_CURRENT_SOURCE_DIR}/DisplayServiceMessages.hh)
ENDIF(UNIX)
Index: controllerFederate.cc
===================================================================
RCS file: /sources/certi/applications/HLA_Tutorial/controllerFederate.cc,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- controllerFederate.cc 26 Nov 2007 11:56:15 -0000 1.6
+++ controllerFederate.cc 28 Nov 2007 16:47:30 -0000 1.7
@@ -164,7 +164,7 @@
* @exception RTI::FederateInternalError internal error
*/
void
- discoverObjectInstance ( RTI::ObjectHandle theObject,
+ discoverObjectInstance (RTI::ObjectHandle theObject,
RTI::ObjectClassHandle theObjectClass,
const char *theObjectName)
throw ( RTI::CouldNotDiscover,
@@ -186,7 +186,7 @@
* @param[in] theTag
*/
void
- reflectAttributeValues( RTI::ObjectHandle theObject,
+ reflectAttributeValues (RTI::ObjectHandle theObject,
const RTI::AttributeHandleValuePairSet&
theAttributes,
const char *theTag)
@@ -308,6 +308,9 @@
cerr << "Error: unknown non-RTI exception." << endl;
}
+ dispSE.dispAddToAttributeHandleSet();
+
+ /* add attribute handle to AttributeHandleSet */
auto_ptr<RTI::AttributeHandleSet>
attrU(RTI::AttributeHandleSetFactory::create(1));
auto_ptr<RTI::AttributeHandleSet>
@@ -316,6 +319,8 @@
attrU->add(uID);
attrY->add(yID);
+ dispSE.dispPublishObjectClass();
+
/* publish u */
try {
rtiAmb.publishObjectClass(twoLevelContrID, *attrU);
@@ -326,6 +331,8 @@
cerr << "Error: unknown non-RTI exception." << endl;
}
+ dispSE.dispSubscribeToObjectClass();
+
/* subscribe to y */
try {
rtiAmb.subscribeObjectClassAttributes(twoLevelContrID, *attrY);
@@ -338,6 +345,10 @@
/* Object Management */
+ dispSE.dispObjectManagement();
+
+ dispSE.dispRegisterObjectInstance();
+
/* register object */
RTI::ObjectHandle objInstID_u;
@@ -350,16 +361,10 @@
cerr << "Error: unknown non-RTI exception." << endl;
}
- /* Time Management */
- try {
- rtiAmb.enableAsynchronousDelivery();
- } catch ( RTI::Exception &e ) {
- cerr << "RTI exception: " << e._name << " ["
- << (e._reason ? e._reason : "undefined") << "]." << endl;
- } catch ( ... ) {
- cerr << "Error: unknown non-RTI exception." << endl;
- }
+ dispSE.dispTick();
+ dispSE.dispDiscoverObjectInstance();
+ /* discover y */
cout << "Wait for second federate." << endl;
while (!myFedAmb.getDiscoverY()) {
@@ -426,6 +431,12 @@
}
myFedAmb.setNewY(false);
+ if (tSim==tStart) {
+ cout << "gaskfgkjh" << endl;
+ dispSE.dispUpdateAttributeValues();
+ dispSE.dispReflectAttributeValues();
+ }
+
cout << "tSim: " << tSim << ", u= " << u << ", y= " << y << endl;
tSim += h;
}
Index: processFederate.cc
===================================================================
RCS file: /sources/certi/applications/HLA_Tutorial/processFederate.cc,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- processFederate.cc 26 Nov 2007 11:56:15 -0000 1.5
+++ processFederate.cc 28 Nov 2007 16:47:30 -0000 1.6
@@ -293,6 +293,7 @@
cerr << "Error: unknown non-RTI exception." << endl;
}
+ /* add attribute handle to AttributeHandleSet */
auto_ptr<RTI::AttributeHandleSet>
attrU(RTI::AttributeHandleSetFactory::create(1));
auto_ptr<RTI::AttributeHandleSet>
@@ -335,16 +336,6 @@
cerr << "Error: unknown non-RTI exception." << endl;
}
- /* Time Mangement */
- try {
- rtiAmb.enableAsynchronousDelivery();
- } catch ( RTI::Exception &e ) {
- cerr << "RTI exception: " << e._name << " ["
- << (e._reason ? e._reason : "undefined") << "]." << endl;
- } catch ( ... ) {
- cerr << "Error: unknown non-RTI exception." << endl;
- }
-
cout << "Wait for second federate." << endl;
while (!myFedAmb.getDiscoverU()) {