WebIQ Custom Packages 2.jpg

WebIQ - Custom Library Packages

Sgilk
Contributor
Introduction

There is a large active community around software development using Javascript. Open source Javascript libraries are a great way to utilize existing, tested software, instead of recreating a solution. This How-To will cover the process of integrating custom libraries and additional plugins into WebIQ using ThreeJS as an example. All code used in this example is attached at the bottom of the article.

Prerequisites

It is assumed you have a licensed copy of WebIQ designer and a general knowledge of the software. To access Smart HMI documentation, an account will be required.

Instructions
Create Independent Library Package

In this example, a package will be installed that is dependent on this library. For this reason, the independent library package must be installed first.

Follow these steps to create an independent library package:
  1. Navigate to the designer packages directory at: %APPDATA%\webiq-designer\packages

  2. Create a new folder with your package name. WebIQ suggests adhering to their naming convention of lib-$name. For ThreeJS, this would be lib-threeJS.

  3. In the top level folder of the package, add a file named webiq.json with the JSON below. Information on package file structuring can be found here: https://www.smart-hmi.com/user/download/deliver/docs/documentation-dev-designer-package-format-2.12-...

    {
      “format”: 2,
      “name”: “lib-threeJS”,
      “description”: “ThreeJS 0.144.0”,
      “type”: “library”,
      “version”: “0.144.0”,
      “forceInstall”: false,
      “forceUpdate”: false,
      “keep”: [
      ],
      “localeVariables”: {
      },
      “requires”: {
        “visuals”: “^2.0.0”
      }
    }
    ​

     

  4. Create the sub folders js\custom-libs to hold the library javascript files. Download the built source code and place it in this folder. The code can be found here: https://github.com/mrdoob/three.js/blob/dev/build/three.min.js

  5. You can also place the ThreeJS license file in this folder with a unique name (ie. Lib-three-LICENSE). Packages will throw an error message in the designer package manager if there are duplicate file names. The license file can be found here:https://github.com/mrdoob/three.js/blob/dev/LICENSE

At this point, your package structure should look like the tree below.PackageStrucure.png 

Create Dependent Library Package

This package depends on the installation of the previous package.

Following a similar process to step 1, ThreeJS plugin packages can be created as follows:
  1. Create a new package folder for the add on of your choice. For this example, OrbitControls will be used.

  2. It is important to name dependent libraries such that they will be loaded after the parent library. Libraries are loaded alphabetically in WebIQ, so in this example, the Orbit Controls package will be named (lib-threeJS-OrbitControls) and the javascript file itself (threeJS-OrbitControls.js). 

  3. WebIQ does not currently support Javascript modules, so the source code of the plugin will be used. The code for OrbitControls can be found here: https://github.com/mrdoob/three.js/blob/dev/examples/js/controls/OrbitControls.js
  4. In the webiq.json file, add the JSON below. Since this is dependent on the ThreeJS library, this is included in the “requires” property.
{
  “format”: 2,
  “name”: “lib-threeJS-OrbitControls”,
  “description”: “threeJS OrbitControls Module”,
  “type”: “library”,
  “version”: “0.144.0”,
  “forceInstall”: false,
  “forceUpdate”: false,
  “keep”: [
  ],
  “localeVariables”: {
  },
  “requires”: {
    “visuals”: “^2.0.0”,
    “lib-threeJS”: “^0.144.0”
  }
}
​

 

Install Packages

In the WebIQ Designer package manager, the lib-threeJS package should now be available for install. The dependent packages should have an unmet dependency error which prevents their installation.

UnmetDependencies.png

After lib-threeJS is installed, the dependent packages should be available for installation.

MetDependencies.png

Test Libraries

To test the threeJS library and OrbitControls installation, create a local-script and add it to the application in the layout manager. Instantiate some objects defined in the threeJS and OrbitControls library. An example script is provided below.

The Company 

Empowering HMI Excellence
Smart HMI is a team of experts for the development, enablement and integration of 100% Web-Technology based Software, which empowers every customer to easily create future-oriented industrial HMI solutions. The Software Platform WebIQ – developed by Smart HMI -is a 100% Web-Technology based, forward-looking Visualization-System with comprehensive Design-possibilities to create industrial Web HMI’s.

SmartHMI_Logo.png

Sgilk
Sgilk
Hello, my name is Sam and I am a Software Applications Engineer supporting ctrlX Automation. Feel free to reach out if you have any questions!
Must Read
Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist