11import datetime
2- from typing import List , Optional , Tuple
32
43from .s7comm import AsyncS7Comm , enums
54from .s7comm .packets .variable_address import VariableAddress
@@ -50,31 +49,32 @@ async def get_cpu_state(self) -> enums.CPUStatus:
5049 async def read_area (self , address : str ) -> bytes :
5150 return await self .s7comm .read_area (VariableAddress .from_string (address ))
5251
53- async def write_area (self , address : str , data : bytes ) -> int :
54- return await self .s7comm .write_area (address = VariableAddress .from_string (address ), data = data )
52+ async def write_area (self , address : str , data : bytes ) -> None :
53+ await self .s7comm .write_area (address = VariableAddress .from_string (address ), data = data )
5554
56- async def get_order_code (self ) -> Optional [ str ] :
55+ async def get_order_code (self ) -> str | None :
5756 response = await self .s7comm .read_szl (szl_id = 0x0011 , szl_index = 0x0000 )
58- szl_data = SZLResponseData .parse (response .data )
57+ szl_data = SZLResponseData .parse (response .data . data )
5958 for date_tree in szl_data .szl_data_tree_list :
6059 module_identification = ModuleIdentificationDataTree .parse (date_tree )
6160 if module_identification .index == ModuleIdentificationIndex .MODULE_IDENTIFICATION :
6261 return module_identification .order_number
6362 return None
6463
6564 async def read_szl (self , szl_id : int , szl_index : int = 0x0000 ) -> SZLResponseData :
66- return await self .s7comm .read_szl (szl_id = szl_id , szl_index = szl_index )
65+ response_data = await self .s7comm .read_szl (szl_id = szl_id , szl_index = szl_index )
66+ return SZLResponseData .parse (response_data .data .data )
6767
6868 async def read_szl_list (self ) -> SZLResponseData :
6969 response_data = await self .s7comm .read_szl (szl_id = 0x0000 , szl_index = 0x0000 )
7070 return SZLResponseData .parse (response_data .data .data )
7171
72- async def read_multi_vars (self , items : List [str ]) -> List [bytes ]:
72+ async def read_multi_vars (self , items : list [str ]) -> list [bytes ]:
7373 vars_ = [VariableAddress .from_string (item ) for item in items ]
7474 response = await self .s7comm .read_multi_vars (items = vars_ )
7575 return response .values ()
7676
77- async def write_multi_vars (self , items : List [ Tuple [str , bytes ]]) -> bool :
77+ async def write_multi_vars (self , items : list [ tuple [str , bytes ]]) -> bool :
7878 vars_ = [(VariableAddress .from_string (address ), data ) for address , data in items ]
7979 response = await self .s7comm .write_multi_vars (items = vars_ )
8080 return response .check_result ()
@@ -85,7 +85,7 @@ async def set_plc_system_datetime(self) -> int:
8585 async def delete (self , block_type : str , block_num : int ) -> int :
8686 raise NotImplementedError
8787
88- async def full_upload (self , _type : str , block_num : int ) -> Tuple [bytearray , int ]:
88+ async def full_upload (self , _type : str , block_num : int ) -> tuple [bytearray , int ]:
8989 raise NotImplementedError
9090
9191 async def upload (self , block_num : int ) -> bytearray :
0 commit comments