Views
A View file is a text file with the extension .ovv
, located at:
C:\ProgramData\Omniview\Server\<OVSS_NAME>\Projects\<PROJECT_NAME>\View\
View files use the JSON file format to define page properties and objects.
Structure of a View
{
"$type": "View",
"Name": "ExampleView",
"UpdateRate": "1000",
"Width": "800",
"Height": "600",
"Background": "#FFFFFF",
"ScriptResources": [],
"OnLoadedExpressions": [],
"ViewObjects": [
{
// View Object 1
},
{
// View object 2
}
]
}
Property | Notes |
---|---|
$type | "View" |
Name | Unique name given to a view that can be used from a script |
UpdateRate | Time in milliseconds. The update rate determines the refresh rate of the view. Any object transforms or functions will be evaluated at this rate. |
Width | Screen width in pixels. |
Height | Screen height in pixels. |
Background | Background color, expressed as "#RRGGBB" or "#RRGGBBAA" (optional alpha channel) in hexadecimal. E.g. "#00FFFF" would result in a Cyan background |
ScriptResources | A list of file paths where any script resources are located. E.g. Standard_Include.Script.Client.Util.py |
OnLoadedExpressions | A python expression or list of expressions that will be evaluated when the page is first loaded. |
ViewObjects | A list of graphical objects displayed on the page. |
View Objects
See View Object Overview.
Parameter Lists
When a View is called from code (for example, a button press event handler), a parameter list can be passed in. When a parameter name is located in the View the corresponding will be inserted. Parameters are marked using double curly brackets. For example, the string {{equip_id}}
will be replaced with the equip_id value when a parameter list is passed in. If no parameter list is passed in or no matching parameter is found, the literal string {{equip_id}}
will be used. The parameter list must be passed in as a Python dictionary with values keyed by parameter names.
Parameters will replace . The string to be replaced with a parameter
The example below is a simple popup where the equipment ID is passed in as a parameter. This feature is commonly used for status popups for repetitive objects like valves and motors.
{
"ViewObjects":[
{
"$type": "TextBlock",
"Name":"TextBlock1",
"Height": 30.0,
"Width": 500.0,
"X": 0,
"Y": 5,
"TextAlignment": "Center",
"FontSize": 30,
"Text":"{{equip_id}}"
},
{
...
}
]
}
from Omniview import *
parameters = {"equip_id":"Compactor_1"}
Omniview.DisplayPopup("Example_popup", "Popup Title", "EquipmentPopup", Vector2(50,230), parameters, True, True, False, True)
If no parameter list is used, the unmodified string will be used.
Omniview.DisplayPopup("Example_popup", "Popup Title", "EquipmentPopup", Vector2(50,230), True, True, False, True)