Client¶
Snap7 client used for connection to a siemens7 server.
-
class
snap7.client.
Client
[source]¶ A snap7 client
-
ab_read
(start, size)[source]¶ This is a lean function of Cli_ReadArea() to read PLC process outputs.
-
ab_write
(start, data)[source]¶ This is a lean function of Cli_WriteArea() to write PLC process outputs
-
as_db_read
(db_number, start, size)[source]¶ This is the asynchronous counterpart of Cli_DBRead.
Returns: user buffer.
-
db_read
(db_number, start, size)[source]¶ This is a lean function of Cli_ReadArea() to read PLC DB.
Returns: user buffer.
-
full_upload
(_type, block_num)[source]¶ Uploads a full block body from AG. The whole block (including header and footer) is copied into the user buffer.
Parameters: block_num – Number of Block
-
get_block_info
(blocktype, db_number)[source]¶ Returns the block information for the specified block.
-
get_connected
()[source]¶ Returns the connection status
Returns: a boolean that indicates if connected.
-
list_blocks
()[source]¶ Returns the AG blocks amount divided by type.
Returns: a snap7.types.BlocksList object.
-
list_blocks_of_type
(blocktype, size)[source]¶ This function returns the AG list of a specified block type.
-
read_area
(area, dbnumber, start, size)[source]¶ This is the main function to read data from a PLC. With it you can read DB, Inputs, Outputs, Merkers, Timers and Counters.
Parameters: - dbnumber – The DB number, only used when area= S7AreaDB
- start – offset to start writing
- size – number of units to read
-
read_multi_vars
(items)[source]¶ This function read multiple variables from the PLC.
Parameters: items – list of S7DataItem objects Returns: a tuple with the return code and a list of data items
-
set_connection_params
(address, local_tsap, remote_tsap)[source]¶ Sets internally (IP, LocalTSAP, RemoteTSAP) Coordinates. This function must be called just before Cli_Connect().
Parameters: - address – PLC/Equipment IPV4 Address, for example “192.168.1.12”
- local_tsap – Local TSAP (PC TSAP)
- remote_tsap – Remote TSAP (PLC TSAP)
-