pymammotion 0.5.69__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.
Files changed (154) hide show
  1. pymammotion/__init__.py +53 -0
  2. pymammotion/agora/__init__.py +0 -0
  3. pymammotion/agora/agora_api.py +755 -0
  4. pymammotion/agora/agora_rtc_capabilities.py +748 -0
  5. pymammotion/agora/agora_websockets.py +1175 -0
  6. pymammotion/aliyun/__init__.py +1 -0
  7. pymammotion/aliyun/client.py +235 -0
  8. pymammotion/aliyun/cloud_gateway.py +982 -0
  9. pymammotion/aliyun/model/aep_response.py +21 -0
  10. pymammotion/aliyun/model/connect_response.py +51 -0
  11. pymammotion/aliyun/model/dev_by_account_response.py +195 -0
  12. pymammotion/aliyun/model/login_by_oauth_response.py +64 -0
  13. pymammotion/aliyun/model/regions_response.py +29 -0
  14. pymammotion/aliyun/model/session_by_authcode_response.py +19 -0
  15. pymammotion/aliyun/model/thing_response.py +12 -0
  16. pymammotion/aliyun/regions.py +62 -0
  17. pymammotion/aliyun/tea/core.py +297 -0
  18. pymammotion/aliyun/tmp_constant.py +171 -0
  19. pymammotion/bluetooth/__init__.py +1 -0
  20. pymammotion/bluetooth/ble.py +62 -0
  21. pymammotion/bluetooth/ble_message.py +676 -0
  22. pymammotion/bluetooth/const.py +27 -0
  23. pymammotion/bluetooth/data/__init__.py +0 -0
  24. pymammotion/bluetooth/data/convert.py +25 -0
  25. pymammotion/bluetooth/data/framectrldata.py +40 -0
  26. pymammotion/bluetooth/data/notifydata.py +62 -0
  27. pymammotion/bluetooth/model/__init__.py +0 -0
  28. pymammotion/bluetooth/model/atomic_integer.py +54 -0
  29. pymammotion/const.py +13 -0
  30. pymammotion/data/__init__.py +0 -0
  31. pymammotion/data/model/__init__.py +8 -0
  32. pymammotion/data/model/account.py +8 -0
  33. pymammotion/data/model/device.py +192 -0
  34. pymammotion/data/model/device_config.py +72 -0
  35. pymammotion/data/model/device_info.py +60 -0
  36. pymammotion/data/model/device_limits.py +49 -0
  37. pymammotion/data/model/enums.py +77 -0
  38. pymammotion/data/model/errors.py +12 -0
  39. pymammotion/data/model/events.py +14 -0
  40. pymammotion/data/model/generate_geojson.py +565 -0
  41. pymammotion/data/model/generate_route_information.py +26 -0
  42. pymammotion/data/model/hash_list.py +475 -0
  43. pymammotion/data/model/location.py +36 -0
  44. pymammotion/data/model/mowing_modes.py +77 -0
  45. pymammotion/data/model/rapid_state.py +45 -0
  46. pymammotion/data/model/raw_data.py +215 -0
  47. pymammotion/data/model/region_data.py +102 -0
  48. pymammotion/data/model/report_info.py +182 -0
  49. pymammotion/data/model/work.py +27 -0
  50. pymammotion/data/mower_state_manager.py +369 -0
  51. pymammotion/data/mqtt/__init__.py +1 -0
  52. pymammotion/data/mqtt/event.py +227 -0
  53. pymammotion/data/mqtt/mammotion_properties.py +276 -0
  54. pymammotion/data/mqtt/properties.py +203 -0
  55. pymammotion/data/mqtt/status.py +57 -0
  56. pymammotion/event/__init__.py +6 -0
  57. pymammotion/event/event.py +96 -0
  58. pymammotion/homeassistant/__init__.py +3 -0
  59. pymammotion/homeassistant/mower_api.py +514 -0
  60. pymammotion/homeassistant/rtk_api.py +54 -0
  61. pymammotion/http/__init__.py +0 -0
  62. pymammotion/http/encryption.py +220 -0
  63. pymammotion/http/http.py +673 -0
  64. pymammotion/http/model/__init__.py +0 -0
  65. pymammotion/http/model/camera_stream.py +31 -0
  66. pymammotion/http/model/http.py +249 -0
  67. pymammotion/http/model/response_factory.py +61 -0
  68. pymammotion/http/model/rtk.py +16 -0
  69. pymammotion/mammotion/__init__.py +0 -0
  70. pymammotion/mammotion/commands/__init__.py +0 -0
  71. pymammotion/mammotion/commands/abstract_message.py +24 -0
  72. pymammotion/mammotion/commands/mammotion_command.py +81 -0
  73. pymammotion/mammotion/commands/messages/__init__.py +0 -0
  74. pymammotion/mammotion/commands/messages/basestation.py +43 -0
  75. pymammotion/mammotion/commands/messages/driver.py +122 -0
  76. pymammotion/mammotion/commands/messages/media.py +87 -0
  77. pymammotion/mammotion/commands/messages/navigation.py +564 -0
  78. pymammotion/mammotion/commands/messages/network.py +205 -0
  79. pymammotion/mammotion/commands/messages/ota.py +38 -0
  80. pymammotion/mammotion/commands/messages/system.py +330 -0
  81. pymammotion/mammotion/commands/messages/video.py +33 -0
  82. pymammotion/mammotion/control/__init__.py +0 -0
  83. pymammotion/mammotion/control/joystick.py +145 -0
  84. pymammotion/mammotion/devices/__init__.py +29 -0
  85. pymammotion/mammotion/devices/base.py +163 -0
  86. pymammotion/mammotion/devices/mammotion.py +571 -0
  87. pymammotion/mammotion/devices/mammotion_bluetooth.py +496 -0
  88. pymammotion/mammotion/devices/mammotion_cloud.py +355 -0
  89. pymammotion/mammotion/devices/mammotion_mower_ble.py +48 -0
  90. pymammotion/mammotion/devices/mammotion_mower_cloud.py +39 -0
  91. pymammotion/mammotion/devices/managers/managers.py +81 -0
  92. pymammotion/mammotion/devices/mower_device.py +120 -0
  93. pymammotion/mammotion/devices/mower_manager.py +107 -0
  94. pymammotion/mammotion/devices/rtk_ble.py +89 -0
  95. pymammotion/mammotion/devices/rtk_cloud.py +115 -0
  96. pymammotion/mammotion/devices/rtk_device.py +50 -0
  97. pymammotion/mammotion/devices/rtk_manager.py +125 -0
  98. pymammotion/mqtt/__init__.py +6 -0
  99. pymammotion/mqtt/aliyun_mqtt.py +237 -0
  100. pymammotion/mqtt/linkkit/__init__.py +5 -0
  101. pymammotion/mqtt/linkkit/h2client.py +585 -0
  102. pymammotion/mqtt/linkkit/linkkit.py +3025 -0
  103. pymammotion/mqtt/mammotion_future.py +26 -0
  104. pymammotion/mqtt/mammotion_mqtt.py +214 -0
  105. pymammotion/mqtt/mqtt_models.py +66 -0
  106. pymammotion/proto/__init__.py +4841 -0
  107. pymammotion/proto/basestation.proto +51 -0
  108. pymammotion/proto/basestation_pb2.py +35 -0
  109. pymammotion/proto/basestation_pb2.pyi +89 -0
  110. pymammotion/proto/common.proto +7 -0
  111. pymammotion/proto/common_pb2.py +25 -0
  112. pymammotion/proto/common_pb2.pyi +13 -0
  113. pymammotion/proto/dev_net.proto +321 -0
  114. pymammotion/proto/dev_net_pb2.py +111 -0
  115. pymammotion/proto/dev_net_pb2.pyi +515 -0
  116. pymammotion/proto/luba_msg.proto +76 -0
  117. pymammotion/proto/luba_msg_pb2.py +41 -0
  118. pymammotion/proto/luba_msg_pb2.pyi +97 -0
  119. pymammotion/proto/luba_mul.proto +129 -0
  120. pymammotion/proto/luba_mul_pb2.py +61 -0
  121. pymammotion/proto/luba_mul_pb2.pyi +178 -0
  122. pymammotion/proto/mctrl_driver.proto +107 -0
  123. pymammotion/proto/mctrl_driver_pb2.py +57 -0
  124. pymammotion/proto/mctrl_driver_pb2.pyi +167 -0
  125. pymammotion/proto/mctrl_nav.proto +591 -0
  126. pymammotion/proto/mctrl_nav_pb2.py +136 -0
  127. pymammotion/proto/mctrl_nav_pb2.pyi +1067 -0
  128. pymammotion/proto/mctrl_ota.proto +80 -0
  129. pymammotion/proto/mctrl_ota_pb2.py +45 -0
  130. pymammotion/proto/mctrl_ota_pb2.pyi +128 -0
  131. pymammotion/proto/mctrl_pept.proto +34 -0
  132. pymammotion/proto/mctrl_pept_pb2.py +33 -0
  133. pymammotion/proto/mctrl_pept_pb2.pyi +58 -0
  134. pymammotion/proto/mctrl_sys.proto +741 -0
  135. pymammotion/proto/mctrl_sys_pb2.py +206 -0
  136. pymammotion/proto/mctrl_sys_pb2.pyi +1213 -0
  137. pymammotion/proto/message_pool.py +3 -0
  138. pymammotion/proto/py.typed +0 -0
  139. pymammotion/py.typed +0 -0
  140. pymammotion/utility/constant/__init__.py +3 -0
  141. pymammotion/utility/constant/device_constant.py +315 -0
  142. pymammotion/utility/conversions.py +5 -0
  143. pymammotion/utility/datatype_converter.py +124 -0
  144. pymammotion/utility/device_config.py +755 -0
  145. pymammotion/utility/device_type.py +489 -0
  146. pymammotion/utility/map.py +259 -0
  147. pymammotion/utility/movement.py +18 -0
  148. pymammotion/utility/mur_mur_hash.py +159 -0
  149. pymammotion/utility/periodic.py +106 -0
  150. pymammotion/utility/rocker_util.py +194 -0
  151. pymammotion-0.5.69.dist-info/METADATA +93 -0
  152. pymammotion-0.5.69.dist-info/RECORD +154 -0
  153. pymammotion-0.5.69.dist-info/WHEEL +4 -0
  154. pymammotion-0.5.69.dist-info/licenses/LICENSE +674 -0
@@ -0,0 +1,3 @@
1
+ import betterproto2
2
+
3
+ default_message_pool = betterproto2.MessagePool()
File without changes
pymammotion/py.typed ADDED
File without changes
@@ -0,0 +1,3 @@
1
+ from .device_constant import PosType, WorkMode, device_mode
2
+
3
+ __all__ = ["WorkMode", "device_mode", "PosType"]
@@ -0,0 +1,315 @@
1
+ from enum import IntEnum
2
+
3
+ from pymammotion.data.model.report_info import ConnectData
4
+
5
+
6
+ class bleOrderCmd:
7
+ allpowerfullRW = 67
8
+ alongBorder = 9
9
+ areaAndTimeAndPathUpdate = 27
10
+ autoUnderPile = 65
11
+ batteryValueUpdate = 5
12
+ bleAlive = 59
13
+ cancelCurrentRecord = 62
14
+ cancelLogUpdate = 45
15
+ cancelPauseExecuteTask = 47
16
+ checkFramwareVersion = 41
17
+ checkFramwareVersionCallBack = 42
18
+ checkSoftVersion = 35
19
+ checkSoftVersionCallBack = 36
20
+ closeKinfe = 50
21
+ close_clear_connect_current_wifi = 77
22
+ deletingConnectionPath = 22
23
+ deviceOrderResponse = 46
24
+ deviceStatusUpdate = 31
25
+ endChannelLine = 15
26
+ endDrawBarrier = 13
27
+ endDrawBorder = 11
28
+ errorCodeUpdate = 34
29
+ framwarePackageCallBack = 40
30
+ framwareSuccessUpdate = 48
31
+ framwareUpdateCallBack = 38
32
+ generateRouteInformation = 210
33
+ getAreaData = 209
34
+ getDeiveBorderState = 64
35
+ getDeviceInfo = 63
36
+ getDeviceLogInfo = 43
37
+ getHashList = 208
38
+ getrecordwifi = 69
39
+ initPointUpdate = 3
40
+ job_plan_setting_read_delete = 78
41
+ job_plan_setting_read_delete_unable_time = 79
42
+ kinfeState = 51
43
+ knifeHightUpdate = 29
44
+ logProgressUpdate = 44
45
+ openKinfe = 49
46
+ optimizationBorderUpadate = 17
47
+ optimizationChannalLineUpdate = 19
48
+ optimizationObstacleUpdate = 18
49
+ originLagLog = 52
50
+ pauseExecuteTask = 7
51
+ removeObstaclesOrObstructions = 21
52
+ replyOptimizationPackage = 20
53
+ resetBaseStation = 61
54
+ responseDevice = 52
55
+ retrunGenerateRouteInformation = 211
56
+ returnCharge = 8
57
+ rtloactionUpdate = 4
58
+ saveTask = 16
59
+ sendBorderPackage = 21
60
+ sendBorderPackageCallBack = 22
61
+ sendChannalLinePackage = 25
62
+ sendChannalLinePackageCallBack = 26
63
+ sendContrlCallBack = 2
64
+ sendControl = 1
65
+ sendExecuteTask = 6
66
+ sendFramwarePackage = 39
67
+ sendFramwareUpdate = 37
68
+ sendObstaclePackage = 23
69
+ sendObstaclePackageCallBack = 24
70
+ sendPlan = 32
71
+ setKnifeHight = 28
72
+ setMaxSpeed = 33
73
+ startChannelLine = 14
74
+ startDrawBarrier = 12
75
+ startDrawBorder = 10
76
+ startWorkOrder = 60
77
+ startjob = 212
78
+ synTime = 57
79
+ task = 213
80
+ taskProgressUpdate = 30
81
+ testPW = 52
82
+ wificonnectinfoupdate = 68
83
+ wirteReadSpeed = 66
84
+
85
+
86
+ class SystemUpdateBuf:
87
+ BATTERY_STATE_INDEX = 2
88
+ CHARGE_POS_VAILD_INDEX = 9
89
+ CHARGE_POS_X_F_INDEX = 7
90
+ CHARGE_POS_Y_F_INDEX = 8
91
+ CHARGE_TOWARD_INDEX = 3
92
+ ERR_CODE_10_INDEX = 21
93
+ ERR_CODE_1_INDEX = 3
94
+ ERR_CODE_2_INDEX = 5
95
+ ERR_CODE_3_INDEX = 7
96
+ ERR_CODE_4_INDEX = 9
97
+ ERR_CODE_5_INDEX = 11
98
+ ERR_CODE_6_INDEX = 13
99
+ ERR_CODE_7_INDEX = 15
100
+ ERR_CODE_8_INDEX = 17
101
+ ERR_CODE_9_INDEX = 19
102
+ ERR_CODE_CNT_INDEX = 2
103
+ ERR_CODE_ID_INDEX = 0
104
+ ERR_CODE_LEN_INDEX = 1
105
+ ERR_CODE_STAMP_10_INDEX = 22
106
+ ERR_CODE_STAMP_1_INDEX = 4
107
+ ERR_CODE_STAMP_2_INDEX = 6
108
+ ERR_CODE_STAMP_3_INDEX = 8
109
+ ERR_CODE_STAMP_4_INDEX = 10
110
+ ERR_CODE_STAMP_5_INDEX = 12
111
+ ERR_CODE_STAMP_6_INDEX = 14
112
+ ERR_CODE_STAMP_7_INDEX = 16
113
+ ERR_CODE_STAMP_8_INDEX = 18
114
+ ERR_CODE_STAMP_9_INDEX = 20
115
+ SU_LAT_D_INDEX = 5
116
+ SU_LON_D_INDEX = 6
117
+ SU_SPEED_F_INDEX = 4
118
+ SYSTEM_ERR_CODE_INDEX_END = 23
119
+ SYSTEM_INIT_CONFIG_ID_INDEX = 0
120
+ SYSTEM_INIT_CONFIG_INDEX_END = 10
121
+ SYSTEM_INIT_CONFIG_LEN_INDEX = 1
122
+ SYSTEM_ZONE_STATE_INDEX_END = 22
123
+ ZONE_STATE_1_INDEX = 2
124
+ ZONE_STATE_ID_INDEX = 0
125
+ ZONE_STATE_LEN_INDEX = 1
126
+
127
+
128
+ class SystemRapidStateTunnelIndex(IntEnum):
129
+ DIS_CAR_RTK_STARS_INDEX = 15
130
+ DIS_RTK_STATUS_INDEX = 13
131
+ L1_SATS_INDEX = 2
132
+ L2_SATS_INDEX = 6
133
+ POS_LEVEL_INDEX = 1
134
+ POS_TYPE_INDEX = 10
135
+ RAPID_WORK_STATE_VER_INDEX = 12
136
+ REAL_POS_X_F_INDEX = 7
137
+ REAL_POS_Y_F_INDEX = 8
138
+ REAL_TOWARD_F_INDEX = 9
139
+ RTK_AGE_F_INDEX = 3
140
+ SIGNAL_QUALITY_INDEX = 0
141
+ TOP4_TOTAL_MEAN_INDEX = 14
142
+ VEL_MEAN_F_INDEX = 5
143
+ VEL_TOP_F_INDEX = 4
144
+ VSIAM_STATE_INDEX = 16
145
+ ZONE_HASH_INDEX = 11
146
+
147
+
148
+ class SystemTardStateTunnel:
149
+ APP_CONNECTED_INFO = 27
150
+ BATTERY_VAL_INDEX = 2
151
+ BOL_HASH_INDEX = 6
152
+ BREAK_POINT_HASH_INDEX = 11
153
+ BREAK_POINT_INFO_INDEX = 10
154
+ BREAK_POINT_X_F_INDEX = 12
155
+ BREAK_POINT_Y_F_INDEX = 13
156
+ CHARGE_STATE_INDEX = 1
157
+ CUT_HEIGHT_INDEX = 3
158
+ DEVICE_OLD_STATUS_INDEX = 25
159
+ DEVICE_STATE_INDEX = 0
160
+ DRAWING_RTK_BAD_OLD_STATE_INDEX = 29
161
+ MAINTAIN_TOTAL_BATTERY_CYCLES_INDEX = 32
162
+ MAINTAIN_TOTAL_MILEAGE_INDEX = 30
163
+ MAINTAIN_TOTAL_MOWING_TIME_INDEX = 31
164
+ MOW_RUN_SPEED_INDEX = 24
165
+ PATH_HASH_INDEX = 7
166
+ PATH_POS_X_F_INDEX = 15
167
+ PATH_POS_Y_F_INDEX = 16
168
+ PLAN_STATE_INDEX = 5
169
+ REAL_PATH_INDEX = 14
170
+ RTK_LORA_NUM_CHANNEL = 35
171
+ RTK_LORA_NUM_LOC_ID = 36
172
+ RTK_LORA_NUM_NET_ID = 37
173
+ RTK_LORA_NUM_SCAN = 34
174
+ RTK_RESTARTING_INDEX = 28
175
+ RTK_STARS_NUM = 33
176
+ RTK_STATUS = 38
177
+ SENSOR_STATE_INDEX = 4
178
+ SYSTEM_TIME_STAMP = 26
179
+ TARD_WORK_STATE_END = 21
180
+ TARD_WORK_STATE_VER_INDEX = 22
181
+ TASK_AREA_INDEX = 9
182
+ TASK_PROGRESS_INDEX = 8
183
+ TEST_SWITCH_STATE_INDEX = 23
184
+ UB_ERR_CODE_HASH_INDEX = 20
185
+ UB_INIT_CONFIG_HASH_INDEX = 19
186
+ UB_REAL_PATH_HASH_INDEX = 18
187
+ UB_ZONE_STATE_HASH_INDEX = 17
188
+
189
+
190
+ class WorkMode:
191
+ MODE_NOT_ACTIVE = 0
192
+ MODE_ONLINE = 1
193
+ MODE_OFFLINE = 2
194
+ MODE_DISABLE = 8
195
+ MODE_INITIALIZATION = 10
196
+ MODE_READY = 11
197
+ MODE_WORKING = 13
198
+ MODE_RETURNING = 14
199
+ MODE_CHARGING = 15
200
+ MODE_UPDATING = 16
201
+ MODE_LOCK = 17
202
+ MODE_PAUSE = 19
203
+ MODE_MANUAL_MOWING = 20
204
+ MODE_UPDATE_SUCCESS = 22
205
+ MODE_OTA_UPGRADE_FAIL = 23
206
+ MODE_JOB_DRAW = 31
207
+ MODE_OBSTACLE_DRAW = 32
208
+ MODE_CHANNEL_DRAW = 34
209
+ MODE_ERASER_DRAW = 35
210
+ MODE_EDIT_BOUNDARY = 36
211
+ MODE_LOCATION_ERROR = 37
212
+ MODE_BOUNDARY_JUMP = 38
213
+ MODE_CHARGING_PAUSE = 39
214
+
215
+
216
+ NO_REQUEST_MODES = (
217
+ WorkMode.MODE_JOB_DRAW,
218
+ WorkMode.MODE_OBSTACLE_DRAW,
219
+ WorkMode.MODE_CHANNEL_DRAW,
220
+ WorkMode.MODE_ERASER_DRAW,
221
+ WorkMode.MODE_UPDATING,
222
+ WorkMode.MODE_EDIT_BOUNDARY,
223
+ WorkMode.MODE_UPDATING,
224
+ WorkMode.MODE_LOCK,
225
+ WorkMode.MODE_MANUAL_MOWING,
226
+ )
227
+
228
+
229
+ def device_connection(connect: ConnectData) -> str:
230
+ """Return string representation of device connection."""
231
+
232
+ if connect.wifi_rssi != 0 and connect.ble_rssi != 0:
233
+ return "WIFI/BLE"
234
+
235
+ if connect.connect_type == 2 or connect.used_net == "NET_USED_TYPE_WIFI" or connect.wifi_rssi != 0:
236
+ return "WIFI"
237
+
238
+ if connect.connect_type == 1 or connect.used_net == "NET_USED_TYPE_MNET":
239
+ return "3G/4G"
240
+
241
+ if connect.ble_rssi != 0:
242
+ return "BLE"
243
+
244
+ return "None"
245
+
246
+
247
+ def device_mode(value: int) -> str:
248
+ """Return the mode corresponding to the given value.
249
+
250
+ This function takes a value and returns the corresponding mode from a
251
+ predefined dictionary.
252
+
253
+ Args:
254
+ value (int): The value for which mode needs to be determined.
255
+
256
+ Returns:
257
+ str: The mode corresponding to the input value. Returns "Invalid mode" if no
258
+ mode is found.
259
+
260
+ """
261
+
262
+ modes = {
263
+ 0: "MODE_NOT_ACTIVE",
264
+ 1: "MODE_ONLINE",
265
+ 2: "MODE_OFFLINE",
266
+ 8: "MODE_DISABLE",
267
+ 10: "MODE_INITIALIZATION",
268
+ 11: "MODE_READY",
269
+ 12: "MODE_UNCONNECTED",
270
+ 13: "MODE_WORKING",
271
+ 14: "MODE_RETURNING",
272
+ 15: "MODE_CHARGING",
273
+ 16: "MODE_UPDATING",
274
+ 17: "MODE_LOCK",
275
+ 19: "MODE_PAUSE",
276
+ 20: "MODE_MANUAL_MOWING",
277
+ 22: "MODE_UPDATE_SUCCESS",
278
+ 23: "MODE_OTA_UPGRADE_FAIL",
279
+ 31: "MODE_JOB_DRAW",
280
+ 32: "MODE_OBSTACLE_DRAW",
281
+ 34: "MODE_CHANNEL_DRAW",
282
+ 35: "MODE_ERASER_DRAW",
283
+ 36: "MODE_EDIT_BOUNDARY",
284
+ 37: "MODE_LOCATION_ERROR",
285
+ 38: "MODE_BOUNDARY_JUMP",
286
+ 39: "MODE_CHARGING_PAUSE",
287
+ }
288
+ return modes.get(value, "Invalid mode")
289
+
290
+
291
+ class PosType(IntEnum):
292
+ """Position of the robot."""
293
+
294
+ AREA_BORDER_ON = 7
295
+ AREA_INSIDE = 1
296
+ AREA_OUT = 0
297
+ CHANNEL_AREA_OVERLAP = 9
298
+ CHANNEL_ON = 3
299
+ CHARGE_ON = 5
300
+ DUMPING_AREA_INSIDE = 8
301
+ DUMPING_OUTSIDE = 10
302
+ ABNORMAL_POSITIONING = 11
303
+ NO_AREAS = 100
304
+ OBS_ON = 2
305
+ TURN_AREA_INSIDE = 4
306
+ VIRTUAL_INSIDE = 6
307
+
308
+
309
+ def camera_brightness(value: int) -> str:
310
+ """Return the brightness corresponding to the given value."""
311
+ modes = {
312
+ 0: "Dark",
313
+ 1: "Light",
314
+ }
315
+ return modes.get(value, "Invalid mode")
@@ -0,0 +1,5 @@
1
+ import math
2
+
3
+
4
+ def parse_double(val: float, d: float):
5
+ return val / math.pow(10.0, d)
@@ -0,0 +1,124 @@
1
+ import base64
2
+
3
+
4
+ class DatatypeConverter:
5
+ encode_map: list[str | int] | None = None
6
+
7
+ @staticmethod
8
+ def init_encode_map():
9
+ """Initialize the encode map for DatatypeConverter if it is not already
10
+ initialized.
11
+
12
+ This function initializes the encode map for DatatypeConverter by
13
+ creating a list of 64 elements and populating it with characters for
14
+ encoding. If the encode map is already initialized, it returns the
15
+ existing encode map.
16
+
17
+ Returns:
18
+ list: The encode map for DatatypeConverter.
19
+
20
+ """
21
+
22
+ if DatatypeConverter.encode_map is None:
23
+ c_arr: list[str | int] = [0] * 64
24
+ for num in range(26):
25
+ c_arr[num] = chr(num + 65)
26
+ for num_2 in range(26, 52):
27
+ c_arr[num_2] = chr(num_2 - 26 + 97)
28
+ for num_3 in range(52, 62):
29
+ c_arr[num_3] = chr(num_3 - 52 + 48)
30
+ c_arr[62] = "+"
31
+ c_arr[63] = "/"
32
+ DatatypeConverter.encode_map = c_arr
33
+ return DatatypeConverter.encode_map
34
+
35
+ @staticmethod
36
+ def parseBase64Binary(s: str) -> bytes:
37
+ return base64.b64decode(s)
38
+
39
+ @staticmethod
40
+ def printBase64Binary(bArr: bytes) -> str:
41
+ """Print the Base64 str representation of a byte array."""
42
+ return DatatypeConverter._printBase64Binary(bArr)
43
+
44
+ @staticmethod
45
+ def encode(i):
46
+ return DatatypeConverter.encode_map[i & 63]
47
+
48
+ @staticmethod
49
+ def _printBase64Binary(bArr: bytes, i: int = 0, i2=None) -> str:
50
+ """Print the Base64 binary representation of a byte array.
51
+
52
+ This function takes a byte array and optional start and end indices to
53
+ print the Base64 binary representation.
54
+
55
+ Args:
56
+ bArr (list): A list of bytes to be converted to Base64 binary.
57
+ i (int): The starting index of the byte array (default is 0).
58
+ i2 (int): The ending index of the byte array (default is the length of bArr).
59
+
60
+ Returns:
61
+ str: The Base64 binary representation of the input byte array.
62
+
63
+ """
64
+
65
+ if i2 is None:
66
+ i2 = len(bArr)
67
+ cArr = [""] * (((i2 + 2) // 3) * 4)
68
+ DatatypeConverter._printBase64Binary_core(bArr, i, i2, cArr, 0)
69
+ return "".join(cArr)
70
+
71
+ @staticmethod
72
+ def _printBase64Binary_core(bArr: bytes, i, i2, cArr, i3) -> int:
73
+ """Encode binary data into Base64 format.
74
+
75
+ This function encodes binary data into Base64 format following the
76
+ Base64 encoding algorithm.
77
+
78
+ Args:
79
+ bArr (list): List of binary data to be encoded.
80
+ i (int): Starting index of the binary data to be encoded.
81
+ i2 (int): Length of binary data to be encoded.
82
+ cArr (list): List to store the encoded Base64 characters.
83
+ i3 (int): Starting index in the cArr to store the encoded characters.
84
+
85
+ Returns:
86
+ int: The index in cArr where encoding ends.
87
+
88
+ Note:
89
+ This function assumes that DatatypeConverter has a method 'encode' and
90
+ 'init_encode_map' for encoding.
91
+
92
+ """
93
+
94
+ DatatypeConverter.init_encode_map() # Ensure encode_map is initialized
95
+ while i2 >= 3:
96
+ cArr[i3] = DatatypeConverter.encode(bArr[i] >> 2)
97
+ cArr[i3 + 1] = DatatypeConverter.encode(((bArr[i] & 3) << 4) | ((bArr[i + 1] >> 4) & 15))
98
+ cArr[i3 + 2] = DatatypeConverter.encode(((bArr[i + 1] & 15) << 2) | ((bArr[i + 2] >> 6) & 3))
99
+ cArr[i3 + 3] = DatatypeConverter.encode(bArr[i + 2] & 63)
100
+ i2 -= 3
101
+ i += 3
102
+ i3 += 4
103
+
104
+ if i2 == 1:
105
+ cArr[i3] = DatatypeConverter.encode(bArr[i] >> 2)
106
+ cArr[i3 + 1] = DatatypeConverter.encode((bArr[i] & 3) << 4)
107
+ cArr[i3 + 2] = "="
108
+ cArr[i3 + 3] = "="
109
+
110
+ if i2 == 2:
111
+ cArr[i3] = DatatypeConverter.encode(bArr[i] >> 2)
112
+ cArr[i3 + 1] = DatatypeConverter.encode(((bArr[i] & 3) << 4) | ((bArr[i + 1] >> 4) & 15))
113
+ cArr[i3 + 2] = DatatypeConverter.encode((bArr[i + 1] & 15) << 2)
114
+ cArr[i3 + 3] = "="
115
+
116
+ return i3
117
+
118
+
119
+ # Usage Example:
120
+ # converter = DatatypeConverter()
121
+ # encoded = converter.printBase64Binary(b"Hello, World!")
122
+ # print(encoded) # Output: "SGVsbG8sIFdvcmxkIQ=="
123
+ # decoded = converter.parseBase64Binary(encoded)
124
+ # print(decoded) # Output: b'Hello, World!'