This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

Object and Modbus Mapping Delete via Script
Hi all,

I need some help with database manipulation. I'm familiar with the correct methodology for adding objects via script.
What I am interested to know is the best practice for deleting objects via script.
Specifically, I need to delete an object and also remove the affiliated link in the modbus mapping.

EDIT: Also how to delete modbus devices via script.
I note the method does not work;

return { id = 1 }

Thanks in Advance,
Try this:
addr = '1/1/1'

-- delete object

-- clear modbus mapping
id = buslib.encodega(addr)
db:query('UPDATE modbus_mapping SET bus_address="" WHERE bus_address=?', id)

-- restart modbus
os.execute('sh /lib/genohm-scada/plugins/modbus/; sleep 1; sh /lib/genohm-scada/plugins/modbus/')
Thanks! Works as expected.
Also, The following code worked to delete the entire modbus device. Care should be taken to remove the associated mapping in modbus_mapping as this will cause conflicts when adding new devices.
db:query('DELETE FROM modbus_devices', id)

Forum Jump: