Skip to content

Getting started Development ‐ Windows

Patrykb0802 edited this page Jul 3, 2024 · 12 revisions

Table of Contents

1. Scada-LTS

2. Database

3. IntelliJ

4. Docker Compose

5. Tips for developers

6. SeroUtils library license

Current technology stack table:

Technology Version Description
Java 11 Base programic language
Gradle 7.1 Tool for building the application
Tomcat 9.0.75 Servlet server for application
MySQL Server 8.0.33 Database server for data persistence
MySQL Client DBeaver 23.1.2
or newer
Database client
Node.js 14.20.1 JavaScript runtime for New UI
Git 2.17.1 Version control for source code
Windows 7/10/11 Operating system (Must be updated to latest version )

1. Scada-LTS ↑↑↑

1.1 Installation ↑↑↑

To install Scada-LTS go to the windows-installer website and follow the instructions in the README.

1.2 Configuration ↑↑↑

Tomcat - Configuration ↑↑↑

System - Configuration of Enviroment variables

To add enviroment variables in Windows operating system:

  1. (WIN 11) Type in bottom search bar "Edit the system enviroment variables", press Enter and window should pop up.
    (WIN 10) On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings.

  2. Select Enviroment Variables... from the bottom of the window.

    NOTE: Do steps below only if you don't see CATALINA_HOME variable in the bottom list.

  3. Press New... at the bottom of the window.

    For CATALINA_HOME it should look like this:

    image

    NOTE: Remember to use your own paths, for Catalina it's path to tomcat folder inside Scada-LTS installation location.

Deleting unnecessary content from context.xml file.

  1. Locate context.xml file. Default path is: C:\Program Files\Scada-LTS\tomcat\conf.

  2. Open it with any available text editor.

  3. Delete whole <Resource> block. File should look similar to image below:

image
  1. Save file and you are done. This should help with database information mismatch.

Setting start up type to manual for Tomcat service

After installing Scada on Windows you should have 4 icons on desktop. One of the is service manager. To turn on manual start up:

  1. Launch Scada-LTS service manager

  2. Go to general tab and select manual from Startup type: droplist.

image
  1. Now you shouldn't have problem with launching and controlling Tomcat from IntelliJ level.

jSerialComm - Configuration ↑↑↑

Scada-LTS installer automatically installs jSerialComm.jar to your project. This .jar file will automatically select and load the correct native jSerialComm library for your platform and architecture.

In case of any problems with this library we refer to official sources and their Troubleshoot section.


2. Database ↑↑↑

2.1 MySQL Client ↑↑↑

Installation ↑↑↑

    Download Windows DBeaver Installer, run it and wait for it to finish. To launch it use desktop icon.

Configuration ↑↑↑

NOTE: Before configurating DBeaver make sure that your MySQL Server is turned on.

  1. In top left corner of DBeaver window click on image icon to add "New database connection".

image

  1. Select MySQL and press 'Next' button.
  1. Set port 3308 and click on 'Finish'. If the drivers have not been installed before, the program will suggest downloading and installing, click ok:
  1. If you have set password for root, you have to enable allowPublicKeyRetrieval in Connection Settings window in Driver properties tab.
  1. Press Test connection button on the bottom left corner of the window. If everything is set up correctly the following window should pop up.
image

2.2 MySQL Server - Configuration ↑↑↑

  • Setting password for root

  1. In DBeaver at left side in Database Navigator tab right-click on scadalts and select Set as default.
  1. In tool bar located on top press dropdown arrow next to SQL and select New SQL script, script window should appear on the right.
  1. Copy two lines from below to script execution window and press Execute SQL script icon (image)

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
    FLUSH PRIVILEGES;

image

  1. After these steps password for root should be set.
  • Changing default database port to 3306

  1. Navigate to your Scada-LTS installation location, head to mysql folder (Default path: C:\Program Files\Scada-LTS\mysql) and edit my.ini file with any text editor.

  2. Change port=XXXX to port=3306

  3. This will help with running application correctly in IntelliJ software.

  • Restarting MySQL server after modifications.

Scada installer should have created two icons on your desktop called Start/Stop MySQL Community Server 8.0. In order to restart your MySQL server:

  1. Run Stop MySQL Community Server 8.0 as administrator.

  2. And than run Start MySQL Community Server 8.0 as administrator.

    This should apply all changes you have made to MySQL server.

3. IntelliJ ↑↑↑

  1. Download desired version of IntelliJ here, run it and wait for installation to finish.

  2. After installation is completed, on welcome screen select "Create New Project" and select "Get from VCS".

  3. Choose repository URL and use Git Version Control. Paste the URL of the Scada-LTS project from below and click "Clone" button.

    https://github.com/SCADA-LTS/Scada-LTS.git

    If there is a privilege dialog, click "Trust this project" button to load the gradle configuration.

        Gradle will load the dependencies and prepare project for development. (It may take a while)

  1. After everything loads, in Project tab, go to gradle > wrapper > gradle-wrapper.properties and change version of your gradle to 7.1.

  2. Make sure to change your indent settings to be same as on Github repository, so code will be clean and easy to read. First, locate a indent configuration button in bottom right corner of your IDE.

        image

        Tabs and Indents window should pop up, make sure to uncheck "Use tab character", your configuration should look like this:

        image

3.1 Node.js ↑↑↑

To install Node.js on Windows:

  1. Download Node.js v14.20.1 intaller from this website: https://nodejs.org/dist/v14.20.1/node-v14.20.1-x64.msi

  2. Launch installer, choose install location.

  3. When this window appears remember to choose "Will be installed on local hard drive" on Add to PATH.

image
  1. Proceed until installation is finished.

3.2 Troubleshoot ↑↑↑

Invalid Gradle JDK configuration found

  1. In IntelliJ project in top left corner, go to File > Settings.

  2. Type Gradle in search bar.

  1. In the Gradle JVM dropdown list select correct version of JDK and press OK.

Problem with SDK

e.g.:

  1. In IntelliJ, in Project bar right-click on Scada-LTS and select Open Module Settings.

  2. In Project Structure window on left side select Project.

  1. Select correct version of SDK from dropdown list marked on image above and press OK.

Granting Access to a Scada-LTS Folder

  1. Go to Scada-LTS folder location. (Default path: C:\Program Files)

  2. Right click on Scada-LTS folder and select Properties.

  3. Go to Security tab and press Edit....
    image

    If you don't see the user you want to grant access to on the list Group or user names:, you can add it by following instructons below:

    • In the Edt... menu press Add...

    • In the Enter the object names to select area type your user's name and press Check Names and press Ok.

    Animation

  4. Select from the Group or user names: list, the user to whom you want to grant access.

  5. In Permissions for username tab mark Modify, Read & Execute, List Folder Contents, Read, Write in Allow column, than press Apply and OK.

Animation2

  1. Wait for the window, that is executing granting access to disapear and you are done.

Problems with file encoding

If you are getting some file encoding errors e.g.: unmappable character (0x98) for encoding windows-1250 here is quick solution:

  1. In IntelliJ, go to Help > Edit Custom VM Options...

image

  1. Add following line to file that just showed up:
  • -Dfile.encoding=UTF-8

After editing your .vmoptions file, it should look like this:

image

  1. Restart your IntelliJ to apply the changes

4. Docker Compose [↑↑↑]↑↑↑

4.1 Installation ↑↑↑

  1. Go to https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe and download Docker Desktop Installer

  2. Launch installer.

  3. Mark "Use WSL 2 instead of Hyper-V (recommended)" checkbox, otherwise you might have problems with virtualization.

    NOTE: If you don't see the checkbox and you are having trouble launching Docker, go to Troubleshoot section below.

  4. Wait until insallation is finished and restart your PC.

4.2 Launching ↑↑↑

  1. Download docker-compose.yml file to desired folder.

  2. Right click on the folder where your docker-compose.yml file is and press Open in Windows Terminal and run:

docker-compose up database
  1. In second terminal and same location:
docker-compose up scadalts

NOTE: You have to wait for docker-compose up database to finish, otherwise errors may appear.

After setup is finished you should be able to access Scada-LTS via web browser by typing localhost:8080/Scada-LTS URL in search bar.

4.3 Troubleshoot ↑↑↑

Most common problem with Docker is disabled Virtualization, to turn it on you have to make sure that your processor supports virtualization and turn it on in BIOS settings.

For Intel Processors virtualization technology in BIOS should be called:

  • Virtualization Technology (VT-x)
    or
  • Intel Virtualization Technology (Intel VT)

For AMD Processors virtualization technology in BIOS should be called:

  • AMD Virtualization (AMD-V)
    or
  • AMD SVM (Secure Virtual Machine)

To check where exactly to look for such setting in BIOS check check documentation of your motherboard/laptop manufacturer.

NOTE: For basic intructions how to enable virtualization you can try visiting this website and follow the instructions.

⚠️ Remember to follow docker's instructions firstly, if they don't help proceed with further instructions.

If your docker doesn't work after first executing its instructions, you can try enabling and disabling certain Windows features.

  • Windows 10 - Enabling features from image below might help with virtualization errors.

If there is "Hyper-V" feature on your list, disable it.

To enter Windows features window type in bottom search bar "Turn Windows features on or off" and press enter.

5. Tips for developers ↑↑↑

Building the application ↑↑↑

To build the application on your own environment you can use Gradle.We provide example scripts that can be used inside Scada-LTS project to perform specific operations. Commands with their explanations are listed below.

5.1 Gradle Tasks ↑↑↑

To run Gradle Task you have to use gradle version 7 or similar with Java version 11. It should also work on other versions but you have to change the targetVersion in build.gradle file.

Command Explanation
gradle war Build Scada-LTS war file
gradle run Launch Tomcat instance
gradle runDebug Launch Tomcat instance in debug mode, ability to plug debugger into the Tomcat port and use it
gradle buildRunDebugProd Build and start production version of Scada-LTS application
gradle buildRunDebugDev Build and start developer version of Scada-LTS application
gradle test Launch Backend Unit Tests
gradle scadalts-ui::testUi Launch Frontend Unit Tests

Logging JVM parameters ↑↑↑

If you want to see what parameters is your JVM using you can add these three lines of code to build.gradle file:

Process ipProcess = new Runtime().exec("jps -lvm");
int exitValue = ipProcess.waitFor();
println "JAVA__:" + ipProcess.getText()

5.2 Error: Address already in use - terminating OpenJDK processes ↑↑↑

This error occurs when you try to start new instance of Scada-LTS while other Java virtual machine is still working. This error occurs only in Widnows and there is easy fix for it:

  1. Open task manager (You can use this key combination: Ctrl+shift+esc)

  2. Look for OpenJDK processes and terminate them. Example:

image
  1. After that, you should be able to launch Scada-LTS with no error.

5.3 IntelliJ plugins ↑↑↑

Sonarlint

  1. In any IntelliJ project go to: File > Settings > Plugins and select Marketplace.

  2. In search bar type Sonarlint an press Install next to it.

  3. IntelliJ will ask you to restart it.

  4. After restart your plugin is set and ready to go.

6. SeroUtils library license ↑↑↑

Matthew Lohbihler matthew@serotonin.ai has granted us permission to use the SeroUtils.jar library for ScadaLTS team. ScadaLTS team can use the code seroUtils without limitation.

Fragement with the correspondence of Grzegorz Bylica and Matthew Lohbihler:

"(...) The good news is that you may hereby and without limitation use the seroUtils code as you like. (...)"

Clone this wiki locally