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

AVEVA™ Batch Management

Security Control Examples

  • Last UpdatedNov 03, 2021
  • 4 minute read

The following InTouch script is secured by AVEVA Batch Management security. The example starts with the configuration of a custom security application and function in the Security Editor.

To Configure Batch Management Security

  1. Add a custom application to the AVEVA Batch Management security system called InTouch.

  2. Add a function to that application called Open Valve.

  3. Set the function to require Done By security.

Example 1: WinType = secWindowModal

The following InTouch script acts to manually force a valve only if AVEVA Batch Management security is passed. This is the easiest way to implement the BatchSecurity control.

{Script to open valve XV101 manually}

{Check InBatch for Security Clearance (Modal Window)}

IF #BatchSec3.FunctionClearance( 99, 1, "", 0, 0) == 0 THEN

{0 means it's OK, open the valve}

XV101_MAN = 1;

ELSE

{There's a problem, show the error message.}

OPR_MESSAGE = #BatchSec3.LastErrorMessage;

ENDIF;

Example 2: WinType = secWindowModeless

The following scripts show how this same function is accomplished with a modeless window (script continues even while security dialog is up). The first script is on the valve icon or button on the graphical.

{Check InBatch Security (Modeless Window)}

{Use 101 to identify the valve in the UserData argument}

#BatchSec3.FunctionClearance( 99, 1, "", 1, 101);

{END OF SCRIPT (user is still answering security dialog(s)}

A second script is required for a modeless dialog. It is an event script on the BatchSec control FunctionClearanceComplete Event. It gets called when the security information is finally filled out by the operator.

{{ActiveX Script: FunctionClearanceComplete}

IF #ThisEvent.FunctionClearanceCompleteResult == 0 THEN

{ Security Test Passed. User data tells me what was requested. }

IF #ThisEvent.FunctionClearanceCompleteUserData == 100 THEN

XV100_MAN = 1;

ENDIF;

IF #ThisEvent.FunctionClearanceCompleteUserData == 101 THEN

XV101_MAN = 1;

ENDIF;

IF #ThisEvent.FunctionClearanceCompleteUserData == 102 THEN

XV102_MAN = 1;

ENDIF;

ELSE

{ Security failed. error message }

OPR_MESSAGE = #ThisControl.LastErrorMessage;

ENDIF;

Example 3: WinType = secWindowlessEvent

This script is the most complicated case. The WindowlessEvent interface was designed to allow users to create their own security dialogs. These dialogs would be shown to the user when the RequestUserInfo and RequestNewPassword events are raised. The dialogs must be modal because the user information must be supplied to the interface before the event handling routine terminates. Therefore, this window type should not be used by InTouch, because InTouch cannot (and should not) use modal dialogs.

Note: The WindowlessEvent window type should not be used with InTouch.

The following code sample is of a Visual Basic application, which uses AVEVA Batch Management security. The command button, Command1 has some secured functionality.

Private Sub Command1_Click()

BatchSec1.FunctionClearance MyApp, MyFunc, "", _

secWindowlessEvent, MyUserData

End Sub

Private Sub BatchSec1_FunctionClearanceComplete(ByVal Result As BATCHSECCTRLLibCtl.secResultType, ByVal ApplicationID As Long, ByVal FunctionID As Long, ByVal UserData As Long)

If Result = secResultOk Then

' Security is OK.

' Do originally requested action encoded in UserData...

Select Case UserData

Case 1

' Do Case 1

Case 2

' Do Case 2

'...

End Select

Else

MsgBox BatchSec1.LastErrorMessage, , _

"Security Error Code " & Str(BatchSec1.LastErrorCode)

End If

End Sub

Private Sub BatchSec1_RequestNewPassword( _

ByVal RequestType As BATCHSECCTRLLibCtl.secRequestType, _

ByVal UserID As String, ByVal UserData As Long)

frmNewPasswordDlg.UserID.Text = UserID

frmNewPasswordDlg.Show vbModal

End Sub

Private Sub BatchSec1_RequestUserInfo( _

ByVal RequestType As BATCHSECCTRLLibCtl.secRequestType, _

ByVal ApplicationID As Long, _

ByVal ApplicationName As String, _

ByVal FunctionID As Long, ByVal FunctionName As String, _

ByVal UserData As Long)

frmSecDialog.lblApplication.Caption = ApplicationName

frmSecDislog.lblFunction.Caption = FunctionName

Select Case RequestType

Case secRequestType.secRequestApplication

frmSecDialog.lblLevel.Caption = "Application"

frmSecDialog.Show vbModal

BatchSec1.DoneByUserID = frmSecDialog.UserID.Text

BatchSec1.DoneByPassword = _

frmSecDialog.Password.Text

Case secRequestType.secRequestDoneBy

frmSecDialog.lblLevel.Caption = "Done By"

frmSecDialog.Show vbModal

BatchSec1.DoneByUserID = frmSecDialog.UserID.Text

BatchSec1.DoneByPassword = _

frmSecDialog.Password.Text

Case secRequestType.secRequestCheckBy

frmSecDialog.lblLevel.Caption = "Check By"

frmSecDialog.Show vbModal

BatchSec1.CheckByUserID = frmSecDialog.UserID.Text

BatchSec1.CheckByPassword = _

frmSecDialog.Password.Text

End Select

End Sub

Example 4: WinType = secWindowlessCheck

This type of window assumes that some scripting or code provides the UserID and password information directly into the security object properties before the FunctionClearance or ApplicationClearance method is called. This window type can be used in conjunction with the QueryApplicationSecurity or QueryFunctionSecurity methods in order to determine which if any dialogs would need to be shown. Because the call to the FunctionClearance or Application Clearance method occurs after the information is supplied, this window type can be used by InTouch, because the security dialogs to execute in this mode can be modeless.

{InTouch script to open XV101 in manual mode}

{On XV101 icon click}

SEC_APPLICATION = 99;

SEC_FUNCTION = 1;

SEC_USERDATA = 101;

SEC_LEVEL = BatchSec3.QueryFunctionSecurity(SEC_APPLICATION, SEC_FUNCTION);

IF SEC_LEVEL == 0 THEN

{No security required. Grant permission.}

SEC_GRANTED = SEC_USERDATA;

ELSE

SEC_REQUEST = "Done By"; {Ask for Done By Check}

Show "Security Check"

ENDIF;

{Data Change Script on SEC_GRANTED}

IF SEC_GRANTED == 100 THEN

XV100_MAN = 1;

ENDIF;

IF SEC_GRANTED = 101 THEN

XV101_MAN = 1;

ENDIF;

IF SEC_GRANTED = 102 THEN

XV102_MAN = 1;

ENDIF;

{Reset}

SEC_GRANTED = 0;

{OK Button Click Script on "Security Check" Window}

IF SEC_REQUEST == "Done By" THEN

BatchSec3.DoneByUserID = SEC_USERID;

BatchSec3.DoneByPassword = SEC_PASSWORD;

IF SEC_LEVEL = 1 THEN

BatchSec3.FunctionClearance( SEC_APPLICATION,
SEC_FUNCTION, "", 3, SEC_USERDATA );

HideSelf;

ELSE

{Reset Window to accept entries for Check By}

SEC_REQUEST = "Check By";

ENDIF;

ELSE

{SEC_REQUEST = "Check By"}

BatchSec3.CheckByUserID = SEC_USERID;

BatchSec3.CheckByPassword = SEC_PASSWORD;

BatchSec3.FunctionClearance( SEC_APPLICATION,
SEC_FUNCTION, "", 3, SEC_USERDATA );

HideSelf;

ENDIF;

{Reset Security Check Window fields}

SEC_USERID = "";

SEC_PASSWORD = "";

{{ActiveX Script: FunctionClearanceComplete}

IF #ThisEvent.FunctionClearanceCompleteResult == 0 THEN

{ Security Test Passed. User data tells me what was requested. }

SEC_GRANTED = #ThisEvent.FunctionClearanceCompleteUserData;

ELSE

{ Security failed. error message }

OPR_MESSAGE = #ThisControl.LastErrorMessage;

ENDIF;

TitleResults for “How to create a CRG?”Also Available in