certi-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[certi-cvs] applications/HLA_TestsSuite CMakeLists.txt test...


From: certi-cvs
Subject: [certi-cvs] applications/HLA_TestsSuite CMakeLists.txt test...
Date: Wed, 09 Jul 2008 15:37:37 +0000

CVSROOT:        /sources/certi
Module name:    applications
Changes by:     Christian Stenzel <approx>      08/07/09 15:37:37

Modified files:
        HLA_TestsSuite : CMakeLists.txt 
Added files:
        HLA_TestsSuite : test_NotificationSwitches.cc 
                         test_NotificationSwitches.fed 

Log message:
        first pattern for test federate notification services (#6893)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/CMakeLists.txt?cvsroot=certi&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/test_NotificationSwitches.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/test_NotificationSwitches.fed?cvsroot=certi&rev=1.1

Patches:
Index: CMakeLists.txt
===================================================================
RCS file: /sources/certi/applications/HLA_TestsSuite/CMakeLists.txt,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- CMakeLists.txt      2 Jul 2008 09:38:00 -0000       1.18
+++ CMakeLists.txt      9 Jul 2008 15:37:36 -0000       1.19
@@ -166,4 +166,12 @@
                       SOURCE_FILES Interactive_Federate.cc
                       COMMENTS "A multi-purpose test interactive Federate")
 
+#########################################################################
+# ADD TEST Notification SWITCH FEDERATE 
+#########################################################################      
             
+HLATestsSuite_ADD_TEST(test_NotificationSwitches
+                      FED_FILE test_NotificationSwitches.fed
+                      SOURCE_FILES test_NotificationSwitches.cc
+                      COMMENTS "A multi-purpose test interactive Federate")
+
 MESSAGE(STATUS "*** ${CMAKE_PROJECT_NAME} has been successfully configured 
***")

Index: test_NotificationSwitches.cc
===================================================================
RCS file: test_NotificationSwitches.cc
diff -N test_NotificationSwitches.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ test_NotificationSwitches.cc        9 Jul 2008 15:37:36 -0000       1.1
@@ -0,0 +1,266 @@
+#include <RTI.hh>
+#include <fedtime.hh>
+#include <NullFederateAmbassador.hh>
+
+#include <iostream>
+#include <sstream>
+#include <memory>
+#include <string>
+#include <cstdlib>
+
+using std::string;
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::auto_ptr;
+
+#define MAX_FEDERATES 10
+
+class NotificationSwitchesFed : public NullFederateAmbassador {
+
+private:
+    string federationName;
+    string fedFile;
+    bool creator;
+
+public:
+    NotificationSwitchesFed(void) {
+        federationName = "TestNotificationSwitches";
+        fedFile = "test_NotificationSwitches.fed";
+        creator = false;
+    };
+
+    virtual ~NotificationSwitchesFed() throw (RTI::FederateInternalError) {
+    };
+
+    int
+    main(void) {
+        this->create_and_join();
+        if (creator) {
+            cout << "Press ENTER to start execution ..." << endl;
+            getchar();
+
+            this->enableClassRelevanceAdvisorySwitch();
+            this->disableClassRelevanceAdvisorySwitch();
+            this->enableInteractionRelevanceAdvisorySwitch();
+            this->disableInteractionRelevanceAdvisorySwitch();
+            this->enableAttributeRelevanceAdvisorySwitch();
+            this->disableAttributeRelevanceAdvisorySwitch();
+            this->enableAttributeScopeAdvisorySwitch();
+            this->disableAttributeScopeAdvisorySwitch();
+
+        } else {
+            this->enableClassRelevanceAdvisorySwitch();
+            this->disableClassRelevanceAdvisorySwitch();
+            this->enableInteractionRelevanceAdvisorySwitch();
+            this->disableInteractionRelevanceAdvisorySwitch();
+            this->enableAttributeRelevanceAdvisorySwitch();
+            this->disableAttributeRelevanceAdvisorySwitch();
+            this->enableAttributeScopeAdvisorySwitch();
+            this->disableAttributeScopeAdvisorySwitch();
+        }
+        this->resign_and_destroy();
+        return 0;
+    };
+
+private:
+
+    void
+    create_and_join(void) {
+        try {
+            rtiamb.createFederationExecution(federationName.c_str(),
+                                             fedFile.c_str());
+            creator = true;
+        } catch ( RTI::FederationExecutionAlreadyExists& e) {
+            cout << "--> Federation already created by another federate."
+            << endl;
+        } catch ( RTI::Exception &e ) {
+            cerr << "RTI exception: " << e._name << " ["
+            << (e._reason ? e._reason : "undefined") << "]." << endl;
+        } catch ( ... ) {
+            cerr << "Error: Unknown non-RTI exception." << endl;
+        }
+
+        string federateName = "NotificationSwitches0";
+        for (int i=1;i<=MAX_FEDERATES;i++) {
+            cout << "Try to join joining federation: " << i << endl;
+            try {
+                cout << "Try to join federation as " << federateName << "." <<
+                endl;
+                rtiamb.joinFederationExecution(federateName.c_str(),
+                                               federationName.c_str(),
+                                               this);
+                cout << "Joined federation as " << federateName << "." <<
+                endl;
+                break;
+            } catch (RTI::FederateAlreadyExecutionMember& e) {
+                cout << "Federate already execution member" << endl;
+                federateName[10] = i+'0';
+                if (i==MAX_FEDERATES) {
+                    cout << "More than " << MAX_FEDERATES << " out there." <<
+                    endl;
+                    exit(-1);
+                }
+                continue;
+            } catch ( RTI::Exception &e ) {
+                cerr << "RTI exception: " << e._name << " ["
+                << (e._reason ? e._reason : "undefined") << "]." << endl;
+            } catch ( ... ) {
+                cerr << "Error: Unknown non-RTI exception." << endl;
+            }
+        }
+
+    }
+
+    void
+    resign_and_destroy(void) {
+        try {
+            rtiamb.resignFederationExecution(
+                RTI::DELETE_OBJECTS_AND_RELEASE_ATTRIBUTES);
+        } catch ( RTI::Exception &e ) {
+            cerr << "RTI exception: " << e._name << " ["
+            << (e._reason ? e._reason : "undefined") << "]." << endl;
+        } catch ( ... ) {
+            cerr << "Error: Unknown non-RTI exception." << endl;
+        }
+
+        try {
+            rtiamb.destroyFederationExecution(federationName.c_str());
+        } catch (RTI::FederatesCurrentlyJoined) {
+            cout << "Federates currently joined." << endl;
+        } catch ( RTI::Exception &e ) {
+            cerr << "RTI exception: " << e._name << " ["
+            << (e._reason ? e._reason : "undefined") << "]." << endl;
+        } catch ( ... ) {
+            cerr << "Error: Unknown non-RTI exception." << endl;
+        }
+    }
+
+    void
+    enableClassRelevanceAdvisorySwitch(void) {
+       try {
+           rtiamb.enableClassRelevanceAdvisorySwitch();
+        } catch ( RTI::Exception &e ) {
+            cerr << "RTI exception: " << e._name << " ["
+            << (e._reason ? e._reason : "undefined") << "]." << endl;
+        } catch ( ... ) {
+            cerr << "Error: unknown non-RTI exception." << endl;
+        }
+    }
+
+    void
+    disableClassRelevanceAdvisorySwitch(void) {
+       try {
+           rtiamb.disableClassRelevanceAdvisorySwitch();
+        } catch ( RTI::Exception &e ) {
+            cerr << "RTI exception: " << e._name << " ["
+            << (e._reason ? e._reason : "undefined") << "]." << endl;
+        } catch ( ... ) {
+            cerr << "Error: unknown non-RTI exception." << endl;
+        }
+    }
+
+    void
+    enableInteractionRelevanceAdvisorySwitch(void) {
+       try {
+           rtiamb.enableInteractionRelevanceAdvisorySwitch();
+        } catch ( RTI::Exception &e ) {
+            cerr << "RTI exception: " << e._name << " ["
+            << (e._reason ? e._reason : "undefined") << "]." << endl;
+        } catch ( ... ) {
+            cerr << "Error: unknown non-RTI exception." << endl;
+        }
+    }
+
+    void
+    disableInteractionRelevanceAdvisorySwitch(void) {
+       try {
+           rtiamb.disableInteractionRelevanceAdvisorySwitch();
+        } catch ( RTI::Exception &e ) {
+            cerr << "RTI exception: " << e._name << " ["
+            << (e._reason ? e._reason : "undefined") << "]." << endl;
+        } catch ( ... ) {
+            cerr << "Error: unknown non-RTI exception." << endl;
+        }
+    }
+
+    void
+    enableAttributeRelevanceAdvisorySwitch(void) {
+       try {
+           rtiamb.enableAttributeRelevanceAdvisorySwitch();
+        } catch ( RTI::Exception &e ) {
+            cerr << "RTI exception: " << e._name << " ["
+            << (e._reason ? e._reason : "undefined") << "]." << endl;
+        } catch ( ... ) {
+            cerr << "Error: unknown non-RTI exception." << endl;
+        }
+    }
+
+    void
+    disableAttributeRelevanceAdvisorySwitch(void) {
+       try {
+           rtiamb.disableAttributeRelevanceAdvisorySwitch();
+        } catch ( RTI::Exception &e ) {
+            cerr << "RTI exception: " << e._name << " ["
+            << (e._reason ? e._reason : "undefined") << "]." << endl;
+        } catch ( ... ) {
+            cerr << "Error: unknown non-RTI exception." << endl;
+        }
+    }
+
+    void
+    enableAttributeScopeAdvisorySwitch(void) {
+       try {
+           rtiamb.enableAttributeScopeAdvisorySwitch();
+        } catch ( RTI::Exception &e ) {
+            cerr << "RTI exception: " << e._name << " ["
+            << (e._reason ? e._reason : "undefined") << "]." << endl;
+        } catch ( ... ) {
+            cerr << "Error: unknown non-RTI exception." << endl;
+        }
+    }
+
+    void
+    disableAttributeScopeAdvisorySwitch(void) {
+       try {
+           rtiamb.disableAttributeScopeAdvisorySwitch();
+        } catch ( RTI::Exception &e ) {
+            cerr << "RTI exception: " << e._name << " ["
+            << (e._reason ? e._reason : "undefined") << "]." << endl;
+        } catch ( ... ) {
+            cerr << "Error: unknown non-RTI exception." << endl;
+        }
+    }
+
+    void
+    tickRTI(void) {
+        try {
+            rtiamb.tick();
+        } catch ( RTI::Exception &e ) {
+            cerr << "RTI exception: " << e._name << " ["
+            << (e._reason ? e._reason : "undefined") << "]." << endl;
+        } catch ( ... ) {
+            cerr << "Error: unknown non-RTI exception." << endl;
+        }
+    }
+
+    void
+    tickRTI(double min, double max) {
+        try {
+            rtiamb.tick(min, max);
+        } catch ( RTI::Exception &e ) {
+            cerr << "RTI exception: " << e._name << " ["
+            << (e._reason ? e._reason : "undefined") << "]." << endl;
+        } catch ( ... ) {
+            cerr << "Error: unknown non-RTI exception." << endl;
+        }
+    }
+
+protected:
+    RTI::RTIambassador rtiamb;
+};
+
+int main(int argc, char **argv) {
+    NotificationSwitchesFed testFed;
+    return testFed.main();
+}

Index: test_NotificationSwitches.fed
===================================================================
RCS file: test_NotificationSwitches.fed
diff -N test_NotificationSwitches.fed
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ test_NotificationSwitches.fed       9 Jul 2008 15:37:37 -0000       1.1
@@ -0,0 +1,28 @@
+;; TwoLevelController 
+
+(Fed
+  (Federation HugeAVPVTest)
+  (FedVersion v1.3)
+  (Federate "NotificationSwitches0" "Public")
+  (Federate "NotificationSwitches1" "Public")
+  (Federate "NotificationSwitches2" "Public")
+  (Federate "NotificationSwitches3" "Public")
+  (Federate "NotificationSwitches4" "Public")
+  (Federate "NotificationSwitches5" "Public")
+  (Federate "NotificationSwitches6" "Public")
+  (Federate "NotificationSwitches7" "Public")
+  (Federate "NotificationSwitches8" "Public")
+  (Federate "NotificationSwitches9" "Public")
+  (Spaces
+  )
+  (Objects
+    (Class ObjectRoot
+      (Attribute privilegeToDelete reliable timestamp)
+      (Class RTIprivate)
+    )
+  )
+  (Interactions
+    (Class InteractionRoot BEST_EFFORT RECEIVE
+    )
+  )
+)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]