Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
en:sw:01-mervis:08-sscp-bridge [2019/10/29 10:05]
martyy [SSCP to SQL Bridge]
en:sw:01-mervis:08-sscp-bridge [2020/07/15 08:23]
jan_kozak [Configuration file structure]
Line 1: Line 1:
 ====== SSCP to SQL Bridge ====== ====== SSCP to SQL Bridge ======
-This daemon-based service allows bi-directional data transfer between an Unipi PLC running Mervis and a SQL database through an SSCP protocol (the proprietary protocol used by Mervis ​runtime and Mervis IDE).  The daemon can run anywhere - on the system with Mervis runtime running, on the same system as a database server or another remote machine.+This daemon-based service allows bi-directional data transfer between an Unipi PLC running Mervis and a SQL database through an SSCP protocol (the proprietary protocol used by Mervis). ​ The daemon can run on any Linux machine (database server or another remote machine) or directly on the PLC.
  
 {{ :​en:​sw:​01-mervis:​sscp-sql-bridge.png?​direct |}} {{ :​en:​sw:​01-mervis:​sscp-sql-bridge.png?​direct |}}
 ===== Installation scenarios ===== ===== Installation scenarios =====
   * **Daemon runs on the PLC**   * **Daemon runs on the PLC**
-    * In this case the daemon runs on the PLC right next to the Mervis RT and send the data to a remote database. Requires IP connection between the PLC and the database server. +    * In this casethe daemon runs on the PLC right next to the Mervis RT and send the data to a remote database. Requires IP connection between the PLC and the database server. 
-  * **Daemon runs a different machine/​server**+  * **Daemon runs on a different machine/​server**
     * This can be divided into two scenarios depending on the network connection.     * This can be divided into two scenarios depending on the network connection.
     * **Daemon has IP access to the PLC**     * **Daemon has IP access to the PLC**
       * This is the reverse installation of the first case, where the Daemon runs on the PLC.       * This is the reverse installation of the first case, where the Daemon runs on the PLC.
       * The Daemon is installed to a server and communicates with the PLC and send the data to the database server.       * The Daemon is installed to a server and communicates with the PLC and send the data to the database server.
-      * The database server can run on the same server as the daemon or totally ​different machine.+      * The database server can run on the same server as the daemon or different machine.
     * **Daemon does NOT have IP access to the PLC**     * **Daemon does NOT have IP access to the PLC**
       * __This option will be available soon__       * __This option will be available soon__
-      * This scenario uses Mervis Proxy server to read the data from the PLC and send them to the database server. The advantage is that the Daemon does not require IP access to he PLC so the server running the Daemon can be on the other side of the World (behind NAT or firewall limiting access to the internal network).+      * This scenario uses Mervis Proxy server to read the data from the PLC and send them to the database server. The advantage is that the Daemon does not require IP access to the PLC so the server running the Daemon can be on the other side of the World (behind NAT or firewall limiting access to the internal network).
       * Requires the PLC to be connected to the Proxy server.       * Requires the PLC to be connected to the Proxy server.
       * Limited by the speed of the Proxy.       * Limited by the speed of the Proxy.
Line 37: Line 37:
   - Add the Unipi Debian repostiory into your apt-sources list (__skip this step if you are working with an Unipi PLC__). **Replace** the  **<​distro>​** placeholder with your Debian distribution name – **stretch** or **buster**. <​code>​sudo su   - Add the Unipi Debian repostiory into your apt-sources list (__skip this step if you are working with an Unipi PLC__). **Replace** the  **<​distro>​** placeholder with your Debian distribution name – **stretch** or **buster**. <​code>​sudo su
 echo "deb https://​repo.unipi.technology/​debian <​distro>​ main" >> /​etc/​apt/​sources.list.d/​unipi.list echo "deb https://​repo.unipi.technology/​debian <​distro>​ main" >> /​etc/​apt/​sources.list.d/​unipi.list
-wget https://​repo.unipi.technology/​debian/​unipi_pub.gpg -O - | apt-key add +wget https://​repo.unipi.technology/​debian/​unipi_pub.gpg -O - | apt-key add apt-get update </​code>​
-apt-get update </​code>​+
   - Install the application package.<​code>​apt-get install sscp-sql-bridge</​code>​   - Install the application package.<​code>​apt-get install sscp-sql-bridge</​code>​
 Packages with external libraries (libyaml, libmysqlcppconn,​ libboost-system,​ libssl) are installed automatically if necessary. By default, binary executable is installed into ///​opt/​unipi/​tools directory.//​ Packages with external libraries (libyaml, libmysqlcppconn,​ libboost-system,​ libssl) are installed automatically if necessary. By default, binary executable is installed into ///​opt/​unipi/​tools directory.//​
Line 44: Line 43:
 All configuration consists of these two files: All configuration consists of these two files:
   - **/​etc/​unipi/​sscp-sql-bridge.d/​mapping.yaml** is the main configuration file containing IP addresses and credentials for both database server(s) and mervis-running machine(s) as well as all settings related to the variables transferred. By default, the file contains a commented example configuration that **must be replaced by the right values according to the application.**   - **/​etc/​unipi/​sscp-sql-bridge.d/​mapping.yaml** is the main configuration file containing IP addresses and credentials for both database server(s) and mervis-running machine(s) as well as all settings related to the variables transferred. By default, the file contains a commented example configuration that **must be replaced by the right values according to the application.**
-  - One or more **.vlist** file(s) containing a list of all variables in the Mervis project(s). These files are generated automatically by the Mervis IDE and are located in the main Mervis project folder. Default path within the PLC is /​opt/​unipi/​data/​ and can be changed in the *mapping.yaml* file. This file should not be edited manually.+  - One or more **.vlist** file(s) containing a list of all variables in the Mervis project(s). These files are generated automatically by the Mervis IDE and are located in the main Mervis project folder ​in your Windows PC. These files should be copied (eg. using SCP) from the PC to the PLC/server where this toll will run. Default path within the PLC/​server ​is /​opt/​unipi/​data/​ and can be changed in the **mapping.yaml** file. This .vlist ​file should not be edited manually.
  
-Care should be taken that the configuration files follow the valid YAML format. An online YAML validator can be used to ensure this. Do not add any extra fields that are not listed in the example.+Make sure the configuration files follow the valid YAML format. An online YAML validator ​(such as this one https://​codebeautify.org/​yaml-validator) ​can be used to ensure this. Do not add any extra fields that are not listed in the example.
  
 The structure of the mapping.yaml file is described below. The structure of the mapping.yaml file is described below.
Line 57: Line 56:
 If no error message appears in the output, the service can be enabled and started in the background (ie in daemon mode): If no error message appears in the output, the service can be enabled and started in the background (ie in daemon mode):
 <​code>​ <​code>​
-systemctl enable sscp-sql-daemon +systemctl enable sscp-sql-bridge 
-systemctl start sscp-sql-daemon+systemctl start sscp-sql-bridge
 </​code>​ </​code>​
  
Line 69: Line 68:
     * **sscp_username** — sscp credentials,​ can be set through Mervis IDE     * **sscp_username** — sscp credentials,​ can be set through Mervis IDE
     * **sscp_password** — sscp credentials,​ can be set through Mervis IDE     * **sscp_password** — sscp credentials,​ can be set through Mervis IDE
-    * **db_user** — DB server ​credentials +    * **db_user** — DB server ​login 
-    * **db_pass** — DB server ​credentials+    * **db_pass** — DB server ​password
     * **db_ip** — DB server IP (can be 127.0.0.1 if the daemon runs on the same machine)     * **db_ip** — DB server IP (can be 127.0.0.1 if the daemon runs on the same machine)
     * **db_port** — Database server port (3306 is usually the default)     * **db_port** — Database server port (3306 is usually the default)
Line 85: Line 84:
  
 ~~NOTOC~~ ~~NOTOC~~
- 
-