Basic procedure
Demo control as a template
Download the HTML5 API example to your computer. Then the demo controls with element wrappers JavaScript are available to you.
We recommend using the copy of an ElementWrapper.js
from the HTML5 examples as a template and adapting the name and functionality to your HTML5 control.
For more information, see Example: HTML5-API
You can integrate an HTML5 control which you have either developed yourself or taken from an external source into your CODESYS programming system. To do this, proceed as follows.
Create a JavaScript file named
ElementWrapper.js
for your HTML5 control. Or copy an element wrapper file from the HTML5 API example (for example, the JS file of theHTML5DemoButton
element).Rename the wrapper object in the JS file. The name is predefined and is made up of the element name with
ElementWrapper
added to it.Important
The file name must always be
ElementWrapper.js
. And the wrapper object call up in it, which is generated by the framework at runtime, requires a name that is assigned to the element according to the following logic:<element name>ElementWrapper
In the JS file for your element, the name of the wrapper object matches the new control.
The following code fragment shows this for the
HTML5DemoButton
control:var HTML5DemoButtonElementWrapper; HTML5DemoButtonElementWrapper = function(idGenerator) …
Specify all files which are required to run the element. These can be stylesheet files (CSS), JavaScript files (JS), or image files (SVG).
Create an element image (
ElementImage.svg
). After installation, the element is displayed in the Visualization Toolbox view.
Create an XML file (
.html5control.xml
) with general information. The HTML5 Control Editor helps you with this.Tip
The options of the HTML5 Control Editor are described in the chapter "HTML5 Control Editor".
Create the mapping of the properties of the HTML5 control to the CODESYS visualization element properties.
Localize the interface texts.
Install the element.
Sign the element.
Tip
Follow the step-by-step instructions Recommended development process with detailed recommendations for debugging.