Пример #1
0
        }               //	enc ctr

        //-
        #endregion

        #region         //	Public Override Methods
        //---------------------------------

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

            for (int i = 0; i < count; i++)
            {
                DaRequest request = Requests[i] as DaRequest;

                if ((request != null) && (request.ProgressRequestState(EnumRequestState.CREATED, EnumRequestState.INPROGRESS) == true))
                {
                    DaBaseElement element = request.AddressSpaceElement as DaBaseElement;

                    if (element != null)
                    {
                        element.HandleReadRequest(request);
                    }
                    else
                    {
                        request.Result = EnumResultCode.E_FAIL;
                        request.Value  = null;
                        request.Complete();
                    }   //	end if ... else
                }
            }
            return((int)EnumResultCode.S_OK);
        }               //	end HandleReadRequests
Пример #2
0
        }           //	end HandleItemWriteRequest

        /// <summary>
        /// Executes the command
        /// </summary>
        /// <param name="anAddress"></param>
        /// <param name="aCommand"></param>
        /// <returns></returns>
        protected int ExecuteCommands(
            string anAddress,
            string aCommand,
            string aDescription)
        {
            try
            {
                //	Delegate command execution to the application
                AddressSpaceElement targetElement;
                // TODO: replace the QueryAddressSpaceElementData call with BISDemo specific message
                BISDaRoot daRoot = Application.Instance.DaAddressSpaceRoot as BISDaRoot;
                daRoot.findAddressSpaceElementData(anAddress, out targetElement);

                DaBaseElement element = targetElement as DaBaseElement;

                if (element == null)
                {
                    //	the targeted element was not found
                    return((int)EnumResultCode.E_FAIL);
                }                   //	end if

                return(element.ExecuteCommand(anAddress, aCommand, aDescription));
            }
            catch
            {
                return((int)EnumResultCode.E_FAIL);
            }       //	end try ... catch
        }           //	end ExecuteCommand
Пример #3
0
        //---------------------------------

        public uint findAddressSpaceElementData(string anAddress, out AddressSpaceElement anElement)
        {
            anElement = null;
            Hashtable elements = Hashtable.Synchronized(this.m_elements);

            foreach (object element in elements.Values)
            {
                DaBaseElement daElement = element as DaBaseElement;
                if (daElement.ItemId == anAddress)
                {
                    anElement = daElement;
                    break;
                }           //	end if
            }               //	end foreach

            return((uint)EnumResultCode.S_OK);
        }
Пример #4
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
Пример #5
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
Пример #6
0
        }           //	end AddProperty

        public virtual void Simulate()
        {
            try
            {
                if (this.HasChildren)
                {
                    ArrayList children = this.GetChildren();
                    foreach (object element in children)
                    {
                        DaBaseElement daElement = element as DaBaseElement;
                        if (daElement != null)
                        {
                            daElement.Simulate();
                        }           //	end if
                    }               //	end
                }                   //	end if

                m_simulationOn = !m_simulationOn;
            }
            catch (Exception e)
            {
                Application.Instance.Trace(EnumTraceLevel.WRN, EnumTraceGroup.OPCSERVER, "DaBaseElement.Simulate", "Exception" + e.ToString());
            }       //	end try ... catch
        }           //	end if
Пример #7
0
        }               //	end BuildEventCategories

        public static void BuildNamespace()
        {
            device1Node             = new DaBaseElement();
            device1Node.HasChildren = true;
            device1Node.Name        = "BMS1";
            Application.Instance.DaAddressSpaceRoot.AddChild(device1Node);

            ValueQT value = new ValueQT(0, EnumQuality.GOOD, DateTime.Now);

            device1Node.AddProperty(new DaConstantProperty(6666, "HIERARCHY", "HIERARCHY", value));

            device1Node.AddChild(new DataPointElement("Datapoint11", 5002, "Meeting room 1"));
            device1Node.AddChild(new DataPointElement("Datapoint12", 5003, "Office 1"));
            device1Node.AddChild(new DataPointElement("Datapoint13", 5003, "Office 2"));
            device1Node.AddChild(new DataPointElement("Datapoint14", 5003, "Office 3"));
            device1Node.AddChild(new DataPointElement("Datapoint15", 5002, "Office 4"));
            device1Node.AddChild(new DataPointElement("Datapoint16", 5003, "Office 5"));
            device1Node.AddChild(new DeviceElement("DeviceState", 5001, "Device connection status datapoint"));

            device2Node             = new DaBaseElement();
            device2Node.HasChildren = true;
            device2Node.Name        = "BMS2";
            Application.Instance.DaAddressSpaceRoot.AddChild(device2Node);

            value = new ValueQT(0, EnumQuality.GOOD, DateTime.Now);
            device2Node.AddProperty(new DaConstantProperty(6666, "HIERARCHY", "HIERARCHY", value));

            device2Node.AddChild(new DataPointElement("Datapoint21", 5004, "Meeting room 1"));
            device2Node.AddChild(new DataPointElement("Datapoint22", 5004, "Office 1"));
            device2Node.AddChild(new DataPointElement("Datapoint23", 5004, "Office 2"));
            device2Node.AddChild(new DataPointElement("Datapoint24", 5004, "Office 3"));
            device2Node.AddChild(new DataPointElement("Datapoint25", 5005, "Office 4"));
            device2Node.AddChild(new DataPointElement("Datapoint26", 5005, "Office 5"));
            device2Node.AddChild(new DataPointElement("Datapoint27", 5004, "Office 5"));
            device2Node.AddChild(new DeviceElement("DeviceState", 5001, "Device connection status datapoint"));

            CommandElement cmd = new CommandElement();

            CommandProperty cmdProperty = new CommandProperty(5001, "DeviceState");

            cmdProperty.AddCommand("1", "Initialises Comms");
            cmdProperty.AddCommand("0", "Closes Comms");
            cmd.AddProperty(cmdProperty);

            cmdProperty = new CommandProperty(5002, "BMS1 5002");
            cmdProperty.AddCommand("3", "Init");
            cmdProperty.AddCommand("2", "Close");
            cmd.AddProperty(cmdProperty);

            cmdProperty = new CommandProperty(5003, "BMS1 5003");
            cmdProperty.AddCommand("5", "Resets sensor");
            cmdProperty.AddCommand("4", "Activates the sensor");
            cmd.AddProperty(cmdProperty);

            cmdProperty = new CommandProperty(5004, "BMS2 5004");
            cmdProperty.AddCommand("7", "Activate Zone");
            cmdProperty.AddCommand("6", "Deactivate Zone");
            cmd.AddProperty(cmdProperty);

            cmdProperty = new CommandProperty(5005, "BMS2 5005");
            cmdProperty.AddCommand("9", "Heating on");
            cmdProperty.AddCommand("8", "Heating off");
            cmd.AddProperty(cmdProperty);

            Application.Instance.DaAddressSpaceRoot.AddChild(cmd);
        }               //	end BuildNamespace