Skip to content

Getting started Development

Patrykb0802 edited this page Jul 13, 2023 · 15 revisions

Table of Contents

1. Scada-LTS Installation using standalone installer

2. Enviromental variables

3. Node.js

4. IntelliJ

5. DBeaver - MySQL Client

6. Docker compose

7. jSerialComm Configuration

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 8.0.33 Database server for data persistence
Node.js 14.20.1 JavaScript runtime for New UI
Git 2.17.1 Version control for source code

1. Scada-LTS Installation using standalone installer ↑↑↑

Linux

  1. Go to /~https://github.com/SCADA-LTS/linux-installer and select releases tab and then download latest release to desired folder.

  2. Go to location of downloaded installer and extract it.

  3. Start first script by using terminal and typing ./mysql_start.sh

    Script will ask for some basic information to make configuration run correctly. Below is an example of the data that can be entered:

    • Port: 3306
    • Username: root
    • Password: root
    • root password: root

    After providing the information you should wait for the line confirming the correct operation of the database:
    ~/linux-installer-1.2.0/mysql/server/bin/mysqld: ready for connections. Version: '8.0.33' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server - GPL.

  4. Start second terminal and run ./tomcat_start.sh script.

    Similar to first script you will have to provide some information, example below:

    • Enter port: 8080
    • Enter username: tcuser
    • Enter password: tcuser
    • Enter database port: 3306
    • Enter database username: root
    • Enter database password: root

    After that you should be able to access Scada-LTS via web browser by typing in search bar localhost:8080/Scada-LTS


Windows

Java installation for Windows

The base project is written in Java. So to start development a new features to Scada-LTS you need to install Java Development Kit (JDK). Download microsoft-jdk-11.0.18-windows-x64.msi file and run;

When installing Java remember to set Will be installed on local hard drive on Set JAVA_HOME variable.

image

Scada-LTS

  1. Go to /~https://github.com/SCADA-LTS/windows-installer and select releases tab and then download latest Beta release to desired folder.

    NOTE: There always be two versions of standalone installer, beta and non-beta. For development we recommend using Beta version. Non-beta version might be more stable but may not include some important features that are necessery for development.

  2. Launch the installer.

    NOTE: if blue Windows Defender SmartScreen pop-up appears select "More info" and "Run anyway"

  3. Installer will ask for initial Tomcat configuration. Use example data from below:

    • Tomcat HTTP Port: 8080
    • Username: root
    • Password: root

    NOTE: Installed database is available on port 3308.

2. Enviromental variables ↑↑↑

Linux

  1. You will have to add PATH for Java and Catalina in ~/.bashrc file using any available text editor e.g.:

    nano ~/.bashrc or vim ~/.bashrc

  2. On the bottom of this text file add two lines from below:

    export CATALINA_HOME="/absolute_path_to_installer/linux-installer-1.2.0/tomcat64/server" export JAVA_HOME="/absolute_path_to_installer/linux-installer-1.2.0/java/jdk"

  3. After all that type in terminal:

    source ~/.bashrc

    This will reload Enviromental variables.


Windows

To add enviromental 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 Scada-LTS installation location in tomcat folder.

3. Node.js ↑↑↑

Linux

  1. You can check if you have any nvm or node.js installed on your PC using these commands:

     nvm --version  
     node --version
    
  2. You will need nvm which is Node Version Manager. You can install it running this command in terminal:

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash

  3. You can check if nvm has installed correctly by typing:

    nvm --verison

  4. When everything went succesfull we can install chosen version of Node.js with command below:

    nvm install v14.20.1

  5. To make sure that correct version of node is installed type:

    node --version

    NOTE: If you want to uninstall node or change version of it, you have to use nvm from now on.


Windows

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.

4. IntelliJ ↑↑↑

Linux

  1. Download desired version of IntelliJ here.

  2. Put it in freshly made folder and extract it.

  3. Go inside extracted folder, then to bin folder and run ./idea.sh script.

  4. Install git with command below:

    sudo apt-get install git-all

    You can confirm if git setup finished correctly by running git version in terminal.

  5. Intellij is set up and ready to use.


Windows

  1. Download desired version of IntelliJ here.

  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.

Troubleshoot

Invalid Gradle JDK configuration found

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

  2. Type Gradle in search bar.

image

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

Problem with SDK

e.g.:
image

  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.

image

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

5. DBeaver - MySQL Client ↑↑↑

Installation

Linux

    Download Linux DBeaver Installer, run it and wait for it to finish. To launch it type dbeaver in console.

Windows

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


Configuration (same for both Windows and Linux)

  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.

image

  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:

image

6. Docker-compose ↑↑↑

Linux

To check if you have any version of docker installed, run command from below in terminal.

dpkg -l | grep -i docker

Installing docker compose

  1. Start with commands below to update the apt package index:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
  1. Run these commands to add docker’s official GPG key:
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
  1. Use command below to set up repository:
echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  1. Install Docker engine and all necessary docker plugins.
    sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

  2. Install docker-compose itself with command below:
    sudo apt install docker-compose

  3. Add non-admin user to docker group use command below:
    sudo usermod -aG docker user_name

    user_name is the username of user you want to be able to launch docker-compose.

Launching docker-compose on Linux

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

  2. Go inside docker-compose.yml location using 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.

Uninstalling docker compose

To uninstall all files related to docker use these two commands below:

  • sudo apt-get purge -y `dpkg-query -W -f='${binary:Package}\t' '*docker*'`
  • sudo apt-get autoremove -y --purge `dpkg-query -W -f='${binary:Package}\t' '*docker*'`

To delete all files that docker created e.g. groups, sockets etc. use commands below:

sudo rm -rf /var/lib/docker /etc/docker
sudo rm /etc/apparmor.d/docker
sudo groupdel docker
sudo rm -rf /var/run/docker.sock
sudo rm /etc/apt/keyrings/docker.gpg

If you deleted everything correctly command below should return nothing.

  • dpkg -l | grep -i docker

Windows

Installing docker compose

  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.

Launching docker-compose on Windows

  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.

Troubleshoot

NOTE: If you are having problems with virtualization visit this website and follow the instructions.

If your docker doesn't work you can try enabling and disabling certain features. If that doesn't help, follow docker instructions.

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

If there is "Hyper-V" feature on your list, disable it.
image
     To enter Windows features window type in bottom search bar "Turn Windows features on or off" and press enter.

7. jSerialComm Configuration ↑↑↑

Linux

More information about jSerialComm: https://fazecast.github.io/jSerialComm/

However, on linux system configuration is necessary as long as we are not running on root:

sudo usermod -a -G uucp username
sudo usermod -a -G dialout username
sudo usermod -a -G lock username
sudo usermod -a -G tty username

Windows

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.

Archives (Date: 30.06.2023) ↑↑↑

Table of Contents

Current technology stack table:

Technology Version Description
Java 11 Base programic language
Gradle 7.1 Tool for building the application
Tomcat 9.0.41 Servlet server for application
MySQL 5.7 Database server for data persistence
Node.js 14.20.1 JavaScript runtime for New UI
Git 2.17.1 Version control for source code

Tools Installation

Java

    The base project is written in Java. So to start development a new features to Scada-LTS you need to install Java Development Kit (JDK). You can do that easily by downloading the valid version from the jdk.java.net website. Then you only need to extract that file and set-up the PATH variable to /bin directory.

Windows

  • For windows download dedicated Windowsx64.zip version.
  • Extract that file in location where you want to keep your Java binaries
    (for example C:\services\java\jdk-11)
  • Set-up the PATH environment variable to bin directory of your installation location
    (for example C:\services\java\jdk-11\bin)
  • Verify that Java is installed correctly, open your terminal and type java -version

Linux

  • For Linux base systems download Linux_x64.tar.gz
  • Create a directory sudo mkdir /opt/java
  • Extract archive to that directory
    (for example: sudo tar -xzf openjdk-11*.tar.gz -C /opt/java/)
  • Set-up the PATH environment variable to bin directory of you installation location
    (for example nano ~/.bashrc and then add at the bottom of that file this lines and save it)

export JAVA_HOME=/opt/java/jdk-11
export PATH=$JAVA_HOME/bin:$PATH

  • Verify that Java is installed correctly, open your terminal and type java -version

Gradle

    Gradle is a general-purpose build tool that makes taht the build process is very simple. Installation of gradle is well described on their official web page. So follow the tutorial and then verify that gradle is installed:

gradle -v

Support Gradle v6.8.1-v7.1

Tomcat

    Tomcat is an servlet web-application server.

  • Download the Tomcat server from their official distribution page
    (If you want to download a specific version use that link to dist archive)

  • Extract that file to specific location

    • Windows: like in our example to C:\services\tomcat
    • Linux: in the same way as before but to /opt/tomcat
  • Set-up the new environment variable with name: CATALINA_HOME that is a reference to tomcat main directory.
    (That is required to perform Java build operation)

  • Import additional Tomcat server libraries:

    • Add that file to /usr/share/tomcat9/lib/ directory.
    • Add files from that directory to tomcat /usr/share/tomcat9/lib/ libs.
  • Setup the Database connection in $CATALINA_HOME\conf\context.xml file.
    Replace it with that configuration file

    From version 2.6.10 there's change in context.xml to work with Docker Compose, so after coping this file to Tomcat, change line: url="jdbc:mysql://database:3306/scadalts" to url="jdbc:mysql://localhost:3306/scadalts"

MySQL

    MySQL must be matching the provided version. If not there will be a problem with establishing the connection from the Scada-LTS application.

Windows

  • Use dedicated installer
  • Configure default password to "root" user: "root".
  • Create a new database with name: "scadalts".

Linux

There is a know bug that on Ubuntu 20.xx there is a problem with installing the MySQL server. It was solved by using the docker image with that server version.

  • Install mysql-server package
    sudo apt update
    sudo apt install mysql-server-5.7
    
  • Configure MySQL server with defaulr password to "root" user: "root".
    sudo mysql_secure_installation
    
  • Initialize MySQL data directory
    • Versions < 5.7.6 - mysql_install_db
    • Versions >= 5.7.6 - mysqld --initialize
  • Enable MySQL server
    sudo systemctl start mysql
    
  • Create a new database with name: "scadalts".

If there is a problem with MySQL server check the Internet for the solution. This installation process was based on the digitalOcean tutorial so check it for more details.

Node.js

  • Download the Long Term Support (LTS) version of Node.js from official site.
  • Extract that file to specific location
    • Windows: like in our example to C:\services\node
    • Linux: in the same way as before but to /opt/node
  • Add a new entry to PATH that is a reference to Node.js main directory.
    (/opt/node/node-v15/bin:$PATH)
  • Verify that Node.js is installed correctly, open your terminal and type node -v
  • Verify that Node Package Manager (npm) was installed with Node.js correctly.
    Open your terminal and type npm -v

Git

    Linux has installation of git by default. So you don't need to install it, but on Windows you need to download it from official site. The easiest way to install git is to use the installer.

Scada-LTS project initialization

Find a good place on your local drive where to store your Scada-LTS project. And in that place use Git Tool to download it from the GitHub repository.

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

Now you should be able to build and run the project using Gradle (support v6.8.1-v7.1). That command will build the Java application from source code and then will try to compile the Frontend apllication with installing all necessary dependencies. Then that two projects will be bundled together into the one Scada-LTS.war file that will be deployed to the Tomcat server.

gradle buildRunDebugDev

When it will be ready you should be able to access to the application at the following address: localhost:8080/ScadaBR.

Integrated Developmnet Environments (IDEs)

It's up to you to choose the IDE that you want to use. But we recommend to use the JetBrains IntelliJ for the base Java application and VisualStudio Code for the Frontend sub-project. But you can use any other IDE that you want.

Quick install - Linux Ubuntu 20.04+

1. Install mysql server/client commandline:

2. Install mysql client: (optional)

sudo dpkg -i dbeaver-ce_22.1.4_amd64.deb

3. Install JDK11:

sudo apt update
sudo apt install openjdk-11-jdk

4. Install Apache Tomcat 9:

tar -x -f apache-tomcat-9.0.53.tar.gz
  • Set CATALINA_HOME in ~/.bashrc :
vim ~/.bashrc
source ~/.bashrc
  • Copy jar lib to CATALINA_HOME/lib from:
/~https://github.com/SCADA-LTS/Scada-LTS/tree/develop/tomcat/lib
/~https://github.com/SCADA-LTS/Scada-LTS/raw/develop/WebContent/WEB-INF/lib/mysql-connector-java-5.1.49.jar
  • Copy context.xml file to CATALINA_HOME/conf:
/~https://github.com/SCADA-LTS/Scada-LTS/blob/develop/docker/config/context.xml

5. Install Git:

sudo apt update
sudo apt install git

6. Install npm:

sudo apt update
sudo apt install npm

7. Install and configure Intellij:

tar -x -f ideaIC-2022.2.tar.gz
  • run:
./ideaIC-2022.2/bin/idea.sh
  • Clone Scada-LTS project;
  • Create remote JVM port 8000, module Scada-LTS as remote-debug;
  • Build, deploy, and run application (mysql server is running, support Gradle v6.8.1-v7.1):
gradle buildRunDebugDev

8. Open application: Open in browser:

http://localhost:8080/ScadaBR