pascalSCADA OPM: s7family: Class TSiemensProtocolFamily

Pascal SCADA OPM

Class TSiemensProtocolFamily

Unit

s7family

Declaration

type TSiemensProtocolFamily = class(TProtocolDriver)

Description

TSiemensProtocolFamily

Hierarchy

Overview

Fields

Protected PDUIncoming:LongInt;
Protected PDUOutgoing:LongInt;
Protected FPLCs:TS7CPUs;
Protected FAdapterInitialized:Boolean;

Methods

Protected function GetTagInfo(tagobj:TTag):TTagRec; virtual;
Protected procedure SetBytes(Ptr:PByte; idx:LongInt; values:BYTES);
Protected function initAdapter:Boolean; virtual;
Protected function disconnectAdapter:Boolean; virtual;
Protected function connectPLC(var CPU:TS7CPU):Boolean; virtual;
Protected function disconnectPLC(var CPU:TS7CPU):Boolean; virtual;
Protected function exchange(var CPU:TS7CPU; var msgOut:BYTES; var msgIn:BYTES; IsWrite:Boolean):Boolean; virtual;
Protected procedure sendMessage(var msgOut:BYTES); virtual;
Protected function getResponse(var msgIn:BYTES; var BytesRead:LongInt):TIOResult; virtual;
Protected function SwapBytesInWord(W:Word):Word;
Protected procedure PrepareToSend(var msg:BYTES); virtual;
Protected procedure AddParam(var MsgOut:BYTES; const param:BYTES); virtual;
Protected procedure AddData(var MsgOut:BYTES; const data:BYTES); virtual;
Protected procedure InitiatePDUHeader(var MsgOut:BYTES; PDUType:LongInt); virtual;
Protected function NegotiatePDUSize(var CPU:TS7CPU):Boolean; virtual;
Protected function SetupPDU(var msg:BYTES; MsgOutgoing:Boolean; out PDU:TPDU; out error:integer):Boolean; virtual;
Protected procedure PrepareReadRequest(var msgOut:BYTES); virtual;
Protected procedure PrepareWriteRequest(var msgOut:BYTES); virtual;
Protected procedure PrepareReadOrWriteRequest(const WriteRequest:Boolean; var msgOut:BYTES); virtual;
Protected procedure AddToReadRequest(var msgOut:BYTES; iArea, iDBnum, iStart, iByteCount:LongInt); virtual;
Protected procedure AddParamToWriteRequest(var msgOut:BYTES; iArea, iDBnum, iStart:LongInt; buffer:BYTES); virtual;
Protected procedure AddDataToWriteRequest(var msgOut:BYTES; iArea, iDBnum, iStart:LongInt; buffer:BYTES); virtual;
Protected procedure RunPLC(CPU:TS7CPU);
Protected procedure StopPLC(CPU:TS7CPU);
Protected function S7ErrorCodeToProtocolErrorCode(code:Word):TProtocolIOResult;
Protected function DoublesToBytes(const Values:TArrayOfDouble; Start, Len:LongInt):BYTES;
Protected function BytesToDoubles(const ByteSeq:BYTES; Start, Len:LongInt):TArrayOfDouble;
Protected function CreatePLC(iRack, iSlot, iStation:LongInt):LongInt; virtual;
Protected procedure DeletePLC(PLCIndex:Integer); virtual;
Protected procedure UpdateMemoryManager(pkgin, pkgout:BYTES; writepkg:Boolean; ReqList:TS7ReqList; var ResultValues:TArrayOfDouble);
Protected procedure DoAddTag(TagObj:TTag; TagValid:Boolean); override;
Protected procedure DoDelTag(TagObj:TTag); override;
Protected procedure DoScanRead(Sender:TObject; var NeedSleep:LongInt); override;
Protected procedure DoGetValue(TagRec:TTagRec; var values:TScanReadRec); override;
Protected function DoWrite(const tagrec:TTagRec; const Values:TArrayOfDouble; Sync:Boolean):TProtocolIOResult; override;
Protected function DoRead(const tagrec:TTagRec; out Values:TArrayOfDouble; Sync:Boolean):TProtocolIOResult; override;
Public function SizeOfTag(aTag:TTag; isWrite:Boolean; var ProtocolTagType:TProtocolTagType):BYTE; override;
Public function LiteralTagAddress(aTag: TTag; aBlockTag: TTag=nil):AnsiString; override;
Public procedure OpenTagEditor(InsertHook: TAddTagInEditorHook; CreateProc: TCreateTagProc); override;
Public function HasTabBuilderEditor: Boolean; override;

Properties

Published property ReadSomethingAlways;

Description

Fields

Protected PDUIncoming:LongInt;

: Where PDU starts on incoming and outgoing packets.

Protected PDUOutgoing:LongInt;

: Where PDU starts on incoming and outgoing packets.

Protected FPLCs:TS7CPUs;

: Lists all CPU's being read by the protocol driver.

See also
TS7CPU
Protected FAdapterInitialized:Boolean;

: If the protocol needs to initialize the adapter, stores if it was initialized.

Methods

Protected function GetTagInfo(tagobj:TTag):TTagRec; virtual;

: Returns a structure with informations about the tag.

Protected procedure SetBytes(Ptr:PByte; idx:LongInt; values:BYTES);

: Gets a byte from a pointer of bytes. function GetByte(Ptr:PByte; idx:LongInt):LongInt; : Sets a byte in a pointer of bytes. procedure SetByte(Ptr:PByte; idx:LongInt; value:Byte); : Sets a lot of bytes in a pointer of bytes.

Protected function initAdapter:Boolean; virtual;

: Initializes the adapter, if needed.

Protected function disconnectAdapter:Boolean; virtual;

: Disconnects from adapter.

Protected function connectPLC(var CPU:TS7CPU):Boolean; virtual;

: Connects on a PLC.

Parameters
CPU
TS7CPU. Represents the PLC to connect.
Protected function disconnectPLC(var CPU:TS7CPU):Boolean; virtual;

: Disconnects from a PLC.

Parameters
CPU
TS7CPU. Represents the PLC to disconnect.
Protected function exchange(var CPU:TS7CPU; var msgOut:BYTES; var msgIn:BYTES; IsWrite:Boolean):Boolean; virtual;

: Exchange data with a PLC.

Parameters
CPU
TS7CPU. PLC to exchange data.
msgOut
BYTES. Packet to send to PLC.
msgIn
BYTES. Stores the received packet from PLC.
IsWrite
Boolean. Tells if the message to be send to PLC will write in PLC memory.
Returns

True if successful.

Protected procedure sendMessage(var msgOut:BYTES); virtual;

: Sends a message.

Parameters
msgOut
BYTES. Message to send.
Protected function getResponse(var msgIn:BYTES; var BytesRead:LongInt):TIOResult; virtual;

: Gets a incoming packet from the communication port.

Parameters
msgIn
BYTES. Stores the incoming packet.
BytesRead
LongInt. Packet length.
Returns

iorOK if was come some packet.

Protected function SwapBytesInWord(W:Word):Word;

: Swap the bytes of a word.

Parameters
W
Word. Word to swap their bytes.
Returns

The word with their bytes swaped.

Protected procedure PrepareToSend(var msg:BYTES); virtual;

: Prepares a message to be sent.

Parameters
msg
BYTES. Message to be prepared.
Protected procedure AddParam(var MsgOut:BYTES; const param:BYTES); virtual;

: Adds a parameter into the message to be sent.

Parameters
MsgOut
BYTES. Message to be sent.
param
BYTES. Parameter to be added.
Protected procedure AddData(var MsgOut:BYTES; const data:BYTES); virtual;

: Adds a dataset into the message to be sent.

Parameters
MsgOut
BYTES. Message to be sent.
data
BYTES. Data to be added.
Protected procedure InitiatePDUHeader(var MsgOut:BYTES; PDUType:LongInt); virtual;

: Initialize the PDU on outgoing message.

Parameters
MsgOut
BYTES. Outgoing message to initiate the PDU.
PDUType
LongInt. Kind of PDU to create.
Protected function NegotiatePDUSize(var CPU:TS7CPU):Boolean; virtual;

: Negotiate the maximum PDU size.

Parameters
CPU
TS7CPU. PLC to negotiate the maximum PDU size.
Protected function SetupPDU(var msg:BYTES; MsgOutgoing:Boolean; out PDU:TPDU; out error:integer):Boolean; virtual;

: Creates a PDU structure from message.

Parameters
msg
BYTES. Menssage to get the PDU structure.
MsgOutgoing
Boolean. If True the message will be sent to PLC, if not the message is comming from the PLC.
PDU
TPDU. The PDU structure extracted from message.
Returns

The error number of PDU, if exists.

Protected procedure PrepareReadRequest(var msgOut:BYTES); virtual;

: Prepares the message to do a memory read request from PLC.

Parameters
msgOut
BYTES. Message to be sent to PLC requesting a memory read.
Protected procedure PrepareWriteRequest(var msgOut:BYTES); virtual;

: Prepares the message to write data into the PLC memory.

Parameters
msgOut
BYTES. Message to sent to write data into the PLC memory.
Protected procedure PrepareReadOrWriteRequest(const WriteRequest:Boolean; var msgOut:BYTES); virtual;

: Prepares the message to read or write on PLC.

Parameters
WriteRequest
Boolean. If True, the message will write something in PLC memory.
msgOut
BYTES. Message to be prepared to request a read/write.
Protected procedure AddToReadRequest(var msgOut:BYTES; iArea, iDBnum, iStart, iByteCount:LongInt); virtual;

: Add into the outgoing message, informations about what must be read from PLC.

Parameters
msgOut
BYTES. Message to be sent to PLC requesting a memory read.
iArea
LongInt. Wanted memory area.
iDBnum
LongInt. If iArea is vtS7_DB, what's the DB number.
iStart
LongInt. Start address of memory.
iByteCount
LongInt. How many bytes to read.
Protected procedure AddParamToWriteRequest(var msgOut:BYTES; iArea, iDBnum, iStart:LongInt; buffer:BYTES); virtual;

: Add into the outgoing message, informations about the data to be written on PLC.

Parameters
msgOut
BYTES. Message to be sent to write data on PLC.
iArea
LongInt. Wanted memory area.
iDBnum
LongInt. If iArea is vtS7_DB, what's the DB number.
iStart
LongInt. Start address of memory.
buffer
BYTES. Data to be written on PLC.
Protected procedure AddDataToWriteRequest(var msgOut:BYTES; iArea, iDBnum, iStart:LongInt; buffer:BYTES); virtual;

: Add into the outgoing message the data to be written on PLC.

Parameters
msgOut
BYTES. Message to be sent to write data on PLC.
iArea
LongInt. Wanted memory area.
iDBnum
LongInt. If iArea is vtS7_DB, what's the DB number.
iStart
LongInt. Start address of memory.
buffer
BYTES. Data to be written on PLC.
Protected procedure RunPLC(CPU:TS7CPU);

: Put the PLC in RUN state, if possible. Don't work yet.

Protected procedure StopPLC(CPU:TS7CPU);

: Stops the PLC, if possible. Don't work yet.

Protected function S7ErrorCodeToProtocolErrorCode(code:Word):TProtocolIOResult;

: Converts a Siemens error code to a protocol error code.

Protected function DoublesToBytes(const Values:TArrayOfDouble; Start, Len:LongInt):BYTES;

: Converts TArrayOfDouble to BYTES.

Parameters
Values
TArrayOfDouble. Array to be converted.
Start
LongInt. First element of Values to be converted.
Len
LongInt. How many elements to convert from Start.
Returns

Converted Array of BYTES.

Protected function BytesToDoubles(const ByteSeq:BYTES; Start, Len:LongInt):TArrayOfDouble;

: Converts BYTES to TArrayOfDouble.

Parameters
ByteSeq
BYTES. Array of byte to be converted to Double.
Start
LongInt. First element of ByteSeq to be converted.
Len
LongInt. How many elements to convert from Start.
Returns

Array of TArrayOfDouble.

Protected function CreatePLC(iRack, iSlot, iStation:LongInt):LongInt; virtual;

: Creates a PLC in the addressed PLC's list.

Parameters
iRack
LongInt. PLC Rack.
iSlot
LongInt. PLC Slot.
iStation
LongInt. PLC Address.
Returns

The PLC index on PLC list.

Protected procedure DeletePLC(PLCIndex:Integer); virtual;

: Delete a PLC from the addressed PLC's list.

Parameters
PLCIndex
LongInt. Index of PLC in the PLC's list.
Protected procedure UpdateMemoryManager(pkgin, pkgout:BYTES; writepkg:Boolean; ReqList:TS7ReqList; var ResultValues:TArrayOfDouble);

: Updates the manager of non-continuous memory blocks.

Parameters
pkgin
BYTES. Message received from PLC
pkgout
BYTES. Message sent to PLC
writepkg
Boolean. If True, the packet sent will change the PLC memory.
ReqList
TS7ReqList. List of all requests sent.
ResultValues
TArrayOfDouble. Values of the last request.
Protected procedure DoAddTag(TagObj:TTag; TagValid:Boolean); override;

:

See also
TProtocolDriver.DoAddTag
Protected procedure DoDelTag(TagObj:TTag); override;

:

See also
TProtocolDriver.DoDelTag
Protected procedure DoScanRead(Sender:TObject; var NeedSleep:LongInt); override;

:

See also
TProtocolDriver.DoScanRead
Protected procedure DoGetValue(TagRec:TTagRec; var values:TScanReadRec); override;

:

See also
TProtocolDriver.DoGetValue
Protected function DoWrite(const tagrec:TTagRec; const Values:TArrayOfDouble; Sync:Boolean):TProtocolIOResult; override;

estas funcoes ficaram apenas por motivos compatibilidade com os tags e seus metodos de leitura e escrita diretas. :

See also
TProtocolDriver.DoWrite
Protected function DoRead(const tagrec:TTagRec; out Values:TArrayOfDouble; Sync:Boolean):TProtocolIOResult; override;

:

See also
TProtocolDriver.DoRead
Public function SizeOfTag(aTag:TTag; isWrite:Boolean; var ProtocolTagType:TProtocolTagType):BYTE; override;

:

See also
TProtocolDriver.SizeOfTag
Public function LiteralTagAddress(aTag: TTag; aBlockTag: TTag=nil):AnsiString; override;

:

See also
TProtocolDriver.LiteralTagAddress
Public procedure OpenTagEditor(InsertHook: TAddTagInEditorHook; CreateProc: TCreateTagProc); override;

:

See also
TProtocolDriver.OpenTagEditor
Public function HasTabBuilderEditor: Boolean; override;

:

See also
TProtocolDriver.HasTabBuilderEditor

Properties

Published property ReadSomethingAlways;

:

See also
TProtocolDriver.ReadSomethingAlways

Generated by PasDoc 0.14.0.