certi-cvs
[Top][All Lists]
Advanced

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

[certi-cvs] applications/HLA_TestsSuite create_destroy.cc c...


From: certi-cvs
Subject: [certi-cvs] applications/HLA_TestsSuite create_destroy.cc c...
Date: Thu, 15 May 2008 14:58:54 +0000

CVSROOT:        /sources/certi
Module name:    applications
Changes by:     ROUSSELOT <rousse>      08/05/15 14:58:53

Modified files:
        HLA_TestsSuite : create_destroy.cc create_destroy.hh 

Log message:
        Adding synchronizations tests

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/create_destroy.cc?cvsroot=certi&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/applications/HLA_TestsSuite/create_destroy.hh?cvsroot=certi&r1=1.1&r2=1.2

Patches:
Index: create_destroy.cc
===================================================================
RCS file: /sources/certi/applications/HLA_TestsSuite/create_destroy.cc,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- create_destroy.cc   14 May 2008 13:33:23 -0000      1.6
+++ create_destroy.cc   15 May 2008 14:58:52 -0000      1.7
@@ -6,7 +6,7 @@
   Create_Destroy() throw (RTI::RTIinternalError) {}
   virtual ~Create_Destroy() throw (RTI::FederateInternalError) {}
   virtual bool publishAndSubscribe(char *classe,char *attribut,char 
*interact,char *param);
-
+  void workOnSynchro() ;
 
 
 private:
@@ -62,6 +62,38 @@
 Object_discovered = theObject;
 
 }
+//---------------------- announceSynchronizationPoint -------------------------
+void
+announceSynchronizationPoint(const char *label, const char *tag)
+    throw (RTI::FederateInternalError)
+{
+    std::cout << std::endl << "<----- 
announceSynchronizationPoint("<<label<<","<<tag<<")"<<std::endl;
+    if ( strcmp(label, synchroLabel) == 0  && strcmp(tag,synchroTag) == 0 ) {
+        //paused = true ;
+        printf("Synchronization point (%s,%s) announced\n",label,tag);
+    }      
+    else {
+        printf("Unexpected synchronization point (%s,%s)\n",label,tag);
+    }
+}
+
+//-------------------------federation synchronized ----------------------------
+void
+federationSynchronized(const char *label)
+    throw (RTI::FederateInternalError)
+{
+    std::cout << std::endl << "<----- 
federationSynchronized("<<label<<")"<<std::endl;
+    if (strcmp(label, synchroLabel) == 0) {
+        //paused = false ;
+        printf("federationSynchronized with label %s\n", label);
+    }
+}
+//----------------------- synchronizationPointRegistrationSucceeded -----------
+void synchronizationPointRegistrationSucceeded(const char *label) 
+     throw (RTI::FederateInternalError)
+{
+    std::cout << std::endl << "<----- 
synchronizationPointRegistrationSucceeded("<<label<<")"<<std::endl; 
+}
 //------------------------- reflectAttributeValues ----------------------------
 void
 reflectAttributeValues(
@@ -118,6 +150,7 @@
     RTI::InteractionClassHandle InteractClassID ;
     RTI::ParameterHandle ParameterID ;
   RTI::ObjectHandle Object_discovered;
+    char synchroLabel[NBCAR] ,synchroTag[NBCAR] ;
 };
 
 //Ambassador
@@ -461,9 +494,17 @@
          printf("publish and subscribe made\n");;
      }
 
-//=============================== 6d step  ====================================
+//=============================== 7d step  ====================================
+    // REGISTER SYNCHRONIZATION POINT
+    answer = say_Y_N("Do you want to work on Synchronizations ? [y/n]",8);
+    if ( answer == 'y' )
+       {
+       myCreate_Destroy->workOnSynchro() ;
+       }
+
+//=============================== 8d step  ====================================
 //RESIGNING FEDERATION EXECUTION
-  answer = say_Y_N("Do you want to resign federation ? [y/n]",8);
+  answer = say_Y_N("Do you want to resign federation ? [y/n]",9);
   if ( answer == 'y' )
      {
      try {
@@ -474,9 +515,9 @@
           { printf("ERROR : Resign not done %s (%s)\n",e._name,e._reason); }
      }
 
-//=============================== 7d step  ====================================
+//=============================== 9d step  ====================================
 //DESTROYING FEDERATION EXECUTION
-  answer = say_Y_N("Do you want to destroy federation ? [y/n]",9);
+  answer = say_Y_N("Do you want to destroy federation ? [y/n]",10);
   if ( answer == 'y' )
      {
       try {
@@ -518,10 +559,10 @@
           }
      }
      //delete myCreate_Destroy ;
-//=============================== 7d step  ====================================
+//=============================== 10d step  
====================================
 //CREATE -JOIN - RESIGN -DESTROY - CREATE - JOIN - RESIGN - DESTROY
 
-  answer = say_Y_N("Do you want to do loop create-join-resign-destroy 2 times 
? [y/n]",10);
+  answer = say_Y_N("Do you want to do loop create-join-resign-destroy 2 times 
? [y/n]",11);
   if ( answer == 'y' )
      {
      printf("************************************** LOOP n°1 
*************\n");
@@ -692,6 +733,69 @@
     
printf("------------------------------------------------------------------------\n");
     }
 }
+//=========================== workOnSynchro ===================================
+// Working on synchronizations
+void
+Create_Destroy::workOnSynchro()
+{
+    char answer ;
+
+    printf("Label ? : ");
+    scanf("%s",synchroLabel);
+    printf("Tag ? : ");
+    scanf("%s",synchroTag);
+
+    // REGISTER SYNCHRONIZATION POINT
+    answer = say_Y_N("Do you want to do a 
registerFederationSynchronizationPoint ? [y/n]",81);
+    if ( answer == 'y' )
+       {
+       try {
+            
myCreate_Destroy->registerFederationSynchronizationPoint(synchroLabel,synchroTag);
+            printf("Synchronization point registered with label %s and tag 
%s\n",
+                   synchroLabel,synchroTag);
+        }
+        catch (RTI::Exception& e) {
+            printf("Synchronization point registration failed \n");
+            }
+       }
+
+     // TICK
+     answer = say_Y_N("Do you want to do a tick to get synchronization point 
registration succeeded ? [y/n]",82);
+    if ( answer == 'y' )
+       {  
+       myCreate_Destroy->tick(); 
+       }
+
+     // TICK
+     answer = say_Y_N("Do you want to do a tick to get announce 
synchronization point ? [y/n]",83);
+    if ( answer == 'y' )
+       {  
+       myCreate_Destroy->tick(); 
+       }
+
+    // SYNCHRONIZATION ACHEIVED
+    answer = say_Y_N("Do you want to do a SynchronizationPointAchieved ? 
[y/n]",84);
+    if ( answer == 'y' )
+       {
+       printf("Label ? : ");
+       scanf("%s",synchroLabel);
+       try {
+            myCreate_Destroy->synchronizationPointAchieved(synchroLabel);
+            printf("Synchronization point achieved with label 
%s\n",synchroLabel);
+        }
+        catch (RTI::Exception& e) {
+            printf("Synchronization point achievement failed \n");
+            }
+       }
+      
+     // TICK
+     answer = say_Y_N("Do you want to do a tick to get federation synchronized 
? [y/n]",85);
+    if ( answer == 'y' )
+       {  
+       myCreate_Destroy->tick(); 
+       }
+}
+
 // ----------------------------------------------------------------------------
 /** get handles of objet/interaction classes
  */
@@ -742,6 +846,7 @@
     RTI::ObjectHandle object_handle ;
     int dx ,x;
 
+
     // Get all class and attributes handles
     // For class name (like Bille)
     // For attribute name (like PositionX)
@@ -877,9 +982,10 @@
        }
 
     
+ 
     // SEND INTERACTION
     // 1 parameter : PositionX value stored in ParameterSet
-//    answer = say_Y_N("Do you want to do a sendInteraction ? [y/n]",701);
+//    answer = say_Y_N("Do you want to do a sendInteraction ? [y/n]",706);
     answer = 'n' ;
     if ( answer == 'y' )
        {

Index: create_destroy.hh
===================================================================
RCS file: /sources/certi/applications/HLA_TestsSuite/create_destroy.hh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- create_destroy.hh   28 Apr 2008 12:17:03 -0000      1.1
+++ create_destroy.hh   15 May 2008 14:58:52 -0000      1.2
@@ -11,4 +11,7 @@
 void changingNames(char *federationname,char *fedfilename);
 bool creeFedExec(char *federationName, char *fileName);
 
+
 using std::auto_ptr ;
+
+




reply via email to

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