Display Test Object Data In Omicron Control Center Custom Dialog

Welcome to the second part of the tutorial series about Omicron Control Center (OCC) Custom Dialog. In this tutorial, I will show you how to retrieve the data from the OCC document test object and display it to the custom dialog.


Now, open the OCC document that created in the first part of this series. If you don't have it, please check the first part of the series (Omicron Control Center Custom Dialog - Creating Custom Dialog). Follow the step by step procedure there to create the a OCC document then return to this page.

Before we start writing coding, we have to add Omicron libraries to reference of the existing OCC document. In the View tab and under the Document Views group, click the Script View button to open the scripts we've created in the previous tutorial. Stop the script by clicking the Stop Script button under the Run Script group to enable us to edit or modify the script. Click the References button then the reference dialog will open. In the reference list, find the OMXRio (4.20), OMXRioData (4.20), OMXRioDependency (4.20) & OMXRioFilter (4.20) and thick them then click OK button. In my computer the Omicron reference library installed is version 4.20, your computer might be different.

Once the libraries loaded, copy the codes below and paste them into the script window. The codes below will be use to get the data from the OCC Document test object and display in the custom dialog.

Function GetDisplayString(Parameter As AutoParameter) As String
	If Not Parameter Is Nothing Then
		GetDisplayString = Parameter.DisplayString
	Else
		GetDisplayString = "-"
	End If
End Function

Then declare Public GlobalTO as Xrio and set an instance from the document's test object inside the SetRelayInformation procedure in the first line before the Begin Dialog.

Set GlobalTO = Document.TestObjects(1).Specific

Then copy the codes below and insert them to inside the SetRelayInformation procedure between the line Dim dlg As UserDialog and Dialog dlg.

dlg.txtSubstationName = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".SUBSTATION_NAME"))
dlg.txtSubstationAddress = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".SUBSTATION_ADDRESS"))
dlg.txtCBName = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".CB_NAME"))
dlg.txtCircuitName = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".CIRCUIT_NAME"))
dlg.txtDeviceType = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".DEVICE_TYPE"))
dlg.txtManufacturer = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".MANUFACTURER"))
dlg.txtSerialNumber = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".SERIAL_NUMBER"))
dlg.txtDeviceAddress = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".DEVICE_ADDRESS"))

Once completed the overall code should be looks like the codes below.

' ************************************************************
' This is module *Module1 .
' Automatically generated uses comments are placed here.
' Don't edit these lines.
' {BEGINUSES}
'#Uses "*Module1"
' {ENDUSES}
' ************************************************************

Public Const BASIC_INFO_PATH As String = "CUSTOM.RELAY_INFORMATION.BASIC"
Public GlobalTO As XRio

Sub SetRelayInformation
	On Error GoTo ErrorHandler
	Set GlobalTO = Document.TestObjects(1).Specific

	Begin Dialog UserDialog 480,273,"Relay Information Dialog Editor" ' %GRID:10,7,1,1
		Text 10,14,140,14,"Substation Name:",.lblSubstationName
		Text 10,42,140,14,"Substation Address:",.lblSubstationAddress
		Text 10,70,140,14,"CB Name:",.lblCBName
		Text 10,98,140,14,"Circuit Name:",.lblCircuitName
		Text 10,126,140,14,"Device Type:",.lblDeviceType
		Text 10,154,140,14,"Manufacturer:",.lblManufacturer
		Text 10,182,140,14,"Serial Number:",.lblSerialNumber
		Text 10,210,90,14,"Device Address:",.lblDeviceAddress
		TextBox 160,14,300,21,.txtSubstationName
		TextBox 160,42,300,21,.txtSubstationAddress
		TextBox 160,70,300,21,.txtCBName
		TextBox 160,98,300,21,.txtCircuitName
		TextBox 160,126,300,21,.txtDeviceType
		TextBox 160,154,300,21,.txtManufacturer
		TextBox 160,182,300,21,.txtSerialNumber
		TextBox 160,210,300,21,.txtDeviceAddress
		OKButton 370,238,90,21,.btnOK
	End Dialog
	Dim dlg As UserDialog

	dlg.txtSubstationName = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".SUBSTATION_NAME"))
	dlg.txtSubstationAddress = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".SUBSTATION_ADDRESS"))
	dlg.txtCBName = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".CB_NAME"))
	dlg.txtCircuitName = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".CIRCUIT_NAME"))
	dlg.txtDeviceType = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".DEVICE_TYPE"))
	dlg.txtManufacturer = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".MANUFACTURER"))
	dlg.txtSerialNumber = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".SERIAL_NUMBER"))
	dlg.txtDeviceAddress = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".DEVICE_ADDRESS"))

	Dialog dlg

	Set GlobalTO = Nothing

	Exit Sub
ErrorHandler:
	MsgBox(Err.Description, vbOkOnly+ vbCritical,"Error")
End Sub

Function GetDisplayString(Parameter As AutoParameter) As String
	If Not Parameter Is Nothing Then
		GetDisplayString = Parameter.DisplayString
	Else
		GetDisplayString = "-"
	End If
End Function


Now, close the script window by clicking the Back To Report View button then run the script by click the Set Relay Information button in the Home tab under the User Commands group and the result should be like the in the image below.


Now, we have successfully display the test object data into custom dialog that we've created. I will show you in the next tutorial on how to save the data back to test object once the OK button was clicked.


Comments