Warning, /sdk/cutehmi/extensions/CuteHMI/DataAcquisition.1/README.md is written in an unsupported language. File is not indexed.
0001 # Data Acquisition 0002 0003 ![Development status](doc/status-alpha.svg) 0004 0005 This extension provides fundamental components for data acquisition - a pillar of SCADA system. 0006 0007 This extension internally relies on [CuteHMI.SharedDatabase.1](../SharedDatabase.1/) extension and it is heavily recommended to use 0008 it with database connection created with [CuteHMI.SharedDatabase.1](../SharedDatabase.1/). 0009 0010 Currently PostgreSQL and SQLite backends are supported. 0011 0012 ## Creating the schema 0013 0014 In order to use this extension, apart from making [CuteHMI.SharedDatabase.1](../SharedDatabase.1/) operational, a schema has to be 0015 created. This can be done from C++ or QML, but creation and drop scripts are also listed below. 0016 0017 ### Console tool 0018 0019 Schema can be created with [cutehmi.console.0](../../../tools/cutehmi.console.0/) tool. To do so launch the tool. 0020 ``` 0021 cutehmi.console.0 CuteHMI.DataAcquisition.1 0022 ``` 0023 0024 #### TL;DR 0025 0026 To determine whether it will work at all, type the following in the console. 0027 ``` 0028 # service.start() 0029 CuteHMI.2: [NOTIFICATION] Service 'Database Service' has started. 0030 # schema.create() 0031 CuteHMI.2: [NOTIFICATION] Successfully created 'console' schema. 0032 ``` 0033 This should create default SQLite database, appropriate for testing. 0034 0035 To drop the schema type: 0036 ``` 0037 # schema.drop() 0038 CuteHMI.2: [NOTIFICATION] Dropped 'console' schema. 0039 ``` 0040 0041 #### Custom setup 0042 0043 For customized setup, first you need to pick a database type. 0044 ``` 0045 # db.type = "QPSQL" 0046 ``` 0047 Valid types are `QPSQL` for PostgreSQL and `QSQLITE` for SQLite. 0048 0049 Supply database name. 0050 ``` 0051 # db.name = "meinDatabase" 0052 ``` 0053 Note that SQLite will create a file with database given name, but for PostgreSQL you must create database beforehand! 0054 0055 Then for PostgreSQL typically follows `host`, `port`, `user` and `password`, but SQLite driver ignores most of these fields. 0056 ``` 0057 # db.host = "localhost" 0058 # db.port = 5432 0059 # db.user = "postgres" 0060 # db.password = "postgres" 0061 ``` 0062 0063 Start the service. 0064 ``` 0065 # service.start() 0066 CuteHMI.2: [NOTIFICATION] Service 'Database Service' has started. 0067 ``` 0068 If you get errors, fix database setup, ensure that database is runnig, check permissions, firewall, default gateway, etc. Start 0069 with cables... 0070 0071 Now you may choose shcema name. 0072 ``` 0073 # schema.name = "meinSchema" 0074 ``` 0075 0076 Schema user can be also selected. Database defaults are used if left empty. 0077 ``` 0078 # schema.user = "Adolf" 0079 ``` 0080 0081 To complete the process call create() slot. 0082 ``` 0083 # schema.create() 0084 CuteHMI.2: [NOTIFICATION] Successfully created 'meinSchema' schema. 0085 ``` 0086 0087 Schema can be dropped in a similar way by calling drop() slot. 0088 ``` 0089 # schema.drop() 0090 CuteHMI.2: [NOTIFICATION] Dropped 'meinSchema' schema. 0091 ``` 0092 0093 ### PostgreSQL 0094 0095 Following script is used for PostgreSQL to create schema. All occurrences of `%1` shall be replaced with given schema name. 0096 0097 @include sql/postgres/create.sql 0098 0099 To drop the schema use the following. 0100 0101 @include sql/postgres/drop.sql 0102 0103 ### SQLite 0104 0105 Following script is used for SQLite to create schema. SQLite treats database name as a schema, therefore schema name is incorporated 0106 into table names. This requires table names to be wrapped in square brackets. All occurrences of `%1` shall be replaced with given 0107 schema name. 0108 0109 @include sql/sqlite/create.sql 0110 0111 To drop the schema use the following. 0112 0113 @include sql/sqlite/drop.sql