Exemple #1
0
        public void TestConnectTheNodeToOtherNode_Test2_RootTest()
        {
            //K
            //|
            //A     B
            //|\     \
            //C D     E
            // / \   / \
            // F  G  H  I
            //     \/
            //     J
            SortedTree <ClassAsTreeValue <string> > tree = new SortedTree <ClassAsTreeValue <string> >();

            AddNodeWholeTreeTestHelper(ref tree);
            AreEqualGetFroeachRepresentationHelper("CFJGDAKHIEB", tree, "after initialization");
            Assert.AreEqual(2, tree.GetRoots().Count, "there should be 2 roots");
            tree.AddNode(L);
            AreEqualGetFroeachRepresentationHelper("CFJGDAKHIEBL", tree, "after L adding");
            Assert.AreEqual(3, tree.GetRoots().Count, "there should be 3 roots");
            tree.AddNode(M);
            AreEqualGetFroeachRepresentationHelper("CFJGDAKHIEBLM", tree, "after M adding");
            Assert.AreEqual(4, tree.GetRoots().Count, "there should be 4 roots");
            tree.ConnectTheNodeToOtherNode(L, 0, M, 0);
            Assert.AreEqual(3, tree.GetRoots().Count, "there should be 3 roots");
            AreEqualGetFroeachRepresentationHelper("CFJGDAKHIEBML", tree, "after connecting L and M");
            tree.AddNode(N);
            Assert.AreEqual(4, tree.GetRoots().Count, "there should be 4 roots");
            AreEqualGetFroeachRepresentationHelper("CFJGDAKHIEBMLN", tree, "after N adding");
            tree.ConnectTheNodeToOtherNode(J, 0, L, 0);
            Assert.AreEqual(3, tree.GetRoots().Count, "there should be 3 roots");
            AreEqualGetFroeachRepresentationHelper("CFMLJGDAKHIEBN", tree, "after connecting J and L");
        }
Exemple #2
0
        public void TestConnectTheNodeToOtherNode_Test2_RootTest3()
        {
            //K L
            //|/
            //A
            //|
            //C
            SortedTree <ClassAsTreeValue <string> > tree = new SortedTree <ClassAsTreeValue <string> >();

            tree.AddNode(C);
            tree.AddNode(K);
            tree.AddNode(L);
            tree.AddNode(A);
            tree.ConnectTheNodeToOtherNode(A, 0, C, 0);
            tree.ConnectTheNodeToOtherNode(L, 0, A, 0);
            tree.ConnectTheNodeToOtherNode(K, 0, A, 1);
            AreEqualGetFroeachRepresentationHelper("CAKL", tree, "after all (after splitter adding)");
        }
Exemple #3
0
        public void TestConnectTheNodeToOtherNode_Test2_RootTest2()
        {
            //K
            //|
            //A     B
            //|\     \
            //C D     E
            // / \   / \
            // F  G  H  I
            //     \/
            //     J
            SortedTree <ClassAsTreeValue <string> > tree = new SortedTree <ClassAsTreeValue <string> >();

            AddNodeWholeTreeTestHelper(ref tree);
            AreEqualGetFroeachRepresentationHelper("CFJGDAKHIEB", tree, "after initialization");
            Assert.AreEqual(2, tree.GetRoots().Count, "there should be 2 roots");
            tree.AddNode(L);
            AreEqualGetFroeachRepresentationHelper("CFJGDAKHIEBL", tree, "after L adding");
            Assert.AreEqual(3, tree.GetRoots().Count, "there should be 3 roots");
            tree.RemoveConnectionBetweeenParentAndChildAndMoveElementToRoots(K, A);
            Assert.AreEqual(4, tree.GetRoots().Count, "there should be 4 roots");
            tree.AddNode(M);
            Assert.AreEqual(5, tree.GetRoots().Count, "there should be 5 roots");
            //do tego dazymy:
            //K M
            //|/
            //L  (to jest splitter)
            //|
            //A     B
            //|\     \
            //C D     E
            // / \   / \
            // F  G  H  I
            //     \/
            //     J
            tree.ConnectTheNodeToOtherNode(L, 0, A, 0);
            Assert.AreEqual(4, tree.GetRoots().Count, "there should be 4 roots");
            tree.ConnectTheNodeToOtherNode(M, 0, L, 1);
            Assert.AreEqual(3, tree.GetRoots().Count, "there should be 3 roots");
            tree.ConnectTheNodeToOtherNode(K, 0, L, 0);
            Assert.AreEqual(3, tree.GetRoots().Count, "there should be 3 roots");
            AreEqualGetFroeachRepresentationHelper("CFJGDALKHIEBM", tree, "after all (after splitter adding)");
        }
 /// <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 ) );
   }
 }
Exemple #5
0
        public void TestConnectTheNodeToOtherNode()
        {
            //K
            //|
            //A     B
            //|\     \
            //C D     E
            // / \   / \
            // F  G  H  I
            //     \/
            //     J
            SortedTree <ClassAsTreeValue <string> > tree = new SortedTree <ClassAsTreeValue <string> >();

            AddNodeWholeTreeTestHelper(ref tree);
            tree.RemoveConnectionBetweeenParentAndChildAndMoveElementToRoots(H, J);
            tree.ConnectTheNodeToOtherNode(J, 0, B, 0);

            string expected;
            string actual;

            expected = "CFHIEBJGDAK";
            actual   = GetForeachRepresentation(tree);
            Assert.AreEqual(expected, actual, "Problem with foreach statement: tree are not the same");
        }