Click or drag to resize

Example Transactions

Home
Transaction 0 - set value into OPC tag

This transaction is responsible for setting some values to first three registers:

Transaction 0 - set value into OPC tag

This transaction can be defined using the C# notation as:

C#
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
Transaction 1 - data bridging and addition

The transaction is shown in the picture below:

Transaction 1 - data bridging and addition

The meaning is:

C#
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 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.

Transaction 2 – OPC calculations (multiplication)

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).

Transaction 2 – OPC calculations (multiplication)

The meaning of this transaction is (using C# notation):

C#
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.

Transaction 3 - OPC mixed calculations

This transaction is doing some simple math:

Transaction 3 - OPC mixed calculations

The meaning of this transaction is (using C# notation):

C#
R109 = R103 + R104;
R110 = R103 * R104;

Change the R103 and R104 values using OPC Viewer to see the results.

Transaction 4 – OPC logical operations

This transaction presents some logical operations:

Transaction 4 – OPC logical operations

The meaning of this transaction is (using C# notation):

C#
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 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).

Transaction 5 - OPC calculations (division and subtraction)

This transaction presents some logical operations:

Transaction 5 - OPC calculations (division and subtraction)

The meaning of this transaction is (using C# notation):

C#
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 Note

If the R101 value is 0 (the system minute is 0) the transaction returns an error and no values are written.

Transaction 6 - OPC mixed calculations and logical operations (rising test)

This transaction presents some logical operations:

Transaction 6 - OPC mixed calculations and logical operations (rising test)

The meaning of this transaction is (using C# notation):

C#
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.

Transaction 7 and Transaction 8 – OPC mixed logical operations

This transaction presents some logical operations:

OPC mixed logical operations

The meaning of this transaction is (using C# notation):

C#
F105= Test.If.Value.Is.InRange(R105, 0 , 50 );
F106 = Test.If.Are.Equal ( R103 , R104 );
OPC mixed logical operations

The meaning of this transaction is (using C# notation):

C#
F105= Test.If.Value.Is.InRange(R109, 0 , 100 );
F105= Test.If.Value.Is.InRange(R110, 0 , 100 );