Class TNoDave

TObject <-- ... <-- TComponent <-- TNoDave
Declared in Unit NoDaveComponent

No known Subclasses

Used by Classes:

TNoDaveConnectThread, TNoDaveReadThread

Description:

The Class TNoDave encapsulates the access to the libnodave.dll of Thomas Hergenhahn. All the settings for the communication are available in the properties of TNoDave.
Used in
Register, TNoDaveConnectThread, TNoDaveReadThread

List of Constructors:

public constructor Create
Initialize a new instance of the TNoDave component.

List of Destructors:

public destructor Destroy
Close an active connection and call the inherited Destroy method.

List of Methods:

protected function AreaCode
Determine the S7-ID of an Area.
protected function BufferAt
Return a Pointer to the requested PLC-data point within the buffer.
public procedure Connect
Open the connection to the PLC.
public procedure Disconnect
Close the connection to the PLC.
protected procedure DoConnect
Open the connection to the PLC specified by the properties Protocol, CPURack, CPUSlot, COMPort, IPAddress, IPPort, MPILocal, MPIRemote and/or MPISpeed
protected procedure DoOnConnect
Create the worker-thread for cyclic reading if neccessary and call the OnConnect-eventhandler if specified.
protected procedure DoOnDisconnect
Stop and Destroy the worker-thread for cyclic reading if neccessary and call the OnDisconnect-eventhandler if specified.
protected procedure DoOnError
Call the OnError-eventhandler if specified.
protected procedure DoOnRead
Call the OnRead-eventhandler if specified.
protected procedure DoOnWrite
Call the OnWrite-eventhandler if specified.
protected procedure DoReadBytes
Read the PLC-data into the buffer.
public procedure DoSetDebug
Set the debug-options of the libnodave.dll
protected procedure DoWriteBytes
Write the Buffer-data into the PLC.
protected procedure DoWriteValue
Write a single value into the specified address of the PLC without changing the properties of the TNoDave-instance.
public function GetBit
Return the Bit-value read last from the PLC at the specified address.
public function GetByte
Return the Byte-value read last from the PLC at the specified address.
public function GetDInt
Return the LongInt-value read last from the PLC at the specified address.
public function GetDWord
Return the LongWord-value read last from the PLC at the specified address.
public function GetErrorMsg
Return the text message for an error code.
public function GetFloat
Return the Float-value read last from the PLC at the specified address.
public function GetInt
Return the SmallInt-value read last from the PLC at the specified address.
public function GetWord
Return the Word-value read last from the PLC at the specified address.
public function ListReachablePartners
Scan the MPI-bus for all reachable partners
protected procedure Loaded
Open the connection to the PLC after the instance is completely loaded from the stream and if Active is True.
public procedure Lock
Lock the communication-routines for the current tread.
protected function ProtCode
Determine the libnodave.dll-code of a protocol
public procedure ReadBytes
Read the specified Data from the PLC into the buffer.
public procedure ReadBytes
Read the Data specified by the properties Area, DBNumber, BufOffs and BufLen from the PLC into the buffer.
public function ReadSZL
Read a SZL-list from the connected PLC.
public procedure ResetInterface
Reset the NetLink-adapter via network-command
public function Swap16
Swap the byte-order in a 16-bit value.
public function Swap32
Swap the byte-order in a 32-bit value.
public procedure Unlock
Unlock the communication-routines for other threads.
protected procedure WriteBit
Write a Bit-value into the PLC at the specified address without changing the properties of the TNoDave-instance.
public procedure WriteBit
Write a Bit-value into the PLC at the specified address without changing the properties of the TNoDave-instance.
public procedure WriteByte
Write a Byte-value into the PLC at the specified address without changing the properties of the TNoDave-instance.
public procedure WriteBytes
Write the buffer into the PLC at the address specified by the properties Area, DBNumber, BufOffs and BufLen.
public procedure WriteBytes
Write the buffer into the PLC at the specified address after setting up the properties with the given values.
public procedure WriteDInt
Write a LongInt-value into the PLC at the specified address without changing the properties of the TNoDave-instance.
public procedure WriteDWord
Write a LongWord-value into the PLC at the specified address without changing the properties of the TNoDave-instance.
public procedure WriteFloat
Write a Float-value into the PLC at the specified address without changing the properties of the TNoDave-instance.
public procedure WriteInt
Write a SmallInt-value into the PLC at the specified address without changing the properties of the TNoDave-instance.
public procedure WriteWord
Write a Word-value into the PLC at the specified address without changing the properties of the TNoDave-instance.

Properties:

published property Active: Boolean read GetActive write SetActive
Property for the connection-status.
Used in
Connect, Disconnect, DoConnect, ListReachablePartners, ReadBytes, ReadSZL, ResetInterface, WriteBytes, TNoDaveConnectThread.Execute, TNoDaveReadThread.Execute

published property Area: TNoDaveArea read FArea write SetArea
Property for the PLC-area
Used in
TNoDaveReadThread.Execute

published read-only property Buffer: String read GetBuffer
Property for the pointer to the internal buffer memory.
published property BufLen: Integer read FBufLen write SetBufLen
Property for the length of the buffer.
Used in
TNoDaveReadThread.Execute

published property BufOffs: Integer read FBufOffs write SetBufOffs
Property for the offset of the buffer within the address-range of the PLC.
Used in
TNoDaveReadThread.Execute

published property COMPort: String read FComPort write SetComPort
Property for the name of the COM-Port used for the serial-to-MPI adapter.
published property COMSpeed: TNoDaveComSpeed read FComSpeed write SetComSpeed
Property for the speed of the COM-Port used for the serial-to-MPI adapter.
Used in
DoConnect

published property CPURack: Integer read FCpuRack write SetCpuRack
Property for the number of the rack containing the CPU of the PLC.
published property CPUSlot: Integer read FCpuSlot write SetCpuSlot
Property for the number of the slot containing the CPU of the PLC.
published read-only property CycleTime: Cardinal read FCycleTime
Property for the duration in ms of the last communication cycle.
published property DBNumber: Integer read FDBNumber write SetDBNumber
Property for the number of the datablock in the PLC.
Used in
TNoDaveReadThread.Execute

published property DebugOptions: TNoDaveDebugOptions read GetDebugOptions write SetDebugOptions
Property for the debug-options.
published property Interval: Cardinal read FInterval write SetInterval
Property for the minimal round-trip cycle time for the background-communication with the PLC in milliseconds.
Used in
TNoDaveReadThread.Execute

published property IntfName: String read FIntfName write SetIntfName
Property for the symbolic name of the interface.
published property IntfTimeout: Integer read FIntfTimeout write SetIntfTimeout
Property for the timeout of the interface in milliseconds.
published property IPAddress: String read FIPAddress write SetIPAddress
Property for the IP-address or name of the TCP/IP partner station.
published property IPPort: Integer read FIPPort write SetIPPort
Property for the IP-port of the TCP/IP partner station.
published read-only property LastErrMsg: String read GetLastErrMsg
Property for the text describing the code in LastError.
Used in
TNoDaveReadThread.Execute

published read-only property LastError: Integer read FLastError
Property for the return-code of the last call of a communication-method.
Used in
TNoDaveReadThread.Execute

public read-only property MaxPDUData: Integer read GetMaxPDUData
Property for the maximum datasize of one read-request
Used in
DoReadBytes, DoWriteBytes

published property MPILocal: Integer read FMPILocal write SetMPILocal
Property for the local MPI-address used for the MPI-communication.
published property MPIRemote: Integer read FMPIRemote write SetMPIRemote
Property for the remote MPI-address used for the MPI-communication.
published property MPISpeed: TNoDaveSpeed read FMPISpeed write SetMPISpeed
Property for the MPI-speed used for the MPI-communication.
published property OnConnect: TNotifyEvent read FOnConnect write FOnConnect
Property for the OnConnect-eventhandler
Used in
DoOnConnect

published property OnDisconnect: TNotifyEvent read FOnDisconnect write FOnDisconnect
Property for the OnDisconnect-eventhandler
Used in
DoOnDisconnect

published property OnError: TNoDaveOnErrorEvent read FOnError write FOnError
Property for the OnError-eventhandler
Used in
DoOnError

published property OnRead: TNotifyEvent read FOnRead write FOnRead
Property for the OnRead-eventhandler
Used in
DoOnRead

published property OnWrite: TNotifyEvent read FOnWrite write FOnWrite
Property for the OnWrite-eventhandler
Used in
DoOnWrite

published property Protocol: TNoDaveProtocol read FProtocol write SetProtocol
Property for the Protocol used for the communication with the PLC.
Used in
ResetInterface

public read-only property SZLCount: Integer read GetSZLCount
Property for the number of items in the internal SZL-Buffer
public read-only property SZLItem [Index: Integer]: Pointer read GetSZLItem
Property for the items in the internal SZL-Buffer
public read-only property SZLItemSize: Integer read GetSZLItemSize
Property for the size of one item in the internal SZL-Buffer

Constructors:

public constructor Create(aOwner: TComponent); override
Initialize a new instance of the TNoDave component.
Parameters
aOwner
Owner of the created instance.
Overrides
Create


Destructors:

public destructor Destroy; override
Close an active connection and call the inherited Destroy method.
Overrides
Destroy


Methods:

protected function AreaCode(Area: TNoDaveArea): Integer
Determine the S7-ID of an Area.
Parameters
Area
Requested Area.
Result
S7-ID of the Area.
Called by
DoReadBytes, DoWriteBytes, DoWriteValue, WriteBit

protected function BufferAt(Address: Integer; Size: Integer = 1; Buffer: Pointer = Nil; BufOffs: Integer = 0; BufLen: Integer = 0): Pointer
Return a Pointer to the requested PLC-data point within the buffer.
Parameters
Address
PLC-Address of the datapoint.
Size
Size of the datapoint in bytes.
Buffer
Pointer to the buffer holding the PLC-data. The internal buffer is used, if Nil (default).
BufOffs
Offset-address of the buffer within the address-range of the PLC.
BufLen
Length of the buffer in bytes.
Result
Pointer to the requested data point if the address is located in the buffer, else Nil.
Called by
GetBit, GetByte, GetDInt, GetDWord, GetFloat, GetInt, GetWord

public procedure Connect(Wait: Boolean = True)
Open the connection to the PLC.
Parameters
Wait
If False the connection is opened asyncronous in a separate thread. Default is True.
Called by
Loaded

public procedure Disconnect
Close the connection to the PLC.
Called by
Destroy, TNoDaveReadThread.Execute

protected procedure DoConnect(OnlyIntf: Boolean = False)
Open the connection to the PLC specified by the properties Protocol, CPURack, CPUSlot, COMPort, IPAddress, IPPort, MPILocal, MPIRemote and/or MPISpeed
Parameters
OnlyIntf
Open only the interface, don't connect to the PLC
Called by
Connect, ResetInterface, TNoDaveConnectThread.Execute

protected procedure DoOnConnect
Create the worker-thread for cyclic reading if neccessary and call the OnConnect-eventhandler if specified.
Called by
Connect, TNoDaveConnectThread.DoOnConnect

protected procedure DoOnDisconnect
Stop and Destroy the worker-thread for cyclic reading if neccessary and call the OnDisconnect-eventhandler if specified.
Called by
Disconnect

protected procedure DoOnError(ErrorMsg: String)
Call the OnError-eventhandler if specified.
Parameters
ErrorMsg
The text-message for the OnError-event
Called by
BufferAt, Connect, Disconnect, DoConnect, DoReadBytes, DoWriteBytes, DoWriteValue, WriteBit, TNoDaveConnectThread.DoOnError, TNoDaveReadThread.DoOnError

protected procedure DoOnRead
Call the OnRead-eventhandler if specified.
Called by
ReadBytes, TNoDaveReadThread.DoOnRead

protected procedure DoOnWrite
Call the OnWrite-eventhandler if specified.
Called by
WriteBytes

protected procedure DoReadBytes(Area: TNoDaveArea; DB, Start, Size: Integer; Buffer: Pointer = Nil)
Read the PLC-data into the buffer.
Parameters
Area
Requested PLC-area.
DB
Number of requested datablock. Only used, if reading from Datablocks in the PLC.
Start
Start-address of the requested data within the address-range of the PLC.
Size
Length of the requested PLC-data in bytes.
Buffer
Pointer to the buffer. The internal buffer of the instance is used, if Nil (default).
Called by
ReadBytes, ReadBytes, TNoDaveReadThread.Execute

public procedure DoSetDebug(Options: Integer)
Set the debug-options of the libnodave.dll
Parameters
Options
Value of the debug-options.

protected procedure DoWriteBytes(Area: TNoDaveArea; DB, Start, Size: Integer; Buffer: Pointer = Nil)
Write the Buffer-data into the PLC.
Parameters
Area
Requested PLC-area.
DB
Number of requested datablock. Only used, if reading from Datablocks in the PLC.
Start
Start-address of the requested data within the address-range of the PLC.
Size
Length of the requested PLC-data in bytes.
Buffer
Pointer to the buffer. The internal buffer of the instance is used, if Nil (default).
Called by
WriteBytes, WriteBytes

protected procedure DoWriteValue(Address, Size: Integer; Value: Pointer)
Write a single value into the specified address of the PLC without changing the properties of the TNoDave-instance.
Parameters
Address
PLC-Address of the data point.
Size
Size in bytes of the value.
Value
The value to be written.
Called by
WriteByte, WriteDInt, WriteDWord, WriteFloat, WriteInt, WriteWord

public function GetBit(Address, Bit: Integer; Buffer: Pointer = Nil; BufOffs: Integer = 0; BufLen: Integer = 0): Boolean
Return the Bit-value read last from the PLC at the specified address.
Parameters
Address
Byte-address of the requested value
Bit
Bit-address of the requested value
Buffer
Pointer to the buffer holding the PLC-data. The internal buffer is used, if Nil (default).
BufOffs
Offset-address of the buffer within the address-range of the PLC.
BufLen
Length of the buffer in bytes.
Result
The requested value or False, if the requested address was not found within the buffer.

public function GetByte(Address: Integer; Buffer: Pointer = Nil; BufOffs: Integer = 0; BufLen: Integer = 0): Byte
Return the Byte-value read last from the PLC at the specified address.
Parameters
Address
Address of the requested value
Buffer
Pointer to the buffer holding the PLC-data. The internal buffer is used, if Nil (default).
BufOffs
Offset-address of the buffer within the address-range of the PLC.
BufLen
Length of the buffer in bytes.
Result
The requested value or 0, if the requested address was not found within the buffer.

public function GetDInt(Address: Integer; Buffer: Pointer = Nil; BufOffs: Integer = 0; BufLen: Integer = 0): LongInt
Return the LongInt-value read last from the PLC at the specified address.
Parameters
Address
Address of the requested value
Buffer
Pointer to the buffer holding the PLC-data. The internal buffer is used, if Nil (default).
BufOffs
Offset-address of the buffer within the address-range of the PLC.
BufLen
Length of the buffer in bytes.
Result
The requested value or 0, if the requested address was not found within the buffer.

public function GetDWord(Address: Integer; Buffer: Pointer = Nil; BufOffs: Integer = 0; BufLen: Integer = 0): LongWord
Return the LongWord-value read last from the PLC at the specified address.
Parameters
Address
Address of the requested value
Buffer
Pointer to the buffer holding the PLC-data. The internal buffer is used, if Nil (default).
BufOffs
Offset-address of the buffer within the address-range of the PLC.
BufLen
Length of the buffer in bytes.
Result
The requested value or 0, if the requested address was not found within the buffer.

public function GetErrorMsg(Error: Integer): String
Return the text message for an error code.
Parameters
Error
The error code.
Result
Text message correspondig to the error code.

public function GetFloat(Address: Integer; Buffer: Pointer = Nil; BufOffs: Integer = 0; BufLen: Integer = 0): Double
Return the Float-value read last from the PLC at the specified address.
Parameters
Address
Address of the requested value
Buffer
Pointer to the buffer holding the PLC-data. The internal buffer is used, if Nil (default).
BufOffs
Offset-address of the buffer within the address-range of the PLC.
BufLen
Length of the buffer in bytes.
Result
The requested value or 0, if the requested address was not found within the buffer.

public function GetInt(Address: Integer; Buffer: Pointer = Nil; BufOffs: Integer = 0; BufLen: Integer = 0): SmallInt
Return the SmallInt-value read last from the PLC at the specified address.
Parameters
Address
Address of the requested value
Buffer
Pointer to the buffer holding the PLC-data. The internal buffer is used, if Nil (default).
BufOffs
Offset-address of the buffer within the address-range of the PLC.
BufLen
Length of the buffer in bytes.
Result
The requested value or 0, if the requested address was not found within the buffer.

public function GetWord(Address: Integer; Buffer: Pointer = Nil; BufOffs: Integer = 0; BufLen: Integer = 0): Word
Return the Word-value read last from the PLC at the specified address.
Parameters
Address
Address of the requested value
Buffer
Pointer to the buffer holding the PLC-data. The internal buffer is used, if Nil (default).
BufOffs
Offset-address of the buffer within the address-range of the PLC.
BufLen
Length of the buffer in bytes.
Result
The requested value or 0, if the requested address was not found within the buffer.
Called by
ReadSZL

public function ListReachablePartners: TNoDaveReachablePartnersMPI
Scan the MPI-bus for all reachable partners
Result
List with True for available partners and False for unavailable partners.

protected procedure Loaded; override
Open the connection to the PLC after the instance is completely loaded from the stream and if Active is True.
Overrides
Loaded

public procedure Lock
Lock the communication-routines for the current tread.
protected function ProtCode(Prot: TNoDaveProtocol): Integer
Determine the libnodave.dll-code of a protocol
Parameters
Prot
The requested protocol
Result
The libnodave.dll code for the protocol
Called by
DoConnect

public procedure ReadBytes(Area: TNoDaveArea; DB, Start, Size: Integer; Buffer: Pointer = Nil); overload
Read the specified Data from the PLC into the buffer.
Parameters
Area
Requested PLC-area.
DB
Number of requested datablock. Only used, if reading from Datablocks in the PLC.
Start
Start-address of the requested data within the address-range of the PLC.
Size
Length of the requested PLC-data in bytes.
Buffer
Pointer to the buffer for PLC-data. The internal buffer is used, if Nil (default).

public procedure ReadBytes(Buffer: Pointer = Nil); overload
Read the Data specified by the properties Area, DBNumber, BufOffs and BufLen from the PLC into the buffer.
Parameters
Buffer
Pointer to the buffer for PLC-data. The internal buffer is used, if Nil (default).
Called by
DoConnect, ReadBytes

public function ReadSZL(ID, Index: Integer): Integer
Read a SZL-list from the connected PLC.
Parameters
ID
The SZL-ID of the list.
Index
The SZL-Index of the list.
Result
Error code for the function result, 0 if OK.

public procedure ResetInterface
Reset the NetLink-adapter via network-command
public function Swap16(Value: SmallInt): SmallInt
Swap the byte-order in a 16-bit value.
Parameters
Value
The value for the conversion.
Result
The converted value.

public function Swap32(Value: Integer): Integer
Swap the byte-order in a 32-bit value.
Parameters
Value
The value for the conversion.
Result
The converted value.

public procedure Unlock
Unlock the communication-routines for other threads.
protected procedure WriteBit(Area: TNoDaveArea; DB, Address, Bit: Integer; Value: Boolean); overload
Write a Bit-value into the PLC at the specified address without changing the properties of the TNoDave-instance.
Parameters
Area
Requested PLC-area.
DB
Number of requested datablock. Only used, if writing into datablocks of the PLC.
Address
Byte-address of the value
Bit
Bit-address of the value
Value
Value to write into the PLC.
Called by
WriteBit

public procedure WriteBit(Address, Bit: Integer; Value: Boolean); overload
Write a Bit-value into the PLC at the specified address without changing the properties of the TNoDave-instance.
Parameters
Address
Byte-address of the value
Bit
Bit-address of the value
Value
Value to write into the PLC.

public procedure WriteByte(Address: Integer; Value: Byte)
Write a Byte-value into the PLC at the specified address without changing the properties of the TNoDave-instance.
Parameters
Address
Byte-address of the value
Value
Value to write into the PLC.

public procedure WriteBytes(Buffer: Pointer = Nil); overload
Write the buffer into the PLC at the address specified by the properties Area, DBNumber, BufOffs and BufLen.
Parameters
Buffer
Pointer to the buffer for PLC-data. The internal buffer is used, if Nil (default).
Called by
WriteBytes

public procedure WriteBytes(Area: TNoDaveArea; DB, Start, Size: Integer; Buffer: Pointer = Nil); overload
Write the buffer into the PLC at the specified address after setting up the properties with the given values.
Parameters
Area
Requested PLC-area. Changes the property Area.
DB
Number of requested datablock. Changes the property DBNumber. Only used, if writing into datablocks of the PLC.
Start
Start-address of the buffer within the address-range of the PLC. Changes the property BufOffs.
Size
Length of the buffer in bytes. Changes the property BufLen.
Buffer
Pointer to the buffer for PLC-data. The internal buffer is used, if Nil (default).

public procedure WriteDInt(Address: Integer; Value: LongInt)
Write a LongInt-value into the PLC at the specified address without changing the properties of the TNoDave-instance.
Parameters
Address
Byte-address of the value
Value
Value to write into the PLC.

public procedure WriteDWord(Address: Integer; Value: LongWord)
Write a LongWord-value into the PLC at the specified address without changing the properties of the TNoDave-instance.
Parameters
Address
Byte-address of the value
Value
Value to write into the PLC.

public procedure WriteFloat(Address: Integer; Value: Single)
Write a Float-value into the PLC at the specified address without changing the properties of the TNoDave-instance.
Parameters
Address
Byte-address of the value
Value
Value to write into the PLC.

public procedure WriteInt(Address: Integer; Value: SmallInt)
Write a SmallInt-value into the PLC at the specified address without changing the properties of the TNoDave-instance.
Parameters
Address
Byte-address of the value
Value
Value to write into the PLC.

public procedure WriteWord(Address: Integer; Value: Word)
Write a Word-value into the PLC at the specified address without changing the properties of the TNoDave-instance.
Parameters
Address
Byte-address of the value
Value
Value to write into the PLC.