public override void OnReceiveHLAsubscribeObjectClassAttributes(HLAsubscribeObjectClassAttributesMessage msg) { base.OnReceiveHLAsubscribeObjectClassAttributes(msg); // TODO ANGEL: Habría que registrar al federado con la info en la que está interesado IList<HLAobjectRoot> objects = ((FederateAmbassador)parent.FederateAmbassador).GetObjects(); this.SendInfoAboutObjects(objects, msg); }
protected void SendInfoAboutObjects(IList <HLAobjectRoot> objects, HLAsubscribeObjectClassAttributesMessage msg) { foreach (HLAobjectRoot obj in objects) { // if it is a local object and its class handle is equal to the object class handle sent if (obj.HLAprivilegeToDeleteObject && obj.ClassHandle.Equals(msg.HLAobjectClass)) { parent.RegisterObjectInstance(obj); IList <HLAattributeHandleValuePair> propertyValuePair = new List <HLAattributeHandleValuePair>(); // TODO ANGEL: Esto es incorrecto y esta mal. Puede haber propiedades que no sean remotas foreach (IAttributeHandle attribute in msg.HLAattributeList) { AttributeDescriptor ad = parent.descriptorManager.GetAttributeDescriptor(attribute); if (ad == null) { throw new InvalidAttributeHandle(attribute.ToString()); } else { PropertyInfo pi = obj.GetType().BaseType.GetProperty(ad.Name); if (!ad.Name.Equals("HLAprivilegeToDeleteObject") && pi != null) { object value = pi.GetValue(obj, null); if (value != null) { propertyValuePair.Add(new HLAattributeHandleValuePair(((XRTIAttributeHandle)ad.Handle).Identifier, value)); } } } } HLAattributeHandleValuePair[] propertyValuePairArray = new HLAattributeHandleValuePair[propertyValuePair.Count]; propertyValuePair.CopyTo(propertyValuePairArray, 0); // TODO ANGEL: Que pasa con el userTag parent.UpdateAttributeValues(obj.InstanceHandle, propertyValuePairArray, null); } } }
///<summary> Reads this HLAsubscribeObjectClassAttributesMessage from the specified stream.</summary> ///<param name="reader"> the input stream to read from</param> ///<returns> the object</returns> ///<exception cref="System.IO.IOException"> if an error occurs</exception> public override object Deserialize(HlaEncodingReader reader, ref object msg) { HLAsubscribeObjectClassAttributesMessage decodedValue; if (!(msg is HLAsubscribeObjectClassAttributesMessage)) { decodedValue = new HLAsubscribeObjectClassAttributesMessage(); BaseInteractionMessage baseMsg = msg as BaseInteractionMessage; decodedValue.InteractionClassHandle = baseMsg.InteractionClassHandle; decodedValue.FederationExecutionHandle = baseMsg.FederationExecutionHandle; decodedValue.UserSuppliedTag = baseMsg.UserSuppliedTag; } else { decodedValue = msg as HLAsubscribeObjectClassAttributesMessage; } object tmp = decodedValue; decodedValue = base.Deserialize(reader, ref tmp) as HLAsubscribeObjectClassAttributesMessage; try { byte[] objectClassByteArray = reader.ReadHLAopaqueData(); decodedValue.HLAobjectClass = objectClassFactory.Decode(objectClassByteArray, 0); decodedValue.HLAattributeList = attributeHandleSetFactory.Create(); int count = reader.ReadHLAinteger32BE(); for (int i = 0; i < count; i++) { IAttributeHandle attributeHandle = attributeHandleFactory.Decode(reader.ReadHLAopaqueData(), 0); decodedValue.HLAattributeList.Add(attributeHandle); } decodedValue.HLAactive = reader.ReadHLAboolean(); /* * decodedValue.HLAobjectClass = new byte[reader.ReadHLAinteger32BE()]; * * for (int i = 0; i < decodedValue.HLAobjectClass.Length; i++) * { * decodedValue.HLAobjectClass[i] = reader.ReadHLAoctet(); * } * decodedValue.HLAattributeList = new byte[reader.ReadHLAinteger32BE()][]; * * for (int i = 0; i < decodedValue.HLAattributeList.Length; i++) * { * decodedValue.HLAattributeList[i] = new byte[reader.ReadHLAinteger32BE()]; * * for (int j = 0; j < decodedValue.HLAattributeList[i].Length; j++) * { * decodedValue.HLAattributeList[i][j] = reader.ReadHLAoctet(); * } * } * decodedValue.HLAactive = reader.ReadHLAboolean(); */ } catch (System.IO.IOException ioe) { throw new RTIinternalError(ioe.ToString()); } return(decodedValue); }
///<summary> Reads this HLAsubscribeObjectClassAttributesMessage from the specified stream.</summary> ///<param name="reader"> the input stream to read from</param> ///<returns> the object</returns> ///<exception cref="System.IO.IOException"> if an error occurs</exception> public override object Deserialize(HlaEncodingReader reader, ref object msg) { HLAsubscribeObjectClassAttributesMessage decodedValue; if (!(msg is HLAsubscribeObjectClassAttributesMessage)) { decodedValue = new HLAsubscribeObjectClassAttributesMessage(); BaseInteractionMessage baseMsg = msg as BaseInteractionMessage; decodedValue.InteractionClassHandle = baseMsg.InteractionClassHandle; decodedValue.FederationExecutionHandle = baseMsg.FederationExecutionHandle; decodedValue.UserSuppliedTag = baseMsg.UserSuppliedTag; } else { decodedValue = msg as HLAsubscribeObjectClassAttributesMessage; } object tmp = decodedValue; decodedValue = base.Deserialize(reader, ref tmp) as HLAsubscribeObjectClassAttributesMessage; try { byte[] objectClassByteArray = reader.ReadHLAopaqueData(); decodedValue.HLAobjectClass = objectClassFactory.Decode(objectClassByteArray, 0); decodedValue.HLAattributeList = attributeHandleSetFactory.Create(); int count = reader.ReadHLAinteger32BE(); for (int i = 0; i < count; i++) { IAttributeHandle attributeHandle = attributeHandleFactory.Decode(reader.ReadHLAopaqueData(), 0); decodedValue.HLAattributeList.Add(attributeHandle); } decodedValue.HLAactive = reader.ReadHLAboolean(); /* decodedValue.HLAobjectClass = new byte[reader.ReadHLAinteger32BE()]; for (int i = 0; i < decodedValue.HLAobjectClass.Length; i++) { decodedValue.HLAobjectClass[i] = reader.ReadHLAoctet(); } decodedValue.HLAattributeList = new byte[reader.ReadHLAinteger32BE()][]; for (int i = 0; i < decodedValue.HLAattributeList.Length; i++) { decodedValue.HLAattributeList[i] = new byte[reader.ReadHLAinteger32BE()]; for (int j = 0; j < decodedValue.HLAattributeList[i].Length; j++) { decodedValue.HLAattributeList[i][j] = reader.ReadHLAoctet(); } } decodedValue.HLAactive = reader.ReadHLAboolean(); */ } catch (System.IO.IOException ioe) { throw new RTIinternalError(ioe.ToString()); } return decodedValue; }
protected void SendInfoAboutObjects(IList<HLAobjectRoot> objects, HLAsubscribeObjectClassAttributesMessage msg) { foreach (HLAobjectRoot obj in objects) { // if it is a local object and its class handle is equal to the object class handle sent if (obj.HLAprivilegeToDeleteObject && obj.ClassHandle.Equals(msg.HLAobjectClass)) { parent.RegisterObjectInstance(obj); IList<HLAattributeHandleValuePair> propertyValuePair = new List<HLAattributeHandleValuePair>(); // TODO ANGEL: Esto es incorrecto y esta mal. Puede haber propiedades que no sean remotas foreach (IAttributeHandle attribute in msg.HLAattributeList) { AttributeDescriptor ad = parent.descriptorManager.GetAttributeDescriptor(attribute); if (ad == null) { throw new InvalidAttributeHandle(attribute.ToString()); } else { PropertyInfo pi = obj.GetType().BaseType.GetProperty(ad.Name); if (!ad.Name.Equals("HLAprivilegeToDeleteObject") && pi != null) { object value = pi.GetValue(obj, null); if (value != null) { propertyValuePair.Add(new HLAattributeHandleValuePair(((XRTIAttributeHandle)ad.Handle).Identifier, value)); } } } } HLAattributeHandleValuePair[] propertyValuePairArray = new HLAattributeHandleValuePair[propertyValuePair.Count]; propertyValuePair.CopyTo(propertyValuePairArray, 0); // TODO ANGEL: Que pasa con el userTag parent.UpdateAttributeValues(obj.InstanceHandle, propertyValuePairArray, null); } } }
public override void OnReceiveHLAsubscribeObjectClassAttributes(HLAsubscribeObjectClassAttributesMessage msg) { if (log.IsDebugEnabled) log.Debug("[" + federationName + "] Received HLAsubscribeObjectClassAttributes = " + msg.ToString()); }
///<summary> ///Set the joined federate's subscription status of attributes belonging ///to an object class. ///</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 abstract void OnReceiveHLAsubscribeObjectClassAttributes(HLAsubscribeObjectClassAttributesMessage msg);