Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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();
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        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>
        ///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);
        }
Ejemplo n.º 6
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();
                    }
                }
            }
        }