⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 my_fed.cc

📁 certi-SHM-3.0.tar 不错的开源的分布式方针软件 大家多多支持 他是linux
💻 CC
📖 第 1 页 / 共 2 页
字号:
        Local.dy = dy1 ;        D.Out(pdDebug, "**** receiveInteraction(*) - dx1 = %f, local.dx = %f",              dx1, Local.dx);        D.Out(pdDebug, "**** receiveInteraction(*) - dy1 = %f, local.dy = %f",              dy1, Local.dy);    }}// ----------------------------------------------------------------------------//! reflectAttributeValues.voidFed::reflectAttributeValues(ObjectHandle theObject,                            const AttributeHandleValuePairSet& theAttributes,                            const FedTime& theTime,                            const char */*theTag*/,                            EventRetractionHandle /*theHandle*/)    throw (ObjectNotKnown,           AttributeNotKnown,           InvalidFederationTime,           FederateInternalError){    D.Out(pdTrace, "reflectAttributeValues");    int i=0 ;    float oldx, oldy ;    // AttributeHandle *attribut ;    ULong valueLength ;    char *attrValue ;    if (verbose)        cout << "<= RAV " << ((RTIfedTime) theTime).getTime() << endl ;    for (i=0 ; i<RemoteCount ; i++) {        if (Remote[i].ID == theObject)            break ;    }    if (i == RemoteCount)        D.Out(pdError, "Fed: error, id not found (%d).", theObject);    else {        Remote[i].Effacer();        D.Out(pdDebug, "reflectAttributeValues - nb attributs= %d",              theAttributes.size());        for (unsigned int j=0 ; j<theAttributes.size(); j++) {            AttributeHandle handle = theAttributes.getHandle(j);            valueLength = theAttributes.getValueLength(j);            attrValue = new char[valueLength] ;            theAttributes.getValue(j, attrValue, valueLength);            if (handle == AttrXID) {                if (attrValue != NULL) {                    oldx = Remote[i].x ;                    Remote[i].x = atof(attrValue);                    Remote[i].dx = Remote[i].x - oldx ;                    D.Out(pdDebug, "reflectAttributeValues - x= %f, dx= %f",                          Remote[i].x, Remote[i].dx);                    delete[] attrValue ;                }                else                    D.Out(pdError, "Fed: ERREUR: missing Attribute.");            }            else if (handle == AttrYID) {                if (attrValue != NULL) {                    oldy = Remote[i].y ;                    Remote[i].y = atof(attrValue);                    Remote[i].dy = Remote[i].y - oldy ;                    D.Out(pdDebug, "reflectAttributeValues - y= %f, dy= %f",                          Remote[i].y, Remote[i].dy);                    delete[] attrValue ;                }                else                    D.Out(pdError, "Fed: ERREUR: missing Attribute.");            }            else                D.Out(pdError, "Fed: ERREUR: handle inconnu.");        }        Remote[i].Afficher();    }}// ----------------------------------------------------------------------------//! Get object IDs from the RTIA and register local objects.void Fed::RegisterObjects(const char *s){    Local.ID = RTIA->registerObjectInstance(BouleClassID, s);    //    Local.ID = RTIA->registerObjectInstance(BilleClassID, s);    D.Out(pdRegister, "Local object registered under ID %d.", Local.ID);}// ----------------------------------------------------------------------------//! removeObjectInstance.voidFed::removeObjectInstance(ObjectHandle theObject,                          //ObjectRemovalReason theReason,                          const FedTime& /*theTime*/,                          const char */*theTag*/,                          EventRetractionHandle /*theHandle*/)    throw (ObjectNotKnown,           InvalidFederationTime,           FederateInternalError){    int i = 0 ;    for (int i=0 ; i<RemoteCount ; i++) {        if (Remote[i].ID == theObject)            break ;    }    if (i == RemoteCount)        printf("Fed: error, id not found (%ld)\n", theObject);    else {        printf("Fed: RemoveObject id=%ld\n", theObject);        Remote[i].Effacer();        RemoteCount-- ;    }}// ----------------------------------------------------------------------------/*! Envoie une interaction, dont les parametres DX et DY ont pour valeur les  dx et dy de la bille Local, et dont l'etiquette temporelle vaut  InteractionTime.*/voidFed::sendInteraction(const FedTime& InteractionTime, ObjectHandle Id){    char buf[512] ;    ParameterHandleValuePairSet *parameterSet=NULL ;    parameterSet = ParameterSetFactory::create(3);    sprintf(buf, "%ld", Id);    parameterSet->add(ParamBoulID, buf, strlen(buf)+1);    D.Out(pdDebug, "SendInteraction");    D.Out(pdDebug, "SendInteraction - ParamBoulID= %u", ParamBoulID);    D.Out(pdDebug, "SendInteraction - x= %d", Id);    D.Out(pdDebug, "SendInteraction - buf= %s", buf);    // D.Out(pdDebug, "SendInteraction - ParamBoulID= %u, x= %f, buf= %s",    // ParamBoulID, Id, buf);    sprintf(buf, "%f", Local.dx);    parameterSet->add(ParamDXID, buf, strlen(buf)+1);    D.Out(pdDebug, "SendInteraction - ParamDXID= %u, x= %f, buf= %s",          ParamDXID, Local.dx, buf);    sprintf(buf, "%f", Local.dy);    parameterSet->add(ParamDYID, buf, strlen(buf)+1);    D.Out(pdDebug, "SendInteraction - ParamDYID= %u, x= %f, buf= %s",          ParamDYID, Local.dy, buf);    D.Out(pdRegister, "Sending interaction(DX= %f, DY= %f).", Local.dx, Local.dy);    try {        RTIA->sendInteraction(BingClassID, *parameterSet, InteractionTime, "");    }    catch (Exception& e) {        D.Out(pdExcept, "**** Exception sending interaction : %d", &e);    }    delete parameterSet ;}// ----------------------------------------------------------------------------//! SendUpdate updates a ball by sending entity position and color./*! Envoie un updateAttributeValue pour l'objet Local avec une etiquette  temporelle de UpdateTime.*/void Fed::SendUpdate(const FedTime& UpdateTime){    char buf[512] ;    AttributeHandleValuePairSet *attributeSet ;    attributeSet = AttributeSetFactory::create(3);    D.Out(pdTrace, "SendUpdate.");    sprintf(buf, "%f", Local.x);    attributeSet->add(AttrXID, buf, strlen(buf)+1);    D.Out(pdDebug, "SendUpdate - AttrXID= %u, x= %f, size= %u",          AttrXID, Local.x, attributeSet->size());    sprintf(buf, "%f", Local.y);    attributeSet->add(AttrYID, buf, strlen(buf)+1);    D.Out(pdDebug, "SendUpdate - AttrYID= %u, y= %f, size= %u",          AttrYID, Local.y, attributeSet->size());    sprintf(buf, "%d", Local.Color);    attributeSet->add(AttrColorID, buf, strlen(buf)+1);    D.Out(pdDebug, "SendUpdate - AttrColorID= %u, color= %f, size= %u",          AttrColorID, Local.color, attributeSet->size());    try {        RTIA->updateAttributeValues(Local.ID, *attributeSet, UpdateTime, "");        if (verbose)            cout << "-> UAV " << ((RTIfedTime) UpdateTime).getTime() << endl ;//         if (log)//             logfile << string(((RTIfedTime) UpdateTime).getTime()) << " : UAV "//                     << string(Local.x) << " " << string(Local.y) << endl ;    }    catch (Exception& e) {        D.Out(pdExcept, "**** Exception updating attribute values: %d", &e);    }    delete attributeSet ;}// ----------------------------------------------------------------------------voidFed::turnInteractionsOn(InteractionClassHandle /*theHandle*/)    throw (InteractionClassNotPublished, FederateInternalError){}// ----------------------------------------------------------------------------voidFed::turnInteractionsOff(InteractionClassHandle /*theHandle*/)    throw (InteractionClassNotPublished, FederateInternalError){}// ----------------------------------------------------------------------------voidFed::startRegistrationForObjectClass(ObjectClassHandle /*theClass*/)    throw (ObjectClassNotPublished, FederateInternalError){}// ----------------------------------------------------------------------------voidFed::stopRegistrationForObjectClass(ObjectClassHandle /*theClass*/)    throw (ObjectClassNotPublished, FederateInternalError){}// ----------------------------------------------------------------------------//! timeAdvanceGrant.voidFed::timeAdvanceGrant(const FedTime& /*theTime*/)    throw (InvalidFederationTime, TimeAdvanceWasNotInProgress,           FederationTimeAlreadyPassed, FederateInternalError){    granted = true ;}// ----------------------------------------------------------------------------//! timeRegulationEnabled.voidFed::timeRegulationEnabled(const FedTime& /*theTime*/)    throw (InvalidFederationTime, EnableTimeRegulationWasNotPending,           FederateInternalError){}// <OWM>// ----------------------------------------------------------------------------//! requestAttributeOwnershipRelease.voidFed::requestAttributeOwnershipRelease(ObjectHandle,                                      const AttributeHandleSet&,                                      const char *)    throw (ObjectNotKnown, AttributeNotKnown, AttributeNotOwned,           FederateInternalError){    cout << "requestAttributeOwnershipRelease..." << endl ;}// ----------------------------------------------------------------------------voidFed::informAttributeOwnership(ObjectHandle theObject, // supplied C1                              AttributeHandle theAttribute, // supplied C1                              FederateHandle theOwner) // supplied C1    throw (ObjectNotKnown,           AttributeNotKnown,           FederateInternalError){    cout << "CALLBACK informAttributeOwnership : Attribute " << theAttribute         << " de l'objet " << theObject << " propri閠

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -