VtrinCmd Tool
This is an internal tool used to import and export files in JSON format.
The table below shows parameters that are used with VtrinCmd (VtrinCmd[.exe] [parameters]). We have provided some examples further below.
-
Many parameters are available in both short and long form. For example,
-cand--connectionstringare equivalent -
Parameter names are case-sensitive. For example,
-uand-Uare different parameters.
Parameters
| Short | Long | Description |
|---|---|---|
| --acceptkeychanges | Accept server key changes. | |
| --acceptnewkeys | Accept new server keys. | |
| -c | --connectionstring <value> | Connection string for the driver. |
| -C | --continueonerror | (with --importjson option) Continue operation when an error occurs. |
| -e | --exportjson <value> | Export JSON class data. "ClassID[properties]:Mask" Multiple separated with | . |
| --exportjsonbag <value> | Export JSON property bag(s) "BagID[VersionTime]:UserID" Multiple separated with. | |
| -T | --exportjsontreenode <value> | Export JSON from TreeNode instance and other related data. NodeId as parameter. |
| -F | --exporttofolder <value> | Export TreeNodes recursively to a folder structure. Folder path as parameter. |
| -M | --fetchmax <value> | (with --query option) Maximum number of rows returned by the query. |
| --fileversion | Display only the file version (VtrinLib.dll) | |
| -f | --force | (with --importjson option) Forcefully remove conflicting instances. |
| -h | --help | Displays all available parameters and usage information. |
| --hidelinenumbers | (with --query option) Don't show line numbers in query results. | |
| -i | --importjson <value> | Import JSON data from a file(s). Multiple files separated with | |
| -I | --importjsonfolder <value> | Import data from .json files in a folder recursively. Folder path as parameter. |
| --includedefault | (with --exportjson option) Include property values identical to default values. | |
| --indent <value> | Number of spaces for indent in exporting/displaying JSON data (Tab used by default). | |
| --noconfirm | No user confirmation with --importjson and --removejson options when processing files in folder(s) | |
| --noreplace | (with --importjson option) Do NOT replace/merge into existing class instances. | |
| -o | --outfile <value> | Write output to a file (with export* options). |
| -q | --query <value> | Query class data. "ClassID[Properties]:Mask". |
| --rawvalues | (with --query option) Show raw values in query results. | |
| -R | --recursive | (with --exportjsontreenode) Export recursively the whole sub tree. |
| --removejson <value> | Remove from data source all data found in JSON file(s). Multiple files or directories. | |
| -U | --savecredentials | (with --connectionstring) Save entered credentials to the credential storage. |
| --showexamples | Show usage examples. | |
| --taketime | Measure amount of time taken by the operation. | |
| --trace | Show diagnostics trace. | |
| -u | --user <value> | (with --connectionstring) User for the connection. (When using vault name prefix with *) |
| --verbose | (with --importjson option) Show verbose trace output on console. | |
| --version | Display the product version (VtrinLib.dll). |
Query language
The query language for --exportjson and --query options is "classid[properties]:mask"
- Classid = The Id of the source class.
- Properties = (Optional) List of class properties to include, comma separated in square brackets [].
- Mask = (Optional) Vtrin where mask string (prefix with : ) for filtering query results.
Further notes for query:
- Multiple queries are supported and should be separated with | (pipe).
- The property list supports * (asterisk) wildcard to include matching property names.
- Property names prefixed with - (dash) are excluded from the results. (Wildcards not supported.)
- With --query option, only properties visible to user by default are included. Using * in the property list overrides this.
- NOTE: Unless --includedefault is used --exportjson only includes properties if their value differs from the default.
Connect to Data Source
Connect to a data source using a connection string. You can connect to a remote server or directly to a local data source.
Remote Connection
Connect through a Vtrin Server WebSocket endpoint.
VtrinCmd --connectionstring wss://server/historyLocal Connection
You can connect locally through the View endpoint or directly to the data source.
WebSocket to Vtrin Server
Works on both Windows and Linux and does not require direct access to database files.
VtrinCmd --connectionstring wss://localhost/viewDirect RTDB connection
Can be used when the View connection is not available, for example when the Vtrin Server is stopped.
VtrinCmd --connectionstring "%APP_DATAPATH%"runcpm VtrinCmd --connectionstring /var/lib/rtdbdataAuthentication
When connecting through a WebSocket endpoint (wss://), use the --user option if credentials are not saved. The password will be prompted separately.
VtrinCmd --connectionstring wss://server/history --user myuserCredentials
Credentials can be saved for reuse when connecting to data sources that require authentication. When saving credentials VtrinCmd prompts for the username and password.
VtrinCmd --connectionstring wss://server/history --savecredentialsSelf-signed Certificates
If the connection fails because the server certificate is not trusted (for example, when using a self-signed certificate), use the --acceptnewkeys option when connecting for the first time.
VtrinCmd --connectionstring wss://server/history --savecredentials --acceptnewkeysGood to know:
-
After a successful connection, you can choose a name for the stored credentials.
-
Saved credentials can later be used with the --user option by adding * before the credential name.
Usage Examples
Export Equipment and PropertyInfo
This example exports all Equipment and EquipmentPropertyInfo class instances and store the output to equipment.json file.
VtrinCmd --connectionstring wss://myserver/mysource --exportjson "Equipment|EquipmentPropertyInfo" --outfile equipment.json
Import data
This example imports data from equipment.json to the connected data source.
VtrinCmd --connectionstring wss://myotherserver/mysource --importjson equipment.json
Export CalculationTask instances
This example exports all CalculationTask instances whose Module is 'MyModule'. However excluding RowModificationTime from the export.
VtrinCmd --connectionstring wss://myserver/mysource --exportjson "CalculationTask[-RowModificationTime]\:Module = 'MyModule'"
Listing Path_ names
This example lists the names and base class names of classes whose name begin with string "Path_" in descending order by name.
VtrinCmd --connectionstring wss://myserver/mysource --query "Class[Id,BaseClassName]\:Id LIKE 'Path\_\*' ORDER BY Id DESC"
Listing System Instances
This example lists all System instances showing values for ComputerName and any property containing word "disk".
VtrinCmd --connectionstring wss://myserver/mysource --query "Path_ABB.Ability.SysDiag.System[ComputerName,*disk*]"
Further Reading:
Updated about 12 hours ago

