OTX-Runtime for DotNet
|
|
An HTML-Screen implementation is a screen, which can be displayed as a web page inside a normal web browser. The layout of a screen is described inside an HTML file. The HTML file contains placeholders for the related screen parameters, see ScreenParameter and some JavaScript to update the parameters. With the OTX-Mapping editor the parameters of a screen signature can be mapped to the placeholders inside an HTML file. If such a screen will opened via OpenScreen and if not already done a Web Server will started. The web server provides the HTML web page and opens a web socket communication with this page. A web application can integrate the content of that web page into an iFrame inside a normal web browser.
Note: The Assembly-Screen Implementation is the default implementation of ICustomScreenImplementation (see DefaultCustomScreenImplementation) delivered with the OTX runtime API.
The HTML-Screen implementation supports the following OTX data types:
The web server has the following functions:
Note: Client-Side processing - Due to performance issues the the screen will be processed at the client, inside the browser via JavaScript and not at the server. Therefore the web page contains active content and the browser must be support JavaScript!
Note: The web server is not part of the normal distribution. There is a separate installer which must be downloaded and installed.
Note: If not already started, the web server must be started, see Start Web Server!
Note: The web server is only available for Windows currently.
The web server should be configured - The web server settings must be adjusted inside the web server configuration, see config.json
found in c:/Users/Public/OpenTestSystem/HtmlScreen/
Example of web server config file config.json:
Parameters:
Note: The StaticFilesPath element is optional. If be left empty, the default path would be: C:/Users/Public/OpenTestSystem/Apps
Note: The CSS files (or JS files) could also be placed next to the HTML files.
The web server delivers the webpage at the address:
Parameters:
Address | Description |
---|---|
http://localhost:ServerPort | All open screens will displayed. The last opened or highlighted screen is in foreground. |
http://localhost:ServerPort/AppId | Only the screen which is mapped to the AppId will displayed |
Sample:
If not already started, the web server must be started. There are different ways to start the web server.
cmd
cd c:\Program Files (x86)\OpenTestSystem\HtmlScreen
NodeJs\node.exe Webserver\server.js
Note: To check, if the web server is started, open the address of the web server inside a browser. The address depends on the Configuration, example:
https://localhost:3000/
. You should see the Default Screen.
If the web server is started and no other screen is opened, the default screen will be displayed. The user can change the default screen, see parameter DefaultScreenPath
in Configuration.
Command | Direction | Description |
---|---|---|
OpenScreen | Server to Client | Informs the client that a screen was opened, see OpenScreen |
HighlightScreen | Server to Client | Informs the client that a screen was highlighted, HighlightScreen |
CloseScreen | Server to Client | Informs the client that a screen was closed, see CloseScreen |
UpdateValueOnCustomHtml | Server to Client | Informs the client about a parameter value update |
UpdateValueRuntime | Client to Server | Informs the web server that a parameter value was changed |
The web socket command OpenScreen
is a JSON request message, send by the web server to the client. The web server will send this request, when a screen was opened inside the OTX runtime and after a new HTML page is available at the server and the client should reload the page, so that the new page can be displayed. The command has the following format:
Example:
Note: To receive this command the client must handle the
onmessage
event of the web socket connection.
The web socket command HighlightScreen
is a JSON request message, send by the web server to the client. The web server will send this request, when a screen was highlighted inside the OTX runtime and after a new HTML page is available at the server and the client should reload the page, so that the new page can be displayed. The command has the following format:
Example:
Note: To receive this command the client must handle the
onmessage
event of the web socket connection.
The web socket command CloseScreen
is a JSON request message, send by the web server to the client. The web server will send this request, when a screen was closed inside the OTX runtime and after a new HTML page is available at the server and the client should reload the page, so that the new page can be displayed. The command has the following format:
Example:
Note: To receive this command the client must handle the
onmessage
event of the web socket connection.
The web socket command UpdateValueOnCustomHtml
is a JSON request message, send by the web server to the client. The web server will send this request, when the value of a parameter has been changed, so that the client can update the HTML page. The command has the following format:
Example:
Note: To receive this command the client must handle the
onmessage
event of the web socket connection.
The web socket command UpdateValueRuntime
is a message, send by the client to the web server to update a certain value of a screen parameter.The command has the following format:
Note: The format of the
ScreenParameterLiteralValue
is described in Data Type Handling.
Example:
Note: The client must send this command via the
send
method of the web socket connection.
Update Structure Value Example:
Update Enumeration Value Example:
The HTML-Screen template file is an arbitrary HTML, example see Screen1.html
inside the sample PTX below, file which contains:
Note: The file and all its dependencies must be located inside the external application path of the OTX-Runtime API, see Project Settings
Note: Each file can contain only one screen and its related screen signature.
Example client-side processing in JavaScript:
To see the example click here to fold.
The HTML-Screen placeholders has two functions:
Format of placeholder:
Placeholder parameter:
Parameter | Required | Description |
---|---|---|
type | x | Type or direction of the ScreenParameter which can be bound to this placeholder. Possible values are 'ScreenInParameter', 'ScreenTermParameter', 'ScreenOutParameter' and 'ScreenInOutParameter' |
name | x | Placeholder name. The name will be mapped inside the mapping file and must be unique inside the template file. |
datatype | x | Name of the expected data type of the placeholder. This is only required for the type safe mapping inside the mapping editor at design time, see OTX data types. |
description | - | Description of the placeholder. The description will be displayed as a tool tip inside the mapping editor at design time. |
Placeholder examples:
Format of Structure value sent to HTML-Screens as JSON:
Format of Enumeration value sent to HTML-Screens as JSON:
Note: The SignatureName attribute is required to identify which signature the enumeration element belongs to. Please change this element with caution.
These placeholders will represent the Structure Signature and Enumeration Signature in HTML template file. The placeholders can be placed anywhere in the HTML template file, but it would be best to place them in a const variable inside a <script> tab.
Note: In case a structure signature is referenced in another structure signature. Then the placeholder of that structure signature should be declared first.
Format of Structure Signature placeholder:
Structure Signature placeholder example:
Structure Signature placeholder example 2:
Format of Enumeration Signature placeholder:
Note: The value of an EnumerationElement can only be an integer number. If the value is something else, the Element won't be created when mapped.
Enumeration Signature example:
The following placeholders should exist inside the HTML file. They will be replaced by the web server with the right values.
Placeholder | Description |
---|---|
$Url_WebSocket | Web socket URL which is configured in Web Server, e.g. "ws://localhost:8080" or "wss://localhost:8080" |
$Screen_Signature | Full name of the OTX screen signature, e.g. "eTesterSamples.FunctionGenerator.Screen2" . If a message is for the related screen, this value will match with the name of the screen signature inside this message. The value can be used to distinguish the web socket messages for other screens. |
config.json
found in c:/Users/Public/OpenTestSystem/HtmlScreen/
if it doesn't exist. And config this file according format in Web Server. Change the value of keys (NodeJsPath, WebserverPath, DefaultScreenPath) by the path you unzip abovehttp://localhost:3000
for unsecured and https://localhost:3000
for secured communication. The port number is the number configured in the web server configuration ServerPort, see Web Server.The web page should now be displayed.
Note: If the web page will not displayed right, please refresh the web page inside the browser, e.g. via key F5.
The example shows how the placeholders can be used inside an HTML template file (Screen1.html
). The full code is inside this Sample Player for HTML-Screens with including Visual Studio Project, see folder OTX-Mapping\APPs
.
Another OTF Sample Solution for OTX-Mapping with Player (source code see folder \EmotiveSampleSolution\OtxMappingSample\OTX-Mapping
)
Note: The HTML file must be copied into ExternalAppPath.
To see the complete file click here to fold.