Exemplo n.º 1
0
		}	//	end ProcessCommandLine
	
		public int BuildAddressSpace()
		{
			try
			{
				MyCreator creator = (MyCreator)Application.Instance.Creator;

				//	DA				
				DaAddressSpaceRoot daRoot = Application.Instance.DaAddressSpaceRoot;
				m_daSimulationElement = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement();
				m_daSimulationElement.Name = "simulation";
				m_daSimulationElement.AccessRights = EnumAccessRights.READWRITEABLE;
				m_daSimulationElement.Datatype = typeof(System.Int32);				
				m_daSimulationElement.IoMode = EnumIoMode.POLL;				
				daRoot.AddChild(m_daSimulationElement);

				m_daSimulationElement.ValueChanged(
					new ValueQT(
						m_random.Next(5000),
						EnumQuality.GOOD,
						DateTime.Now));				
				//AE
				AeAddressSpaceRoot aeRoot = Application.Instance.AeAddressSpaceRoot;
				AeAddressSpaceElement aeElement = creator.CreateAeAddressSpaceElement();
				aeElement.Name = "SimulationElement";
				aeElement.HasChildren = false;
				aeRoot.AddChild(aeElement);
			}
			catch(Exception exc)
			{
				Trace(
					EnumTraceLevel.ERR,
					EnumTraceGroup.USER1,
					"OpcServer:BuildAddressSpace",
					exc.ToString());
				return (int)EnumResultCode.E_FAIL;
			}	//	end try...catch

			return (int)EnumResultCode.S_OK;
		}	//	end BuildAddressSpace
Exemplo n.º 2
0
        //---------------------------------

        // TODO Implement this methods for string based address space using the DA address space elements

        /// <summary>
        /// Returns the corresponding namespace-element
        /// </summary>
        /// <param name="ElementID">Namespace path of the element</param>
        /// <param name="Element">returned element</param>
        /// <returns>
        /// EnumResultCode.E_NOTIMPL°Must be overridden
        /// </returns>
        public override int QueryAddressSpaceElementData(string anElementId, out AddressSpaceElement anElement)
        {
            anElement = null;
            BISDaRoot           daRoot = Application.Instance.DaAddressSpaceRoot as BISDaRoot;
            AddressSpaceElement anAddressSpaceElement = null;

            daRoot.findAddressSpaceElementData(anElementId, out anAddressSpaceElement);
            if (anAddressSpaceElement != null)
            {
                DaBaseElement daElement = anAddressSpaceElement as DaBaseElement;
                if (daElement != null)
                {
                    anElement             = new AeAddressSpaceElement();
                    anElement.Name        = daElement.Name;
                    anElement.HasChildren = daElement.HasChildren;

                    return((int)EnumResultCode.S_OK);
                }         // end if
            }             // end if .. else

            return((int)EnumResultCode.S_FALSE);
        }         // end QueryAddressSpaceElementData
Exemplo n.º 3
0
        }         // end QueryAddressSpaceElementData

        public override int QueryAddressSpaceElementChildren(string anElementId, ArrayList aChildrenList)
        {
            BISDaRoot daRoot   = Application.Instance.DaAddressSpaceRoot as BISDaRoot;
            ArrayList elements = null;

            if (anElementId == "")
            {
                elements = ArrayList.Synchronized(daRoot.GetChildren());
            }
            else
            {
                AddressSpaceElement anElement = null;
                daRoot.findAddressSpaceElementData(anElementId, out anElement);
                if (anElement != null)
                {
                    DaBaseElement daElement = anElement as DaBaseElement;
                    if (daElement != null)
                    {
                        elements = ArrayList.Synchronized(daElement.GetChildren());
                    }     // end if
                }         // end if
            }             // end if .. else

            foreach (object element in elements)
            {
                DaBaseElement daElement = element as DaBaseElement;
                if (daElement != null && daElement.Name != "CMD")
                {
                    AeAddressSpaceElement anElement = new AeAddressSpaceElement();
                    anElement.Name        = daElement.Name;
                    anElement.HasChildren = daElement.HasChildren;
                    aChildrenList.Add(anElement);
                }         //	end if
            }             // end foreach

            return((int)EnumResultCode.S_OK);
        }         // end QueryAddressSpaceElementChildren
        public int BuildAEAddressSpace()
        {
            int result = (int)EnumResultCode.S_OK;

            //AE
            DemoCreator        creator = (DemoCreator)Application.Instance.Creator;
            AeAddressSpaceRoot aeRoot  = Application.Instance.AeAddressSpaceRoot;

            AeAddressSpaceElement keyboardElement = creator.CreateDemoAeAddressSpaceElement();

            keyboardElement.Name        = "keyboard";
            keyboardElement.HasChildren = false;
            if (!aeRoot.AddChild(keyboardElement))
            {
                return((int)EnumResultCode.E_FAIL);
            }

            AeAddressSpaceElement mouseElement = creator.CreateDemoAeAddressSpaceElement();

            mouseElement.Name        = "mouse";
            mouseElement.HasChildren = true;
            if (!aeRoot.AddChild(mouseElement))
            {
                return((int)EnumResultCode.E_FAIL);
            }

            AeAddressSpaceElement rightButtonElement = creator.CreateDemoAeAddressSpaceElement();

            rightButtonElement.Name        = "right button";
            rightButtonElement.HasChildren = false;
            if (!mouseElement.AddChild(rightButtonElement))
            {
                return((int)EnumResultCode.E_FAIL);
            }

            AeAddressSpaceElement leftButtonElement = creator.CreateDemoAeAddressSpaceElement();

            leftButtonElement.Name        = "left button";
            leftButtonElement.HasChildren = false;
            if (!mouseElement.AddChild(leftButtonElement))
            {
                return((int)EnumResultCode.E_FAIL);
            }

            AeAddressSpaceElement timeElement = creator.CreateDemoAeAddressSpaceElement();

            timeElement.Name        = "time";
            timeElement.HasChildren = true;
            if (!aeRoot.AddChild(timeElement))
            {
                return((int)EnumResultCode.E_FAIL);
            }

            AeAddressSpaceElement localElement = creator.CreateDemoAeAddressSpaceElement();

            localElement.Name        = "local";
            localElement.HasChildren = true;
            if (!timeElement.AddChild(localElement))
            {
                return((int)EnumResultCode.E_FAIL);
            }

            AeAddressSpaceElement secondElement = creator.CreateDemoAeAddressSpaceElement();

            secondElement.Name        = "second";
            secondElement.HasChildren = false;
            if (!localElement.AddChild(secondElement))
            {
                return((int)EnumResultCode.E_FAIL);
            }

            AeAddressSpaceElement minuteElement = creator.CreateDemoAeAddressSpaceElement();

            minuteElement.Name        = "minute";
            minuteElement.HasChildren = false;
            if (!localElement.AddChild(minuteElement))
            {
                return((int)EnumResultCode.E_FAIL);
            }

            return(result);
        }