void opcItem_ValueUpdatedEvent(object sender, PollItem.PollItemValueUpdatedEventArgs e)
 {
 }
 internal void RegisterPollItems(string[] itemNames)
 {
     CommonDataContract.PollItem newPollItem;
     foreach (var item in itemNames) {
         newPollItem = new CommonDataContract.PollItem(item);
         AddPollItemToHashtable(newPollItem);
     }
 }
Example #3
0
        /*private static TDConfiguration CreateConfigurationByXML(string xmlFileName) {
            TDConfiguration configuration = new TDConfiguration();

            System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
            xmlDocument.Load(xmlFileName);

            string dataSourceType;
            TDDataSource dataSourceInstance;
            foreach (System.Xml.XmlNode dataSourcesNode in xmlDocument.ChildNodes) {
                if (dataSourcesNode.Name == "data-sources") {
                    foreach (System.Xml.XmlNode dataSourceNode in dataSourcesNode) {
                        if (dataSourceNode.Name == "data-source") {
                            dataSourceType = dataSourceNode.Attributes["type"].Value.ToString();
                            if (dataSourceType.ToLower() == "opc") {
                                dataSourceInstance = CreateOPCDataSourceByXml(dataSourceNode);
                                configuration.GetDataSources.AddDataSource(dataSourceInstance);
                            }
                        }
                    }
                }
            }
            return configuration;
        }

        private static TDDataSource CreateOPCDataSourceByXml(System.Xml.XmlNode dataSourceNode) {
            TDOpcDataSource opcDataSource = new TDOpcDataSource();
            OPCServer opcServer = new OPCServer();
            opcServer.HostName = dataSourceNode.Attributes["hostname"].Value.ToString();
            opcServer.ServerName = dataSourceNode.Attributes["name"].Value.ToString();
            opcDataSource.PollDelay = Convert.ToInt16(dataSourceNode.Attributes["poll-delay"].Value);
            opcDataSource.OpcServer = opcServer;
            OPCGroup opcGroup;
            OPCItem opcItem;
            foreach (System.Xml.XmlNode groupNode in dataSourceNode) {
                if (groupNode.Name == "group") {
                    opcGroup = new OPCGroup();
                    opcServer.Groups.Add(opcGroup);
                    opcGroup.GroupName = groupNode.Attributes["name"].Value.ToString();
                    foreach (System.Xml.XmlNode itemNode in groupNode.ChildNodes) {
                        if (itemNode.Name == "item") {
                            opcItem = new OPCItem();
                            opcGroup.Items.Add(opcItem);
                            opcItem.FullName = itemNode.Attributes["name"].Value.ToString();
                            //opcItem.ValueUpdatedEvent += new EventHandler<PollItem.PollItemValueUpdatedEventArgs>(opcItem_ValueUpdatedEvent);
                            _monitorPollItems.Add(opcItem);
                        }
                    }
                }
            }
            return opcDataSource;
        }
        */
        static void opcItem_ValueUpdatedEvent(object sender, PollItem.PollItemValueUpdatedEventArgs e)
        {
            /*string itemValue = e.NewPollItemValue.Value.ToString();
            string itemID = e.NewPollItemValue.ItemID;
            Console.WriteLine("{0} = {1}", itemID, itemValue);*/
        }
 internal void RegisterPollItem(string pollItemID)
 {
     CommonDataContract.PollItem newPollItem = new CommonDataContract.PollItem(pollItemID);
     AddPollItemToHashtable(newPollItem);
 }