ScriptDeviceObject

 

class

ScriptDeviceObject.

ScriptDeviceObjectMarker

Bases: object

Every ScriptObject instance will be extended with this method. 

is_device

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

Return type

bool

class

ScriptDeviceObject.

ScriptDeviceObject

Bases: ScriptDeviceObject.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

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

device=None

type=None

id=None

version=None

module=None

Updates the specified device.

Warning

Either device or (type and id and version) have to be passed! module can always be omitted.

Parameters

  • type (int) -- The device type.

  • id (str) -- The device identification.

  • version (str) -- The device version.

  • module (str) -- The module ID.

plug

name

device=None

type=None

id=None

version=None

module=None

Plugs the specified device.

Warning

Either device or (type and id and version) have to be passed! module can always be omitted.

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.

add

name

device=None

type=None

id=None

version=None

module=None

Adds the specified device.

Warning

Either device or (type and id and version) have to be passed! module can always be omitted.

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.

insert

name

index

device=None

type=None

id=None

version=None

module=None

Inserts the specified device at the specified index.

Warning

Either device or (type and id and version) have to be passed! module can always be omitted.

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.

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

address

Sets the gateway and address.

If you pass the empty guid 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 host­name.

Parameters

  • gateway (Guid, str or ScriptGateway) -- The gateway (Guid).

  • 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

Returns

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

device_parameters

Gets the set of device parameters.

Since V3.5.8.0, this actually is a ScriptMappableDeviceParameterSet.

Version added

3.5.4.0

connectors

Gets the connectors.

set_gateway_and_device_name

gateway

device_name

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 (Guid, str or ScriptGateway) -- The gateway, its Guid or its string representation.

  • device_name (str) -- The device name.

set_gateway_and_ip_address

gateway

ip_address

port=11740

Sets the gateway and IP address for communication.

Version added

3.5.8.0

Parameters

  • gateway (Guid, str or ScriptGateway) -- The gateway, its Guid or its string representation.

  • ip_address (IPAdressorstr) -- The IP Adress as a string. If port is omitted, the port can be passed here separated by a colon (e.G. "127.0.0.1:11739").

  • 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

Reads the communication settings of the device.

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.

driver_info

Get the driver info of the device.

Version added

3.5.9.0

Return type

allow_symbolic_var_access_in_sync_with_iec_cycle

Property used by the symbol configuration to determine if symbolic vari­able 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

device=None

type=None

id=None

version=None

module=None

Adds the specified device.

Warning

Either device or (type and id and version) have to be passed! module can always be omitted.

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.

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) 

type

Type of the device.

Return type

int

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

version

The version of the device.

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

Return type

str

class

ScriptDeviceObject.

ModuleId

Bases: ScriptDeviceObject.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. 

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. 

gateway_guid

The guid of the gateway.

Return type

Guid

device_address

The address of the device.

Return type

str

prompt_at_login

Whether there's a prompt at login.

Return type

bool

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

device_name

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

Return type

str

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

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

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

scanned_device_name

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

Return type

str

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

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

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

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

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

scaned_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