示例#1
0
        private string GetAttributeName(object instance, long attributeHandle)
        {
            IObjectClassHandle whichClass = ((HLAobjectRoot)instance).ClassHandle;
            IAttributeHandle   theHandle  = new XRTIAttributeHandle(attributeHandle);

            ObjectClassDescriptor ocd = rti.descriptorManager.GetObjectClassDescriptor(whichClass);

            if (ocd == null)
            {
                throw new InvalidObjectClassHandle(whichClass.ToString());
            }
            else
            {
                AttributeDescriptor ad = ocd.GetAttributeDescriptor(theHandle);

                if (ad == null)
                {
                    throw new InvalidAttributeHandle(theHandle.ToString());
                }
                else
                {
                    return(ad.Name);
                }
            }
        }
示例#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();
                        }
                    }
                }
            }
        }
示例#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);
        }
        ///<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);
        }
示例#5
0
        public object UpdateAttributeValuesProxyObject(object instance, HLAattributeHandleValuePair[] methodNameValueMap)
        {
            if (instance is HLAobjectRoot)
            {
                HLAobjectRoot         obj = instance as HLAobjectRoot;
                ObjectClassDescriptor ocd = descriptorManager.GetObjectClassDescriptor(obj.ClassHandle);
                foreach (HLAattributeHandleValuePair entry in methodNameValueMap)
                {
                    if (log.IsDebugEnabled)
                    {
                        log.Debug("The method " + entry.AttributeHandle + " from object " + obj.InstanceHandle +
                                  " has been called; new value:" + entry.AttributeValue + "; parameter type = " + entry.AttributeValue.GetType());
                    }

                    string attrName            = ocd.GetAttributeDescriptor(new XRTIAttributeHandle(entry.AttributeHandle)).Name;
                    HLAAttributeAttribute attr = obj.AttrTable[attrName];
                    attr.propInfo.GetSetMethod().Invoke(obj, new object[] { entry.AttributeValue });
                    //obj.GetType().BaseType.GetProperty(attrName).GetSetMethod().Invoke(obj, new object[] { entry.AttributeValue });
                }
            }

            return(instance);
        }
示例#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();
                    }
                }
            }
        }
示例#7
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);
        }