Scripting Module
Exposes scripting functions to dynamically add/edit/delete devices, database connections, and tags in Ignition.
Current version: 1.0.0
Download link: IA Labs Scripting-module.modl
Cost: This module will be free.
Dependencies: OPC-UA module.
To use:
Simply install the module and call any of the following functions:
Datasource Functions:
system.db.addDatasource(…) - Takes PyArgs, example:
system.db.addDatasource(jdbcDriver="MySQL ConnectorJ", name="MySQL", connectURL="jdbc:mysql://localhost:3306/test", username="root", password="password", props="zeroDateTimeBehavior=convertToNull;")
Possible arguments:
jdbcDriver - String, the name of the JDBC driver in Ignition
name - String
description - String
connectUrl - String
username - String
password - String
props - String, extra connection props
validationQuery - String
maxConnections - Integer
system.db.removeDatasource(String dsName)
system.db.setDatasourceEnabled(String dsName, Boolean enabled)
system.db.setDatasourceMaxConnections(String dsName, Integer maxConnections)
system.db.setDatasourceConnectURL(String dsName, String connectURL)
Device Functions
system.device.addDevice(…) - Takes PyArgs, example:system.device.addDevice(driver="controllogix", deviceName="CLX", hostname="10.10.1.10", slotNumber=0)
Possible arguments (look at properties and compare against driver, not all props work for every device):
driver - String, Possible drivers:"dairysim", "genericsim", "slcsim", "compactlogix", "controllogix", "micrologix", "plc5", "slc", "modbus", "modbusrtu", "s71200", "s7300", "s7400", "tcp", "udp"
deviceName - String
group - String
browseTimeout - Integer
readTimeout - Integer
writeTimeout - Integer
enabled - Boolean
hostname - String
communicationTimeout - Integer
browseCacheTimeout - Integer
connectionPath - String
disableProcessorBrowse - Boolean
slotNumber - Integer
concurrentRequests - Integer
showStringArrays - Boolean
port - Integer
maxHoldingRegisters - Integer
maxInputRegisters - Integer
maxCoils - Integer
maxDiscreteInputs - Integer
reverseWordOrder - Boolean
zeroBasedAddressing - Boolean
spanGaps - Boolean
allowWriteMultipleRegisters - Boolean
allowWriteMultipleCoils - Boolean
reconnectAfterTimeouts - Boolean
reverseStringByteOrder - Boolean
rightJustifyStrings - Boolean
pduSize - Integer
rackNumber - Integer
cpuSlot - Integer
ports - String
inactivityTimeout - Integer
messageDelimiterType - String
messageDelimiter - String
fieldCount - Integer
fieldDelimiter - String
writebackEnabled - Boolean
writebackMessageDelimiter - String
multicast - Boolean
system.device.listDevices()
system.device.removeDevice(String dsName)
system.device.setDeviceEnabled(String dsName, Boolean enabled)
system.device.setDeviceHostname(String dsName, String hostname)
system.device.refreshBrowse(String dsName) - Only for AB controllers
Tag Functions
system.tag.addTag(…) - Takes PyArgs, example:system.tag.addTag(parentPath="Folder", name="TagName", tagType="OPC", dataType="Int4", attributes={"OPCServer":"Ignition OPC-UA", "OPCItemPath":"[DeviceName]N7:0"})
Possible arguments:
parentPath - String
*NOTE: you specify the SQLTag provider name in square brackets at the beginning of the parentPath string. Example: “[myTagProvider]MyTagsFolder”
If the SQLTag provider name is left off then the tag will be added to the default internal provider named “default”.
name - String
tagType - String, Possible types:"OPC", "DB", "UDT_INST"
dataType - String, Possible types:"Int1", "Int2", "Int4", "Int8", "Float4", "Float8", "Boolean", "String", "DateTime", "DataSet"
accessRights - String, Possible types:"Read_Only", "Read_Write", "Custom"
enabled - Boolean
value - Object
attributes - PyDictionary (meta properties), Possible attributes:OPCServer(String.class, ""),
OPCItemPath(String.class, ""),
OPCWriteBackServer(String.class, ""),
OPCWriteBackItemPath(String.class, ""),
ScaleMode(Integer.class, 0),
RawLow(Double.class, 0d),
RawHigh(Double.class, 100d),
ScaledLow(Double.class, 0d),
ScaledHigh(Double.class, 10d),
ClampMode(Integer.class, 0),
Deadband(Double.class, .0001),
FormatString(String.class, "#,##0.##"),
EngUnit(String.class, ""),
Tooltip(String.class, null),
EngHigh(Double.class, new Double(100)),
EngLow(Double.class, new Double(0)),
Documentation(String.class, ""),
Expression(String.class, ""),
ExpressionType(Integer.class, 0),
AlertMode(Integer.class, 0),
AlertAckMode(Integer.class, 1),
AlertSendClear(Integer.class, 1),
AlertMessageMode(Integer.class, 0),
AlertMessage(String.class, ""),
AlertNotes(String.class, ""),
AlertDisplayPath(String.class, ""),
AlertDeadband(Double.class, 0.0d),
LastChange(Date.class, null, false),
DriverName(String.class, ""),
ScanClass(String.class, "Default"),
PollRate(PollingRate.class, new PollingRate()),
SQLBindingDatasource(String.class, ""),
PrimaryHistoryProvider(String.class, ""),
HistoricalDeadband(Double.class, .01),
HistoryEnabled(Boolean.class, false),
HistoricalScanclass(String.class, "Default Historical"),
InterpolationMode(Integer.class, 3),
AlertExecEnabled(Boolean.class, true),
AlertActive(Boolean.class, false, false),
AlertCurrentState(String.class, "", false),
AlertCurrentSeverity(Integer.class, -1, false),
AlertAcknowledged(Boolean.class, false, false),
AlertAcknowledgeUser(String.class, "", false),
AlertActiveTime(Date.class, null, false),
AlertAcknowledgedTime(Date.class, null, false),
AlertClearedTime(Date.class, null, false),
AlertTimestampSource(Integer.class, 0),
AlertMessageSubject(String.class, ""),
HistoryTimestampSource(Integer.class, 0),
HistoryMaxAgeMode(Integer.class, 0),
HistoryMaxAge(Integer.class, 1),
UDTParentType(String.class, ""),
ExtendedProperties(PropertySet.class, null),
PropertyOverrides(OverrideMap.class, null),
UDTMemberUID(String.class, null)
parameters - PyDictionary, used only for UDT instances, contains param for each UDT parameter
system.tag.browseTags(String parentFolder) returns array of BrowseTag, example:tags = system.tag.browseTags("Folder")
for tag in tags:
print tag.name, tag.path, tag.fullPath, tag.isFolder(), tag.isUDT(), tag.isOPC(), tag.isDB(), tag.type
system.tag.removeTag(String tagPath)
system.tag.removeTags(String[] tagPath)
system.tag.editTag(…), PyArgs, Possible arguments:
tagPath - String
attributes - PyDictionary - Same as addTag
parameters - PyDictionary - Same as addTag
system.tag.editTags(…), PyArgs, Possible arguments:
tagPaths - String[]
attributes - PyDictionary - Same as addTag
parameters - PyDictionary - Same as addTag
Feedback is encouraged over on the Module Discussion forum.