ScriptExternalFileObject

class ScriptExternalFileObject.ReferenceMode(value)

Bases: Enum

An enumeration.

LinkAndEmbed = (1,)
Embed = 2
class ScriptExternalFileObject.AutoUpdateMode(value)

Bases: Enum

This enumeration is used to control how changes in a physical file are reflected to the embedded data of a _3S.CoDeSys.Core.External.IFileReference.

Always = (0,)

Changes on the physical file are automatically reflected in the embedded data.

Prompt = (1,)

When the physical file changes, an event will be triggered in order to obtain information whether to automatically update the embedded data or not.

Never = 2

Changes on the physical file are not automatically reflected in the embedded data.

class ScriptExternalFileObject.ScriptExternalFileObjectMarker

Bases: object

Determines whether this object is an external file object or can contain them.

Version added:

3.5.9.0

property is_external_file_object

Gets a value indicating whether this ScriptObject is is an external file object.

Return type:

bool

Returns:

True if it is an external file object; otherwise, False.

property may_contain_external_file_objects

Gets a value indicating whether this ScriptObject or ScriptProject may contain external file objects.

The project root may always contain external file objects, those are not downloaded to the devices. Devices and Applications may contain files which are synchronized to the runtime, depending on the device description and settings.

Return type:

bool

Returns:

True if it may contain external file objects; otherwise, False

class ScriptExternalFileObject.ScriptExternalFileObject

Bases: ScriptExternalFileObjectMarker

Provides the actual functionality of the external file objects.

Version added:

3.5.9.0

property file_path

Gets the file path.

Return type:

str

property reference_mode

Gets the reference mode.

Return type:

ReferenceMode

property auto_update_mode

Gets the auto update mode.

Return type:

AutoUpdateMode

change_modes(reference_mode, auto_update_mode=AutoUpdateMode.Never)

Changes the modes of the external file object.

Parameters:
  • reference_mode (ReferenceMode) – The reference mode.

  • auto_update_mode (AutoUpdateMode`) – The auto update mode. This is optional, and only makes sense if reference_mode is set to ReferenceMode.LinkAndEmbed. Defaults to AutoUpdateMode.Never if omitted.

update()

Updates this instance.

calculate_checksum()

Calculates the checksum of the data.

Return type:

int

Returns:

The CRC 32 value of the data.

property last_modification

Gets the last modification date.

Return type:

DateTime

property length

Gets the length of the data in bytes.

Return type:

int

get_data(filename)

Gets the data by writing it to the specified filename.

Parameters:

filename (str) – The filename.

create_edit_path()

Gets the absolute path where this file reference is edited.

This is the absolute path itself if the file reference is linked to a file system object, or a temporary path if it is embedded into a project.

Return type:

str

Returns:

The edit path of this file reference.

class ScriptExternalFileObject.ScriptExternalFileObjectContainer

Bases: ScriptExternalFileObjectMarker

This interface is implemented by the project root, and by objects which can contain synchable external file objects.

The project root may always contain external file objects, those are not downloaded to the devices. Devices and Applications may contain files which are synchronized to the runtime, depending on the device description and settings.

Version added:

3.5.9.0

create_external_file_object(file_path, name=None, reference_mode=ReferenceMode.Embed, auto_update_mode=AutoUpdateMode.Never)

Creates an external file objects with the specified name.

Parameters:
  • file_path (str) – The file path with the contents of the external file object.

  • name (str) – The name. This is optional, if it is omitted, the filename will be extracted from the path.

  • reference_mode (ReferenceMode) – The reference mode.

  • auto_update_mode (AutoUpdateMode) – The automatic update mode.

Return type:

ScriptExternalFileObject

Returns:

The newly created external file object.