ScriptOnline¶
- ScriptOnline.CredentialSourceKind(Enum)¶
The kinds of authentication allowed for the fallback to the default handler.
- class ScriptOnline.OnlineChangeOption(value)¶
Bases:
Enum
Online change options used for multiple download.
- Never = (0,)¶
Online change shall never be performed. In that case a full download is forced.
- Try = (1,)¶
Online change shall be tried. If not possible, a full download shall be performed.
- Force = (2,)¶
Online change shall be forced. If not possible, the action is terminated with no change.
- Keep = 3¶
Try to login. Do not online update. Do not download. Keep as it is.
- class ScriptOnline.ApplicationState(value)¶
Bases:
Enum
Execution state of an application.
- none = (0,)¶
No valid application state (eg. not loaded).
- run = (1,)¶
Application is running.
- stop = (2,)¶
Application is stopped.
- halt_on_bp = (3,)¶
Halted on a breakpoint.
- debug_step = (4,)¶
Executing a single step in the debugger.
- single_cycle = (5,)¶
Executing a single cycle in the debugger.
- system_application = (255,)¶
TOCHECK maybe to delete, a special flag indicating a system application (only possible state is stop)
- unknown = 65535¶
Unknown application state. uint.MaxValue, exact value depends on system
- class ScriptOnline.OperatingState(value)¶
Bases:
Enum
The global state of an application. Although not defined as such, this enumeration is treated like a flags field, so the effective value may be a combination of more of these values.
- none = (0,)¶
No application loaded.
- program_loaded = (1,)¶
Program code is loaded (ready to execute)
- download = (2,)¶
A download is in progress.
- online_change = (4,)¶
Performing an online change.
- store_bootproject = (8,)¶
Storing the bootproject.
- force_active = (16,)¶
There are currently forced values for this application.
- exception = (32,)¶
- run_after_download = (64,)¶
Download code at the end of download is in progress (initialization of the application)
- store_bootproject_only = (128,)¶
Only the bootproject is stored at download
- exit = (256,)¶
Application exit is still executed (application is no longer active)
- delete = (512,)¶
Application is deleted (object is available, but the content is stil deleted)
- reset = (1024,)¶
Application reset is in progress
- retain_mismatch = (2048,)¶
Retain mismatch occurred during loading the bootproject (retain data does not match to the application)
- bootproject_valid = (4096,)¶
Bootproject available (bootproject matched to running application in RAM)
- load_bootproject = (8192,)¶
Loading bootproject in progress
- flow_active = (16384,)¶
flow control is active
- run_in_flash = (32768,)¶
Application is running in flash only
- core_dump_loaded = (131072,)¶
A Core-Dump for this application is loaded
- executionpoints_active = (262144,)¶
there are Executionpoints active in the application
- core_dump_creating = 524288¶
there are Executionpoints active in the application
- class ScriptOnline.ResetOption(value)¶
Bases:
Enum
This enum defines the different kinds of reset (warm, cold, origin)
- Warm = (0,)¶
Warm reset of the application - keep retain variables.
- Cold = (1,)¶
“Cold” reset - keep persistent variables and applications
- Original = 2¶
Reset “original” - erase all variables, applications, etc.
- class ScriptOnline.BlockDriverType(value)¶
Bases:
Enum
An enumeration to specify the type of Block Driver used on the runtime system
- Generic = (0,)¶
Any of the regular block drivers without special treatment or unknown
- CmpBlkDrvTcp = (1,)¶
The Block Driver TCP in the runtime system
- CmpBlkDrvCom = (2,)¶
The Block Driver COM in the runtime system
- CmpBlkDrvUsb = (3,)¶
The Block Driver UDP in the runtime system
- CmpBlkDrvShm = (4,)¶
The Block Driver Shared Memory in the runtime system
- CmpBlkDrvUdp = (5,)¶
The Block Driver UDP in the runtime system
- CmpBlkDrvCanClient = (6,)¶
The Block Driver CAN Client in the runtime system
- CmpBlkDrvCanServer = (7,)¶
The Block Driver CAN Server in the runtime system
- CmpBlkDrvDirectCall = (8,)¶
The Block Driver Direct Call in the runtime system
- CmpBlkDrvDNS = 9¶
The Block Driver DNS in the runtime system
- class ScriptOnline.ParamType(value)¶
Bases:
Enum
Enumeration defining allowed types for a gateway parameter. The types match the equally named .NET types.
- SByte = (17,)¶
8 bit signed byte
- Byte = (18,)¶
Unsigned byte (8 bit)
- Int16 = (19,)¶
16 bit signed integer
- UInt16 = (20,)¶
16 bit unsigned integer
- Int32 = (21,)¶
32 bit signed integer
- UInt32 = (22,)¶
32 bit unsigned integer
- Int64 = (23,)¶
64 bit signed integer
- UInt64 = (24,)¶
64 bit unsigned integer
- Char = (25,)¶
A single character
- Single = (26,)¶
Single precission FloatingPoint value
- Double = (27,)¶
Double precission FloatingPoint value
- Boolean = (28,)¶
Boolean value (true or false)
- StringAnsi = (29,)¶
ASCII coded string
- StringUnicode = 30¶
Unicode coded string.
- class ScriptOnline.AdditionalDirInfo(value)¶
Bases:
Enum
Flags to get additional information about a file or directory.
- None = (0,)¶
No information available
- PlaceholderDirectory = (1,)¶
The directory is defined as a placeholder directory (e.g. $PlcLogic$) on the PLC.
- RedundantDirectory = 2¶
The directory is a shortcut to another directory (e.g. links to a subdirectory in the default path)
- class ScriptOnline.ScriptOnline¶
Bases:
object
Online functionality for the ScriptEngine.
Some of the commands may temporarily change the active application.
- create_online_application(application=None)¶
Creates an online application.
To prevent resource leaks, script writers should wrap the usage of the online application in a with: block.
- Parameters:
application (
ScriptObject
) – The application object to use. If this parameter is omitted, the active application is used.- Return type:
Before V3.5.0.0
ScriptOnlineApplication
- Return type:
- Returns:
The online application object.
- property UNFORCE¶
Special value for unforcing a variable.
It is returned by
ScriptOnlineApplication.get_prepared_value()
and can be fed toScriptOnlineApplication.set_prepared_value()
. See alsoScriptOnlineApplication.set_unforce_value()
.- Return type:
str
- property UNFORCE_RESTORE¶
Special value for unforcing and restoring a variable.
It is returned by
ScriptOnlineApplication.get_prepared_value()
and can be fed toScriptOnlineApplication.set_prepared_value()
. See alsoScriptOnlineApplication.set_unforce_value()
.- Return type:
str
- create_online_device(device=None)¶
Creates an online device.
- To prevent resource leaks, script writers should wrap the usage
of the online device in a with: block.
- type device:
ScriptObject
- param device:
The application object to use. If this parameter is omitted, the device of the active application is
used. (This parameter is optional.)
- rtype:
ScriptOnlineDevice
- returns:
The online application object.
- set_default_credentials(username, password=None)¶
Sets the default credentials for login to devices.
This setting is in effect until the end of the current script execution. Use None for the username and omit the password to delete the default credentials.
- Version added:
3.5.3.0
- Parameters:
username (str) – The username.
password (str) – The password.
- set_specific_credentials(target, username, password=None)¶
Sets the default credentials for login to a specific device.
This setting is in effect until the end of the current script execution. Use None for the username and omit the password to delete the default credentials.
- Version added:
3.5.3.0
- Parameters:
target (object) – The target. You can pass a device object, an online device object, an application, or an online application. If you pass an application or online application, the setting will take effect for all applications in the corresponding device object.
username (str) – The username.
password (str) – The password.
- clear_all_credentials()¶
Clears all credentials which were set by this script.
This only clears the cretentials at the level of the script. The online manager and other components may cache credentials internally, those caches are currently not cleared by this method.
- Version added:
3.5.3.0
- property auth_fallback_modes¶
Gets or sets the setting how authentication credentials are acquired when no default credentials are set, and no specific credentials match the target.
This setting is in effect until the end of the current script execution. By default, this is set to
CredentialSourceKind.All
. You can modify this value to disable interactive login.- Version added:
3.5.3.0
- Return type:
CredentialSourceKind
- property gateways¶
Gets all currently known gateways.
- Version added:
3.5.8.0
- Return type:
- Returns:
A python tuple containing the gateways.
- property gateway_drivers¶
Gets the gateway drivers.
- Version added:
3.5.8.0
- Return type:
- Returns:
A python tuple containing all gateway drivers.
- register_trusts_certificate(device_object, callback, current_node_name=None)¶
Register a callback which allows to specify if the certificate of a PLC is trusted for the encrypted communication.
- Version added:
3.5.17.0
- Parameters:
device_object (
ScriptObject
) – Device object which provides the node name and Object GUID to get the TLS communication validator.callback (
TrustsCertificateCallback()
) – Callback of the type TrustsCertificateCallback.current_node_name (str) – Optional, node name of the PLC if the parameter device_object can’t provide the node name.
- unregister_trusts_certificate(device_object, current_node_name=None)¶
Unregister a previously registered callback which allowed to specify if the certificate of a PLC is trusted for the encrypted communication.
Use the same parameters as from the registration process.
- Version added:
3.5.17.0
- Parameters:
device_object (
ScriptObject
) – Device object which provides the node name and Object GUID to get the TLS communication validator.current_node_name (str) – Optional, node name of the PLC if the parameter device_object can’t provide the node name.
- unregister_all_trusts_certificate()¶
Unregister all previously registered callbacks which allowed to specify if the certificate of a PLC is trusted for the encrypted communication.
- Version added:
3.5.17.0
- class ScriptOnline.ScriptOnlineApplication¶
Bases:
object
Online application object.
Some of the commands may temporarily change the active application.
This object keeps an internal connection to the device, so it should be disposed when you don’t need it any more: Call the Dispose() method when you’re done with it, or - even better - use the with statement. It will be automatically disposed when the script execution ends, but in long running scripts, you should dispose it yourself to prevent resource leaks, and other side effects of the open connection.
- login(change_option, delete_foreign_apps)¶
Performs the application login.
If the application was logged in before, it will be logged out and a fresh login will be performed.
- Parameters:
change_option (
OnlineChangeOption
) – The change option.delete_foreign_apps (bool) – If set to
True
, delete foreign applications.
- logout()¶
Logs this application out. If the application is not logged in, nothing happens.
- property is_logged_in¶
Gets a value indicating whether this
ScriptOnlineApplication
is logged in.- Return type:
bool
- Returns:
True
if is logged in; otherwise,False
.
- start()¶
Starts this application.
- Raises:
TimeoutException – In case of the operation taking to long.
- stop()¶
Stops this application.
- Raises:
TimeoutException – In case of the operation taking to long.
- property application_state¶
Gets the application state.
- Return type:
- property operation_state¶
Gets the operation status.
- Return type:
- create_boot_application()¶
Creates a boot application for this application on the device.
If the current application is not online, a file dialog asks the user for a path to write the boot file for. You may want to use
ScriptApplication.create_boot_application()
instead.
- source_download()¶
Downloads the source archive to the device.
- write_prepared_values()¶
Writes the prepared values.
- Raises:
ValuesFailedException – If the write of some values fails.
- force_prepared_values()¶
Forces the prepared values.
- Raises:
ValuesFailedException – If the force of some values fails.
- unforce_all_values()¶
Unforces all forced values for the current application.
- Raises:
ValuesFailedException – If the unforce of some values fails.
- get_prepared_value(expression)¶
Gets the prepared value for a given expression.
- Parameters:
expression (str) – The expression
- Return type:
str
- Returns:
The prepared value, or
None
if nothing is prepared.
- read_value(expression)¶
Gets the current value for a given expression.
Monitoring must be enabled.
- Parameters:
expression (str) – The expression.
- Return type:
str
- Returns:
The value.
- read_values(expressions)¶
Gets the current values for a list of expressions.
Monitoring must be enabled.
- Parameters:
expressions (tuple[str]) – The expressions.
- Return type:
list[str]
- Returns:
The values.
- get_prepared_expressions()¶
Gets all expressions for values currently prepared for this application (including those prepared by other scripts, editors etc).
- Return type:
list[str]
- Returns:
The prepared expressions.
- get_forced_expressions()¶
Gets all expressions for values currently forced for this application (including those prepared by other scripts, editors etc).
- Return type:
list[str]
- Returns:
The forced expressions.
- set_prepared_value(expression, value)¶
Prepares values the specified expression.
Use None or the empty string to unprepare the value.
- Parameters:
expression (str) – The expression.
value (str) – The value.
- set_unforce_value(expression, restore=False)¶
Prepares the specified forced expression for unforcing.
- Parameters:
expression (str) – The expression.
restore (bool) – If set to
true
, the value is reset to the value before forcing.
- property timeout¶
Gets or sets the timeout for some operations.
Some operations like start() have to wait for defined application states. If those operations take longer than this timeout, a
TimeoutException
is thrown. The default timeout is 60 seconds.- Return type:
int
- reset(reset_option=ResetOption.Warm, force_kill=False)¶
Resets the online application. This also clears all breakpoints on the application (if any).
If the application is currently halted on a breakpoint, and the device supports to kill a task during the execution cycle (
TargetProperties.TaskKillable
), you can use theforce_kill
parameter to force the reset without running the current cycle to an end. If the device does not supportTargetProperties.TaskKillable
, this parameter will be ignored, and the current cycle will always be finished.- Version added:
3.5.0.0
- Parameters:
reset_option (ResetOption) – The reset_option.
force_kill (bool) – Force the immediate kill of the application without finishing of the current cycle.
- get_online_device()¶
Gets the online device for this application.
- Return type:
- property application¶
Gets the application object for this online application.
- Return type:
- class ScriptOnline.ScriptOnlineDevice¶
Bases:
object
Functionality for manipulating online device objects.
All device objects for which the online manager returns a IOnlineDevice7 instance are extended with this methods.
This object keeps an internal connection to the device, so it should be disposed when you don’t need it any more: Call the Dispose() method when you’re done with it, or - even better - use the with statement. It will be automatically disposed when the script execution ends, but in long running scripts, you should dispose it yourself to prevent resource leaks, and other side effects of the open connection.
- Version added:
3.5.0.0
- reset_origin()¶
Reset the device to the origin (shipping) state.
For example, all plc applications, boot applications, and retain and persistent variables are deleted.
- property device¶
Gets the underlying device object for this online device.
- Return type:
- connect()¶
Connects this instance. The connection is a shared connection to the device.
Please note that other actions like reset_origin may implicitly connect to the device.
- Version added:
3.5.2.0
- disconnect()¶
Disconnects this instance.
As the connection is shared, the underlying connection may actually stay open, for example when an application is still online.
- Version added:
3.5.2.0
- property connected¶
Gets a value indicating whether this
ScriptOnlineDevice
is connected.- Version added:
3.5.2.0
- Return type:
bool
Gets a value indicating whether this ScriptOnlineDevice or anything else has a shared connection to the device.
- Version added:
3.5.2.0
- Return type:
bool
- Returns:
True
if connected; otherwise,False
.
- forced_disconnect()¶
Forcibly disconnects all shared connections to the device (connections via online applications, as well as other connections), and resets the current login and session information.
- Version added:
3.5.2.0
- current_logged_on_username()¶
Gets the name of the user who is currently logged on in the device.
If
None
or an empty string is returned, nobody is logged on.- Version added:
3.5.2.0
- Return type:
str
- create_user_management(load_from_project=True)¶
Creates a new user management instance for this device.
For the devices with runtime V3.5.16.0 or newer you have to use
create_live_user_management()
because they only support the live user management.- Version added:
3.5.2.0
- Parameters:
load_from_project (bool) – By default, the instance is initialized with the information stored in the device object in the current project. By setting this parameter to false, you can suppress this loading, e. G. if you want to load the user management via the
ScriptDeviceUserManagement.upload()
orScriptDeviceUserManagement.load()
methods.- Return type:
- Returns:
The created user management instance.
- Raises:
WrongDeviceUserManagementException – Thrown if the device only supports the live user management.
- download_source(bCompact=False, additional_items=None)¶
Downloads the source archive to the device.
For a definition of the additional items, see
ScriptProjectArchiveCategories
. If you don’t pass anyadditional_items
,ScriptProjectArchiveCategories.default
is used. To exclude all additional items, explicitly passNone
.- Version added:
3.5.4.0
- Parameters:
bCompact (bool) – If
True
, the source archive will only contain the PLC and applications of the current device. IfFalse
, the source archive will contain all PLCs and all applications in the project.additional_items (tuple[:class:`ScriptProjectArchiveCategory]) – The additional items to include in the project archive.
- upload_source(archive_path)¶
Uploads the source from the device, and saves it under the specified output path.
This method will throw various Exceptions on errors.
- Version added:
3.5.4.0
- Parameters:
archive_path (str) – The local path where to save the project archive. (Usually ending with the extension .prj).
- download_file(local_file, remote_file, force_overwrite)¶
Download a file to the PLC.
- Version added:
3.5.9.0
- Parameters:
local_file (str) – Path of the local file.
remote_file (str) – Path of the remote file.
force_overwrite (bool) – Force the overwrite if the remote file already exists.
- upload_file(remote_file, local_file, force_overwrite)¶
Upload a file from the PLC.
- Version added:
3.5.9.0
- Parameters:
remote_file (str) – Path of the remote file.
local_file (str) – Path of the local file.
force_overwrite (bool) – Force the overwrite if the local file already exists.
- rename_file(old_name, new_name)¶
Rename a file on the PLC.
- Version added:
3.5.9.0
- Parameters:
old_name (str) – Path of the remote file with the old name.
new_name (str) – Path of the remote file with the new name.
- delete_file(remote_file)¶
Delete a file on the PLC.
- Version added:
3.5.9.0
- Parameters:
remote_file (str) – Path of the remote file.
- create_directory(remote_directory)¶
Create a directory on the PLC.
- Version added:
3.5.9.0
- Parameters:
remote_directory (str) – Path of the new directory.
- get_file_list_of_directory(remote_directory)¶
Read a directory on the PLC.
- Version added:
3.5.9.0
- Parameters:
remote_directory (str) – Path of the directory.
- Return type:
tuple[
ScriptDirectoryInfo
]- Returns:
Array of info elements which describe the files and directories inside the given remote directory.
- rename_directory(old_name, new_name)¶
Rename a directory on the PLC.
- Version added:
3.5.9.0
- Parameters:
old_name (str) – Path of the remote directory with the old name.
new_name (str) – Path of the remote directory with the new name.
- delete_directory(remote_directory, recursive)¶
Delete a directory on the PLC.
- Version added:
3.5.9.0
- Parameters:
remote_directory (str) – Path of the remote directory.
recursive (bool) – If
True
, delete the directory resursively.
- activate_license(ticket, url=None, license_names=None)¶
Performs a license activation on a remote device.
The first container returned be the device will be used for activation.
- Version added:
3.5.10.0
- Parameters:
ticket (str) – The ticket which contains the licenses.
url (str) – The license server. If
None
the default license server will be used.license_names (tuple[str]) – The licenses which should be activated. If
None
or if no license is specified, every kind of license will be activated by default.
- change_user_password(user, oldPassword, newPassword)¶
Update the passwort of a given user and reset the flag that the user must change the password on next login.
- Version added:
3.5.14.0
- Parameters:
user (str) – The user that shall be authentified.
oldPassword (str) – current password of the given user.
newPassword (str) – new password for the given user.
- create_live_user_management()¶
Create a new live user management which is required by PLC runtime V3.5.16.0 or newer.
You have to create a connection before calling this method otherwise you get an exception. With SP16 or newer version of the PLC runtime you can access the user management only when connected.
- Version added:
3.5.16.0
- Raises:
WrongDeviceUserManagementException – Thrown if the device does not support the live user management.
- Return type:
- set_credentials_for_initial_user(username, password, can_change_password=True, must_change_password=False)¶
Set the username and password for the initial user of the user management if the device requires it or you want one.
If the device requires an user management you need to specify an initial user otherwise you will get an exception. If it is not required and you don’t specify an initial user, no user management is created on the device.
- Version added:
3.5.16.0
- Parameters:
username (str) – Username of the initial user.
password (str) – Password of the initial user
can_change_password (bool) – User can change their password.
must_change_password (bool) – User must change their password with next login.
- exception ScriptOnline.ValuesFailedException¶
Bases:
Exception
This exception is thrown by
ScriptOnlineApplication.write_prepared_values()
andScriptOnlineApplication.force_prepared_values()
.- ValuesFailedException(failed_expressions)¶
Initializes a new instance of the
ValuesFailedException
class.- Parameters:
failed_expressions (list[str]) – The failed expressions.
- Return type:
- property failed_expressions¶
Gets the list of the failedexpressions.
- Return type:
list[str]
- class ScriptOnline.ScriptGateway¶
Bases:
object
Script engine representation of a configured gateway for runtime connections.
- Version added:
3.5.8.0
- property name¶
Gets the name of the gateway.
For backwards compatibility reasons, the gateway names are not guaranteed to be unique - several gateways with the same name may exist.
- Return type:
str
- property guid¶
Gets the unique identifier of the gateway.
- Version added:
3.5.8.0
- Return type:
Guid
- property gateway_driver¶
Gets the gateway protcol driver used for this gateway.
- Version added:
3.5.8.0
- Return type:
- property config_params¶
Gets a python dictionary with a copy of the current configuration of the gateway, using the
ScriptGatewayParameterDescription.id
as keys and the parameter values as values.- Version added:
3.5.8.0
- Return type:
object
- find_address_by_ip(address: IPAddress, port: int = 11740)¶
Finds an CODESYS address by scanning the network by IP or Hostname.
Currently, only IPv4 addresses are supported. This method blocks until either the device responded or the timeout for network scans is reached. Any exceptions coming form the communication layer will be thrown (e.g. if the Gateway is not running).
- Version added:
3.5.8.0
- Parameters:
address (IPAddress) – The IP address.
port (ushort) – The port.
- Raises:
TimeoutException – Thrown in case no device replies.
Exception – Any other exception forwarded from the communication layer.
- Return type:
string
- Returns:
The CODESYS address.
- perform_network_scan()¶
Performs a network scan on this gateway.
This method will block at least for the duration of the network scan timeout period.
- Version added:
3.5.8.0
- Raises:
Exception – Any exceptions occurring durint the network scan.
- Return type:
tuple[
ScriptScanTargetDescription
]- Returns:
The list of devices which were found.
- get_cached_network_scan_result()¶
Gets the cached result of the last network scan on this gateway.
- Return type:
tuple[
ScriptScanTargetDescription
]- Returns:
The list of devices which were found.
- class ScriptOnline.ScriptScanTargetDescription¶
Bases:
object
Description of a scan target found during a device scan.
- Version added:
3.5.8.0
- property device_name¶
Gets the name of the device.
Example: “PLCFeeder”. If no name has been explicitly assigned to the device, it is derived from the corresponding router address, e.g. “@127.5”.
- Return type:
str
- property type_name¶
Gets a string indicating the device type.
Example: “Beckhoff CX1000-100” or “BRC Motion Logic Controller”.
- Return type:
str
- property vendor_name¶
Gets a string indicating the device vendor.
Example: “Beckhoff” or “BRC”
- Return type:
str
- property device_id¶
Gets the ID of the type to be matched with the installed device types (target descriptions).
- Return type:
DeviceID
- property address¶
Gets the router address for this device.
A hierarchical addressing scheme is used. Example: “123.5”. Each component of the router address corresponds to an array element of the return value.
- Return type:
str
- property parent_address¶
Get the router address of the parent node of this device.
Usually this will be the device address without the last address component. Is
None
if the parentAddress is unknown.- Return type:
str
- property locked_in_cache¶
If set to true, the devicedescription will stay in the gateways device cache, even during rebuild.
So this is not a property of the device itself but a property of the device description object and may be changed by plugins.
- Return type:
bool
- property block_driver¶
Property to access the type of block driver used for this target.
- Return type:
- property block_driver_address¶
Property to store and retrieve the driver-specific address for this target.
- Return type:
str
- class ScriptOnline.ScriptGateways(iterable=(), /)¶
Bases:
list
A collection of gateways currently configured in CODESYS.
- Version added:
3.5.8.0
- find_with_name(name)¶
Finds all gateways with the name.
- Parameters:
name (str) – The name.
- Return type:
list[
ScriptGateway
]- Returns:
A (possibly empty) sequence of all gateways with the name.
- remove_gateway(guid: Guid)¶
Removes the specified gateway.
If the specified one is the default one, the next one (if any) will be the new default.
- Parameters:
gateway – The guid of the gateway to remove.
- add_new_gateway(name, parameters, driver=None, gateway_guid=None)¶
Creates and adds a new gateway.
The keys of the
parameters
dictionary need to be integers corresponding to theScriptGatewayParameterDescription.id
, theScriptGatewayParameterDescription
itself, or strings corresponding to theScriptGatewayParameterDescription.name
of the parameter (if the names are unique). The values will be converted using theconvert_gateway_parameter()
method.- Parameters:
name (str) – The name.
parameters (dict[int or str or ScriptGatewayParameterDescription, object]) – The gateway parameters (as a python dictionary).
driver (
ScriptGatewayDriver
) – The driver - if you don’t pass a driver, the default TCP/IP driver will be used.gateway_guid (Guid or None) – The gateway guid - if
None
is passed, a new one will be generated.
- Return type:
- class ScriptOnline.ScriptGatewayDrivers(iterable=(), /)¶
Bases:
list
Represents a list of script gateway drivers.
- Version added:
3.5.8.0
- find_with_name(name)¶
Finds all gateway drivers with the name.
- Parameters:
name (str) – The name.
- Return type:
list of
ScriptGatewayDriver
- Returns:
A (possibly empty) sequence of all gateway drivers with the name.
- property default_driver¶
Gets the default gateway driver (currently bound to TCP/IP on standard CODESYS and most derivates).
- Return type:
- class ScriptOnline.ScriptGatewayDriver¶
Bases:
object
Script engine representation of a gateway driver.
- Version added:
3.5.8.0
- property guid¶
A Guid that uniquely identifies the driver type.
Each implementation for a gateway driver is identified by a Guid.
- Return type:
Guid
- property name¶
Get the user-readable name of this gateway driver.
- Return type:
str
- property gateway_parameters¶
Gets the gateway parameter descriptions - those are used when a new gateway with this driver is created.
- Return type:
- Returns:
A collection containing the gateway parameters.
- class ScriptOnline.ScriptGatewayParameterDescriptions(iterable=(), /)¶
Bases:
list
A collection of script gateway parameters.
- Version added:
3.5.8.0
- class ScriptOnline.ScriptGatewayParameterDescription¶
Bases:
object
Description of parameters for a gateway driver - those are used when a new gateway with this driver is created.
- Version added:
3.5.8.0
- property id¶
The id of the parameter.
The id is unique for any particular gateway driver.
- Return type:
long
- property name¶
Human readable string, giving the name of the parameter.
- Return type:
str
- property description¶
Human readable string describing the parameter.
- Return type:
str
- property parameter_type¶
The type of the parameter value.
- The types here have finer granularity than the types
available in python. However, users don’t need to cast to the corresponding .NET types, this will be done by the script engine as long as the generic type kind is matching - e. G. a python integer is ok for all integer param types, or a single-character python string is ok for
ParamType.Char
.
- Return type:
- property default_value¶
Default value of the parameter. May be
None
.- Return type:
object
- validate(value)¶
Check whether the provided object is a valid value for this parameter.
You can use the
ScriptGateways.convert_gateway_parameter()
method to convert the parameter to the corresponding type.- Parameters:
value (object) – The value to check.
- Raises:
Exception – If the object is not valid.
- class ScriptOnline.ScriptDirectoryInfo¶
Bases:
object
Describes contents of a remote directory on the PLC.
- Version added:
3.5.9.0
- property name¶
Gets the name of the file/directory.
- Return type:
str
- property creation_time¶
Get the creation time of the file/directory.
- Return type:
DateTime
- property last_access_time¶
Get the last access time of the file/directory.
- Return type:
DateTime
- property last_modification_time¶
Get the last modification time of the file/directory.
- Return type:
DateTime
- property is_directory¶
Whether it is a directory.
- Return type:
bool
- property is_file¶
Whether it is a file.
- Return type:
bool
- property size¶
Get the file size in bytes.
- Return type:
int
- property additional_dir_info¶
Get the additional information of the file/directory.
- Return type:
- ScriptOnline.TrustsCertificateCallback(certificate, chain, node_name)¶
This callback allows to specify if the certificate of a PLC should be trusted for the encrypted communcation.
- Version added:
3.5.17.0
- Parameters:
certificate (X509Certificate2) – Certificate of the PLC.
chain (X509Chain) – Chain of trust.
node_name (str) – Name of the PLC.
- Return type:
bool
- Returns:
True, if you trust the certificate.