Using User Defined Field In Omicron Control Center Document

Welcome to my tutorial page. In this tutorial, I will show you how to use UserDefined field in the OCC document. 

In the Report View of the Control Center, you can customize your overall report. Test modules may be embedded in the report, and run from it. One report can be used as a standard template to retest and compare one or more test objects. Example, by inserting basic field like page number, page count, page title and etc. UserDefined field is basically the same with the basic field but it can only use programmatically. Because if insert UserDefined field it will display nothing or empty. So, this is the tutorial all about, how to use these fields. 

Now download this file Omicron Control Center - UserDefined Field. This file was created in the previous tutorial series called Omicron Control Center Custom Dialog using Test Universe 4.20. If you can't open this file, your software might be outdated. You have to upgrade you Test Universe to version 4.20 or check the link below to create this file using your current Test Universe version.


Insert your logo or any picture by pasting inside the report view on the right side. Next, insert a new field by clicking the Field button at the Insert tab. Make sure the report view is selected to enable the Field insert button. Meaning the cursor should be inside the report view because the field will be inserted in the current cursor position.


When the Insert Field dialog open, scroll down at the available fields until you find the UserDefined 01 then select it and click OK button. This will display "n/a" because this field has no data. Insert another two UserDefined field, UserDefined 02 and UserDefined 03 then format them according to what you like. 


Once you complete the procedure above, the UserDefined should be arrange accordingly in the image. As you can see I also inserted a page brake meaning the information below that page brake will be printed in the next page.


Now, open the Script window by clicking the Script View button under the View tab then stop the script when its running. Find the SetRelayInformation procedure then insert the code below right after the line Dialog dlg.

Document.UserField(1) = UCase dlg.txtSubstationName
Document.UserField(2) = UCase dlg.txtCBName & " - " & dlg.txtCircuitName
Document.UserField(3) = UCase dlg.txtDeviceType

Once it done, click the Back to Report View button then run the script by clicking the SetRelayInformation button at Home tab. 


Change the relay data information then click OK button.


As you can see, the UserDefined fields has been updated. So, that's it. You can find the way where you gonna use this.

In the next tutorial, I will show you how to make a import filter for Omicron Control Center document. Check the video below to see what I mean.


See you next time.

Overall codes:
' ************************************************************
' 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 Const SOURCE_PATH As String = "CUSTOM.RELAY_PARAMETERS.SOURCE"
Public Const TEST_CONTROLLER_PATH As String = "CUSTOM.TEST_CONTROLLER"
Public GlobalTO As XRio

Dim Source_Array() As String
Dim Source_Enum As AutoParameter


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,140,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

	Document.UserField(1) = UCase dlg.txtSubstationName
	Document.UserField(2) = UCase dlg.txtCBName & " - " & dlg.txtCircuitName
	Document.UserField(3) = UCase dlg.txtDeviceType

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

	Document.TestObjects(1).CommitChanges

	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

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

	Begin Dialog UserDialog 480,105,"Source Controller",.SourceControllerFunction ' %GRID:10,7,1,1
		Text 10,14,140,14,"Source:",.lblSource
		Text 10,42,140,14,"Selected Source:",.lblSelectedSource
		DropListBox 160,14,300,21,Source_Array(),.dlbSource,2
		TextBox 160,42,300,21,.txtSelectedSource
		OKButton 370,70,90,21,.btnOK
		CancelButton 270,70,90,21
	End Dialog

	Dim dlg As UserDialog

	Dim DialogResult As Integer

	DialogResult = Dialog (dlg)

	Set GlobalTO = Nothing

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

Function GetParameterEnumList(EnumParameter As AutoParameter) As String()
	Dim Result As String
	If Not EnumParameter Is Nothing Then
		For i  = 1 To EnumParameter.ParameterEnum.EnumValues.Count
			Result = Result & EnumParameter.ParameterEnum.EnumValues.Item(i).DisplayName & ","
		Next
	Else
		Result = "-,"
	End If
	GetParameterEnumList = Split(Result,",")
End Function

Function GetEnumIndex(EnumParameter As AutoParameter) As Integer
	Dim Result As Integer
	If Not EnumParameter Is Nothing Then
		For i = 1 To EnumParameter.ParameterEnum.EnumValues.Count
			If Trim(UCase(EnumParameter.ParameterEnum.EnumValues.Item(i).DisplayName)) Like Trim(UCase(EnumParameter.DisplayString)) Then
				Result = i-1
			End If
		Next
	Else
		Result = 0
	End If

	GetEnumIndex=Result
End Function

Sub SetEnumValue(EnumParameter As AutoParameter, ValueIndex As Integer)
	If Not EnumParameter Is Nothing Then
		EnumParameter.ParameterEnum.SetDisplayValue EnumParameter.ParameterEnum.EnumValues.Item(ValueIndex+1).DisplayName, ""
	End If
End Sub

Rem See DialogFunc help topic for more information.
Private Function SourceControllerFunction(DlgItem$, Action%, SuppValue?) As Boolean
	Select Case Action%
	Case 1 ' Dialog box initialization
		Set	Source_Enum = GlobalTO.XRioDocument.GetParamFromIDs(TEST_CONTROLLER_PATH & ".SOURCE")
		Source_Array = GetParameterEnumList(Source_Enum)

		DlgEnable "txtSelectedSource",False

		DlgListBoxArray "dlbSource",Source_Array()
		DlgValue "dlbSource",GetEnumIndex(Source_Enum)

		DlgText "txtSelectedSource", GetSourceControllerFeedback(DlgText("dlbSource"))
	Case 2 ' Value changing or button pressed
		Rem SourceControllerFunction = True ' Prevent button press from closing the dialog box
		Select Case DlgItem
			Case "dlbSource"
				DlgText "txtSelectedSource", GetSourceControllerFeedback(DlgText(DlgItem))
				SourceControllerFunction = True
			Case "btnOK"
				SetEnumValue Source_Enum, DlgValue("dlbSource")
				Set Source_Enum = Nothing
			Case "CancelButton"
				Set Source_Enum = Nothing
			Case Else
		End Select

	Case 3 ' TextBox or ComboBox text changed
	Case 4 ' Focus changed
	Case 5 ' Idle
		Rem Wait .1 : SourceControllerFunction = True ' Continue getting idle actions
	Case 6 ' Function key
	End Select
End Function

Private Function GetSourceControllerFeedback(Reference As String) As String
	Select Case Reference
		Case "Source 1"
			GetSourceControllerFeedback = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(SOURCE_PATH & ".SOURCE1.NAME"))
		Case "Source 2"
			GetSourceControllerFeedback = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(SOURCE_PATH & ".SOURCE2.NAME"))
	End Select
End Function



Comments