Example Transactions |
This topic contains the following sections:
This transaction is responsible for setting some values to first three registers:
This transaction can be defined using the C# notation as:
R100 = Random( 100 ); //random numbers from 0 to 100 is assigned to register 100 R101 = System.DateTime.Now.Minute; //current minute from system time is assigned to register 101 R102 = 123; //value 123 is assigned to register 102
The transaction is shown in the picture below:
The meaning is:
R105 = R100; //move the value of register R100 to register R105 R106 = R100 + R101; //add values from registers R100 and R101 and assign the result to register R106
Note |
---|
To avoid reading of R100 twice, the “splitter” (“-<”) operation is used. To verify whether this operation works, check the value of R105 (is it equal to R100 ?) and R106 (is it equal to R100 + R101?). The answer should be yes to the above questions. |
This transaction presents comparison of using multiply and 10pow operations. 10pow operation scales the input value. It calculates the selected power of 10 and multiplies this value by the input value. (e.g.: operation parameter: ‘0’ – do not scale the value (10^0=1); ‘1’ means multiply the source value by 10 (10^1=10); ‘-2’ – divide the source value by 100 (10^(-2)=0.01=1/100).
The meaning of this transaction is (using C# notation):
R107 = 10 * R101; R108 = 10pow( R101 , 1 ); // note: 10pow(R101,1) = 10^1 * R101 = 10 * R100
Of course, after this operation the R107 and R108 values should be equal.
This transaction is doing some simple math:
The meaning of this transaction is (using C# notation):
R109 = R103 + R104; R110 = R103 * R104;
Change the R103 and R104 values using OPC Viewer to see the results.
This transaction presents some logical operations:
The meaning of this transaction is (using C# notation):
F100 = Test.If.Value.Is.InRange( R100 , 0 , 100 ); // this means: // if (R100 > 0 && R100 < 100) // F100 = 1; // true // else // F100 = 0; // false F101 = Test.If.Are.Equal ( R100 + R100 , R100 * 2 );// this means: // if ((R100 + R100 ) == R100 * 2) // F101 = 1; // true // else // F101 = 0; // false
Note |
---|
That value of R100 is a random number between 0 and 100. Of course, after this transaction the F100 and F101 values must be 1 (this means that DataPorter works as expected). |
This transaction presents some logical operations:
The meaning of this transaction is (using C# notation):
F102 = Test.If.Are.Equal ( R101 / R101 , 1 );// this means: // if ((R101 / R101) == 1) // F102 = 1; // true // else // F102 = 0; // false F103 = Test.If.Are.Equal ( R101 - R101 , 0 );// this means: // if ((R101 - R101) == 0) // F103 = 1; // true // else // F103 = 0; // false
Of course, after this transaction the F102 and F103 values must be 1 (this means that DataPorter works as expected).
Note |
---|
If the R101 value is 0 (the system minute is 0) the transaction returns an error and no values are written. |
This transaction presents some logical operations:
The meaning of this transaction is (using C# notation):
F100 = Test.If.Value.Is.InRange(10pow( R100 , 2 ) – R100 * 100, 0 , 1 ); // this means: // temp1 = 10pow( R100 , 2 ); //temp1 = R100 * 10^2; //this is temporal variable // temp2 = R100 * 100; // this is second temporal variable // if ( (temp1-temp2) >= 0 && (temp1-temp2) < 1) // F104 = 1; // true // else // F104 = 0; // false
Analyze the code to find that the F104 value should be always 1.
This transaction presents some logical operations:
The meaning of this transaction is (using C# notation):
F105= Test.If.Value.Is.InRange(R105, 0 , 50 ); F106 = Test.If.Are.Equal ( R103 , R104 );
The meaning of this transaction is (using C# notation):
F105= Test.If.Value.Is.InRange(R109, 0 , 100 ); F105= Test.If.Value.Is.InRange(R110, 0 , 100 );