#include <PsnPvmReferenceObjectHandle.h>
Inheritance diagram for PsnPvmReferenceObjectHandle:


Public Methods | |
| PsnPvmReferenceObjectHandle (PsSimulatedObject &object, PsController &controller) | |
| contructor | |
| PsnPvmReferenceObjectHandle (PsSimulatedObject &object, PsController &controller, PsnSignalDispatcher *signalDispatcher) | |
| Constructor using a allready initialised signal dispatcher. | |
| virtual | ~PsnPvmReferenceObjectHandle () |
| destructor | |
| void | emettreValAttributs (PsnPvmOutgoingMessage *messFD, PsnPvmOutgoingMessage *messEV) |
| emission initiale des valeurs d'attribut vers un nouveau miroir abonne | |
| virtual void | insertInStream (ostream &=cout) const |
| insert synchronisation management data for mirrorObjectHandles in output stream | |
| virtual void | extract (istream &=cin) |
| extract synchronisation management data from mirrorObjectHandle from input stream | |
| virtual void | unpack (PsIncomingSynchronisationMessage &) |
| unpack from a synchronisation message | |
| void | makeSynchronisationMessage (const PsDate &date) |
| On stocke dans le canal le message a envoyer. | |
| virtual void | packInitialValues (PsnPvmOutgoingMessage &message) |
Static Protected Methods | |
| int | plusPetitSSMultSup (const int A, const int B) |
| Calcul du plus petit ss-multiple de A > B. | |
Protected Attributes | |
| map< PsName, PsnSvmLink * > | _needUpdateOutputValues |
| map< PsName, PsnSvmLink * > | _needAllOutputValues |
| the list of processes that need a complete message (versus just an update if the simulated object has been activated and the outputs have changed) during the next syncronisation message | |
Definition at line 37 of file PsnPvmReferenceObjectHandle.h.
|
||||||||||||
|
contructor
Definition at line 34 of file PsnPvmReferenceObjectHandle.cxx.
00036 : PsnReferenceObjectHandle ( object, controller) 00037 { 00038 } |
|
||||||||||||||||
|
Constructor using a allready initialised signal dispatcher.
Definition at line 40 of file PsnPvmReferenceObjectHandle.cxx.
00043 : PsnReferenceObjectHandle ( object, controller, signalDispatcher) 00044 { 00045 } |
|
|
destructor
Definition at line 49 of file PsnPvmReferenceObjectHandle.cxx.
00050 {
00051 }
|
|
||||||||||||
|
emission initiale des valeurs d'attribut vers un nouveau miroir abonne
Definition at line 56 of file PsnPvmReferenceObjectHandle.cxx.
00058 {
00059
00060 }
|
|
|
extract synchronisation management data from mirrorObjectHandle from input stream
Reimplemented from PsnReferenceObjectHandle. Definition at line 194 of file PsnPvmReferenceObjectHandle.cxx. References _needAllOutputValues, CancelRegistration, EventReceived, map< PsName, PsnSvmLink * >::insert(), make_pair(), PsFrequency, PsnReferenceObjectHandle::receiveRegistrationForSignal(), RegisterForSignal, and Registration.
00194 {
00195 #if defined (_DEBUGPVMMESS)
00196 cerr << "PsnPvmReferenceObjectHandle::extract:"<<endl;
00197 #endif
00198 // Type de message
00199 PsString typeMess ;
00200 // Nom du processus ou se trouve le miroir (cas de l'EV)
00201 PsName processName ;
00202
00203 in >> typeMess ;
00204 cerr << "PsnPvmReferenceObjectHandle::extract: received a message of type " <<typeMess<<endl;
00205 if (typeMess == "EV")
00206 {
00207 int typeEv ;
00208 in >> typeEv ;
00209 cerr << "PsnPvmReferenceObjectHandle::extract: received an event message of type " <<typeEv<<endl;
00210 if (typeEv == Registration)
00211 {
00212 // Frequency max des refs du pss distant
00213 PsFrequency freqPssDist ;
00214 // Frequency de ce pss
00215 PsFrequency freqLocale ;
00216 // Frequency de communication
00217 PsFrequency freqComm ;
00218
00219 // On recupere le nom du processus associe
00220 in >> processName ;
00221 #ifdef _DEBUGPVMMESS
00222 cout << "PsnPvmReferenceObjectHandle::extract "<<processName << " registred a mirror "<< endl ;
00223 #endif
00224 // On recupere le processus associe
00225 PsnSvmLink * canal = dynamic_cast<PsPvmController &>(_controller).getDistributedVirtualMachine()->getLinkToProcessNamed (processName) ;
00226
00227 PsnProcess * processDescriptor = dynamic_cast<PsPvmController &>(_controller).getDistributedVirtualMachine()->getProcessDescriptorNamed (processName) ;
00228
00229 //the registering process needs a complete version of the outputs of the object in the next synchronisation message
00230 _needAllOutputValues.insert ( make_pair (processName,canal) ) ;
00231
00232 // // On recupere la frequency max des refs du pss distant
00233 // freqPssDist = processDescriptor->getMaxFrequencyOfHostedObjects () ;
00234 // // On recupere la frequency locale
00235 // freqLocale = _myObject. getObjectDescriptor ().getFrequency () ;
00236 // // On calcule la frequency de communication
00237 // #ifdef _DEBUGPVMMESS
00238 // cout << "freqLocale : " << freqLocale << endl ;
00239 // cout << "freqPssDist : " << freqPssDist << endl ;
00240 // #endif
00241 // if (freqLocale > freqPssDist) {
00242 // freqComm = plusPetitSSMultSup(freqLocale,
00243 // freqPssDist) ;
00244 // #ifdef _DEBUGPVMMESS
00245 // cout << "freqComm : " << freqComm << endl ;
00246 // #endif
00247 // } else {
00248 // freqComm = freqLocale ;
00249 // #ifdef _DEBUGPVMMESS
00250 // cout << "freqComm : " << freqComm << endl ;
00251 // #endif
00252 // }
00253 // // On la stocke
00254 // _processFrequencies.insert(ProcessFrequenciesType::value_type(processName, freqComm)) ;
00255 }
00256 else if (typeEv == CancelRegistration) {
00257 cout << "On se desabonne" << endl ;
00258 }
00259 else if (typeEv == EventReceived) {
00260 #ifdef DEBUG
00261 cerr << "On recoit un evenement en provenance d'un miroir" << endl ;
00262 #endif
00263 assert ( false ) ;
00264 //PsEvent evt ( in ) ;
00265 //in >> evt ;
00266 //receiveReallyEvent (evt) ;
00267 }
00268 else if (typeEv == RegisterForSignal)
00269 {
00270 #ifdef DEBUG
00271 cout << "On recoit un signal en provenance d'un miroir" << endl ;
00272 #endif
00273 PsName sigId ;
00274 PsName abonne ;
00275 PsName eventId ;
00276 in >> sigId >> abonne >> eventId ;
00277 receiveRegistrationForSignal (sigId, abonne, eventId );
00278 }
00279 else {
00280 cerr<<"PsnPvmReferenceObjectHandle::extract : Type d'evenement incorrect"<<endl ;
00281 }
00282 }
00283 else {
00284 cerr<<"PsnPvmReferenceObjectHandle::extract : Type d'evenement incorrect" <<endl ;
00285 }
00286 }
|
|
|
insert synchronisation management data for mirrorObjectHandles in output stream
Reimplemented from PsnReferenceObjectHandle. Definition at line 63 of file PsnPvmReferenceObjectHandle.cxx. References PsController::error().
00064 {
00065 PsController::error ("On utilise l'insert du referentiel") ;
00066 }
|
|
|
On stocke dans le canal le message a envoyer.
Definition at line 292 of file PsnPvmReferenceObjectHandle.cxx. References PsnReferenceObjectHandle::_dateOfLastActivation, PsnObjectHandle::_myObject, _needAllOutputValues, _needUpdateOutputValues, map< PsName, PsnSvmLink * >::begin(), map< PsName, PsnSvmLink * >::clear(), map< PsName, PsnSvmLink * >::end(), PsSimulatedObject::getName(), PsnObjectHandle::getSimulatedObject(), map< PsName, PsnSvmLink * >::insert(), packInitialValues(), and PsDate.
00293 {
00294 #if defined (_DEBUGEXECPVM) || defined (_DEBUGPVMMESS)
00295 cerr<<"PsnPvmReferenceObjectHandle::makeSynchronisationMessage ( const PsDate & "<<date<< ")"<<endl;
00296 #endif
00297 PsnPvmOutgoingMessage * message ;
00298
00299 if ( _dateOfLastActivation == date )
00300 // only send a synchronisation message if the handled object has been activated
00301 {
00302 PsNameToPointerMap<PsnSvmLink>::iterator pCanal ; // iterateur
00303 // ProcessFrequenciesType::iterator pFreq ; // iterateur
00304 // PsDate dtComm ;
00305 // PsFrequency freqComm ;
00306 #ifdef _DEBUGPVMMESS
00307 cout<<"makeSynchronisationMessages of "<<getSimulatedObject().getName()<<endl;
00308 #endif
00309 // On initialise l'iterateur sur la frequency
00310 //pFreq = _processFrequencies.begin () ;
00311 //Pour tous les abonnes
00312 for (pCanal = _needUpdateOutputValues.begin () ;
00313 pCanal != _needUpdateOutputValues.end ();
00314 pCanal ++)
00315 {
00316 // On calcule le pas de temps de la communication
00317 // freqComm = (*pFreq).second ;
00318 // dtComm = 1000 / freqComm ;
00319 #ifdef _DEBUGPVMMESS
00320 cout << "dtComm : " << dtComm << endl ;
00321 #endif
00322 // On verifie qu'il faut reellement emettre
00323 // devrait maintenant etre inutile a cause des Frames majeures et mineures
00324 // if (_controller.getSimulatedDate () % dtComm == 0)
00325 // {
00326 // On recupere le message ou stocker les donnees
00327 message = &(*pCanal).second->getOutgoingBuffer () ;
00328 #ifdef _DEBUGPVMMESS
00329 cout <<"PsnPvmReferenceObjectHandle::makeSynchronisationMessage writing to the buffer: " <<message<< endl ;
00330 #endif
00331 // On va construire le message
00332 // On ajoute le destinataire, puis le type du message puis les outputs
00333 *message << _myObject.getName ()
00334 << static_cast<int> (SynchronisationMessage)
00335 << _myObject ;
00336
00337 #ifdef _DEBUGDISTRIBUTEDINIT
00338 cerr<<"PsnPvmReferenceObjectHandle::makeSynchronisationMessage : sending a message to ";
00339 (*pCanal).second->printDebuggingInformation();
00340 cerr<<" for object "<<_myObject.getName()<<endl;
00341 #endif
00342 }
00343 // On passe a la frequency suivante
00344 // pFreq ++ ;
00345 // }
00346 }
00347 else
00348 {
00349 #ifdef _DEBUGPVMMESS
00350 cerr <<"PsnPvmReferenceObjectHandle::makeSynchronisationMessage : No synchronisation needed at " << date
00351 <<", last activation : "<<_dateOfLastActivation<<endl ;
00352 #endif
00353 }
00354 // send complete values to the processes needing a complete list of the values with their associated production date.
00355 // this is done after updating, because processes in that list are then automatically inserted in the list of process needing only updates
00356 for (map<PsName, PsnSvmLink *>::iterator i = _needAllOutputValues.begin() ;
00357 i != _needAllOutputValues.end() ;
00358 ++i)
00359 {
00360 packInitialValues ( (i->second)->getOutgoingBuffer () ) ;
00361
00362 _needUpdateOutputValues.insert ( *i ) ;
00363 }
00364 _needAllOutputValues.clear() ;
00365 #ifdef _DEBUGPVMMESS
00366 cerr <<"PsnPvmReferenceObjectHandle::makeSynchronisationMessage end" <<endl ;
00367 #endif
00368 }
|
|
|
Definition at line 408 of file PsnPvmReferenceObjectHandle.cxx. References PsnObjectHandle::_myObject, PsSimulatedObject::getName(), PsName::pack(), and PsSimulatedObject::packAllValues(). Referenced by makeSynchronisationMessage().
00409 {
00410 _myObject.getName ().pack ( message ) ;
00411 message << static_cast<int> (InitialValuesMessage) ;
00412 _myObject.packAllValues ( message ) ;
00413 }
|
|
||||||||||||
|
Calcul du plus petit ss-multiple de A > B.
Definition at line 372 of file PsnPvmReferenceObjectHandle.cxx.
00372 {
00373 // Fournit le plus petit sous-multiple de A plus grand que B
00374 int i = B ; // Valeur testee
00375 // Valeur max au dela de laquelle pas ss-multiple
00376 int valMax = div (A, 2).quot ;
00377 bool ssMult = false ; // i ss-multiple de A ???
00378
00379 #ifdef DEBUG
00380 cout << "plusPetitSSMultSup***************************************" << endl ;
00381 cout << "A : " << A << ", B : " << B << endl ;
00382 cout << "valMax : " << valMax << endl ;
00383 #endif
00384
00385 // On verifie si i ss-multiple de A
00386 ssMult = (div (A, i).rem == 0) ;
00387 while ((! ssMult) && (i <= valMax)) {
00388 i++ ;
00389 // On verifie si i ss-multiple de A
00390 ssMult = (div (A, i).rem == 0) ;
00391 }
00392 if (i > valMax) {
00393 #ifdef DEBUG
00394 cout << "res : " << A << endl ;
00395 cout << "Fin de plusPetitSSMultSup***************************************" << endl;
00396 #endif
00397 return A ;
00398 } else {
00399 #ifdef DEBUG
00400 cout << "res : " << i << endl ;
00401 cout << "Fin de plusPetitSSMultSup***************************************" << endl;
00402 #endif
00403 return i ;
00404 }
00405 }
|
|
|
unpack from a synchronisation message
Reimplemented from PsFlowable. Definition at line 69 of file PsnPvmReferenceObjectHandle.cxx. References _needAllOutputValues, _needUpdateOutputValues, CancelRegistration, PsnReferenceObjectHandle::cancelRegistrationForSignal(), CancelRegistrationForSignal, PsEventCreator::createEvent(), map< PsName, PsnSvmLink * >::erase(), EventReceived, PsSimulatedObject::getSimulatedDate(), PsnObjectHandle::getSimulatedObject(), map< PsName, PsnSvmLink * >::insert(), make_pair(), PsDate, PsFrequency, PsnRequestType, PsnReferenceObjectHandle::receiveEvent(), PsnReferenceObjectHandle::receiveRegistrationForSignal(), RegisterForSignal, Registration, PsEvent::unpack(), and PsName::unpack().
00070 {
00071 #if defined (_DEBUGPVMMESS)
00072 cerr << "PsnPvmReferenceObjectHandle::unpack"<<endl;
00073 #endif
00074 // Frequency max des refs du pss distant
00075 PsFrequency freqPssDist ;
00076 // Frequency de ce pss
00077 PsFrequency freqLocale ;
00078 // Frequency de communication
00079 PsFrequency freqComm ;
00080
00081 PsnRequestType typeMess ;
00082 int messageType ;
00083
00084 in >> messageType ;
00085 typeMess = static_cast <PsnRequestType> (messageType) ;
00086
00087 #if defined (_DEBUGPVMMESS)
00088 cerr << "PsnPvmReferenceObjectHandle::unpack: received a message of type " <<typeMess<<" "<<Registration
00089 <<" at date "<<getSimulatedObject().getSimulatedDate()
00090 <<endl;
00091 #endif
00092
00093 if (typeMess == Registration)
00094 {
00095 // name of the process sending the message
00096 PsName processName ;
00097
00098 processName.unpack ( in ) ;
00099 #ifdef _DEBUGPVMMESS
00100 cout << "PsnPvmReferenceObjectHandle::unpack " << processName << " registering a mirror "<< endl ;
00101 #endif
00102 PsnSvmLink * canal = dynamic_cast<PsPvmController &>(_controller).getDistributedVirtualMachine()->getLinkToProcessNamed (processName) ;
00103
00104 PsnProcess * processDescriptor = dynamic_cast<PsPvmController &>(_controller).getDistributedVirtualMachine()->getProcessDescriptorNamed (processName) ;
00105
00106 //the registering process needs a complete version of the outputs of the object in the next synchronisation message
00107 _needAllOutputValues.insert ( make_pair(processName, canal) ) ;
00108
00109 // // On recupere la frequency max des refs du pss distant
00110 // freqPssDist = processDescriptor->getMaxFrequencyOfHostedObjects () ;
00111 // // On recupere la frequency locale
00112 // freqLocale = _myObject. getObjectDescriptor ().getFrequency () ;
00113 // // On calcule la frequency de communication
00114 // #ifdef _DEBUGPVMMESS
00115 // cout << "freqLocale : " << freqLocale << endl ;
00116 // cout << "freqPssDist : " << freqPssDist << endl ;
00117 // #endif
00118 // if (freqLocale > freqPssDist)
00119 // {
00120 // freqComm = plusPetitSSMultSup(freqLocale,
00121 // freqPssDist) ;
00122 // #ifdef _DEBUGPVMMESS
00123 // cout << "freqComm : " << freqComm << endl ;
00124 // #endif
00125 // }
00126 // else
00127 // {
00128 // freqComm = freqLocale ;
00129 // #ifdef _DEBUGPVMMESS
00130 // cout << "freqComm : " << freqComm << endl ;
00131 // #endif
00132 // }
00133 // // On la stocke
00134 // _processFrequencies.insert (ProcessFrequenciesType::value_type(processName, freqComm)) ;
00135 }
00136 else if (typeMess == CancelRegistration)
00137 {
00138 // name of the process sending the message
00139 PsName processName ;
00140 processName.unpack ( in ) ;
00141
00142 _needUpdateOutputValues.erase (processName) ;
00143 //_processFrequencies.erase ( processName ) ;
00144 _needAllOutputValues.erase ( processName ) ;
00145 }
00146 else if (typeMess == EventReceived)
00147 {
00148 #if ( defined (_DEBUGPVMMESS) || defined (_DEBUGPVMEVENTS ) )
00149 cerr << "PsnPvmReferenceObjectHandle::unpack: received an event relayed from an mirror" << endl ;
00150 #endif
00151 PsEvent * event ;
00152 PsName classToCreate ;
00153 PsEventIdentifier eventId;
00154 PsDate eventDate;
00155 PsName sender, receiver ;
00156 in >> classToCreate >> eventId>> eventDate>>sender>>receiver ;
00157 event = PsEventCreator::createEvent (classToCreate, eventId, eventDate, sender, receiver ) ;
00158 event->unpack ( in ) ;
00159 PsnReferenceObjectHandle::receiveEvent ( event ) ;
00160 }
00161 else if (typeMess == RegisterForSignal)
00162 {
00163 #ifdef _DEBUGPVMMESS
00164 cout << "PsnPvmReferenceObjectHandle::unpack: RegisterForSignal" << endl ;
00165 #endif
00166 PsName sigId ;
00167 PsName registrant ;
00168 PsName eventId ;
00169 in >> sigId >> registrant >> eventId ;
00170 receiveRegistrationForSignal (sigId, registrant, eventId );
00171 }
00172 else if (typeMess == CancelRegistrationForSignal)
00173 {
00174 #ifdef _DEBUGPVMMESS
00175 cout << "PsnPvmReferenceObjectHandle::unpack: CancelRegistrationForSignal" << endl ;
00176 #endif
00177 PsName sigId ;
00178 PsName registrant ;
00179 in >> sigId >> registrant ;
00180 cancelRegistrationForSignal (sigId, registrant) ;
00181 }
00182 else
00183 {
00184 cerr<<"PsnPvmReferenceObjectHandle::unpack : unknown request"<<endl; ;
00185 }
00186
00187 #if defined (_DEBUGPVMMESS)
00188 cerr << "PsnPvmReferenceObjectHandle::unpack finished" <<endl;
00189 #endif
00190 }
|
|
|
the list of processes that need a complete message (versus just an update if the simulated object has been activated and the outputs have changed) during the next syncronisation message
Definition at line 79 of file PsnPvmReferenceObjectHandle.h. Referenced by extract(), makeSynchronisationMessage(), and unpack(). |
|
|
Definition at line 71 of file PsnPvmReferenceObjectHandle.h. Referenced by makeSynchronisationMessage(), and unpack(). |
| Documentation generated on Mon Nov 25 15:26:22 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |