Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Description

Adds a new device connection in Ignition. Accepts a dictionary of parameters to configure the connection. Acceptable parameters differ by device type: i.e., a Modbus/TCP connection requires a hostname and port, but a simulator doesn't require any parameters.


When using this function, the arguments MUST be passed as keyword arguments.


Syntax - Using deviceType

system.device. addDevice(deviceType, deviceName, deviceProps )


  • Parameters

String  driverType  - The device driver type. Possible values are listed in the Device Types table below.

String  deviceName  - The name that will be given to the the new device connection.

PyDictionary deviceProps - A dictionary of device connection properties and values. Each deviceType has different properties, but most require at least a hostname. Keys in the dictionary are case-insensitive, spaces are omitted, and the names of the properties that appear when manually creating a device connection.

  • Returns

nothing

  • Scope

All

Device Types


Note that this function may be called to add devices using 3rd party drivers: you simply need the driver type, which the module developer will be able to provide.

Driver NameDriver Type
Legacy Allen-Bradley CompactLogixCompactLogix
Legacy Allen-Bradley ControlLogixControlLogix
Simulators Dairy Demo SimulatorDairyDemoSimulator
DNP3 DriverDnp3Driver
Allen-Bradley Logix DriverLogixDriver
Allen-Bradley MicroLogixMicroLogix
Modbus RTUModbusRtu
Modbus TCPModbusTcp
Omron NJ Drivercom.inductiveautomation.omron.NjDriver
Allen-Bradley PLC5PLC5
Driver NameDriver Type
Siemens S7-300S7300
Siemens S7-400S7400
Siemens S7-1200S71200
Siemens S7-1500S71500
Allen-Bradley SLCSLC
Simulators SLC SimulatorSLCSimulator
Simulators Generic SimulatorSimulator
TCPDriver
UDP DriverUDPDriver

Device Properties

The deviceProps parameter is where you supply configuration values to the new connection. Value properties depend on which deviceType was specified. To find the valid properties for each type, simply check the OPC-UA and Device Connections section of the manual, and find the property list. The keys in the deviceProps parameter are case-insensitive, and have the spaces omitted. Device properties not specified in the deviceProps parameter will fallback to default values if not specified (where applicable: i.e., "hostname" typically does not have a default value).

Modbus Example

Below we see an example using the ModbusTcp deviceType. The left portion is from the newly created device connection on the Gateway, and the right portion is the function that created the connection. The Hostname, Port, and Max Holding Registers Per Request properties were specified in the call. Note the following:

  • port in the dictionary does not have to match the casing of the Port property on the device page.
  • The Communication Timeout property was not specified in the dictionary, so it is set to the default value of 2000.
  • Max Holding Registers Per Request was included in the dictionary with all spaces removed, and successfully configured with a value of 325.

Device Properties

The deviceProps parameter is where you supply configuration values to the new connection. Value properties depend on which deviceType was specified. To find the valid properties for each type, simply check the OPC-UA and Device Connections section of the manual, and find the property list. The keys in the deviceProps parameter are case-insensitive, and have the spaces omitted. Device properties not specified in the deviceProps parameter will fallback to default values if not specified (where applicable: i.e., "hostname" typically does not have a default value).

Modbus Example

Below we see an example using the ModbusTcp deviceType. The left portion is from the newly created device connection on the Gateway, and the right portion is the function that created the connection. The Hostname, Port, and Max Holding Registers Per Request properties were specified in the call. Note the following:

  • port in the dictionary does not have to match the casing of the Port property on the device page.
  • The Communication Timeout property was not specified in the dictionary, so it is set to the default value of 2000.
  • Max Holding Registers Per Request was included in the dictionary with all spaces removed, and successfully configured with a value of 325.

Code Examples
Code Snippet
#Add a device using the Allen-Bradley Logix Driver for firmware v21+ devices
deviceProps = {}
deviceProps["Hostname"] = "192.168.1.2"
system.device.addDevice(deviceName="Test1", deviceType="LogixDriver", deviceProps=deviceProps)
  • No labels