コード例 #1
0
ファイル: Main.cs プロジェクト: mpostol/OPCDA.DataPorter
        private void InitializationClient()
        {
            Device m_device;

            BaseStation.ItemDescriber.XMLManagement xml_desc = new BaseStation.ItemDescriber.XMLManagement();
            Main.m_ds_dsc = new BaseStation.ItemDescriber.ItemDecriberDataSet();
            xml_desc.readXMLFile(Main.m_ds_dsc, CAS.DataPorter.Properties.Settings.Default.ItemDscConfigurationFile);
            //Device initialization:
            m_device = new CAS.Lib.DeviceSimulator.Device();
            HTTPSoapServer.SetDevice(m_device);
            //initialization from xml file
            //servers/groups/tags initialization
            using (ConfigurationManagement cm = new ConfigurationManagement())
            {
                cm.ReadConfiguration(AppConfigManagement.filename);
                foreach (OPCCliConfiguration.ServersRow srvdsc in cm.Configuartion.Servers)
                {
                    //server initialization
                    OPCDataQueue.CrateServer(srvdsc, ref m_VolumeConstrain);
                }
                foreach (OPCCliConfiguration.TransactionsRow transdsc in cm.Configuartion.Transactions)
                {
                    OPCDataQueue.CreateTransaction(transdsc);
                }
            }
            OPCDataQueue.SwitchOnScanning();
            MonitorInterface.Start(cProductName, cProductVersion);
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: mpostol/OPCDA.DataPorter
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
 protected override void Dispose(bool disposing)
 {
     OPCDataQueue.DisconnectAllServers();
     if (disposing && (components != null))
     {
         components.Dispose();
     }
     base.Dispose(disposing);
 }
コード例 #3
0
ファイル: Main.cs プロジェクト: mpostol/OPCDA.DataPorter
 /// <summary>
 /// Stops  the DataPorter.
 /// </summary>
 public void Stop()
 {
     if (isStarted)
     {
         string msg = "Closing the application. Product name: {0}, product version: {1}";
         new EventLogMonitor(String.Format(msg, Application.ProductName, Application.ProductVersion), EventLogEntryType.Information, 0, 1829).WriteEntry();
         isStarted = false;
         OPCDataQueue.DisconnectAllServers();
     }
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OPCClientGroup"/> class.
 /// </summary>
 /// <param name="group">The group description from XML configuration file<see cref="OPCCliConfiguration.SubscriptionsRow"/>.</param>
 /// <param name="items">The table of items <see cref="OPCCliConfiguration.ItemsRow"/>.</param>
 /// <param name="server">Server that this group should belong to</param>
 /// <param name="parent">The parent.</param>
 /// <param name="volumeConstrain">The volume constrain.</param>
 internal OPCClientGroup
   (
   OPCCliConfiguration.SubscriptionsRow group,
   OPCCliConfiguration.ItemsRow[] items,
   OPC_Interface server,
   OPCDataQueue parent,
   ref uint? volumeConstrain
   )
 {
   if ( volumeConstrain.HasValue )
     if ( volumeConstrain.Value < items.Length )
       throw new LicenseException( typeof( Main ), Main.MainComponent, CAS.Lib.CodeProtect.Properties.Resources.Tx_LicVolumeConstrainErr );
     else
       volumeConstrain = volumeConstrain.Value - Convert.ToUInt32( items.Length );
   OpcDa.SubscriptionState state = group.CreateSubscriptionState;
   m_OPCGroup = server.CreateOPCGroup( (uint)group.ID, (uint)group.ID_server, group.Asynchronous, state );
   m_OPCGroup.Tags = Tags( items, server, m_OPCGroup );
   m_AllGroups.Add( this );
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OPCClientTransaction"/> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 /// <param name="ParentDataQueue">The parent data queue.</param>
 internal OPCClientTransaction( OPCCliConfiguration.TransactionsRow configuration, OPCDataQueue ParentDataQueue )
   : base( ParentDataQueue, new TimeSpan( 0, 0, 0, 0, configuration.TransactionRate == 0 ? 1 : configuration.TransactionRate ) )
 {
   bool canBeAdded = true;
   if ( !configuration.IsBadQualityValueNull() )
     m_BadQualityValue = configuration.BadQualityValue;
   m_StopIfBadQuality = configuration.StopIfBadQuality;
   OPCCliConfiguration.OperationsRow[] operations = configuration.GetOperationsRows();
   // stworzymy tablice operacji do wykonania;
   SortedList<long, Operation> operationList = new SortedList<long, Operation>( configuration.GetOperationsRows().Length );
   SortedList<long, OPCCliConfiguration.OperationsRow> operationRowList =
     new SortedList<long, OPCCliConfiguration.OperationsRow>( configuration.GetOperationsRows().Length );
   SortedTree<Operation> myOperationTree = new SortedTree<Operation>();
   try
   {
     //najpierw dodajemy wszystkie operacje
     foreach ( OPCCliConfiguration.OperationsRow row in configuration.GetOperationsRows() )
     {
       try
       {
         Operation operrowOperation = OperationFactory.GetOperation( row, m_StopIfBadQuality, m_BadQualityValue );
         operationRowList.Add( (long)operrowOperation.Statistics.Identifier, row );
         operationList.Add( (long)operrowOperation.Statistics.Identifier, operrowOperation );
         myOperationTree.AddNode( operrowOperation ); //najpiewr dodajemy wszystykie jako rooty
       }
       catch ( Exception ex )
       {
         Exception newExcetion = new Exception( String.Format( Resources.tx_OPCDataQueue_Operation_CannotBeAdded, row.Name ), ex );
         throw newExcetion;
       }
     }
     //teraz dodajemy wszystkie linki:
     foreach ( Operation node in myOperationTree )
       foreach ( OPCCliConfiguration.OperationLinksRow OpLinksRow in operationRowList[ node.Statistics.Identifier ].GetOperationLinksRowsByFK_OPERATION_OperationLinks() )
       {
         myOperationTree.ConnectTheNodeToOtherNode( operationList[ OpLinksRow.ID_Operation ], OpLinksRow.Input_number,
           operationList[ OpLinksRow.IDChild_Operation ], OpLinksRow.ChildOutput_number );
       }
   }
   catch ( Exception ex )
   {
     Main.MainComponent.SystemExceptionHandler( ex, 158, this.ToString() );
     canBeAdded = false;
   }
   if ( canBeAdded )
   {
     m_Transaction = new Transaction( configuration, myOperationTree );
     m_AllTransactions.Add( this );
   }
   else
   {
     Main.MainComponent.Tracer.TraceWarning( 194, this.GetType().ToString(),
       String.Format( Resources.tx_OPCDataQueue_Transaction_CannotBeAdded, configuration.Name ) );
   }
 }