Questo sito utilizza i cookie per migliorare servizi ed esperienza degli utenti. Se decidi di continuare la navigazione consideriamo che accetti il loro uso.

Panoramica Cerca Sopra
Dettagli del download
Sample20a: FileIO-Cyclic Read / W Sample20a: FileIO-Cyclic Read / Write
(0 voti)

This sample shows how to access files reading and/or writing from the CycleUpdate method, thus in a cyclic way.

This sample contains the following projects and module instances.

A static library (TcAsyncFileIo) providing the file access.
Code for file access could be shared, thus this code is located in a static library used by the driver projects.
One driver (TcAsyncBufferReadingDrv) providing two instances
ReadingModule: Uses the static library to read the file AsyncTest.txt
WriteDetectModule: Detecting write operations and initializing reads
One driver (TcAsyncBufferWritingDrv) providing one instance
WriteModule: Uses the static library to write the file AsyncTest.txt

When starting the sample, the writing module starts writing data to the file, which will be located in the Bootproject-Path (usually C:TwinCAT3.xBootAsyncTest.txt). The input variable “bDisableWriting” could be used in inhibit writing.

The objects are connected to each other: After writing is done the WritingModule triggers the DetectModule of the TcAsyncBufferReadingDrv. This initiates a read operation by the ReadingModule.

Please monitor the “nBytesWritten” / “nBytesRead” output variables of the WritingModule / ReadingModule. Additionally, log messages are generated on level “verbose”. As usual, these could be configured using the TraceLevelMax Parameter of the modules.

One driver (TcAsyncFileFindDrv) providing one instance
FileFindModule: Uses the static library to list files of a directory

Use the input variable “bExecute” to trigger the action. The Parameter “FilePath” holds the directory to list (default: “c:TwinCAT3.1Boot*”).

Please monitor the trace (Loglevel “Verbose”) for list of found files.

 

Understanding the Sample

The TcAsyncFileIO project contains different classes in a static library. This library is used by the driver projects for reading and writing.

Each class is dedicated to represent one file-access operation like open / read / write / list / close / ... Since the execution is done within a cyclic real time-context, each operation has a state and the class encapsulates this statemachine.

As an entry point for understanding the file access, please start with the TcFsmFileReader and TcFsmFileWriter classes.

 

If there are too much trace messages for understanding the sample, disable modules!

Informazioni

Versione:
Dimensione87.67 KB
Downloads0
Lingua
Licenza
Autore
Sito Web
Prezzo
Creato17-02-2015
Creato da
Modificato il17-02-2015
Modificato daroby

Solo gli utenti registrati e loggati possono scaricare questo file.

.

.