private TDConfiguration CreateTestConfiguration()
        {
            TDConfiguration configuration = new TDConfiguration();
            OPCServer opcServer = new OPCServer();
            opcServer.HostName = "localhost";
            opcServer.ServerName = "Advosol.SimDAServer.1";

            OPCGroup opcGroup = new OPCGroup();
            opcGroup.OwnerServer = opcServer;
            opcGroup.GroupName = "SimulatedData";
            opcServer.Groups.Add(opcGroup);

            OPCItem opcItem = new OPCItem();
            opcItem.FullName = "SimulatedData.Random";
            opcItem.ItemName = "SimulatedData.Random";

            opcItem.ValueUpdatedEvent += new EventHandler<PollItem.PollItemValueUpdatedEventArgs>(opcItem_ValueUpdatedEvent);

            opcGroup.Items.Add(opcItem);

            TDOpcDataSource opcDataSource = new TDOpcV2DataSource();
            opcDataSource.OpcServer = opcServer;
            opcDataSource.PollDelay = 1000;

            configuration.GetDataSources.AddDataSource(opcDataSource);
            return configuration;
        }
Ejemplo n.º 2
0
        private static TDConfiguration CreateTestConfiguration()
        {
            TDConfiguration configuration = new TDConfiguration();
            OPCServer opcServer = new OPCServer();
            opcServer.HostName = "localhost";
            opcServer.ServerName = "Advosol.SimDAServer.1";

            OPCGroup opcGroup = new OPCGroup();
            opcGroup.OwnerServer = opcServer;
            opcGroup.GroupName = "SimulatedData";
            opcServer.Groups.Add(opcGroup);

            OPCItem opcItem = new OPCItem();
            opcItem.FullName = "SimulatedData.Random";
            opcItem.ItemName = "SimulatedData.Random";

            opcGroup.Items.Add(opcItem);
            _monitorPollItems.Add(opcItem);

            TDOpcDataSource opcDataSource = new TDOpcV2DataSource();
            opcDataSource.OpcServer = opcServer;

            configuration.GetDataSources.AddDataSource(opcDataSource);
            return configuration;
        }
Ejemplo n.º 3
0
 private static void FillMonitorItems(TDConfiguration configuration)
 {
     foreach (TDDataSource item in configuration.GetDataSources) {
         foreach (var opcGroup in (item as TDOpcDataSource).OpcServer.Groups) {
             foreach (var opcItem in opcGroup.Items) {
                 _monitorPollItems.Add(opcItem);
                 if (opcItem.SubItems != null) {
                     foreach (var subItem in opcItem.SubItems) {
                         _monitorPollItems.Add(subItem);
                     }
                 }
             }
         }
     }
 }
 private void CreatePollProcesses(TDConfiguration configuration, TDDataManager currentDataManager)
 {
     _pollProcesses = new List<TDPollProcess>();
     TDPollProcess newProcess;
     foreach (TDDataSource currentDataSource in configuration.GetDataSources) {
         switch (currentDataSource.DataSourceType) {
             case TDDataSource.TDDataSourceType.OPC_V2:
                 if (currentDataSource is TDOpcDataSource) {
                     newProcess = CreateOPCV2PollProcess(currentDataSource as TDOpcDataSource, currentDataManager);
                     _pollProcesses.Add(newProcess);
                 }
                 break;
             case TDDataSource.TDDataSourceType.OPC_V3:
                 if (currentDataSource is TDOpcDataSource) {
                     newProcess = CreateOPCV3PollProcess(currentDataSource as TDOpcDataSource, currentDataManager);
                     _pollProcesses.Add(newProcess);
                 }
                 break;
         }
     }
 }
        public 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().Substring(0,3) == "opc") {
                                dataSourceInstance = CreateOPCDataSourceByXml(dataSourceNode);
                                configuration.GetDataSources.AddDataSource(dataSourceInstance);
                            }
                        }
                    }
                }
            }
            return configuration;
        }
 public TDProcessManager(TDConfiguration configuration, Interfaces.IDataStore dataStore)
 {
     _currentConfiguration = configuration;
     _currentDataManager = new TDDataManager(dataStore);
     CreatePollProcesses(configuration, _currentDataManager);
 }
 public TDProcessManager(TDConfiguration configuration)
     : this(configuration, new InternalDAL.InternalDataStore())
 {
 }