pascalSCADA OPM: ProtocolDriver: Class TProtocolDriver

Pascal SCADA OPM

Class TProtocolDriver

Unit

ProtocolDriver

Declaration

type TProtocolDriver = class(TComponent, IPortDriverEventNotification)

Description

TProtocolDriver

Hierarchy

  • TComponent
  • TProtocolDriver

Overview

Fields

Protected PReadSomethingAlways:Boolean;
Protected PUpdatingMultipleTags:Integer;
Protected FProtocolReady:Boolean;
Protected PDriverID:Cardinal;
Protected PCommPort:TCommPortDriver;
Protected FScanReadID:Cardinal;
Protected FScanWriteID:Cardinal;
Protected FReadID:Cardinal;
Protected FWriteID:Cardinal;
Protected FReadCS:TCriticalSection;
Protected FWriteCS:TCriticalSection;
Protected FPause:TCrossEvent;
Protected PCallersCS:TCriticalSection;

Methods

Protected procedure HighLatencyOperationWillBegin(Sender:TObject);
Protected procedure HighLatencyOperationWasEnded(Sender:TObject);
Protected function GetPortOpenedEvent:TNotifyEvent;
Protected function GetPortClosedEvent:TNotifyEvent;
Protected function GetPortDisconnectedEvent:TNotifyEvent;
Protected function NotifyThisEvents:TNotifyThisEvents; virtual;
Protected procedure PortOpened(Sender: TObject); virtual;
Protected procedure PortClosed(Sender: TObject); virtual;
Protected procedure PortDisconnected(Sender: TObject); virtual;
Protected procedure SetCommPort(CommPort:TCommPortDriver);
Protected procedure CopyIOPacket(const Source:TIOPacket; var Dest:TIOPacket);
Protected procedure CommPortCallBack(var Result:TIOPacket); virtual;
Protected procedure DoAddTag(TagObj:TTag; TagValid:Boolean); virtual;
Protected procedure DoDelTag(TagObj:TTag); virtual;
Protected procedure DoScanRead(Sender:TObject; var NeedSleep:LongInt); virtual; abstract;
Protected procedure DoGetValue(TagRec:TTagRec; var values:TScanReadRec); virtual; abstract;
Protected function DoWrite(const tagrec:TTagRec; const Values:TArrayOfDouble; Sync:Boolean):TProtocolIOResult; virtual; abstract;
Protected function DoRead (const tagrec:TTagRec; out Values:TArrayOfDouble; Sync:Boolean):TProtocolIOResult; virtual; abstract;
Public procedure AddTag(TagObj:TTag);
Public procedure StartUpdateMultipleTags;
Public procedure StopUpdateMultipleTags;
Public procedure RemoveTag(TagObj:TTag);
Public function IsMyTag(TagObj:TTag):Boolean;
Public function SizeOfTag(aTag:TTag; isWrite:Boolean; var ProtocolTagType:TProtocolTagType):BYTE; virtual; abstract;
Public function ScanRead(const tagrec:TTagRec):Cardinal;
Public function ScanWrite(const tagrec:TTagRec; const Values:TArrayOfDouble):Cardinal;
Public procedure Read(const tagrec:TTagRec);
Public procedure Write(const tagrec:TTagRec; const Values:TArrayOfDouble);
Public function LiteralTagAddress(aTag:TTag; aBlockTag:TTag=nil):AnsiString; virtual;
Public procedure OpenTagEditor(InsertHook:TAddTagInEditorHook; CreateProc:TCreateTagProc); virtual;
Public function HasTabBuilderEditor:Boolean; virtual;

Properties

Protected property ReadSomethingAlways: Boolean read PReadSomethingAlways write PReadSomethingAlways default true;
Protected property ReadOnly: Boolean read GetIsReadOnly write SetIsReadOnly;
Public property TagCount: LongInt read GetTagCount;
Public property Tag[index:LongInt]: TTag read GetTag;
Public property TagName[index:LongInt]: AnsiString read GetTagName;
Public property TagByName[Nome:AnsiString]: TTag read GetTagByName;
Published property CommunicationPort: TCommPortDriver read PCommPort write SetCommPort nodefault;
Published property DriverID: Cardinal read PDriverID;
Published property AvgTagUpdateTime: Double read FUserUpdateTime;

Description

Fields

Protected PReadSomethingAlways:Boolean;

: Tells if at least one item must be read at each scan cycle of protocol driver.

Protected PUpdatingMultipleTags:Integer;

: Missing comment.

Protected FProtocolReady:Boolean;

: Tells if the protocol driver is ready

Protected PDriverID:Cardinal;

: Stores the unique identification of protocol driver.

Protected PCommPort:TCommPortDriver;

: Stores the communication port driver used by protocol driver.

Protected FScanReadID:Cardinal;

: Stores the unique identification of each kind of request.

Protected FScanWriteID:Cardinal;

: Stores the unique identification of each kind of request.

Protected FReadID:Cardinal;

: Stores the unique identification of each kind of request.

Protected FWriteID:Cardinal;

: Stores the unique identification of each kind of request.

Protected FReadCS:TCriticalSection;

: Mutex that protect the protocol driver.

Protected FWriteCS:TCriticalSection;

: Mutex that protect the protocol driver.

Protected FPause:TCrossEvent;

: Stop thread to keep the normal execution of the all system.

Protected PCallersCS:TCriticalSection;

: Mutex that protect the scan procedures of the protocol driver.

Methods

Protected procedure HighLatencyOperationWillBegin(Sender:TObject);

: Tells to driver that a high latency operation will begins, releasing some resources of the driver.

Protected procedure HighLatencyOperationWasEnded(Sender:TObject);

: Tells to driver that a high latency operation was ended, taking back some resources back to driver.

Protected function GetPortOpenedEvent:TNotifyEvent;

: Returns the procedure of protocol driver that must be called when the communication port was open.

See also
PortOpened
NotifyThisEvents
Protected function GetPortClosedEvent:TNotifyEvent;

: Returns the procedure of protocol driver that must be called when the communication port was closed.

See also
PortClosed
NotifyThisEvents
Protected function GetPortDisconnectedEvent:TNotifyEvent;

: Returns the procedure of protocol driver that must be called when the communication port was disconnected.

See also
PortDisconnected
NotifyThisEvents
Protected function NotifyThisEvents:TNotifyThisEvents; virtual;

: Returns what's the events of communication port driver must be notified to protocol driver.

See also
PortOpened
PortClosed
PortDisconnected
TNotifyEvent
Protected procedure PortOpened(Sender: TObject); virtual;

: Procedure called by the communication port when it was open.

See also
NotifyThisEvents
GetPortOpenedEvent
Protected procedure PortClosed(Sender: TObject); virtual;

: Procedure called by the communication port when it was closed.

See also
NotifyThisEvents
GetPortClosedEvent
Protected procedure PortDisconnected(Sender: TObject); virtual;

: Procedure called by the communication port when it was disconnected.

See also
NotifyThisEvents
GetPortDisconnectedEvent
Protected procedure SetCommPort(CommPort:TCommPortDriver);

: Sets the communication port driver that will be used by the protocol driver.

Protected procedure CopyIOPacket(const Source:TIOPacket; var Dest:TIOPacket);

: Copies a TIOPacket to another

Parameters
Source
TIOPacket. Source record.
Dest
TIOPacket. Destination record.
Protected procedure CommPortCallBack(var Result:TIOPacket); virtual;

: Callback called by the communication port driver to returns the result of I/O. (Result TIOPacket. Record with the data and I/O results returned by the communication port. Is destroyed automaticaly.

Parameters
Protected procedure DoAddTag(TagObj:TTag; TagValid:Boolean); virtual;

: Procedure called to add a tag into the scan of the protocol driver.

Parameters
TagObj
TTag. Tag to be added into the scan of protocol driver.
See also
AddTag
Protected procedure DoDelTag(TagObj:TTag); virtual;

: Procedure called to remove a tag from the scan of the protocol driver.

Parameters
TagObj
TTag. Tag to be removed of the scan of protocol driver.
See also
RemoveTag
Protected procedure DoScanRead(Sender:TObject; var NeedSleep:LongInt); virtual; abstract;

: Procedure called by the protocol driver threads to check if has some tags that must be updated/readed from device.

Parameters
Sender
TObject. Thread that's calling the procedure.
NeedSleep
LongInt. If the procedure did not found anything to be read/updated, write in this variable a negative value to force the scheduler of the OS to switch to another thread, or a positive value to make the caller thread sleep. The time of the sleep is the value of this variable. If this procedure found some tag that was updated, write 0 (zero) on this variable.
See also
TProtocolDriver.DoRead
Protected procedure DoGetValue(TagRec:TTagRec; var values:TScanReadRec); virtual; abstract;

: Procedure called by the protocol driver threads to update the tag values.

Parameters
TagRec
TTagRec. Structure with informations about the tag.
values
TScanReadRec. Array with the tag values.
Protected function DoWrite(const tagrec:TTagRec; const Values:TArrayOfDouble; Sync:Boolean):TProtocolIOResult; virtual; abstract;

: Function called to write tag values (single or block) on device.

.

Parameters
tagrec
TTagRec. Strucutre with informations about the tag.
Values
TArrayOfDouble. Values to be written on device.
Returns

TProtocolIOResult

Protected function DoRead (const tagrec:TTagRec; out Values:TArrayOfDouble; Sync:Boolean):TProtocolIOResult; virtual; abstract;

: Function called to read values from your device.

.

Parameters
tagrec
TTagRec. Strucutre with informations about the tag.
Values
TArrayOfDouble. Array that will store the values read from your device.
Returns

TProtocolIOResult

Public procedure AddTag(TagObj:TTag);

: Add a tag into the scan cycle of the protocol driver.

Parameters
Tag
TTag. Tag to be added into scan cycle of the protocol driver.
Exceptions raised
Exception
if something is wrong.
Public procedure StartUpdateMultipleTags;
 
Public procedure StopUpdateMultipleTags;
 
Public procedure RemoveTag(TagObj:TTag);

: Remove a tag from the scan cycle of the protocol driver.

Parameters
Tag
TTag. Tag to be removed.
Public function IsMyTag(TagObj:TTag):Boolean;

: Function that returns if the tag is already linked with the protocol driver.

Parameters
TagObj
TTag. Tag to be checked if it's linked.
Returns

True if the tag is linked with protocol.

Public function SizeOfTag(aTag:TTag; isWrite:Boolean; var ProtocolTagType:TProtocolTagType):BYTE; virtual; abstract;

: Returns the word size of the tag on protocol, in bits.

Parameters
Tag
TTag. Tag that wants know the word size.
isWrite
Boolean. If True, returns the word size if want know the size using the write function.
Returns

The current word size on protocol of the tag, OR 0 (zero) if it fails.

Public function ScanRead(const tagrec:TTagRec):Cardinal;

: Requests a tag update.

Parameters
tagrec
TTagRec. Record with informations about the tag.
Returns

Cardinal. The unique identification number of the request.

Public function ScanWrite(const tagrec:TTagRec; const Values:TArrayOfDouble):Cardinal;

: Write values asynchronous using the scan of the protocol driver.

Parameters
tagrec
TTagRec. Record with informations about the tag.
Values
TArrayOfDouble Values to be written.
Returns

Cardinal. The unique identification number of the request.

Public procedure Read(const tagrec:TTagRec);

: Read the tag value from the device (synchronous).

Parameters
tagrec
TTagRec. Record with informations about the tag.
Public procedure Write(const tagrec:TTagRec; const Values:TArrayOfDouble);

: Write the tag values (synchronous).

Parameters
tagrec
TTagRec. Record with informations about the tag.
Values
TArrayOfDouble Values to be written.
Public function LiteralTagAddress(aTag:TTag; aBlockTag:TTag=nil):AnsiString; virtual;

: Returns the literal address of the tag.

Public procedure OpenTagEditor(InsertHook:TAddTagInEditorHook; CreateProc:TCreateTagProc); virtual;

: Opens the Tag Builder of the protocol driver (if exists)

Public function HasTabBuilderEditor:Boolean; virtual;

: Tell to the protocol editor if the current protocol has a tab builder tool defined.

Properties

Protected property ReadSomethingAlways: Boolean read PReadSomethingAlways write PReadSomethingAlways default true;

: Tells if the protocol driver must read something on each scan cycle.

Protected property ReadOnly: Boolean read GetIsReadOnly write SetIsReadOnly;

: Average time in milliseconds used to update values of tags and their dependents.

Public property TagCount: LongInt read GetTagCount;

: Return how many tags are on scan cycle of the protocol driver.

Public property Tag[index:LongInt]: TTag read GetTag;

: Return the tags using the index.

Public property TagName[index:LongInt]: AnsiString read GetTagName;

: Return the tag names.

Public property TagByName[Nome:AnsiString]: TTag read GetTagByName;

: Returns the tag by the name index.

Published property CommunicationPort: TCommPortDriver read PCommPort write SetCommPort nodefault;

: Communication port driver used by the protocol driver.

See also
TCommPortDriver
The base class of an communication port driver.
Published property DriverID: Cardinal read PDriverID;

: Unique protocol identification.

Published property AvgTagUpdateTime: Double read FUserUpdateTime;

: Average time in milliseconds used to update values of tags and their dependents.


Generated by PasDoc 0.14.0.