Hello everyone,
I have a question about the SQL query in ignition. Is it possible to insert new device details in SQL through a query using ignition UI?
Example,Suppose in the ignition four sensors are connected. (Like a temperature, pressure) Now, the other four sensors added in the field and I want to not add sensor details manually in MySQL for data logging. *
*** So, I add multiple numeric text fields in the ignition and add these details in the numeric text field (Such as sensor name, sensor mac_id, gateway_id,)and then add a button for the insert of the query. when I press the button that time insert query will be run on raw will be added to the database.**
Your question is unclear.
- Have you created OPC tags for these four new sensors?
- Are you using Ignition's Historian or are you logging these in your own custom database?
So, I add multiple numeric text fields in the ignition ...
Do you mean, "In the Vision window I have added multiple Numeric Text Field components ..."
... and add these details in the numeric text field (Such as sensor name, sensor mac_id, gateway_id,) and then add a button for the insert of the query.
OK. So you have created a form with Numeric Text Field components, but you can't enter text names, MAC address or gateway_id in a numeric field.
When I press the button that time insert query will be run on raw will be added to the database.
That should be OK.
It's certainly possible to execute a sql statement in ignition, whether that's a SELECT, INSERT, DELETE, etc. But is this what you actually mean, or are you actually asking if you can add a new Device connection (eg to a new PLC) to the gateway via script, or add new tags (eg UDT instances) for the new sensors into the tag tree via script?
I need to add new tag via script in the database.
You can use system.tag.configure to create new tags via script. It just need a base folder to create them in and the tag's to create as a list of tag json objects. Copy the json of other similar tags for a reference. For udt instances I would recommend removing all tags keys from the json unless you're adding property overrides, as they're useless and just clutter the json
can you brief it with example for inserting raw in the database?
machineName = "Machine01"
tags = {
"name": machineName,
"tagType": "Folder",
"tags": [
{
"name": "Tools",
"tagType": "Folder",
"tags": []
},
{
"name": "Alarm Summary",
"typeId": "Alarm Summary",
"tagType": "UdtInstance",
"tags": [] # there were originally lots of tags in this list which I removed as they're not required to import the UDT instance
},
{
"name": "Common",
"typeId": "SPL/Roll Machine",
"parameters": {
"Description": {
"dataType": "String",
"value": machineType
},
"PLCName": {
"dataType": "String",
"value": machineName
}
},
"tagType": "UdtInstance",
"tags": [] # there were originally lots of tags in this list which I removed as they're not required to import the UDT instance
}
]
}
system.tag.configure('Path/To/Machines/Folder', tags, 'm')
Also, you don't need to delete a post, you can just edit it to make changes to it
2 Likes