bool DelayAtomicSequence::SearchStartStopSeq () { m_mod_start = NULL; m_mod_stop = NULL; Module* pMod = GetParent(); if (pMod == NULL) return false; int i1 = 0, i2 = pMod->GetNumberOfChildren(); for (int i=0;i<pMod->GetNumberOfChildren();++i) { if(!m_start.compare(pMod->GetChild(i)->GetName())) { m_mod_start = pMod->GetChild(i); i1=i; } if(!m_stop.compare(pMod->GetChild(i)->GetName())) { m_mod_stop = pMod->GetChild(i); i2=i; } } return (i1<i2); }
double DelayAtomicSequence::GetDelay(const PrepareMode mode) { double dDelayTime = m_await_time; //if (m_mod_start==NULL && m_mod_stop==NULL) return dDelayTime; Module* pMod = GetParent(); if (pMod == NULL) return -1.0; //find other sequences between pModStart, myself, and pModStop int iMYpos=0, iS1pos=10000, iS2pos=-1; for (int i=0;i<pMod->GetNumberOfChildren();++i) { if( this == pMod->GetChild(i)) iMYpos=i; if(m_mod_start == pMod->GetChild(i)) iS1pos=i; if(m_mod_stop == pMod->GetChild(i)) iS2pos=i; } iS1pos = (iMYpos<iS1pos)?iMYpos:iS1pos; iS2pos = (iMYpos>iS2pos)?iMYpos:iS2pos; //Observe these sequences int j = 0; for (int i=iS1pos;i<=iS2pos;++i) if (i!=iMYpos && mode == PREP_VERBOSE) { char modules[10]; sprintf( modules, "Module%02d", j ) ; Observe( GetAttribute(modules), pMod->GetChild(i)->GetName(),"Duration", mode == PREP_VERBOSE ); j++; } //subtract duration of other sequences between pModStart, myself, and pModStop //do this twice, since cross-dependencies may hinder success in first attempt for (int j=0;j<2;j++) { dDelayTime = m_await_time; for (int i=iS1pos;i<=iS2pos;++i) { double dfact = ( ( i==iS2pos && (m_dt==DELAY_B2C || m_dt==DELAY_C2C) ) || ( i==iS1pos && (m_dt==DELAY_C2E || m_dt==DELAY_C2C) ) ) ? 0.5:1.0; if (i!=iMYpos) dDelayTime -= dfact * pMod->GetChild(i)->GetDuration(); } } #ifdef DEBUG cout << " DELAYTOMICSEQUENCE: " << GetName() << " mode = " << mode << " , m_await_time = " << m_await_time << " , (iS1pos, iMYpos, iS2pos) = (" << iS1pos << "," << iMYpos << "," << iS2pos << ")" << " => delay = " << dDelayTime << endl; #endif return dDelayTime; }