Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA Enterprise SCADA BLT API Reference

Asynchronously execute a Business Logic Tier (BLT) component using the Data Access Layer (DAL)

Asynchronously execute a Business Logic Tier (BLT) component using the Data Access Layer (DAL)

This scenario guides you through the steps required to asynchronously execute the TestBLT Business Logic Tier (BLT) component using the Data Access Layer (DAL) .

To identify the code associated with each step, see to the code comments in the Example code section.

The TestBLT component is called using the following input parameters:

  • table and point names 
  • numberOfAlarms

The TestBLT component returns the following outputs:

  • numberOfAlarms parameter
  • numberOfEvents parameter
  • table and point names are returned as a tabular result or dataset

Toasynchronouslyexecute the BLT component using the DAL

  1. Open the Program.cs file from the created project. 

    In this example, the project is named DALBLTTest and the BLT component is named TestBLT.

  2. Create the method that implements DALBLTConnection.DALBLTExecuteDelegate by doing the following:
    1. Handle the execution status. 
    2. Retrieve the result data.
    3. Retrieve the output values of the parameters.
  3. Create a new method to execute the BLT component by doing the following:
    1. Get a DALBLTConnection to the driver where the BLT component is hosted. For example, RealTime.
    2. Create the BLT component parameters, providing initial values for the input parameters and output variable for the output parameters.
    3. Execute the BLT component asynchronously.  
  4. On the Main method, do the following:
    1. Initialize the DAL client service layer.
    2. Call the BLT component execution asynchronous method.
    3. Wait for the response and the delegate execution.
  5. Run the DALBLTTest.exe to check the DALBLTTest component execution by doing the following:
    1. On the desktop, double-click the Windows PowerShell for DNA shortcut.
    2. Execute the following commands:
      set-silo RealTime
      dalblttest    
       

Example code

// Create the method that implements DALBLTConnection.DALBLTExecuteDelegate.
private static void GetAsynchronousResults(
            List<DALBLTParam> bltParamList,
            Int32 rowsAffected,
            DataSet data,
            DALBLTExecutionStatus executionStatus,
            Object clientObj,
            String failureReason)
{
    // Handle the execution status.
    if (executionStatus == DALBLTExecutionStatus.Success)
    {
        lock (resultLock)
        {
            // Retrieve the result data.
            var table = data.Tables[0];
            foreach (DataRow row in table.Rows)
            {
                var name = row[0].ToString();
                var value = row[1].ToString();
                Console.WriteLine(
quot;The result field
{name} result has value {value}."); } // Retrieve the output values of the parameters. foreach (var param in bltParamList) { if (param.IsOutput) { Console.WriteLine(
quot;The parameter
{param.Name} has value {param.Value}."); } } } } else if (executionStatus == DALBLTExecutionStatus.CreateFailed) { Console.WriteLine(
quot;Failed to create a BLT component:
{failureReason}."); } else if (executionStatus == DALBLTExecutionStatus.ExecutionFailed) { Console.WriteLine(
quot;Failed to execute BLT component:
{failureReason}."); } else { Console.WriteLine(
quot;Unknown execution status received while processing results:
{executionStatus}."); } } private static void AsynchronousExecute() { // Get a DALBLTConnection to the driver where the BLT component is hosted. var bltConnection = DALBLTClient.GetGlobalConnection("Realtime", null); // Create BLT component parameters. var bltParameters = new List<DALBLTParam> { new DALBLTParam(name:"point", value:"0analog", isOutput: false), new DALBLTParam(name:"table", value:"analog", isOutput: false), new DALBLTParam(name:"numberOfAlarms", value:100, isOutput: true), new DALBLTParam(name:"numberOfEvents", value:null, isOutput: true), }; var bltValues = new List<DALBLTParam>(); const String bltName = "TestBLT"; const Int32 maxRowsToReturn = 0; // unlimited rows. // Execute the BLT component asynchronously. var request = bltConnection.Execute( bltName, maxRowsToReturn, bltParameters, GetAsynchronousResults, null); } static void Main(String[] args) { // Initialize the DAL client service layer. DALService.Initialize(); // Call the BLT component execution asynchronous method. AsynchronousExecute(); // Wait for the response and the delegate execution. Console.ReadLine(); }
TitleResults for “How to create a CRG?”Also Available in