solax-py-library 1.0.0.2515__py3-none-any.whl → 1.0.0.2517__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,7 +12,7 @@ class SystemCondition(BaseCondition):
12
12
  def __init__(self, update_value_function, **kwargs):
13
13
  super().__init__(update_value_function, **kwargs)
14
14
 
15
- def meet_system_condition(self, data: SystemConditionItemData, ctx):
15
+ def meet_func(self, data: SystemConditionItemData, ctx):
16
16
  if not self.value:
17
17
  return False
18
18
  child_data = data.childData
@@ -13,7 +13,7 @@ class WeatherCondition(BaseCondition):
13
13
  def __init__(self, update_value_function, **kwargs):
14
14
  super().__init__(update_value_function, **kwargs)
15
15
 
16
- def meet_weather_condition(self, data: WeatherConditionItemData, ctx):
16
+ def meet_func(self, data: WeatherConditionItemData, ctx):
17
17
  if not self.value:
18
18
  return False
19
19
  child_data = data.childData
@@ -3,15 +3,15 @@ import struct
3
3
  from typing import List
4
4
 
5
5
  format_map = {
6
- "int8": "bb",
7
- "uint8": "BB",
8
- "int16": "h",
9
- "uint16": "H",
10
- "int32": "i",
11
- "uint32": "I",
12
- "int64": "q",
13
- "uint64": "Q",
14
- "float": "f",
6
+ "int8": {"format_str": "bb", "length": 1},
7
+ "uint8": {"format_str": "BB", "length": 1},
8
+ "int16": {"format_str": "h", "length": 1},
9
+ "uint16": {"format_str": "H", "length": 1},
10
+ "int32": {"format_str": "i", "length": 2},
11
+ "uint32": {"format_str": "I", "length": 2},
12
+ "int64": {"format_str": "q", "length": 4},
13
+ "uint64": {"format_str": "Q", "length": 4},
14
+ "float": {"format_str": "f", "length": 1},
15
15
  }
16
16
 
17
17
 
@@ -27,25 +27,16 @@ def unpack(data: List, data_format, reversed=False):
27
27
  raise Exception("暂不支持")
28
28
  pack_str = ("<" if reversed else ">") + "H" * len(cur_data)
29
29
  to_pack_data = struct.pack(pack_str, *cur_data)
30
- struct_format = ("<" if reversed else ">") + format_map[data_format]
30
+ struct_format = ("<" if reversed else ">") + format_map[data_format]["format_str"]
31
31
  return struct.unpack(struct_format, to_pack_data)
32
32
 
33
33
 
34
- def struct_transform(value, fmt, order="big"):
34
+ def pack(value, fmt, order="big"):
35
35
  """将10进制的原始值转换为modbus协议需要的精度与类型的值"""
36
36
  opt = "<" if order == "little" else ">"
37
- try:
38
- value = int(value)
39
- if fmt in format_map:
40
- ret = struct.pack(f"{opt}{format_map[fmt]}", value)
41
- ret_list = struct.unpack(f"{opt}H", ret)
42
- else:
43
- ret_list = [0]
44
- except Exception:
45
- if "16" in fmt:
46
- ret_list = [0]
47
- elif "32" in fmt:
48
- ret_list = [0, 0]
49
- else:
50
- ret_list = [0, 0, 0, 0]
37
+ if fmt not in format_map:
38
+ raise Exception("暂不支持")
39
+ value = int(value)
40
+ ret = struct.pack(f'{opt}{format_map[fmt]["format_str"]}', value)
41
+ ret_list = struct.unpack(f'{opt}{"H" * format_map[fmt]["length"]}', ret)
51
42
  return list(ret_list)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: solax-py-library
3
- Version: 1.0.0.2515
3
+ Version: 1.0.0.2517
4
4
  Summary: some common tool
5
5
  Author: shenlvyu
6
6
  Author-email: 13296718439@163.com
@@ -24,8 +24,8 @@ solax_py_library/smart_scene/core/condition/base.py,sha256=saj7dc0Su2Wi_Lx04cesH
24
24
  solax_py_library/smart_scene/core/condition/cabinet_condition.py,sha256=HEVifO3rHk2ElfSCEB0MzVdfrFWlkwqjt6tFhtJ8CLY,1581
25
25
  solax_py_library/smart_scene/core/condition/date_condition.py,sha256=Xhca6VjoM8Bq-I-dFj1RPLTTzbBL81ORkBnR8D-YqUw,772
26
26
  solax_py_library/smart_scene/core/condition/price_condition.py,sha256=mzUnrMuG0DHCxaQQe7-rmE_vra9U6vd-1AYDKkbPPUw,3884
27
- solax_py_library/smart_scene/core/condition/system_condition.py,sha256=oLz0MM47bj6K1saAap3YBteK9UeejSqu5CQVdLvGE1Q,1350
28
- solax_py_library/smart_scene/core/condition/weather_condition.py,sha256=OiKye007PZnocnmcrNQD6ObOEF7VyaYkdqz6D_2lNok,2236
27
+ solax_py_library/smart_scene/core/condition/system_condition.py,sha256=q5KDQdK6wjEvq0__WwBR4Sk-59yA2aIAgxTf1xjxJQk,1338
28
+ solax_py_library/smart_scene/core/condition/weather_condition.py,sha256=Xp7l9m3NW1vyyRGaJC5_gAX4HM-iuj7OGaw5LbZ4ztU,2223
29
29
  solax_py_library/smart_scene/core/service/__init__.py,sha256=wWzHSN2XaHnI-TNtCJWWRHnNC7s3-2GNQo9y0K_PC4Q,69
30
30
  solax_py_library/smart_scene/core/service/runner.py,sha256=SwQ6jb5yFPcyHyfU-THyGDjPEMcNFUOHkvVYA9wB1EE,6201
31
31
  solax_py_library/smart_scene/exceptions/__init__.py,sha256=0hDgr70fFLQB14uorVCwbBhl1yQmZ-uBYGH5XtGm_dg,147
@@ -73,8 +73,8 @@ solax_py_library/upload/types/ftp.py,sha256=9kCeLB0g5Je19v4ifz8YYEsGOhJL1lKBO2C6
73
73
  solax_py_library/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
74
  solax_py_library/utils/cloud_client.py,sha256=5dZrc5fzrNFSXqTPZd7oHt-Y9Jj6RCigB7aXJQMJ8sQ,9610
75
75
  solax_py_library/utils/common.py,sha256=bfnZcX9uM-PjJrYAFv1UMmZgt6bGR7MaOd7jRPNHGxw,1238
76
- solax_py_library/utils/struct_util.py,sha256=nlMaopAWy5bN_NGiNph0Kou5wuuYprq5lTm7h1rXJCA,1477
76
+ solax_py_library/utils/struct_util.py,sha256=pL6L80GXIHasy1ZDIj89-5BzXW1BWI3TPitH7thGGIE,1577
77
77
  solax_py_library/utils/time_util.py,sha256=bY5kj9dmyOuLEQ6uYGQK7jU7y1RMiHZgevEKnkcQcSU,1461
78
- solax_py_library-1.0.0.2515.dist-info/METADATA,sha256=wXQlZNxou41J6NRtFQCV2qK8v1rzEKBUmF0J29qArW0,1827
79
- solax_py_library-1.0.0.2515.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
80
- solax_py_library-1.0.0.2515.dist-info/RECORD,,
78
+ solax_py_library-1.0.0.2517.dist-info/METADATA,sha256=5Lw8G9DB_DWDqsj89QeCJCswLr-Ekz8tm4npB5LzS1I,1827
79
+ solax_py_library-1.0.0.2517.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
80
+ solax_py_library-1.0.0.2517.dist-info/RECORD,,