Exemplo n.º 1
0
        public override void RegisterObjectInstance(object obj)
        {
            lock (this)
            {
                if (obj != null && obj is HLAobjectRoot)
                {
                    HLAobjectRoot objRoot = obj as HLAobjectRoot;

                    string className         = obj.GetType().BaseType.Name;
                    long   objectClassHandle = ((XRTIObjectClassHandle)rti.descriptorManager.GetObjectClassDescriptor(className).Handle).Identifier;
                    objRoot.ClassHandle = new XRTIObjectClassHandle(objectClassHandle);

                    objectInstanceHandleProxyMap[objRoot.InstanceHandle] = objRoot;
                    objectListIsValid = false;

                    ObjectInstanceDescriptor oid = new ObjectInstanceDescriptor(objRoot.ObjectName, objRoot.InstanceHandle, objRoot.ClassHandle, objRoot.OwnFederationExecutionHandle);
                    objectInstanceDescriptorList.Add(oid);
                    rti.descriptorManager.AddObjectInstanceDescriptor(oid);

                    // COMMENT ANGEL: Si el objeto ha sido creado localmente --> Se debe enviar la creación al resto de federados
                    if (objRoot.HLAprivilegeToDeleteObject)
                    {
                        rti.RegisterObjectInstance(objRoot);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private HLAattributeHandleValuePair[] CreateAttributesHandleValuePairList(IDictionary <string, object> methodNameValueMap, IObjectInstanceHandle instanceHandle)
        {
            HLAattributeHandleValuePair[] attributeHandleValuePairList = new HLAattributeHandleValuePair[methodNameValueMap.Count];

            ObjectInstanceDescriptor oid = rti.descriptorManager.GetObjectInstanceDescriptor(instanceHandle);
            IObjectClassHandle       och = oid.ClassHandle;
            ObjectClassDescriptor    ocd = rti.descriptorManager.GetObjectClassDescriptor(och);

            int count = 0;

            foreach (KeyValuePair <string, object> entry in methodNameValueMap)
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug("The method " + entry.Key + " from object " + instanceHandle + " has been called; new value:" + entry.Value + "; parameter type = " + entry.Value.GetType());
                }

                attributeHandleValuePairList[count] = new HLAattributeHandleValuePair();
                attributeHandleValuePairList[count].AttributeHandle = ((XRTIAttributeHandle)ocd.GetAttributeDescriptor(entry.Key).Handle).Identifier;
                attributeHandleValuePairList[count].AttributeValue  = entry.Value;
                count++;
            }

            return(attributeHandleValuePairList);
        }
Exemplo n.º 3
0
        protected void ProcessHLAupdateAttributeValues(HLAupdateAttributeValuesMessage msg)
        {
            // Metafederation RO message
            if (msg.FederationExecutionHandle == HLAobjectRoot.METAFEDERATION_EXECUTION_HANDLE)
            {
                ObjectInstanceDescriptor oid = parent.descriptorManager.GetObjectInstanceDescriptor(new XRTIObjectInstanceHandle(msg.ObjectInstanceHandle));
                ObjectClassDescriptor    ocd = parent.descriptorManager.GetObjectClassDescriptor("Sxtafederate");

                bool timePropertyFound = false;
                if (oid.ClassHandle.Equals(ocd.Handle))
                {
                    if (msg.AttributeHandleValuePairList.Length > 0)
                    {
                        for (int i = 0; i < msg.AttributeHandleValuePairList.Length && !timePropertyFound; i++)
                        {
                            HLAattributeHandleValuePair pair = msg.AttributeHandleValuePairList[i];
                            string propertyName = ocd.GetAttributeDescriptor(new XRTIAttributeHandle(pair.AttributeHandle)).Name;
                            if (propertyName.Equals("HLAlogicalTime") || propertyName.Equals("HLAlookahead") ||
                                propertyName.Equals("HLApendingTime") || propertyName.Equals("HLALITS"))
                            // propertyName.Equals("HLAtimeManagerState") || propertyName.Equals("HLAtimeConstrained") || propertyName.Equals("HLAtimeRegulating"))
                            {
                                timePropertyFound = true;
                            }
                        }

                        if (timePropertyFound)
                        {
                            form.UpdateTimeManagementValueLabels();
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        public override void OnReceiveHLAregisterObjectInstance(HLAregisterObjectInstanceMessage msg)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("Received HLAregisterObjectInstance =  " + msg.ToString());
            }

            lock (this)
            {
                ObjectInstanceDescriptor oid = new ObjectInstanceDescriptor(msg.ObjectName, new XRTIObjectInstanceHandle(msg.ObjectInstanceHandle), new XRTIObjectClassHandle(msg.ObjectClassHandle), msg.FederationExecutionHandle);
                descriptorManager.AddObjectInstanceDescriptor(oid);
            }
        }
Exemplo n.º 5
0
        private HLAattributeHandleValuePair[] CreateAttributeHandleValuePairList(string methodName, object newValue, IObjectInstanceHandle instanceHandle)
        {
            ObjectInstanceDescriptor oid = rti.descriptorManager.GetObjectInstanceDescriptor(instanceHandle);
            IObjectClassHandle       och = oid.ClassHandle;
            ObjectClassDescriptor    ocd = rti.descriptorManager.GetObjectClassDescriptor(och);

            HLAattributeHandleValuePair[] attributeHandleValuePairList = new HLAattributeHandleValuePair[1];
            attributeHandleValuePairList[0] = new HLAattributeHandleValuePair();
            attributeHandleValuePairList[0].AttributeHandle = ((XRTIAttributeHandle)ocd.GetAttributeDescriptor(methodName).Handle).Identifier;
            attributeHandleValuePairList[0].AttributeValue  = newValue;

            return(attributeHandleValuePairList);
        }
        ///<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);
        }
Exemplo n.º 7
0
        protected void ProcessHLAupdateAttributeValuesMetafederation(HLAupdateAttributeValuesMessage msg)
        {
            Lrc.ReflectAttributeValuesExtCallback callback =
                new Lrc.ReflectAttributeValuesExtCallback(this.parent.MetaFederateAmbassador,
                                                          new XRTIObjectInstanceHandle(msg.ObjectInstanceHandle),
                                                          msg.AttributeHandleValuePairList, msg.UserSuppliedTag);

            callback.Call();

            ObjectInstanceDescriptor oid = parent.descriptorManager.GetObjectInstanceDescriptor(new XRTIObjectInstanceHandle(msg.ObjectInstanceHandle));
            ObjectClassDescriptor    ocd = parent.descriptorManager.GetObjectClassDescriptor("Sxtafederate");

            bool timePropertyFound = false;

            if (oid.ClassHandle.Equals(ocd.Handle))
            {
                if (msg.AttributeHandleValuePairList.Length > 0)
                {
                    for (int i = 0; i < msg.AttributeHandleValuePairList.Length && !timePropertyFound; i++)
                    {
                        HLAattributeHandleValuePair pair = msg.AttributeHandleValuePairList[i];
                        string propertyName = ocd.GetAttributeDescriptor(new XRTIAttributeHandle(pair.AttributeHandle)).Name;
                        if (propertyName.Equals("HLAlogicalTime") || propertyName.Equals("HLAlookahead") ||
                            propertyName.Equals("HLApendingTime") || propertyName.Equals("HLALITS") || propertyName.Equals("HLAtimeManagerState") ||
                            propertyName.Equals("HLAtimeConstrained") || propertyName.Equals("HLAtimeRegulating"))
                        {
                            timePropertyFound = true;
                        }
                    }

                    if (timePropertyFound)
                    {
                        parent.UpdateFederate();
                    }
                }
            }
        }
Exemplo n.º 8
0
        public override void RegisterObjectInstance(object obj)
        {
            lock (this)
            {
                if (obj != null && obj is HLAobjectRoot)
                {
                    HLAobjectRoot objRoot = obj as HLAobjectRoot;

                    string className = obj.GetType().BaseType.Name;
                    long objectClassHandle = ((XRTIObjectClassHandle)rti.descriptorManager.GetObjectClassDescriptor(className).Handle).Identifier;
                    objRoot.ClassHandle = new XRTIObjectClassHandle(objectClassHandle);

                    objectInstanceHandleProxyMap[objRoot.InstanceHandle] = objRoot;
                    objectListIsValid = false;

                    ObjectInstanceDescriptor oid = new ObjectInstanceDescriptor(objRoot.ObjectName, objRoot.InstanceHandle, objRoot.ClassHandle, objRoot.OwnFederationExecutionHandle);
                    objectInstanceDescriptorList.Add(oid);
                    rti.descriptorManager.AddObjectInstanceDescriptor(oid);

                    // COMMENT ANGEL: Si el objeto ha sido creado localmente --> Se debe enviar la creación al resto de federados
                    if (objRoot.HLAprivilegeToDeleteObject)
                    {
                        rti.RegisterObjectInstance(objRoot);
                    }

                }
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 public ObjectInstanceDescriptorPropertiesInformation(ObjectInstanceDescriptor obj)
 {
     info = obj;
 }
Exemplo n.º 10
0
 /// <summary> 
 /// Adds an object instance descriptor.
 /// </summary>
 /// <param name="oid">the object instance descriptor to Add
 /// </param>
 public virtual void AddObjectInstanceDescriptor(ObjectInstanceDescriptor oid)
 {
     objectInstanceNameDescriptorMap[oid.Name] = oid;
     objectInstanceHandleDescriptorMap[oid.Handle] = oid;
 }
Exemplo n.º 11
0
        /// <summary>
        ///  Removes an object instance descriptor.
        /// </summary>
        /// <param name="oid">the object instance descriptor to Remove
        /// </param>
        public virtual void RemoveObjectInstanceDescriptor(ObjectInstanceDescriptor oid)
        {
            if (objectInstanceNameDescriptorMap[oid.Name] == oid)
            {
                objectInstanceNameDescriptorMap.Remove(oid.Name);
            }

            if (objectInstanceHandleDescriptorMap[oid.Handle] == oid)
            {
                objectInstanceHandleDescriptorMap.Remove(oid.Handle);
            }
        }
Exemplo n.º 12
0
        public override void OnReceiveHLAregisterObjectInstance(HLAregisterObjectInstanceMessage msg)
        {
            if (log.IsDebugEnabled)
                log.Debug("Received HLAregisterObjectInstance =  " + msg.ToString());

            lock (this)
            {
                ObjectInstanceDescriptor oid = new ObjectInstanceDescriptor(msg.ObjectName, new XRTIObjectInstanceHandle(msg.ObjectInstanceHandle), new XRTIObjectClassHandle(msg.ObjectClassHandle), msg.FederationExecutionHandle);
                descriptorManager.AddObjectInstanceDescriptor(oid);
            }
        }