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
en:sw:01-mervis:08-sscp-bridge [2019/10/29 10:05]
martyy [SSCP to SQL Bridge]
en:sw:01-mervis:08-sscp-bridge [2023/12/18 11:32] (current)
avsetula
Line 1: Line 1:
-====== SSCP to SQL Bridge ====== +====== SSCP to MySQL 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 unit running Mervis and a MySQL 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 unit.
  
 {{ :​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 unit** 
-    * 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 unit right next to the Mervis RT and send the data to a remote database. Requires IP connection between the unit 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 unit** 
-      * 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 unit
-      * 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 unit 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 unit**
       * __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 unit and send them to the database server. The advantage is that the Daemon does not require IP access to the unit 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 unit to be connected to the Proxy server.
       * Limited by the speed of the Proxy.       * Limited by the speed of the Proxy.
    
 ===== Supported operations ===== ===== Supported operations =====
  
-  - **SELECT** - This action will read a row from the specified table and force the values to the relevant Mervis variables within the PLC. The row can be specified using the "​where"​ parameter, which will be directly used as a "​WHERE"​ clause in the SQL query. (Set Mervis variable according to the DB) +  - **SELECT** - This action will read a row from the specified table and force the values to the relevant Mervis variables within the unit. The row can be specified using the "​where"​ parameter, which will be directly used as a "​WHERE"​ clause in the SQL query. (Set Mervis variable according to the DB) 
-  - **UPDATE** -  This action will update a row in the specified table with the variable values in the PLC. The row can be specified using the "​where"​ parameter, which will be directly used as a "​WHERE"​ clause in the SQL query. (Set DB row according to the Mervis variable) +  - **UPDATE** -  This action will update a row in the specified table with the variable values in the unit. The row can be specified using the "​where"​ parameter, which will be directly used as a "​WHERE"​ clause in the SQL query. (Set DB row according to the Mervis variable) 
-  - **INSERT** -  This action will insert a row with current ​PLC values into the specified table each time the variable state is read from the PLC. (Log Mervis variable to the DB)+  - **INSERT** -  This action will insert a row with current ​unit values into the specified table each time the variable state is read from the unit. (Log Mervis variable to the DB)
  
 ===== Supported platforms ===== ===== Supported platforms =====
  
-  * The program is designed to work on both **x64** and **ARM*** platforms including all Unipi PLCs.+  * The program is designed to work on both **x64** and **ARM*** platforms including all Unipi units.
   * The SW is distributed as a binary Debian (.deb) package tested on the Debian 9/10 based Linux distributions.   * The SW is distributed as a binary Debian (.deb) package tested on the Debian 9/10 based Linux distributions.
   * As the SW is **not** an open-source product, contact Unipi support in case you need to operate the SW on another platform.   * As the SW is **not** an open-source product, contact Unipi support in case you need to operate the SW on another platform.
Line 35: Line 35:
 ===== QUICK START GUIDE ===== ===== QUICK START GUIDE =====
 ==== Installation ==== ==== Installation ====
-  - 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 unit__). **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 unit/server where this toll will run. Default path within the unit/​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 64: Line 63:
 ===== Configuration file structure ===== ===== Configuration file structure =====
 Respect YAML structure of the file. The best way is to edit the example installed by default. Respect YAML structure of the file. The best way is to edit the example installed by default.
-  * **plc_n** list of addressed ​PLCs running Mervis — More than 1 PLC can be defined ​+  * **plc_n** list of addressed ​units running Mervis — More than 1 unit can be defined ​
     * **sscp_ip** — IP of machine with mervisrt running (can be 127.0.0.1 if the daemon runs locally)     * **sscp_ip** — IP of machine with mervisrt running (can be 127.0.0.1 if the daemon runs locally)
     * **sscp_port** — TCP port which mervisr listen on (default 12346)     * **sscp_port** — TCP port which mervisr listen on (default 12346)
     * **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)
     * **db_mysql_schema** — DB schema name     * **db_mysql_schema** — DB schema name
     * **vlist_filename** — list of variables (file generated by the Mervis IDE)     * **vlist_filename** — list of variables (file generated by the Mervis IDE)
-    * **variable_sets** list of operation groups — More than 1 operation group can be defined per every PLC.+    * **variable_sets** list of operation groups — More than 1 operation group can be defined per every unit.
         * **type** — type of operation (select, update and insert operations are supported)         * **type** — type of operation (select, update and insert operations are supported)
         * **set_name** — name of the set consisting of one or more variables         * **set_name** — name of the set consisting of one or more variables
Line 85: Line 84:
  
 ~~NOTOC~~ ~~NOTOC~~
- 
-