/// <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 ) ); } }
/// <summary> /// Creates the transaction. /// </summary> /// <param name="transactionDescription">The transaction description.</param> internal static void CreateTransaction( OPCCliConfiguration.TransactionsRow transactionDescription ) { OPCClientTransaction transaction = new OPCClientTransaction( transactionDescription, m_DataQueue ); foreach ( OPCClientGroup gr in OPCClientGroup.AllGroups ) transaction.WriteIsReady += gr.WriteOperation; }