Thales File Interface
- class ThalesFileInterface(address, connectionName='FileExchange')
Class which realizes the file transfer between Term software and Python.
The measurement files cannot be stored on network drives with the Term software, therefore this class was implemented. If Python runs on another computer and controls Thales via network, then with this class the measurement result files can be exchanged via network.
This class establishes an additional socket connection to the Term, which can be used to transfer individual files manually. Or you can set that all ism, isc or isw files are transferred automatically at the end of the measurement.
- Parameters
address – IP address of the computer running the Term software.
connectionName – The name of the connection default FileExchange. But can also be freely assigned.
- close() None
close the file interface
The automatic file sending is disabled and the socket connection is closed.
- enableAutomaticFileExchange(enable: bool = True, fileExtensions: str = '*.ism*.isc*.isw*.iss') str
turn on automatic file exchange
If automatic file exchange is enabled, the files configured with the fileExtensions variable are transferred automatically.
In order for the files to be automatically saved to disk, this must be configured with the
enableSaveReceivedFilesToDisk()
method. With the methodenableKeepReceivedFilesInObject()
can be set whether the files should still remain in the Python object, so that you can read the received files as an array withgetReceivedFiles()
. The standard setting is that the files remain in the object.- Parameters
enable – Enable automatic file exchange. Default = True.
fileExtensions (string) – File extensions that will be exchanged. You can see the default paramter. But you can also specify only one type of file or more.
- Returns
The response string from the device.
- Return type
string
- appendFilesToSkip(file: Union[str, list[str]])
set filenames to be filtered and not processed by Python
Files with these names are not saved to disk by Python and do not remain in the object.
- Parameters
file – Filename or list with filenames to be filtered.
- disableAutomaticFileExchange() str
turn off automatic file exchange
- Returns
the response string from the device
- aquireFile(filename: str) Optional[FileData]
transfer a single file, deprecated because misspelled.
This command transfers a single from Term to Python. This command can only be executed if automatic transfer is disabled. If automatic transfer is enabled, None is returned. The parameter filename is used to specify the full path of the file, on the computer running the Thales software, to be transferred e.g. r”C:\THALES\temp\test1\myeis.ism”.
The function returns the file as dataclass.
- Parameters
filename – Filename with path on the Thales computer.
- Returns
A dataclass with the file or None if this command is called when automatic file exchange is activated.
- acquireFile(filename: str) Optional[FileData]
transfer a single file
This command transfers a single from Term to Python. This command can only be executed if automatic transfer is disabled. If automatic transfer is enabled, None is returned. The parameter filename is used to specify the full path of the file, on the computer running the Thales software, to be transferred e.g. r”C:\THALES\temp\test1\myeis.ism”.
The function returns the file as dataclass.
- Parameters
filename – Filename with path on the Thales computer.
- Returns
A dataclass with the file or None if this command is called when automatic file exchange is activated.
- setSavePath(path: str) None
set the path where the files should be saved on the local computer
This command sets only the path. If the path does not exist, it will be created. The path must be accessible by Python, otherwise there are no restrictions on the path.
- Parameters
path – Path where the files should be saved. For example r”D:\myLocalDirectory”.
- enableSaveReceivedFilesToDisk(enable: bool = True, path: Optional[str] = None) None
enable the automatic saving of files to the hard disk
This command configures that the files are automatically saved by Python. With this command the path can be passed with the optional parameter path. The path must be accessible by Python, otherwise there are no restrictions on the path. Default path is the current working directory of Python.
- Parameters
enable – Enable automatic file saving to the hard disk. Default = True.
path – Optional path where the files should be saved. For example r”D:\myLocalDirectory”.
- disableSaveReceivedFilesToDisk() None
disable the automatic saving of files to the hard disk
- enableKeepReceivedFilesInObject(enable: bool = True) None
Enable that the files remain in the Python object.
If you perform many measurements, the Python object would grow larger and larger due to the number of files, so you can disable that the files are stored in the object as an array. By default, the files remain in the object.
- Parameters
enable – True = Allow the files to remain in the object.
- disableKeepReceivedFilesInObject() None
disable that the files remain in the Python object
- getReceivedFiles() list[thales_remote.file_interface.FileData]
read all files from the Python object
This function returns an array. Each element in the array is a dictionary as described in function
aquireFile()
.- Returns
Array with the files from the Python object.
- getLatestReceivedFile() FileData
read the latest files from the Python object
- Returns
latest file from the Python object
- deleteReceivedFiles() None
delete all files from the Python object
- _saveReceivedFile(fileToWrite: FileData) None
saves the passed file to disk.
- _receiveFile(timeout: Optional[float] = None) Optional[FileData]
receive one file with optional timeout
- Parameters
timeout – receive timeout
- Returns
structure with the file
- _startWorker() None
starts the thread handling the asyncronously incoming data
- _stopWorker() None
stops the thread handling the incoming data gracefully
- _fileReceiverJob() None
method running in a separate thread; manages the received files