ScriptDeviceObject

class ScriptDeviceObject.DeviceTrackingMode(value)

Bases: Enum

Enumeration that defines how a device is tracked on the network.

Name = 0

Tracked by name (e.g. ‘MyPlc’).

SystemAddress = 1

Tracked by system address (e.g. ‘[056D]’).

IPAddressUdp = 2

Tracked by IP using UDP broadcasts.

IPAddressTcp = 3

Tracked by IP using TCP point-to-point connection.

Gateway = 4

Device is a Gateway and will not be tracked.

Dummy = 5

Placeholder device will not be tracked.

DNS = 6

Tracked by Dns-Address using TCP point-to-point connection.

class ScriptDeviceObject.StopResetBehaviour(value)

Bases: Enum

An enumeration.

KeepCurrentValues = 0

The outputs keep the last current values.

SetToDefault = 1

The outputs are set to the default values.

ExecuteProgram = 2

A user defined program is executed.

class ScriptDeviceObject.ConnectorRole(value)

Bases: Enum

Describes the role of a connector

Parent = 0

The connector allows other devices to be connected to the connectors device.

Child = 1

The connector allows its device to be connected to another device.

class ScriptDeviceObject.AccessRight(value)

Bases: Enum

Defines access rights on a parameter.

None = (0,)

The element is not accessible.

Read = 1

Specifies that the element may be read.

Write = 2

Specifies that it is allowed to write to the element.

ReadWrite = 3

Combination of read and write access: The element may be written and read.

class ScriptDeviceObject.ChannelType(value)

Bases: Enum

Defines the types of a channel.

None = 0

Not a channel.

Input = 1

An input channel.

Output = 2

An output channel.

OutputReadOnly = 3

A readonly output channel.

class ScriptDeviceObject.DiagType(value)

Bases: Enum

Describes the function of a parameter in respect to module diagnosis.

None = (0,)

No diagnostic meaning

Diagnosis = (1,)

Provides the diagnostic message

Acknowledge = 2

Acknowledge for current diagnostic message

class ScriptDeviceObject.ScriptDeviceObjectMarker

Bases: object

Every ScriptObject instance will be extended with this method.

property is_device

Gets a value indicating whether this instance is a device object.

Return type:

bool

class ScriptDeviceObject.ScriptDeviceObject

Bases: ScriptDeviceObjectMarker

Functionality for manipulating device objects.

All device objects implementing DeviceObject will be extended with this methods.

get_device_identification()

Gets the device identification.

Return type:

DeviceId

enable()

Marks this device as enabled during download.

disable()

Marks this device as disabled during download.

is_enabled()

Determines whether this instance is enabled during download.

Return type:

bool

Returns:

True if this instance is enabled during download; otherwise, False.

update(type: int, id: str, version: str, module: Optional[str] = None)

Updates the specified device.

Parameters:
  • type (int) – The device type.

  • id (str) – The device identification.

  • version (str) – The device version.

  • module (str) – The module ID. (This parameter is optional.)

plug(name: str, type: int, id: str, version: str, module: Optional[str] = None)

Plugs the specified device.

Parameters:
  • name (str) – Name of the device.

  • type (int) – The device type.

  • id (str) – The device identification.

  • version (str) – The device version.

  • module (str) – The module ID. (This parameter is optional.)

add(name: str, type: int, id: str, version: str, module: Optional[str] = None)

Adds the specified device.

Parameters:
  • name (str) – Name of the device.

  • type (int) – The device type.

  • id (str) – The device identification.

  • version (str) – The device version.

  • module (str) – The module ID. (This parameter is optional.)

insert(name: str, index: int, type: int, id: str, version: str, module: Optional[str] = None)

Inserts the specified device at the specified index.

Parameters:
  • name (str) – Name of the device.

  • index (int) – Index where to insert the device.

  • type (int) – The device type.

  • id (str) – The device identification.

  • version (str) – The device version.

  • module (str) – The module ID. (This parameter is optional.)

unplug()

Unplugs the specified device.

get_simulation_mode()

Gets the simulation mode.

Returns:

True if simulation is enabled.

set_simulation_mode(simulation)

Sets the simulation mode.

Parameters:

simulation (bool) – if set to True, simulation is enabled.

get_gateway()

Gets the gateway.

See also: ScriptDeviceObject.get_device_communication_settings

Return type:

Guid

Returns:

The guid of the gateway.

get_address()

Gets the address of the device.

See also: ScriptDeviceObject.get_device_communication_settings

Return type:

str

Returns:

The device address in the bus independent CODESYS format.

set_gateway_and_address(gateway: ScriptGateway, address: str)

Sets the gateway and address.

If you pass the empty gateway and an empty address, the gateway address will be cleared. You can use ScriptGateway.find_address_by_ip() to search the CODESYS address when you know the ip address or hostname.

Parameters:
  • gateway (ScriptGateway) – The gateway.

  • address (str) – The address in the bus independent CODESYS format.

get_module_identification()

Returns the unique identification of a module.

A module is a special type of device, that is only available within the context of a certain device. The module is identified by the same values as each owning device, with an additional module id, to distinguish it from other modules of the same device.

Examples for modules are device local io modules and similar nodes.

Version added:

3.4.4.0

Return type:

str

Returns:

The module identification, or an empty string if this module has no module identification.

allow_interfaces_at(index)

Get the name of the child interfaces that this device object can accept at the specified insert position.

Version added:

3.5.4.0

Parameters:

index (int) – The child index where a device should be inserted.

Return type:

list[str]

Returns:

A list of possible interface names or None if no device can be inserted at that position.

property device_parameters

Gets the set of device parameters.

Since V3.5.8.0, this actually is a ScriptMappableDeviceParameterSet.

Version added:

3.5.4.0

Return type:

ScriptDeviceParameterSet

property connectors

Gets the connectors.

Return type:

ScriptDeviceConnectorSet

set_gateway_and_device_name(gateway: str, device_name: str)

Sets the gateway and device name for communication.

If you pass the empty guid and an empty address, the gateway address will be cleared. The device will be tracked by its device name - when trying to go online, a quick online scan will be made and the first device with the given name will be selected.

Version added:

3.5.8.0

Parameters:
  • gateway (str) – The gateway Guid(as string) or its name.

  • device_name (str) – The device name.

set_gateway_and_ip_address(gateway: str, ip_address: IPAddress, port: int = 11740)

Sets the gateway and IP address for communication.

Version added:

3.5.8.0

Parameters:
  • gateway (str) – The gateway guid (as string) or name.

  • ip_address (IPAddress) – The IP Address.

  • port (ushort) – The port. Omit to use the default port 11740.

Raises:

InvalidOperaionException – If gateway is passed as a string and several gateways have the same name.

get_device_communication_settings()

Gets the communication settings of the device.

Return type:

ScriptCommunicationSettings

export_io_mappings_as_csv(file_path)

Export the io mappings as a CSV file to the specified absolute path.

Version added:

3.5.8.0

Parameters:

file_path (str) – The absolute path of the file to export.

import_io_mappings_from_csv(file_path)

Imports the io mappings from a CSV file at the specified absolute path.

Version added:

3.5.8.0

Parameters:

file_path (str) – The absolute path of the file to import.

property driver_info

Get the driver info of the device.

Version added:

3.5.9.0

Return type:

ScriptDriverInfo

property allow_symbolic_var_access_in_sync_with_iec_cycle

Property used by the symbol configuration to determine if symbolic variable access is allowed to be synchronized with the IEC cycle.

The default is False and should be kept for most use cases. Setting this to True may increase the jitter for all applications running on the device because the task accessing the variables may block other tasks. The device object has to support DeviceObject (3.5.10.0) to access the value.

Version added:

3.5.10.0

Return type:

bool

class ScriptDeviceObject.ScriptProjectDeviceExtension

Bases: object

Functionality to add top-level devices (e. G. SPS) to projects.

ScriptProject instances are amended with these objects.

Version added:

3.4.3.0

add(name: str, type: int, id: str, version: str, module: Optional[str] = None)

Adds the specified device.

Parameters:
  • name (str) – Name of the device.

  • type (int) – The device type.

  • id (str) – The device identification.

  • version (str) – The device version.

  • module (str) – The module ID. (This parameter is optional.)

class ScriptDeviceObject.DeviceId

Bases: object

Represents a Device ID.

An implementation class of this interface is injected under the name “DeviceID” into the python scope, so python code can create device IDs without the need to subclass that interface. The constructor signature is: DeviceID(int iType, string stId, string stVersion)

property type

Type of the device.

Return type:

int

property id

Id of the device.

The format for this id is specified for each type. The id is unique within the class of devices of one type.

Return type:

str

property version

The version of the device.

The format for the version string is specified for each type.

Return type:

str

class ScriptDeviceObject.ModuleId

Bases: DeviceId

Unique identification for a module.

A module is a special type of device, that is only available within the context of a certain device. The module is identified by the same values as each owning device, with an additional module id, to distinguish it from other modules of the same device.

Examples for modules are device local io modules and similar nodes.

property module_id

Id of the module.

The format for this id is specified for each type. The id is unique within the class of devices of one type.

Return type:

str

class ScriptDeviceObject.ScriptCommunicationSettings

Bases: object

Provides access to the communication settings of the device.

property gateway_guid

The guid of the gateway.

Return type:

Guid

property device_address

The address of the device.

Return type:

str

property prompt_at_login

Whether there’s a prompt at login.

Return type:

bool

property secure_online_mode

Gets a boolean value indicating whether secure online mode is activated for the corresponding devices.

If set, user interfaces should prompt the user before an operation is executed which changes the state of the controller.

Return type:

bool

property device_name

Gets the name of the device as entered on the communication settings page.

Return type:

str

property monitoring_interval_msec

The interval for status and variable monitoring measured in milliseconds.

Default = 200ms, Minimum = 10ms, Maximum = 1000ms, Increment 10ms. Invalid values will be ignored

Return type:

int

property monitoring_interval

The interval for status and variable monitoring measured in milliseconds.

Default = 200ms, Minimum = 10ms, Maximum = 1000ms, Increment 10ms. Invalid values will be ignored

Return type:

TimeSpan

property TrackingMode

Property to get the mode used to track a device on the network - whether the device is tracked via CODESYS address, ip address or name.

Return type:

DeviceTrackingMode

property scanned_device_name

The name of the physical device (E.g. “MyPlc”), as seen in the network scan.

Return type:

str

property scanned_ip_address_and_port

Device IP Address and Port if block driver TCP is used for connection.

Format: “192.168.101.109:11740”, as seen in the network scan.

This may return the emtpy string if it’s not available. Even if some network scan members are set, this does not guarantee that all of them are set.

Return type:

str

property scanned_target_id

Target ID.

Format: “1234 ABCD” (=hexadecimal), same as in device description, as seen in the network scan.

This may return the emtpy string if it’s not available. Even if some network scan members are set, this does not guarantee that all of them are set.

Return type:

str

property scanned_target_name

The name of the target (E.g. “CODESYS PLC Win NT”), as seen in the network scan.

This may return the emtpy string if it’s not available. Even if some network scan members are set, this does not guarantee that all of them are set.

Return type:

str

property scanned_target_type

Target Type (Format: “4096” (=decimal), same as in device description), as seen in the network scan.

This may return the emtpy string if it’s not available. Even if some network scan members are set, this does not guarantee that all of them are set.

Return type:

str

property scanned_target_vendor

The vendor of the target, as seen in the network scan.

This may return the emtpy string if it’s not available. Even if some network scan members are set, this does not guarantee that all of them are set.

Return type:

str

property scanned_target_version

The version of the target, as seen in the network scan.

This may return the emtpy string if it’s not available. Even if some network scan members are set, this does not guarantee that all of them are set.

Return type:

str

property is_communication_encrypted

Get or set if encrypted communication should be used with the device.

Version added:

3.5.16.10

Return type:

bool