-
Notifications
You must be signed in to change notification settings - Fork 313
Remote Export and Import of project configuration
- Login:
curl -d "username=admin&password=admin&submit=Login" -c cookies http://localhost:8080/Scada-LTS/login.htm
- Export:
curl -L -b cookies --output project.zip http://localhost:8080/Scada-LTS/api/export/config/with-images/
- Login as admin, then created file cookies:
curl -d "username=admin&password=admin&submit=Login" -c cookies http://localhost:8080/Scada-LTS/login.htm
- Invoke import, use file cookies, and data_json_encoded:
curl 'http://localhost:8080/Scada-LTS/dwr/call/plaincall/EmportDwr.importData.dwr' -X POST -b cookies --data-raw $'callCount=1\npage=/Scada-LTS/import_project.htm\nhttpSessionId=\nscriptSessionId=D15BC242A0E69D4251D5585A07806324697\nc0-scriptName=EmportDwr\nc0-methodName=importData\nc0-id=0\nc0-param0=string:
data_json_encoded\nbatchId=8\n'
It is important here to generate a cookie file that will be used in requests, and upload a configuration file that we want to import:
- Login as admin:
curl -d "username=admin&password=admin&submit=Login" -c cookies http://localhost:8080/Scada-LTS/login.htm
- Upload file: (you have to replace path_to_project_zip, the @ character stays)
curl -b cookies -v -F importFile=@path_to_project_zip http://localhost:8080/Scada-LTS/import_project.htm
If ok:
if not ok:
- Import Project:
curl 'http://localhost:8080/Scada-LTS/dwr/call/plaincall/EmportDwr.loadProject.dwr' -X POST -b cookies --data-raw $'callCount=1\npage=/Scada-LTS/import_project.htm\nhttpSessionId=\nscriptSessionId=D15BC242A0E69D4251D5585A07806324697\nc0-scriptName=EmportDwr\nc0-methodName=loadProject\nc0-id=0\nbatchId=5\n'
Be careful because the import delete all data from the database, and insert new data:
- Therefore, if you send a request from step 3, the operation cannot be interrupted then.
- You also cannot do step 3 without doing step 2 within the same session.
- If you break something in the database, following these steps correctly gives you the opportunity to fix it. Another way is to delete the entire database and create a new one, then the Application will reinitialize the structures in the database, but this will only restore the default structures and allow you to log in to the application as admin;
This feature is currently limited and you can create the following Data Source this way:
dataSourceTypeId = 1 (VirtualDataSource)
dataSourceTypeId = 3 (ModbusIpDataSource)
dataSourceTypeId = 5 (SnmpDataSource)
dataSourceTypeId = 9 (MetaDataSource)
1. Login
http://localhost:8080/ScadaBR/api/auth/admin/admin GET
or
http://localhost:8080/ScadaBR/login.htm?username=admin&password=admin&submit=Login POST
2. Create new datasource:
http://localhost:8080/ScadaBR/api/datasource POST
example body:
{
"xid": "DS_7973799",
"name": "modbus_ip_1",
"type": 3,
"enabled": true,
"connectionDescription": "common.default",
"updatePeriodType": 1,
"updatePeriods": 5,
"quantize": false,
"timeout": 500,
"retries": 2,
"contiguousBatches": false,
"createSlaveMonitorPoints": false,
"maxReadBitCount": 2000,
"maxReadRegisterCount": 125,
"maxWriteRegisterCount": 120,
"transportType": "TCP",
"host": "localhost",
"port": 502,
"encapsulated": false,
"createSocketMonitorPort": false
}
3. Update datasource:
http://localhost:8080/ScadaBR/api/datasource PUT
body:
{
"id": 1,
"xid": "DS_7973799",
"name": "modbus_ip_1",
"type": 3,
"enabled": true,
"connectionDescription": "common.default",
"updatePeriodType": 1,
"updatePeriods": 5,
"quantize": false,
"timeout": 500,
"retries": 2,
"contiguousBatches": false,
"createSlaveMonitorPoints": false,
"maxReadBitCount": 2000,
"maxReadRegisterCount": 125,
"maxWriteRegisterCount": 120,
"transportType": "TCP",
"host": "localhost",
"port": 502,
"encapsulated": false,
"createSocketMonitorPort": false
}
4. Create datapoint:
range:
Coil status - 1
Input status - 2
Holding register - 3
Input register - 4
http://localhost:8080/ScadaBR/api/datapoint POST
body:
{
"xid": "DP_6352",
"name": "dp_2",
"description": null,
"enabled": true,
"dataSourceTypeId": 3,
"dataSourceId": 5,
"deviceName": "modbus_ip_1",
"pointLocator": {
"dataSourceTypeId": "3",
"dataTypeId": 2,
"settable": true,
"range": 3,
"modbusDataType": 2,
"slaveId": 1,
"slaveMonitor": false,
"socketMonitor": false,
"offset": 0,
"bit": 0,
"registerCount": 0,
"charset": "ASCII",
"settableOverride": true,
"multiplier": 1.0,
"additive": 0.0,
"relinquishable": false
},
"datasourceName": "modbus_ip_1",
"dataSourceXid": "DS_797379",
"typeId": 1,
"settable": true
}
5. Update datapoint:
http://localhost:8080/ScadaBR/api/datapoint PUT
body:
{
"id": 12,
"xid": "DP_6352",
"name": "dp_2",
"description": null,
"enabled": true,
"dataSourceTypeId": 3,
"dataSourceId": 5,
"deviceName": "modbus_ip_1",
"pointLocator": {
"dataSourceTypeId": "3",
"dataTypeId": 2,
"settable": true,
"range": 3,
"modbusDataType": 2,
"slaveId": 1,
"slaveMonitor": false,
"socketMonitor": false,
"offset": 0,
"bit": 0,
"registerCount": 0,
"charset": "ASCII",
"settableOverride": true,
"multiplier": 1.0,
"additive": 0.0,
"relinquishable": false
},
"datasourceName": "modbus_ip_1",
"dataSourceXid": "DS_797379",
"typeId": 1,
"settable": true
}