Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
TAfComPort
Provides basic serial communication functions. It can be used as a data provider for a
data dispatcher.
procedure Close;
Reads the character from the input buffer. If there isn't any character to read, an exception is
raised
procedure ReadData(var Buf; Size: Integer);
Reads the specified number of bytes from input buffer. If there aren't enough data to read, an
exception is raised
function ReadToString: String;
Reads all the data from the input buffer into string
procedure SynchronizeEvent(EventKind: TAfComPortEventKind;
Data: TAfComPortEventData; Timeout: Integer);
Performs normal synchronized events processing. This method should be called from
OnNonSyncEvent only.
procedure WriteChar(C: Char);
Writes the character to the output buffer. If there isn't enough space in the output buffer, an
exception is raised. See OutBufSize property
procedure WriteData(const Data; Size: Integer); override;
Writes the data to the output buffer. It there isn't enough space in the output buffer, an exception
is raised. See OutBufSize property
procedure WriteString(const S: String);
Writes the string to the output buffer. It there isn't enough space in the output buffer, an exception
is raised. See OutBufSize property
property Active: Boolean;
[ReadOnly]
Returns whether transmission is waiting because the XOFF character was received
property XOffSent: Boolean; [ReadOnly]
Returns whether transmission is waiting because the XOFF character was transmitted
property CTS: Boolean; [ReadOnly]
Returns string that contains port number and current communication parameters
(e.g. COM1: 115200,N,8,1)
property AutoOpen: Boolean;
When it is True, the Open method is called after creating the component. Default is False.
Specifies the baud rate used by the communication port. Value brUser allows to specify nonstandard baud rate. See UserBaudRate property
property Databits: TAfDatabits;
TAfDatabits = (db4, db5, db6, db7, db8);
Specifies the user-defined baud rate of the communication port. Setting this property causes
setting BaudRate property to brUser
property WriteThreadPriority: TThreadPriority;
Occurs when the state of CTS signal is changed. To determine the state of CTS signal use CTS
property
property OnDataRecived: TAfCPTDataReceivedEvent;
TAfCPTDataReceivedEvent = procedure(Sender: TObject; Count: Integer) of object;
Occurs when a data is received by communication port. Count is the actual number of bytes
avaiable to read.
You should read the whole number of bytes given in Count parameter. If you read less than Count
number of bytes, the remained data is still kept in internal device's driver buffer, but this event
won't occur until any new data is received. So you would never see the unread data until new
data came to the communication port.There is an internal checking of the number of unread bytes
every 200ms, it can solve this situation. If there are any unread data, the "false" event will occur
to allow you read that data.
Remember, the OnDataReceived event however never occurs when a data dispatcher has
assigned this component as a data provider. In this case, this event is delegated to the data
dispatcher. See TDataDispatcher.OnDataReceived
property OnDSRChanged: TNotifyEvent;
Occurs when the state of DSR signal is changed. To determine the state of DSR signal use DSR
property
property OnRLSDChanged: TNotifyEvent;
Occurs when the state of RLSD signal is changed. To determine the state of RLSD signal use
RLSD property
property OnRINGDetected: TNotifyEvent;
Occurs when the state of RING signal is changed. To determine the state of RING signal use
RING property
property OnLineError: TAfCPTErrorEvent;
TAfCPTErrorEvent = procedure(Sender: TObject; Errors: DWORD) of object;
Occurs when the communication port detects line error or line break. Errors is a code that
indicates type of error. See ClearCommError function and its lpErrors parameter in Win32 API
Help for details.
property OnNonSyncEvent: TAfCPTCoreEvent;
TAfCPTCoreEvent = procedure(Sender: TObject; EventKind: TAfComPortEventKind;
Data: TAfComPortEventData) of object;
TAfComPortEventData = DWORD;
TAfComPortEventKind = TAfCoreEvent;
If assigned it allows you to handle communication event from the event thread directly instead
handling it within VCL main thread synchronized events (e.g. OnDataReceived, OnSyncEvent..).
This approach allows you to handle this event faster than in synchronized events, for example if
your application must respond very fast.
Because VCL is not thread-safe, you can NEVER call any VCL method here, but you can call
SynchronizeEvent method from here and continue with normal message processing or use any
other synchronizing mechanism. Refer to the Examples\NonsyncEventExample for details.
property OnOutBufFree: TNotifyEvent;
This is centralized event of all the communication port events described above.
TAfDataDispatcher
Provides dispatching of incoming data and events into one or more "data-aware"
components. It has its own dispatcher buffer. It can be used with any data provider
component (e.g. TAfComPort) or separately.
procedure AbortWriteStream;
Performs clear command to the all "data-aware" components linked to the dispatcher
procedure ClearBuffer;
Reads the character from dispatcher buffer. If there isn't any character to read, an exception is
raised.
If it is called within OnDataReceived event it doesn't remove any data from dispatcher buffer until
all linked components have seen them.
procedure ReadData(var Buf; Size: Integer);
Reads the specified number of bytes from dispatcher buffer. If there aren't enough data to read,
an exception is raised. If it is called within OnDataReceived event it doesn't remove any data from
dispatcher buffer until all linked
components have seen them.
function ReadString: String;
Reads all the data from dispatcher buffer to string. If it is called within OnDataReceived event it
doesn't remove any data from dispatcher buffer until all linked components have seen them.
procedure WriteChar(C: Char);
Writes the stream to the specified data provider. If FreeAfterWrite is True, the stream will be
automatically destroyed after write finished or be aborted. The stream is sent by small blocks of
data which size is specified in StreamBlockSize property.
Occurs when a data are received from data provider (written to the dispatcher's buffer)
property OnWriteBufFree: TNotifyEvent;
Occurs when data provider's output data was sent. This event however won't occurs when writing
stream is in progress.
property OnWriteStreamBlock: TAfDispStreamEvent;
TAfLineViewer
Represents a virtual text viewer that displays text rows. It also support text highlighting
and user painted area on the control's left side.
property FocusedPoint: TPoint;
Cursor coordinates. TPoint here doesn't mean screen coordinates, but row and col.
property SelectedText: String; [ReadOnly]
When it is True (default), the control scrolls its context (if it is possible) instead repainting all
visible lines.
procedure CopyToClipboard;
Invalidates the desired text area. R here doesn't mean screen coordinates. When FullLine
parameter is True and R.Top = R.Bottom, R.Left and R.Right values are ignored and full text line
is invalidated.
procedure InvalidateFocusedLine;
Converts screen coordinates to the text coordinates (TPoint here doesn't mean screen
coordinates).
procedure ScrollIntoView;
Use ScrollIntoView to ensure that a focused row and column is in the visible area.
property CharHeight: Integer; [ReadOnly]
Sets the size of left user-painted area. This area resides between left side of the control and text
area. See OnDrawLeftSpace for details.
property LineCount: Integer;
Specifies the font style of selected text, see UsedFontStyles for details.
property UseFontCache: Boolean;
When True (default is False), the font style cache is used. It can speed up painting if different font
styles in each line are frequently used.
property UsedFontStyles: TFontStyles;
Specifies font styles for calculating global font height and width. This is important when different
font styles are used in painting.
For example, you would like to highlight some keywords in text by setting font style to Bold. If you
don't include [fsBold] in this property, the bold characters may not fit to calculated size.
property OnBof: TNotifyEvent;
Occurs when the first line is focused (FocusedPoint.Y = 0) and user presses UPARROW key.
property OnCursorChange: TAfCLVCursorEvent;
TAfCLVCursorEvent = procedure (Sender: TObject; CursorPos: TPoint) of object;
Occurs when the focused row or column is changed. CursorPos contains new coordinates.
property OnDrawLeftSpace: TAfCLVDrawLeftSpEvent;
TAfCLVDrawLeftSpEvent = procedure (Sender: TObject; const Line, LeftCharPos:
Integer;
Rect: TRect; State: TAfCLVLineState) of object;
TAfCLVLineState = (lsNormal, lsFocused, lsSelected);
Occurs when a left user-painted area needs to be drawn. Line indicates the row for that area
should be drawn. LeftCharPos indicates the first left visible position of text. State indicates state
of the row.
property OnEof: TNotifyEvent;
Occurs when the last line is focused (FocusedPoint.Y = LineCount - 1) and user presses
DOWNARROW key.
property OnFontChanged: TNotifyEvent;
Occurs when the user presses a mouse button with the mouse pointer over a left user-painted
area
property OnSelectionChange: TNotifyEvent;
TAfTerminal
Representes a terminal window with circular buffer and scroll back mode capability. It
doesn't support terminal emulation like ANSI or VT102, but it can highlight text with up to
16 different colors.
procedure ClearBuffer;
Draws the buffer. This should be called after WriteChar or WriteColorChar methods was called
procedure WriteChar(C: Char);
Writes the character to buffer. The characters written by this method won't be visible until
DrawChangedBuffer method is called
procedure WriteColorChar(C: Char; BColor, FColor: TAfTRMCharColor);
Writes the character to buffer with specified color. The characters written by this method won't be
visible until DrawChangedBuffer method is called.
procedure WriteColorStringAndData(const S: String; BColor, FColor:
TAfTRMCharColor;
UserDataItem: Pointer);
Writes the text with specified color and userdata (when UserDataItem <> nil) to buffer. You don't
have to call DrawChangedBuffer method after calling this method. See UserDataSize property for
details.
Writes the text to buffer. You don't have to call DrawChangedBuffer method after calling this
method.
property BufferLine[Index: Integer]: String; [ReadOnly]
ColorTable contains 16 colors which can be used in terminal. You can set another color palette by
this property.
property RelLineColors[Index: Integer]: TAfTRMCharAttrs;
TAfTRMCharAttrs = array[0..AfCLVMaxLineLength] of TAfTRMCharAttr;
This property is intended for use in OnGetColors event. You can set colors in any previous line
specified by offset from current line being processed. For example, RelLineColors[-1] returns or
set colors for the previous line.
property ScrollBackMode: Boolean;
When False (default), the terminal can show data written to it, users can't scroll back and read
older data.
When True, the terminal doesn't show new data, but users can scroll back and see whole context
of buffer. In this mode, new data are written to temporary buffer and after setting this property to
False are copied to terminal buffer and shown. See AutoScrollBack property.
property TermColor[Color: TColor]: Integer; [ReadOnly]
Returns terminal color index for the specified color. If the color exist, it raises an exception.
property UserData[Index: Integer]: Pointer;
Internal terminal buffer contains text and color information (depended on TermColor property).
Sometimes can be useful to have room for extra data in each line. The size of this room is
specified in UserDataSize property. You can read or write data using this property.
property AutoScrollBack: Boolean;
Specifies the number of rows in terminal buffer. It also clears terminal buffer.
property TerminalCaret: TAfCLVCaretType;
Specifies the size of user data room in terminal buffer. It also clears terminal buffer.
property OnBeepChar: TNotifyEvent;
Do NOT use, it is for debugging purposes only. It'll be removed in future versions
property OnFlushLog: TNotifyEvent;
Occurs before DrawChangedBuffer method is called to get color information for newly inserted
data. If TermColorMode = cmL16_16 you have to specify the color information in Colors[0]
property OnLoggingChange: TNotifyEvent;
Occurs when LF character is written into terminal buffer. Line contains line number of current line.
property OnProcessChar: TAfTRMProcessCharEvent;
TAfTRMProcessCharEvent = procedure (Sender: TObject; var C: Char) of object;
Occurs when new character is written into terminal buffer. You can replace it here or discard it by
setting C to #00.
property OnScrBckBufChange: TAfTRMScrBckBufChange;
Occurs when ScrollBackMode is True and new character is written to the temporary buffer. The
temporary buffer is theoretically unlimited, but you can limit its size here, by setting
ScrollBackMode to False when BufferSize exceeded some size.
property OnScrBckModeChange: TNotifyEvent;
Occurs when UserData is changed. Line contains number of line which use
TAfFileViewer
Represents a simple unlimited text file viewer. It can be used for displaying log files from
terminal window.
procedure CloseFile;
Specifies the filename, but doesn't open the file. See OpenFile method
property FileSize: DWORD; [ReadOnly]
When True (default) scanning the number of lines runs in separate thread
property OnScanBlock: TNotifyEvent;
Occurs when the next block (which size is specified in ScanBlockStep) has been scanned
TAfDataTerminal
Represents a "data-aware" terminal window. It is descendant of TAfTerminal and it allows
connect to a data dispatcher.
Specifies the state of terminal. When True (default), terminal can receive and send data through
assigned data dispatcher.
property Dispatcher: TAfCustomDataDispatcher;
TAfPortComboBox
This is a specialized combo box that allows users to select desired serial port.
property ComNumber: Word;
TAfPortRadioGroup
This is a specialized radio group that allows users to select desired serial port.
property ComNumber: Word;