private void CheckValidTime(ILogicalTime time) { if (time.CompareTo(logicalTimeFactory.MakeInitial()) < 0) { throw new InvalidLogicalTime("Invalid time [" + time + "]"); } if (time.CompareTo(federate.HLAlogicalTime) < 0) { throw new LogicalTimeAlreadyPassed("Time is less than the calling federate's logical time"); } }
public void NextMessageRequestAvailable(ILogicalTime theTime) { lock (this) { /* 1. Process exceptions */ VerifyFederateIsExecutionMember(); // if the calling federate is in time advancing state CheckAdvancing(); CheckValidTime(theTime); // if the calling federate is in pending on calling the enabledTimeConstrained service CheckTimeConstrainedPending(); // if the calling federate is in pending on calling the enabledTimeRegulation service CheckTimeRegulationPending(); /* 2. Set pending flag and pendingTime */ NextMessageRequestAvailableProperty = Status.PENDING; PendingTime = theTime; /* 3. Send all RO messages to the calling federate */ lrc.TickRO(); /* 4. Judge whether the NMR request is granted */ if (this.federate.HLAtimeConstrained) { // Compute GALT ComputeGALT(); // LETS = min{TSO}. LETS equals to infinity for an empty TSO queue ComputeLITS(); if (this.federate.HLALITS.CompareTo(theTime) <= 0 && this.federate.HLALITS.CompareTo(federate.HLAGALT) <= 0) { GrantFederateAdvancing(this.federate.HLALITS); } else if (theTime.CompareTo(federate.HLAGALT) <= 0) { GrantFederateAdvancing(theTime); } } else { GrantFederateAdvancing(theTime); } } }
public void TimeAdvanceRequestAvailable(ILogicalTime theTime) { lock (this) { /* 1. Process exceptions */ VerifyFederateIsExecutionMember(); // if the calling federate is in time advancing state CheckAdvancing(); CheckValidTime(theTime); // if the calling federate is in pending on calling the enabledTimeConstrained service CheckTimeConstrainedPending(); // if the calling federate is in pending on calling the enabledTimeRegulation service CheckTimeRegulationPending(); /* 2. Set pending flag and pendingTime */ TimeAdvanceRequestAvailableProperty = Status.PENDING; PendingTime = theTime; /* 3. Send all RO messages to the calling federate */ lrc.TickRO(); /* 4. Judge whether the TARA request is granted */ if (this.federate.HLAtimeConstrained) { // Compute GALT ComputeGALT(); if (theTime.CompareTo(federate.HLAGALT) <= 0) { GrantFederateAdvancing(theTime); } else { // All messages with time stamp <= GALT are sent to the calling federate lrc.TickTSO(federate.HLAGALT); } } else { GrantFederateAdvancing(theTime); } } }
private void ComputeLITS() { ILogicalTime LITS = lrc.GetLITS(); if (LITS == null) { LITS = LogicalTimeFactory.MakeFinal(); } if (this.federate.HLALITS == null) { this.federate.HLALITS = LITS; } else { if (LITS.CompareTo(this.federate.HLALITS) != 0) { this.federate.HLALITS = LITS; } } }
// ¿Y sí el federado no es regulado? NO se emplea esta función NUNCA en esa situación // ¿Y sí alguno de los otros federados no genera mensajes TSO (no es regulador), se le tiene que tener en cuenta? // Se tiene en cuenta igual ya que podría pasar a ser regulador "sin pararse" private void ComputeGALT() { ILogicalTime GALT = logicalTimeFactory.MakeFinal(); String federationName = ((Sxtafederate)this.federate).HLAfederationNameJoined; IList <Sxtafederate> federates = metaFederateAmbassador.GetFederates(federationName); ILogicalTime federateStature; foreach (Sxtafederate aFederate in federates) { // It is not the calling federate if (aFederate != this.federate) { if (CheckTimeManagementProperties(aFederate)) { // COMMENT ANGEL: Ojo! Debe estar inicializado el currentTime, lookahead y LITS del federado if (aFederate.HLAtimeManagerState == HLAtimeState.TimeGranted) { // S(i) = T(i) + L(i) federateStature = aFederate.HLAlogicalTime.Add(aFederate.HLAlookahead); } else { // COMMENT ANGEL: La implementación puede que no sea del todo correcta // aFederate.HLAtimeManagerState --> Granted or Advancing // aFederate.HLALITS == LETS // S(i) = min{T(i){PendingTime}, LITS(i)} + L(i) if (aFederate.HLApendingTime.CompareTo(aFederate.HLALITS) < 0) { federateStature = aFederate.HLApendingTime; } else { federateStature = aFederate.HLALITS; } federateStature = federateStature.Add(aFederate.HLAlookahead); } if (federateStature.CompareTo(GALT) <= 0) { GALT = federateStature; } } } } // NOTE: Updates property's value only when it changes if (this.federate.HLAGALT == null) { this.federate.HLAGALT = GALT; } else { if (GALT.CompareTo(this.federate.HLAGALT) != 0) { this.federate.HLAGALT = GALT; } } }