コード例 #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);
                    }
                }
            }
        }
コード例 #2
0
ファイル: ObjectManager.cs プロジェクト: agustinsantos/Sxta
        public void OnReceiveCreatedNewObject(object newObject)
        {
            if (newObject is HLAobjectRoot)
            {
                HLAobjectRoot obj = newObject as HLAobjectRoot;

                if (obj.HLAprivilegeToDeleteObject)
                {
                    obj.AddIHLAobjectRootListener((IHLAobjectRootListener)obj.OwnFederateAmbassador);

                    // COMMENT ANGEL: Sólo se registran los objetos locales con esta instrucción
                    //                Los objetos remotos lo realizan en el momento que se invoca la callback DiscoverObjectInstance
                    ((ISxtaFederateAmbassador)obj.OwnFederateAmbassador).RegisterObjectInstance(obj);
                }
            }
        }
コード例 #3
0
ファイル: ObjectManager.cs プロジェクト: agustinsantos/Sxta
        public object UpdateAttributeValuesProxyObject(object instance, IDictionary <string, object> methodNameValueMap)
        {
            if (instance is HLAobjectRoot)
            {
                HLAobjectRoot         obj = instance as HLAobjectRoot;
                ObjectClassDescriptor ocd = descriptorManager.GetObjectClassDescriptor(obj.ClassHandle);
                foreach (KeyValuePair <string, object> entry in methodNameValueMap)
                {
                    if (log.IsDebugEnabled)
                    {
                        log.Debug("The method " + entry.Key + " from object " + obj.InstanceHandle + " has been called; new value:" + entry.Value + "; parameter type = " + entry.Value.GetType());
                    }

                    HLAAttributeAttribute attr = obj.tableMethodInfo2Attr[entry.Key];
                    attr.propInfo.GetSetMethod().Invoke(obj, new object[] { entry.Value });
                }
            }

            return(instance);
        }
コード例 #4
0
ファイル: ObjectManager.cs プロジェクト: agustinsantos/Sxta
        public object CreateProxyObject(string objectName, long objectInstanceHandle, long objectClassHandle)
        {
            //ObjectInstanceDescriptor oid = descriptorManager.GetObjectInstanceDescriptor(new XRTIObjectInstanceHandle(objectInstanceHandle));
            //ObjectClassDescriptor ocd = descriptorManager.GetObjectClassDescriptor(oid.ClassHandle);
            ObjectClassDescriptor ocd  = descriptorManager.GetObjectClassDescriptor(new XRTIObjectClassHandle(objectClassHandle));
            HLAProxyAttribute     attr = new HLAProxyAttribute();

            attr.ObjectClassHandle    = objectClassHandle;
            attr.ObjectInstanceHandle = objectInstanceHandle;
            attr.ObjectName           = ocd.Name;

            object obj = HLAobjectRoot.NewRemoteInstance(ocd.NativeName, attr);

            if (log.IsDebugEnabled)
            {
                log.Debug("The constructor of object " + objectName + " has been called");
            }

            //return Activator.CreateInstance(ocd.NativeName, null, new object[] { attr });

            return(obj);
        }
コード例 #5
0
ファイル: ObjectManager.cs プロジェクト: agustinsantos/Sxta
        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
ファイル: ObjectManager.cs プロジェクト: agustinsantos/Sxta
        public ObjectManager(DescriptorManager aDescriptorManager)
        {
            descriptorManager = aDescriptorManager;

            HLAobjectRoot.AddIHLAobjectRootCreationListener(this);
        }