public override void TimeConstrainedEnabled(ILogicalTime time) { if (log.IsInfoEnabled) { log.Info("Federate is time constrained [time = " + time + "]"); } }
public override void TimeAdvanceGrant(ILogicalTime theTime) { if (log.IsInfoEnabled) { log.Info("Federate is time advance grant to time " + theTime); } }
public override void TimeRegulationEnabled(ILogicalTime time) { if (log.IsInfoEnabled) { log.Info("Federate is time regulator [time = " + time + "]"); } }
public ReceiveInteractionCallback(IFederateAmbassador federate, ILogicalTime time, IInteractionClassHandle interactionClassParam, IParameterHandleValueMap theParametersParam, byte[] userSuppliedTagParam) : base(federate, time) { this.interactionClass = interactionClassParam; this.theParameters = theParametersParam; this.userSuppliedTag = userSuppliedTagParam; }
protected void SimulationMoveActor(Actor anActor, Home aTarget) { if (isActorInLocation(anActor, anActor.Home)) { if (anActor.Home.BoxesCount > 0 || initialTime) { // Función que calcule la llegada ILogicalTime currentTime = rti.QueryLogicalTime(); ILogicalTimeInterval intervalTimeArriveAtTheTarget = GetArrivalTimeToTarget(anActor, aTarget); ILogicalTime timeArriveAtTheTarget = currentTime.Add(intervalTimeArriveAtTheTarget); NotifiesBoxInHouse(timeArriveAtTheTarget); MoveActor(anActor, aTarget); anActor.Home.BoxesCount = 0; } } else { initialTime = false; if (!isActorInTarget(anActor, aTarget)) { MoveActor(anActor, aTarget); } // El muñeco está en el destino else { scenario.MoveActorToHome(anActor.Home.PosX, anActor.Home.PosY); sendedBoxInHouseInteraction = false; } } }
public ReflectAttributeValuesExtCallback(IFederateAmbassador federate, ILogicalTime time, long federateHandle, long interactionIndex, IObjectInstanceHandle theObjectParam, HLAattributeHandleValuePair[] theAttributesParam, byte[] userSuppliedTagParam) : base(federate, time, federateHandle, interactionIndex) { this.theObject = theObjectParam; this.theAttributes = theAttributesParam; this.userSuppliedTag = userSuppliedTagParam; }
/// <summary> Remove and return the head of the queue, or null if the queue is empty. <b>NOTE:</b> All /// receive-order messages will be processed first. Following this, all timestamp-order messages /// less than or equal to the current federate time will be released. /// </summary> protected virtual Callback _Poll(ILogicalTime timeRequest) { Callback callback = _PollROQueue(); if (callback != null) { return(callback); } //////////////////////////////////////////////////////// // no RO messages - check for releasable TSO messages // //////////////////////////////////////////////////////// if (this.tsoQueue.Count > 0) { callback = _PollTSOQueue(timeRequest); if (callback != null) { return(callback); } } ////////////////////////////////////// // no messages that can be released // ////////////////////////////////////// return(null); }
public ProvideAttributeValueUpdateCallback(IFederateAmbassador federate, ILogicalTime time, IObjectInstanceHandle theObjectParam, IAttributeHandleSet theAttributesParam, byte[] userSuppliedTagParam) : base(federate, time) { this.theObject = theObjectParam; this.theAttributes = theAttributesParam; this.userSuppliedTag = userSuppliedTagParam; }
public RemoveObjectInstanceCallback(IFederateAmbassador federate, ILogicalTime time, IObjectInstanceHandle theObjectParam, byte[] userSuppliedTagParam, OrderType sentOrderingParam) : base(federate, time) { this.theObject = theObjectParam; this.userSuppliedTag = userSuppliedTagParam; this.sentOrdering = sentOrderingParam; }
public override void AdvanceTime() { rtiAmbassador.EvokeMultipleCallbacks(0.01, 0.2); for (int i = 0; i < sendingPerIterations && sending < boidsManager.BoidsList.Count; i++) { Boid boid = boidsManager.BoidsList[sending]; boid.FlushAttributeValues(null); sending++; } if (SimulationTime.CompareTo(nextRefreshTime) > 0) { nextRefreshTime = SimulationTime.Add(refreshInterval); if (sending >= boidsManager.BoidsList.Count) { sendingPerIterations -= 1; sending = 0; } else { sendingPerIterations += 1; } /* * federateAmbassador.DumpObjects(); * * for (int i = 0; i < boidsManager.BoidsList.Count; i++) * { * Boid boid = boidsManager.BoidsList[i]; * boid.FlushAttributeValues(null); * } */ } }
public virtual Callback PollTSOQueue(ILogicalTime timeRequest) { lock (thisLock) { return(_PollTSOQueue(timeRequest)); } }
public DiscoverObjectInstanceCallback(IFederateAmbassador federate, ILogicalTime time, long federateHandle, long interactionIndex, IObjectInstanceHandle theObjectParam, IObjectClassHandle theObjectClassParam, string objectNameParam) : base(federate, time, federateHandle, interactionIndex) { this.theObject = theObjectParam; this.theObjectClass = theObjectClassParam; this.objectName = objectNameParam; }
private void GrantFederateAdvancing(ILogicalTime theTime) { /* * 1. Look up if the calling federate is in lookahead-pending state, * the actual lookahead should be recomputed as stated in Carothers, Weatherly, Fujimoto, and Wilson (1997) */ /* 2. Send all TSO messages with time stamp <= to the granted time to the calling federate */ lrc.TickTSO(theTime); /* 3. Call the TAG service to grant the federate to advance its logical time */ if (TimeAdvanceRequestProperty == Status.PENDING) { TimeAdvanceRequestProperty = Status.ON; } if (NextMessageRequestProperty == Status.PENDING) { NextMessageRequestProperty = Status.ON; } if (TimeAdvanceRequestAvailableProperty == Status.PENDING) { TimeAdvanceRequestAvailableProperty = Status.ON; } if (NextMessageRequestAvailableProperty == Status.PENDING) { TimeAdvanceRequestAvailableProperty = Status.ON; } federate.HLAlogicalTime = theTime; this.federateAmbassador.TimeAdvanceGrant(theTime); }
public virtual Callback PollTSOQueue(ILogicalTime timeRequest, int timeoutMillis) { lock (thisLock) { // 1. check to see if we have a message // // there is no need to aquire the lock as we are not accessing the queue directly // lock is reentrant, so we shouldn't take hit for aquiring it in poll() Callback callback = _PollTSOQueue(timeRequest); if (callback != null) { // there is a message so we can just return it return(callback); } } // 2. need to wait for an update to come through // lock (condition) { // wait on condition // TODO!!!. wait time resolution is milliseconds System.Threading.Monitor.Wait(this.condition, timeoutMillis); } lock (thisLock) { // we have been woken up: // -if by timeout: return null // -if by signal: return available message return(_PollTSOQueue(timeRequest)); } }
public override void AdvanceTime() { rtiAmbassador.EvokeMultipleCallbacks(0.01, 0.2); for (int i = 0; i < sendingPerIterations && sending < boidsManager.BoidsList.Count; i++) { Boid boid = boidsManager.BoidsList[sending]; boid.FlushAttributeValues(null); sending++; } if (SimulationTime.CompareTo(nextRefreshTime) > 0) { nextRefreshTime = SimulationTime.Add(refreshInterval); if (sending >= boidsManager.BoidsList.Count) { sendingPerIterations -= 1; sending = 0; } else { sendingPerIterations += 1; } /* federateAmbassador.DumpObjects(); for (int i = 0; i < boidsManager.BoidsList.Count; i++) { Boid boid = boidsManager.BoidsList[i]; boid.FlushAttributeValues(null); } */ } }
public override void OnReceiveHLAregisterObjectInstanceWithTime(HLAregisterObjectInstanceWithTimeMessage msg) { base.OnReceiveHLAregisterObjectInstanceWithTime(msg); ILogicalTime time = parent.LogicalTimeFactory.Decode(msg.LogicalTime, 0); AddCallbackRegisterObjectInstance(msg.ObjectInstanceHandle, msg.ObjectClassHandle, msg.ObjectName, msg.FederateHandle, msg.InteractionIndex, time); }
public override void TimeAdvanceGrant(ILogicalTime theTime) { base.TimeAdvanceGrant(theTime); canAdvanceTime = true; //form.UpdateTimeManagementValueLabels(); }
public override void OnReceiveHLAupdateAttributeValuesReliableWithTime(HLAupdateAttributeValuesReliableWithTimeMessage msg) { base.OnReceiveHLAupdateAttributeValuesReliableWithTime(msg); ILogicalTime time = parent.LogicalTimeFactory.Decode(msg.LogicalTime, 0); AddCallbackUpdateAttributeValues(msg.AttributeHandleValuePairList, msg.ObjectInstanceHandle, msg.UserSuppliedTag, msg.FederateHandle, msg.InteractionIndex, time); }
public void UpdateBoxInHouseTimeLabel(ILogicalTime time) { if (boxInHouseTimeLabel.InvokeRequired) { boxInHouseTime = time; DrawChangesDelegate d = new DrawChangesDelegate(_UpdateBoxInHouseTimeLabel); Invoke(d); } }
private void TimeAdvancedRequest(object sender, EventArgs e) { ILogicalTimeInterval lookahead = new DoubleValuedLogicalTimeInterval(1.0); ILogicalTimeIntervalFactory factory = ((XrtiExecutiveAmbassador)rtiAmbassador).LogicalTimeIntervalFactory; ILogicalTime time = rtiAmbassador.Federate.HLAlogicalTime.Add(lookahead); rtiAmbassador.TimeAdvanceRequest(time); OnDumpObjects(null, null); }
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); } } }
private void AddCallbackRegisterObjectInstance(long objectInstanceHandle, long objectClassHandle, string objectName, long federateHandle, long interactionIndex, ILogicalTime time) { if (parent.State != null) { Lrc.DiscoverObjectInstanceCallback callback = new Lrc.DiscoverObjectInstanceCallback(this.parent.FederateAmbassador, time, federateHandle, interactionIndex, new XRTIObjectInstanceHandle(objectInstanceHandle), new XRTIObjectClassHandle(objectClassHandle), objectName); parent.lrc.AddCallback(callback); } }
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 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); } } }
///<summary> /// Writes this HLAfederate.HLAlogicalTime to the specified stream. ///</summary> ///<param name="writer"> the output stream to write to</param> ///<param name="HLAfederationName"> the property to serialize</param> ///<exception cref="System.IO.IOException"> if an error occurs</exception> public override void Serialize(HlaEncodingWriter writer, object HLAlogicalTime) { try { ILogicalTime logicalTime = (ILogicalTime)HLAlogicalTime; byte[] logicalTimeBytesArray = new byte[logicalTime.EncodedLength()]; logicalTime.Encode(logicalTimeBytesArray, 0); writer.WriteHLAopaqueData(logicalTimeBytesArray); } catch (IOException ioe) { throw new RTIinternalError(ioe.ToString()); } }
protected virtual Callback _PollTSOQueue(ILogicalTime timeRequest) { if (this.tsoQueue.Count > 0) { Callback callback = this.tsoQueue.FindMin(); if (callback != null) { // there is a message at the head of the set, is it of a releasable time? if (callback.Time.CompareTo(timeRequest) <= 0) { // it is! release it - we also need to remove it this.tsoQueue.DeleteMin(); return(callback); } } } return(null); }
public void TickTSO(ILogicalTime timeRequest) { lock (this) { // 1. check for a concurrent access issue // state.CheckAccess(); // 2. signal that we are not ticking // state.Ticking = true; // 3. tick RO messages long nowTime = System.DateTime.Now.Ticks; long endTime = nowTime + TICK_TIMEOUT; Callback c; do { try { c = callbackQueue.PollTSOQueue(timeRequest); if (c != null) { TickProcess(c); } // update the actual time nowTime = System.DateTime.Now.Ticks; } catch (Exception e) { if (log.IsErrorEnabled) { log.Error(e.Message); } break; } } while (c != null && (nowTime < endTime)); // 4. reset the ticking status flag // state.Ticking = false; } }
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; } } }
///<summary> ///Notifies that the box is already in its house ///</summary> ///<param name="msg"> the message associated with the interaction</param> ///<exception cref="InteractionClassNotRecognized"> if the interaction class was not recognized</exception> ///<exception cref="InteractionParameterNotRecognized"> if a parameter of the interaction was not /// recognized</exception> ///<exception cref="InteractionClassNotSubscribed"> if the federate had not subscribed to the /// interaction class</exception> ///<exception cref="FederateInternalError"> if an error occurs in the federate</exception> public void OnReceiveBoxInHouse(BoxInHouseMessage msg) { ILogicalTime time = timeFactory.Decode(msg.Time, 0); if (log.IsDebugEnabled) { log.Debug("Received BoxInHouseMessage [time = " + time + "]"); } form.UpdateBoxInHouseTimeLabel(time); ObjectInstanceDescriptor oid = rti.descriptorManager.GetObjectInstanceDescriptor(home.InstanceHandle); IObjectClassHandle och = oid.ClassHandle; ObjectClassDescriptor ocd = rti.descriptorManager.GetObjectClassDescriptor(och); HLAattributeHandleValuePair[] handleValuePairList = new HLAattributeHandleValuePair[1]; handleValuePairList[0] = new HLAattributeHandleValuePair(); handleValuePairList[0].AttributeHandle = ((XRTIAttributeHandle)ocd.GetAttributeDescriptor("BoxesCount").Handle).Identifier; handleValuePairList[0].AttributeValue = 1; rti.UpdateAttributeValues(home.InstanceHandle, handleValuePairList, new byte[1], time); }
protected ILogicalTime ConvertToFederationLogicalTimeRepresentation(ILogicalTime time) { if (Federation != null) { ILogicalTimeFactory factory = Federation.LogicalTimeFactory; if (factory != null) { byte[] timeByteArray = new byte[time.EncodedLength()]; time.Encode(timeByteArray, 0); return(factory.Decode(timeByteArray, 0)); } else { return(time); } } else { return(time); } }
public void UpdateAttributeValues(string property, object newValue) { Boolean joined = (OwnFederate != null) && ((Sxtafederate)OwnFederate).HLAisJoined; if (!(joined && OwnFederate.HLAtimeRegulating)) { foreach (IHLAobjectRootListener l in listeners) { //TODO Include user Tag UpdateAttributeValues(instanceHandle, ahvm, userSuppliedTag); l.OnReceiveUpdateAttributeValues(instanceHandle, property, newValue); } } else { ILogicalTime time = OwnFederate.HLAlogicalTime.Add(OwnFederate.HLAlookahead); foreach (IHLAobjectRootListener l in listeners) { //TODO Include user Tag UpdateAttributeValues(instanceHandle, ahvm, userSuppliedTag); l.OnReceiveUpdateAttributeValues(instanceHandle, property, newValue, time); } } }
protected void UpdateAttributeValues(IDictionary <string, object> methodNameValueMap) { Boolean joined = (OwnFederate != null) && ((Sxtafederate)OwnFederate).HLAisJoined; if (!(joined && OwnFederate.HLAtimeRegulating)) { foreach (IHLAobjectRootListener l in listeners) { //TODO Include user Tag UpdateAttributeValues(instanceHandle, ahvm, userSuppliedTag); l.OnReceiveUpdateAttributeValues(instanceHandle, methodNameValueMap); } } else { ILogicalTime time = OwnFederate.HLAlogicalTime;//.Add(OwnFederate.HLAlookahead); foreach (IHLAobjectRootListener l in listeners) { //TODO Include user Tag UpdateAttributeValues(instanceHandle, ahvm, userSuppliedTag); l.OnReceiveUpdateAttributeValues(instanceHandle, methodNameValueMap, time); } } }
public override void TimeConstrainedEnabled(ILogicalTime time) { if (log.IsInfoEnabled) log.Info("Federate is time constrained [time = " + time + "]"); }
public TimeRegulationEnabledCallback(IFederateAmbassador federate, ILogicalTime time, ILogicalTime timeParam) : base(federate, time) { this.timeParam = timeParam; }
public TimeConstrainedEnabledCallback(IFederateAmbassador federate, ILogicalTime time, ILogicalTime timeParam) : base(federate, time) { this.timeParam = timeParam; }
public TimeAdvanceGrantedCallback(IFederateAmbassador federate, ILogicalTime time, ILogicalTime timeParam) : base(federate, time) { this.timeParam = timeParam; }
public SynchronizationPointRegistrationSucceededCallback(IFederateAmbassador federate, ILogicalTime time, String label) : base(federate, time) { this.synchronizationPointLabel = label; }
public SynchronizationPointRegistrationFailedCallback(IFederateAmbassador federate, ILogicalTime time, String label, SynchronizationPointFailureReason reasonParam) : base(federate, time) { this.synchronizationPointLabel = label; this.reason = reasonParam; }
public ReflectAttributeValuesCallback(IFederateAmbassador federate, ILogicalTime time, IObjectInstanceHandle theObjectParam, IAttributeHandleValueMap theAttributesParam, byte[] userSuppliedTagParam) : base(federate, time) { this.theObject = theObjectParam; this.theAttributes = theAttributesParam; this.userSuppliedTag = userSuppliedTagParam; }
public override void TimeAdvanceGrant(ILogicalTime theTime) { if (log.IsInfoEnabled) log.Info("Federate is time advance grant to time " + theTime); }
public TimeStampedRemoveObjectInstanceCallback(IFederateAmbassador federate, ILogicalTime time, IObjectInstanceHandle theObjectParam, byte[] userSuppliedTagParam, OrderType sentOrderingParam, ILogicalTime theTimeParam, OrderType receivedOrderingParam) : base(federate, time, theObjectParam, userSuppliedTagParam, sentOrderingParam) { this.timeParam = theTimeParam; this.receivedOrdering = receivedOrderingParam; }
public override void TimeRegulationEnabled(ILogicalTime time) { if (log.IsInfoEnabled) log.Info("Federate is time regulator [time = " + time + "]"); }
public Callback(IFederateAmbassador federate, ILogicalTime time) : this(federate) { this.time = time; }
public Callback(IFederateAmbassador federate, ILogicalTime time, long federateHandle, long interactionIndex) : this(federate, time) { this.federateHandle = federateHandle; this.interactionIndex = interactionIndex; }
private void GrantFederateAdvancing(ILogicalTime theTime) { /* * 1. Look up if the calling federate is in lookahead-pending state, * the actual lookahead should be recomputed as stated in Carothers, Weatherly, Fujimoto, and Wilson (1997) */ /* 2. Send all TSO messages with time stamp <= to the granted time to the calling federate */ lrc.TickTSO(theTime); /* 3. Call the TAG service to grant the federate to advance its logical time */ if (TimeAdvanceRequestProperty == Status.PENDING) TimeAdvanceRequestProperty = Status.ON; if (NextMessageRequestProperty == Status.PENDING) NextMessageRequestProperty = Status.ON; if (TimeAdvanceRequestAvailableProperty == Status.PENDING) TimeAdvanceRequestAvailableProperty = Status.ON; if (NextMessageRequestAvailableProperty == Status.PENDING) TimeAdvanceRequestAvailableProperty = Status.ON; federate.HLAlogicalTime = theTime; this.federateAmbassador.TimeAdvanceGrant(theTime); }
private void AddCallbackUpdateAttributeValues(HLAattributeHandleValuePair[] handleValuePairList, long objectInstanceHandle, byte[] userSuppliedTag, long federateHandle, long interactionIndex, ILogicalTime time) { if (parent.State != null) { Lrc.ReflectAttributeValuesExtCallback callback = new Lrc.ReflectAttributeValuesExtCallback(this.parent.FederateAmbassador, time, federateHandle, interactionIndex, new XRTIObjectInstanceHandle(objectInstanceHandle), handleValuePairList, userSuppliedTag); parent.lrc.AddCallback(callback); } }
/// <summary> /// Computes and returns the time interval between this logical time /// and another one. /// </summary> /// <param name="val">the other logical time /// </param> /// <returns> the logical time interval between this logical time and /// the other logical time /// </returns> public virtual ILogicalTimeInterval Distance(ILogicalTime pVal) { throw new NotImplementedException("Not yet implemented"); }
public void OnReceiveUpdateAttributeValues(IObjectInstanceHandle instanceHandle, string methodName, object newValue, ILogicalTime time) { if (log.IsDebugEnabled) log.Debug("The method " + methodName + " from object " + instanceHandle + " has been called; new value:" + newValue + "; parameter type = " + newValue.GetType()); HLAattributeHandleValuePair[] attributeHandleValuePair = CreateAttributeHandleValuePairList(methodName, newValue, instanceHandle); // TODO ANGEL: que pasa con userSuppliedTag rti.UpdateAttributeValues(instanceHandle, attributeHandleValuePair, null, time); }
/// <summary> /// Computes and returns the time interval between this logical time /// and another one. /// </summary> /// <param name="val">the other logical time /// </param> /// <returns> the logical time interval between this logical time and /// the other logical time /// </returns> public virtual ILogicalTimeInterval Distance(ILogicalTime pVal) { return new LongValuedLogicalTimeInterval(System.Math.Abs(val - ((LongValuedLogicalTime)pVal).val)); }
public void OnReceiveUpdateAttributeValues(IObjectInstanceHandle instanceHandle, IDictionary<string, object> methodNameValueMap, ILogicalTime time) { HLAattributeHandleValuePair[] attributeHandleValuePair = CreateAttributesHandleValuePairList(methodNameValueMap, instanceHandle); // TODO ANGEL: que pasa con userSuppliedTag rti.UpdateAttributeValues(instanceHandle, attributeHandleValuePair, new byte[1], time); }
public AnnounceSynchronizationPointCallback(IFederateAmbassador federate, ILogicalTime time, String label, byte[] tag) : base(federate, time) { this.synchronizationPointLabel = label; this.userSuppliedTag = tag; }