solax-py-library 1.0.0.2514__tar.gz → 1.0.0.2516__tar.gz

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.
Files changed (84) hide show
  1. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/PKG-INFO +1 -1
  2. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/pyproject.toml +1 -1
  3. solax_py_library-1.0.0.2516/solax_py_library/smart_scene/core/action/base.py +10 -0
  4. solax_py_library-1.0.0.2516/solax_py_library/smart_scene/core/action/ems_action.py +6 -0
  5. solax_py_library-1.0.0.2516/solax_py_library/smart_scene/core/action/system_action.py +6 -0
  6. solax_py_library-1.0.0.2516/solax_py_library/utils/struct_util.py +42 -0
  7. solax_py_library-1.0.0.2514/solax_py_library/smart_scene/core/action/base.py +0 -9
  8. solax_py_library-1.0.0.2514/solax_py_library/smart_scene/core/action/ems_action.py +0 -19
  9. solax_py_library-1.0.0.2514/solax_py_library/smart_scene/core/action/system_action.py +0 -241
  10. solax_py_library-1.0.0.2514/solax_py_library/utils/struct_util.py +0 -30
  11. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/README.md +0 -0
  12. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/__init__.py +0 -0
  13. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/device/__init__.py +0 -0
  14. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/device/constant/__init__.py +0 -0
  15. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/device/constant/cabinet.py +0 -0
  16. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/device/constant/inverter_model_info.py +0 -0
  17. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/device/core/__init__.py +0 -0
  18. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/device/core/interver/__init__.py +0 -0
  19. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/device/core/interver/base.py +0 -0
  20. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/device/types/__init__.py +0 -0
  21. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/device/types/alarm.py +0 -0
  22. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/device/types/inverter_config.py +0 -0
  23. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/device/types/modbus_point.py +0 -0
  24. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/exception.py +0 -0
  25. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/__init__.py +0 -0
  26. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/constant/__init__.py +0 -0
  27. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/constant/message_entry.py +0 -0
  28. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/core/__init__.py +0 -0
  29. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/core/action/__init__.py +0 -0
  30. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/core/condition/__init__.py +0 -0
  31. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/core/condition/base.py +0 -0
  32. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/core/condition/cabinet_condition.py +0 -0
  33. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/core/condition/date_condition.py +0 -0
  34. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/core/condition/price_condition.py +0 -0
  35. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/core/condition/system_condition.py +0 -0
  36. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/core/condition/weather_condition.py +0 -0
  37. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/core/service/__init__.py +0 -0
  38. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/core/service/runner.py +0 -0
  39. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/exceptions/__init__.py +0 -0
  40. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/exceptions/price.py +0 -0
  41. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/exceptions/smart_scene.py +0 -0
  42. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/exceptions/weather.py +0 -0
  43. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/types/__init__.py +0 -0
  44. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/types/action.py +0 -0
  45. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/types/condition.py +0 -0
  46. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/smart_scene/types/smart_scene_content.py +0 -0
  47. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/snap_shot/__init__.py +0 -0
  48. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/snap_shot/constant/__init__.py +0 -0
  49. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/snap_shot/constant/crc_table.py +0 -0
  50. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/snap_shot/core/__init__.py +0 -0
  51. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/snap_shot/core/base_modbus.py +0 -0
  52. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/snap_shot/core/parser.py +0 -0
  53. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/snap_shot/core/snap_shot.py +0 -0
  54. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/snap_shot/exceptions/__init__.py +0 -0
  55. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/snap_shot/exceptions/snap_shot.py +0 -0
  56. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/snap_shot/test/__init__.py +0 -0
  57. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/snap_shot/types/__init__.py +0 -0
  58. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/snap_shot/types/address.py +0 -0
  59. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/test/__init__.py +0 -0
  60. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/test/test_smart_scene/__init__.py +0 -0
  61. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/test/test_smart_scene/test_condition.py +0 -0
  62. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/test/test_utils/__init__.py +0 -0
  63. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/test/test_utils/test_cloud_client.py +0 -0
  64. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/upload/__init__.py +0 -0
  65. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/upload/api/__init__.py +0 -0
  66. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/upload/api/service.py +0 -0
  67. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/upload/core/__init__.py +0 -0
  68. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/upload/core/data_adapter/__init__.py +0 -0
  69. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/upload/core/data_adapter/base.py +0 -0
  70. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/upload/core/data_adapter/csv.py +0 -0
  71. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/upload/core/upload_service/__init__.py +0 -0
  72. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/upload/core/upload_service/base.py +0 -0
  73. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/upload/core/upload_service/ftp.py +0 -0
  74. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/upload/exceptions/__init__.py +0 -0
  75. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/upload/exceptions/upload_error.py +0 -0
  76. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/upload/test/__init__.py +0 -0
  77. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/upload/test/test_ftp.py +0 -0
  78. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/upload/types/__init__.py +0 -0
  79. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/upload/types/client.py +0 -0
  80. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/upload/types/ftp.py +0 -0
  81. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/utils/__init__.py +0 -0
  82. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/utils/cloud_client.py +0 -0
  83. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/utils/common.py +0 -0
  84. {solax_py_library-1.0.0.2514 → solax_py_library-1.0.0.2516}/solax_py_library/utils/time_util.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: solax-py-library
3
- Version: 1.0.0.2514
3
+ Version: 1.0.0.2516
4
4
  Summary: some common tool
5
5
  Author: shenlvyu
6
6
  Author-email: 13296718439@163.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "solax-py-library"
3
- version = "1.0.0.2514"
3
+ version = "1.0.0.2516"
4
4
  description = "some common tool"
5
5
  authors = ["shenlvyu <13296718439@163.com>", "x5m8944pjl <371630856@qq.com>"]
6
6
  readme = "README.md"
@@ -0,0 +1,10 @@
1
+ class BaseAction(object):
2
+ def __init__(self, smart_scene_service, do_funcs, **kwargs):
3
+ self.smart_scene_service = smart_scene_service
4
+ self.do_func_map = do_funcs
5
+
6
+ def do_func(self, scene_id, data):
7
+ child_data = data.childData
8
+ child_type = data.childType
9
+ do_func = self.do_func_map.get(child_type)
10
+ return do_func(child_data, scene_id)
@@ -0,0 +1,6 @@
1
+ from solax_py_library.smart_scene.core.action.base import BaseAction
2
+ from solax_py_library.smart_scene.types.action import ActionType
3
+
4
+
5
+ class EMS1000Action(BaseAction):
6
+ action_type = ActionType.EMS1000
@@ -0,0 +1,6 @@
1
+ from solax_py_library.smart_scene.core.action.base import BaseAction
2
+ from solax_py_library.smart_scene.types.action import ActionType
3
+
4
+
5
+ class SystemAction(BaseAction):
6
+ action_type = ActionType.system
@@ -0,0 +1,42 @@
1
+ import copy
2
+ import struct
3
+ from typing import List
4
+
5
+ format_map = {
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
+ }
16
+
17
+
18
+ def unpack(data: List, data_format, reversed=False):
19
+ """
20
+ :param data: 数据字节, 入参均是由modbus读取到的list[uint16]进行转换
21
+ :param data_format: 数据格式
22
+ :param reversed: 是否翻转大小端
23
+ """
24
+ cur_data = copy.deepcopy(data)
25
+ data_format = data_format.lower()
26
+ if data_format not in format_map:
27
+ raise Exception("暂不支持")
28
+ pack_str = ("<" if reversed else ">") + "H" * len(cur_data)
29
+ to_pack_data = struct.pack(pack_str, *cur_data)
30
+ struct_format = ("<" if reversed else ">") + format_map[data_format]["format_str"]
31
+ return struct.unpack(struct_format, to_pack_data)
32
+
33
+
34
+ def pack(value, fmt, order="big"):
35
+ """将10进制的原始值转换为modbus协议需要的精度与类型的值"""
36
+ opt = "<" if order == "little" else ">"
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)
42
+ return list(ret_list)
@@ -1,9 +0,0 @@
1
- # class BaseAction(object):
2
- # def __init__(self, smart_scene_service):
3
- # self.smart_scene_service = smart_scene_service
4
- # self.device_service = DeviceService()
5
- # self.ems_tcp_service = EMSTcpService()
6
- #
7
- #
8
- #
9
- #
@@ -1,19 +0,0 @@
1
- #
2
- # class EMS1000Action(BaseAction):
3
- # def __init__(self, smart_scene_service):
4
- # super().__init__(smart_scene_service)
5
- # self.do_func = self.do_ems1000_action
6
- # self.cabinet_type = None
7
- #
8
- # def do_ems1000_action(self, scene_id, data: EmsActionItemData):
9
- # if data.childType == "DoControl":
10
- # ret = self.do_control(data.childData.data)
11
- # else:
12
- # ret = False
13
- # return ret
14
- #
15
- # def do_control(self, data):
16
- # app_log.info("执行: DO控制")
17
- # self.smart_scene_service.ems_do_control(data)
18
- # return True
19
- #
@@ -1,241 +0,0 @@
1
- # from solax_py_library.smart_scene.core.action.base import BaseAction
2
- # from solax_py_library.smart_scene.types.action import SystemActionType
3
- # from solax_py_library.smart_scene.types.condition import SystemConditionItemData
4
- #
5
- #
6
- # class SystemAction(BaseAction):
7
- # def __init__(self, smart_scene_service, app_log):
8
- # super().__init__(smart_scene_service)
9
- # self.log = app_log
10
- # self.do_func = self.do_system_action
11
- # self.cabinet_type = None
12
- #
13
- # def do_system_action(self, scene_id, data: SystemConditionItemData):
14
- # child_data = data.childData
15
- # child_type = data.childType
16
- # data = child_data.data
17
- # if self.cabinet_type is None:
18
- # self.cabinet_type = self.smart_scene_service.get_cabinet_type()
19
- # if child_type == SystemActionType.systemSwitch:
20
- # return self.system_switch(data[0], scene_id)
21
- # elif child_type == SystemActionType.exportControl:
22
- # return self.export_control(data, scene_id)
23
- # elif child_type == SystemActionType.importControl:
24
- # return self.import_control(data, scene_id)
25
- # elif child_type == SystemActionType.workMode:
26
- # return self.work_mode(data, scene_id)
27
- # return False
28
- #
29
- #
30
- # class SystemSwitchAction(SystemAction):
31
- # def system_switch(self, value, scene_id) -> bool:
32
- # """系统开关机"""
33
- # if value not in [0, 1]:
34
- # value = 1
35
- # if self.cabinet_type in ["TRENE"]:
36
- # self.ems_tcp_service.set_trene_switch(value)
37
- # return True
38
- # else:
39
- # master_sn = self.device_service.get_master_inv_by_device()
40
- # # 如果为AELIO,则只需要操控主机
41
- # if master_sn:
42
- # data = {"sn": master_sn, "switch": value}
43
- # self.log.info(f"执行: 系统开关机, data: {data}")
44
- # t = threading.Thread(
45
- # target=self.smart_scene_service.request_local_server,
46
- # args=("setSystemSwitch", data, scene_id),
47
- # daemon=True,
48
- # )
49
- # t.start()
50
- # return True
51
- #
52
- #
53
- # class ExportControlAction(SystemAction):
54
- # def export_control(self, value, scene_id) -> bool:
55
- # """零输出控制"""
56
- # if len(value) != 4:
57
- # value.extend([1, 0, 1])
58
- # data = {
59
- # "isEnable": value[0],
60
- # "controlMode": value[1],
61
- # "exportValue": value[2],
62
- # "unitType": value[3],
63
- # }
64
- # self.log.info(f"执行: 馈网控制, data: {data}")
65
- # ret = self.smart_scene_service.request_local_server(
66
- # "editOutputControl", data, scene_id
67
- # )
68
- # if not ret or ret["success"] is False:
69
- # return False
70
- # return True
71
- #
72
- #
73
- # class ImportControlAction(SystemAction):
74
- # def import_control(self, value, scene_id) -> bool:
75
- # """需量控制"""
76
- # if self.cabinet_type in ["TRENE"]:
77
- # if len(value) != 3:
78
- # value.extend([1, 0])
79
- # data = {
80
- # "isAllowDischarge": value[1],
81
- # "demandLimitValue": value[2],
82
- # "isEnable": value[0],
83
- # }
84
- # else:
85
- # if len(value) != 2:
86
- # value.append(0)
87
- # data = {
88
- # "isAllowDischarge": 1,
89
- # "demandLimitValue": value[1],
90
- # "isEnable": value[0],
91
- # }
92
- # self.log.info(f"执行: 需量控制, data: {data}")
93
- # ret = self.smart_scene_service.request_local_server(
94
- # "editDemandControl", data, scene_id
95
- # )
96
- # if not ret or ret["success"] is False:
97
- # return False
98
- # return True
99
- #
100
- #
101
- # class WorkModeAction(SystemAction):
102
- # def work_mode(self, value, scene_id) -> bool:
103
- # # 0: self use; 1: 并网优先; 2: 备用模式; 3: 手动; 4: 削峰填谷 5: TOU(暂不用); 16: VPP
104
- # if value[0] not in [0, 1, 2, 3, 4, 16]:
105
- # return False
106
- # data = None
107
- # if self.cabinet_type in ["AELIO"]:
108
- # if value[0] in [0, 1, 2, 3, 4]:
109
- # data = {"useMode": value[0]}
110
- # elif self.cabinet_type in ["TRENE"]:
111
- # if value[0] in [0, 1, 3, 4]:
112
- # data = {"useMode": value[0]}
113
- # else:
114
- # return False
115
- # if data is not None: # 普通模式
116
- # self.log.info(f"普通模式控制 data: {data}")
117
- # # 手动模式
118
- # if data["useMode"] == 3:
119
- # if value[1] == 5:
120
- # value.extend([0, 10])
121
- # self.smart_scene_service.set_manual_mode(
122
- # value[1], value[2], value[3], self.cabinet_type
123
- # )
124
- # else:
125
- # self.smart_scene_service.request_local_server(
126
- # "setAelioUseMode", data, scene_id
127
- # )
128
- # else: # VPP模式
129
- # if self.cabinet_type in ["AELIO"]:
130
- # if value[1] == 1:
131
- # reg_value_list = [1]
132
- # # 有功功率
133
- # reg_value_list.extend(
134
- # self.smart_scene_service.struct_transform(
135
- # value[2] * 1000, "int32", "little"
136
- # )
137
- # )
138
- # # 无功功率
139
- # reg_value_list.extend(
140
- # self.smart_scene_service.struct_transform(
141
- # value[3] * 1000, "int32", "little"
142
- # )
143
- # )
144
- # # 持续时间35秒, 控制超时 35s,控制类型为set
145
- # reg_value_list.extend([35, 35, 1])
146
- # elif value[1] == 2:
147
- # reg_value_list = [2, 1]
148
- # # 能量目标
149
- # reg_value_list.extend(
150
- # self.smart_scene_service.struct_transform(
151
- # value[2] * 1000, "uint32", "little"
152
- # )
153
- # )
154
- # # 功率目标
155
- # reg_value_list.extend(
156
- # self.smart_scene_service.struct_transform(
157
- # value[3] * 1000, "int32", "little"
158
- # )
159
- # )
160
- # # 控制超时 35s
161
- # reg_value_list.extend([35])
162
- # elif value[1] == 3:
163
- # # 控制类型为set,SOC:value[2]
164
- # reg_value_list = [3, 1, value[2]]
165
- # # 充放电功率目标
166
- # reg_value_list.extend(
167
- # self.smart_scene_service.struct_transform(
168
- # value[3] * 1000, "int32", "little"
169
- # )
170
- # )
171
- # # 控制超时 35s
172
- # reg_value_list.extend([35])
173
- # elif value[1] == 4:
174
- # reg_value_list = [4]
175
- # # 电池功率目标
176
- # reg_value_list.extend(
177
- # self.smart_scene_service.struct_transform(
178
- # value[2] * 1000, "int32", "little"
179
- # )
180
- # )
181
- # # 控制超时 35s, # 远程控制超时后需设备执行的模式 0xA0 关闭VPP,0xA1 默认的VPP模式
182
- # reg_value_list.extend([35, 0xA0])
183
- # elif value[1] == 5:
184
- # reg_value_list = [5]
185
- # # 控制超时 35s, # 远程控制超时后需设备执行的模式 0xA0 关闭VPP,0xA1 默认的VPP模式
186
- # reg_value_list.extend([35, 0xA0])
187
- # elif value[1] == 6:
188
- # reg_value_list = [6]
189
- # # 控制超时 35s, # 远程控制超时后需设备执行的模式 0xA0 关闭VPP,0xA1 默认的VPP模式
190
- # reg_value_list.extend([35, 0xA0])
191
- # elif value[1] == 7:
192
- # reg_value_list = [7]
193
- # # 控制超时 35s, # 远程控制超时后需设备执行的模式 0xA0 关闭VPP,0xA1 默认的VPP模式
194
- # reg_value_list.extend([35, 0xA0])
195
- # elif value[1] == 8:
196
- # # 控制类型为set,
197
- # reg_value_list = [8, 1]
198
- # # PV功率限制
199
- # reg_value_list.extend(
200
- # self.smart_scene_service.struct_transform(
201
- # value[2] * 1000, "uint32", "little"
202
- # )
203
- # )
204
- # # 电池功率限制
205
- # reg_value_list.extend(
206
- # self.smart_scene_service.struct_transform(
207
- # value[3] * 1000, "int32", "little"
208
- # )
209
- # )
210
- # # 控制超时 35s, # 远程控制超时后需设备执行的模式 0xA0 关闭VPP,0xA1 默认的VPP模式
211
- # reg_value_list.extend([35, 0xA0])
212
- # elif value[1] == 9:
213
- # # 控制类型为set,
214
- # reg_value_list = [9, 1]
215
- # # PV功率限制
216
- # reg_value_list.extend(
217
- # self.smart_scene_service.struct_transform(
218
- # value[2] * 1000, "uint32", "little"
219
- # )
220
- # )
221
- # # 电池功率限制
222
- # reg_value_list.extend(
223
- # self.smart_scene_service.struct_transform(
224
- # value[3] * 1000, "int32", "little"
225
- # )
226
- # )
227
- # # 控制超时 35s, # 远程控制超时后需设备执行的模式 0xA0 关闭VPP,0xA1 默认的VPP模式
228
- # reg_value_list.extend([value[4], 35, 0xA0])
229
- # else:
230
- # reg_value_list = []
231
- # func_name = PCSOperateFunctionName.SET_AELIO_VPP_MODE
232
- # channel = options.REDIS_WRITE_SERIAL_DEVICE
233
- # future_data = {}
234
- # future_data["func_name"] = func_name
235
- # future_data["operationMode"] = Enumeration.SINGLE_DEVICE_MODE
236
- # future_data["data"] = {"value_list": reg_value_list}
237
- # app_log.info(f"VPP模式控制 data: {future_data}")
238
- # self.smart_scene_service.request_local_redis(
239
- # channel, json.dumps(future_data)
240
- # )
241
- # return True
@@ -1,30 +0,0 @@
1
- import copy
2
- import struct
3
- from typing import List
4
-
5
-
6
- def unpack(data: List, data_format, reversed=False):
7
- """
8
- :param data: 数据字节, 入参均是由modbus读取到的list[uint16]进行转换
9
- :param data_format: 数据格式
10
- :param reversed: 是否翻转大小端
11
- """
12
- cur_data = copy.deepcopy(data)
13
- data_format = data_format.lower()
14
- format_map = {
15
- "int8": "bb",
16
- "uint8": "BB",
17
- "int16": "h",
18
- "uint16": "H",
19
- "int32": "i",
20
- "uint32": "I",
21
- "int64": "q",
22
- "uint64": "Q",
23
- "float": "f",
24
- }
25
- if data_format not in format_map:
26
- raise Exception("暂不支持")
27
- pack_str = ("<" if reversed else ">") + "H" * len(cur_data)
28
- to_pack_data = struct.pack(pack_str, *cur_data)
29
- struct_format = ("<" if reversed else ">") + format_map[data_format]
30
- return struct.unpack(struct_format, to_pack_data)