示例#2
0
        }                 //	end HandleReadRequests

        public override int HandleWriteRequests()
        {
            int count = Requests.Count;

            for (int i = 0; i < count; i++)
            {
                DaRequest request = Requests[i] as DaRequest;
                if (request != null)
                {
                    MyDaAddressSpaceElement element = (MyDaAddressSpaceElement)request.AddressSpaceElement;
                    if (element != null)
                    {
                        ValueQT valueQT = request.Value;
                        request.Result = (EnumResultCode)element.ValueChanged(valueQT);
                    } //	end if
                }     //	end if
            }         //	end for
            return(CompleteRequests());
        }             //	end HandleWriteRequests
示例#3
0
        }           //	end constructor

        public override int HandleReadRequests()
        {
            int count = Requests.Count;

            for (int i = 0; i < count; i++)
            {
                DaRequest request = (DaRequest)Requests[i];
                if ((request != null) && (request.ProgressRequestState(EnumRequestState.CREATED, EnumRequestState.INPROGRESS) == true))
                {
                    if (request.PropertyId == 0)
                    {
                        // get address space element value
                        // take the Toolkit cache value
                        ValueQT cacheValue = null;
                        request.AddressSpaceElement.GetCacheValue(ref cacheValue);
                        request.Value  = cacheValue;
                        request.Result = EnumResultCode.S_OK;
                    }
                    else
                    {
                        // get property value
                        // get the value from the address space element
                        MyDaAddressSpaceElement element = request.AddressSpaceElement as MyDaAddressSpaceElement;
                        if (element != null)
                        {
                            element.GetPropertyValue(request);
                        }
                        else
                        {
                            request.Result = EnumResultCode.E_FAIL;
                        } //	end if ... else
                    }     //	end if ... else
                }         //	end if
            }             //	end for
            return(CompleteRequests());
        }                 //	end HandleReadRequests
示例#4
0
        }           //	end ProcessCommandLine

        public int BuildAddressSpace()
        {
            try
            {
                MyDaAddressSpaceElement tag, node;

                tag              = new MyDaAddressSpaceElement();
                tag.Name         = "accept";
                tag.Type         = MyDaAddressSpaceElement.TYPE_ACCEPT;
                tag.AccessRights = EnumAccessRights.READWRITEABLE;
                tag.Datatype     = typeof(Int32);
                tag.IoMode       = EnumIoMode.POLL;
                Application.Instance.DaAddressSpaceRoot.AddChild(tag);

                node             = new MyDaAddressSpaceElement();
                node.Name        = "maths";
                node.Type        = MyDaAddressSpaceElement.TYPE_NODEMATH;
                node.IoMode      = EnumIoMode.NONE;
                node.HasChildren = true;
                Application.Instance.DaAddressSpaceRoot.AddChild(node);

                g_sin              = new MyDaAddressSpaceElement();
                g_sin.Name         = "sin";
                g_sin.Type         = MyDaAddressSpaceElement.TYPE_SINE;
                g_sin.AccessRights = EnumAccessRights.READABLE;
                g_sin.Datatype     = typeof(double);
                g_sin.IoMode       = EnumIoMode.REPORT;
                node.AddChild(g_sin);
                g_sin.SetEUInfoAnalog(-1.0, 1.0);


                DaProperty property = new DaProperty();
                property.Id           = 6020;
                property.Name         = "Angle";
                property.Description  = "Angle Description";
                property.ItemId       = property.Name;
                property.Datatype     = typeof(short);
                property.AccessRights = EnumAccessRights.READWRITEABLE;
                g_sin.AddProperty(property);

                node             = new MyDaAddressSpaceElement();
                node.Name        = "random";
                node.Type        = MyDaAddressSpaceElement.TYPE_NODERANDOM;
                node.IoMode      = EnumIoMode.NONE;
                node.HasChildren = true;
                Application.Instance.DaAddressSpaceRoot.AddChild(node);

                g_rand100ms              = new MyDaAddressSpaceElement();
                g_rand100ms.Name         = "100ms";
                g_rand100ms.Type         = MyDaAddressSpaceElement.TYPE_RANDOM_100MS;
                g_rand100ms.AccessRights = EnumAccessRights.READABLE;
                g_rand100ms.Datatype     = typeof(Int32);
                g_rand100ms.IoMode       = EnumIoMode.REPORT;
                node.AddChild(g_rand100ms);

                g_rand1s              = new MyDaAddressSpaceElement();
                g_rand1s.Name         = "1s";
                g_rand1s.Type         = MyDaAddressSpaceElement.TYPE_RANDOM_1S;
                g_rand1s.AccessRights = EnumAccessRights.READABLE;
                g_rand1s.Datatype     = typeof(Int32);
                g_rand1s.IoMode       = EnumIoMode.REPORT;
                node.AddChild(g_rand1s);

                //	AE
                MyAeAddressSpaceElement computer = new MyAeAddressSpaceElement();
                computer.Name        = "computer";
                computer.HasChildren = true;
                Application.Instance.AeAddressSpaceRoot.AddChild(computer);

                MyAeAddressSpaceElement clock = new MyAeAddressSpaceElement();
                clock.Name        = "clock";
                clock.HasChildren = true;
                computer.AddChild(clock);

                MyAeAddressSpaceElement timer = new MyAeAddressSpaceElement();
                timer.Name        = "timer";
                timer.HasChildren = false;
                clock.AddChild(timer);

                timer             = new MyAeAddressSpaceElement();
                timer.Name        = "time slot 1";
                timer.HasChildren = false;
                clock.AddChild(timer);
            }
            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