plantstar-shared 2.0.3.0.2.15__py3-none-any.whl → 2.0.3.0.2.16__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.
- plantstar_shared/HmiKeyConstants.py +9 -0
- plantstar_shared/api_types.py +9 -0
- plantstar_shared/convert_bytes_to_object.py +1 -1
- plantstar_shared/tcp_socket_utils.py +22 -86
- {plantstar_shared-2.0.3.0.2.15.dist-info → plantstar_shared-2.0.3.0.2.16.dist-info}/METADATA +1 -1
- {plantstar_shared-2.0.3.0.2.15.dist-info → plantstar_shared-2.0.3.0.2.16.dist-info}/RECORD +8 -7
- {plantstar_shared-2.0.3.0.2.15.dist-info → plantstar_shared-2.0.3.0.2.16.dist-info}/WHEEL +0 -0
- {plantstar_shared-2.0.3.0.2.15.dist-info → plantstar_shared-2.0.3.0.2.16.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,9 @@
|
|
1
|
+
class HmiKeyConstants:
|
2
|
+
APU_IP_ADDRESS = "apu_ip_address"
|
3
|
+
HMI_HOSTNAME = "hmi_hostname"
|
4
|
+
HMI_HOMEPAGE = "hmi_homepage"
|
5
|
+
HMI_IP_ADDRESS_TYPE = "hmi_ip_address_type"
|
6
|
+
HMI_IP_ADDRESS = "hmi_ip_address"
|
7
|
+
HMI_NETMASK = "hmi_netmask"
|
8
|
+
HMI_DEFAULT_GATEWAY = "hmi_default_gateway"
|
9
|
+
HMI_DNS = "hmi_dns"
|
plantstar_shared/api_types.py
CHANGED
@@ -97,7 +97,16 @@ class DataCollectionModuleApiTypes(SysconType):
|
|
97
97
|
class ApuApiTypes(SysconType):
|
98
98
|
SET_IS_INITIALIZING_STATUS = ("data_collection_module_manager/set_is_initializing_status", "data_collection_module_manager/set_is_initializing_status", True)
|
99
99
|
SET_IS_COLDBOOTING_STATUS = ("data_collection_module_manager/set_is_coldbooting_status", "data_collection_module_manager/set_is_coldbooting_status", True)
|
100
|
+
REGISTER_HMI = ("data_collection_module_manager/register_hmi", "data_collection_module_manager/register_hmi", True)
|
101
|
+
REGISTER_DCM = ("data_collection_module_manager/register_dcm", "data_collection_module_manager/register_dcm", True)
|
100
102
|
|
101
103
|
|
102
104
|
class CosmosApiTypes(SysconType):
|
103
105
|
SEND_DATA_DICTIONARY = ("send_data_dictionary", "send_data_dictionary", True)
|
106
|
+
|
107
|
+
|
108
|
+
class HmiApiTypes(SysconType):
|
109
|
+
GET_HMI_SYSTEM_INFORMATION = ("get_hmi_system_information", "get_hmi_system_information", True)
|
110
|
+
SET_HMI_SYSTEM_INFORMATION = ("set_hmi_system_information", "set_hmi_system_information", True)
|
111
|
+
REBOOT_HMI = ("reboot_hmi", "reboot_hmi", True)
|
112
|
+
|
@@ -2,9 +2,9 @@ import msgpack
|
|
2
2
|
|
3
3
|
from plantstar_shared.errors import SocketConnectionError
|
4
4
|
|
5
|
-
|
6
5
|
# Converts bytes into an object using msgpack, with a parameter for strict_map_key
|
7
6
|
def convert_bytes_to_object(object_as_bytes, strict_map_key=False):
|
7
|
+
|
8
8
|
if not object_as_bytes:
|
9
9
|
raise SocketConnectionError
|
10
10
|
|
@@ -2,100 +2,47 @@ import struct
|
|
2
2
|
|
3
3
|
from plantstar_shared.convert_bytes_to_object import convert_bytes_to_object
|
4
4
|
from plantstar_shared.convert_object_to_bytes import convert_object_to_bytes
|
5
|
-
from plantstar_shared.errors import SocketConnectionError
|
5
|
+
from plantstar_shared.errors import SocketConnectionError
|
6
6
|
|
7
|
-
|
8
|
-
SIZE_OF_UNSIGNED_INT_STRUCT = 4 # size of the integer value that precedes data coming from most sockets (DeviceController, DCM, etc)
|
7
|
+
SIZE_OF_UNSIGNED_INT_STRUCT = 4
|
9
8
|
|
10
9
|
|
11
|
-
def read_size_value_from_socket(*, remote_socket
|
12
|
-
|
10
|
+
def read_size_value_from_socket(*, remote_socket):
|
11
|
+
size_struct = remote_socket.recv(SIZE_OF_UNSIGNED_INT_STRUCT)
|
13
12
|
|
14
|
-
if not
|
15
|
-
|
16
|
-
|
17
|
-
if number_of_bytes_for_size_prefix == SIZE_OF_UNSIGNED_INT_FOR_HUSKY:
|
18
|
-
size_for_message = int.from_bytes(size_bytes, 'big') if is_big_endian else int.from_bytes(size_bytes, 'little')
|
19
|
-
elif number_of_bytes_for_size_prefix == SIZE_OF_UNSIGNED_INT_STRUCT:
|
20
|
-
number_format = ">I" if is_big_endian else "<I"
|
21
|
-
|
22
|
-
try:
|
23
|
-
size_for_message = struct.unpack(number_format, size_bytes)[0]
|
24
|
-
except struct.error as error:
|
25
|
-
raise SocketConnectionError
|
26
|
-
else:
|
27
|
-
raise SysconProgrammingError("A size prefix was set to something other than 2 or 4")
|
28
|
-
|
29
|
-
if size_value_includes_size_prefix_bytes:
|
30
|
-
size_for_message = size_for_message - number_of_bytes_for_size_prefix
|
31
|
-
|
32
|
-
return size_for_message, size_bytes
|
33
|
-
|
34
|
-
|
35
|
-
def get_bytes_from_socket(
|
36
|
-
*, remote_socket, number_of_bytes_to_read=None, is_big_endian=True, number_of_bytes_for_size_prefix=0, size_value_includes_size_prefix_bytes=False,
|
37
|
-
size_value_should_be_included_in_final_message=False
|
38
|
-
):
|
39
|
-
"""Obtains a number of bytes from a provided socket, with options for different configurations and situations.
|
40
|
-
Returns byte sequence, and the size value that was obtained from the prefix bytes.
|
41
|
-
|
42
|
-
Keywords / Example Configurations:
|
43
|
-
remote_socket -- the connection that bytes will be read from
|
44
|
-
|
45
|
-
number_of_bytes_to_read -- the number of bytes to read on the socket, if this is known, this is the only optional parameter needed (default: 0)
|
46
|
-
|
47
|
-
is_big_endian -- bool: what format string should be used for unpacking the size value (default: True)
|
48
|
-
|
49
|
-
number_of_bytes_for_size_prefix -- the number of bytes to read to determine the total size of the message to pass (default: 0)
|
13
|
+
if not size_struct:
|
14
|
+
return None
|
50
15
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
-----
|
16
|
+
try:
|
17
|
+
message_length = struct.unpack('>I', size_struct)[0]
|
18
|
+
except struct.error as error:
|
19
|
+
raise SocketConnectionError
|
56
20
|
|
57
|
-
|
21
|
+
return message_length
|
58
22
|
|
59
|
-
get_bytes_from_socket(remote_socket=conn, is_big_endian=True, number_of_bytes_for_size_prefix=4) - reads 4 bytes to get the size, then reads that amount (DCM socket, etc)
|
60
23
|
|
61
|
-
|
62
|
-
|
24
|
+
def get_message_from_socket(*, remote_socket):
|
25
|
+
message_length = read_size_value_from_socket(remote_socket=remote_socket)
|
63
26
|
|
64
|
-
|
27
|
+
if not message_length:
|
28
|
+
return None
|
65
29
|
|
66
30
|
packets = []
|
67
|
-
|
68
|
-
if not number_of_bytes_to_read:
|
69
|
-
if number_of_bytes_for_size_prefix:
|
70
|
-
number_of_bytes_to_read, size_bytes = read_size_value_from_socket(
|
71
|
-
remote_socket=remote_socket, is_big_endian=is_big_endian, number_of_bytes_for_size_prefix=number_of_bytes_for_size_prefix,
|
72
|
-
size_value_includes_size_prefix_bytes=size_value_includes_size_prefix_bytes
|
73
|
-
)
|
74
|
-
|
75
|
-
if not number_of_bytes_to_read:
|
76
|
-
raise SocketConnectionError
|
77
|
-
|
78
|
-
if size_value_should_be_included_in_final_message:
|
79
|
-
packets.append(size_bytes)
|
80
|
-
|
81
|
-
else:
|
82
|
-
raise SysconProgrammingError("get_bytes_from_socket was called with no parameters for number_of_bytes_to_read or number_of_bytes_for_size_prefix")
|
83
|
-
|
84
31
|
bytes_received = 0
|
85
32
|
|
86
33
|
# While loop that will stream in data if the full request is not available yet
|
87
|
-
while bytes_received <
|
88
|
-
buffer_size =
|
34
|
+
while bytes_received < message_length:
|
35
|
+
buffer_size = message_length - bytes_received
|
89
36
|
packet = remote_socket.recv(buffer_size)
|
90
37
|
|
91
38
|
if not packet:
|
92
|
-
|
39
|
+
return None
|
93
40
|
|
94
41
|
packets.append(packet)
|
95
42
|
bytes_received = bytes_received + len(packet)
|
96
43
|
|
97
44
|
data = b''.join(packets)
|
98
|
-
return data
|
45
|
+
return data
|
99
46
|
|
100
47
|
|
101
48
|
def send_message_on_socket(*, remote_socket, dumpsable_object):
|
@@ -115,18 +62,7 @@ def send_encoded_message_on_socket(*, remote_socket, encoded_message):
|
|
115
62
|
bytes_sent += new_bytes_sent
|
116
63
|
|
117
64
|
|
118
|
-
def get_object_from_socket(
|
119
|
-
|
120
|
-
size_value_includes_size_prefix_bytes=False
|
121
|
-
):
|
122
|
-
"""Function that is used between the APU and DCM to send dictionaries. Returns a tuple of the object and its size in bytes."""
|
123
|
-
object_from_interface_as_bytes, size_of_object_in_bytes = get_bytes_from_socket(
|
124
|
-
remote_socket=remote_socket, number_of_bytes_to_read=number_of_bytes_to_read, is_big_endian=is_big_endian, number_of_bytes_for_size_prefix=number_of_bytes_for_size_prefix,
|
125
|
-
size_value_includes_size_prefix_bytes=size_value_includes_size_prefix_bytes
|
126
|
-
)
|
127
|
-
|
128
|
-
if not object_from_interface_as_bytes:
|
129
|
-
raise SocketConnectionError
|
130
|
-
|
65
|
+
def get_object_from_socket(*, remote_socket):
|
66
|
+
object_from_interface_as_bytes = get_message_from_socket(remote_socket=remote_socket)
|
131
67
|
object_from_interface = convert_bytes_to_object(object_from_interface_as_bytes)
|
132
|
-
return object_from_interface
|
68
|
+
return object_from_interface
|
@@ -1,12 +1,13 @@
|
|
1
1
|
plantstar_shared/DataCollectionModuleProcessNames.py,sha256=L21K4eznLCIYAbb4g7qKhyHKS1aK4w9dSu5r6LGewGs,441
|
2
|
+
plantstar_shared/HmiKeyConstants.py,sha256=nVzZim026r2-UplsgS6swMeCYgOhl_OE_RQ-yjcDTUs,319
|
2
3
|
plantstar_shared/HuskyInterfacePacketTypes.py,sha256=tUWcWKpaBgYs2S8zll9E5-YTMqGfOIU4kj5mroQe344,1372
|
3
4
|
plantstar_shared/MockRawDataProcessor.py,sha256=Gc2CfteJdLZwYPj73FuyEv16uTzoJsUB479Xc74S5ow,5382
|
4
5
|
plantstar_shared/RawDataProcessorInterfaceActions.py,sha256=XnXuFW3BFSa89-VmhGAKQxDBPalsQWapw4h0P5q0IXw,632
|
5
6
|
plantstar_shared/SysconType.py,sha256=6Ae9F0fBr0vpXAmP8fYqoWyFUGTEECtS55zAYMkeKlY,1581
|
6
7
|
plantstar_shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
8
|
plantstar_shared/add_size_onto_string_and_return.py,sha256=j7XSs5ubKKo5LCMVljzZudK2nw8CZh-zMSLT_t30aGg,385
|
8
|
-
plantstar_shared/api_types.py,sha256=
|
9
|
-
plantstar_shared/convert_bytes_to_object.py,sha256=
|
9
|
+
plantstar_shared/api_types.py,sha256=farJcD_bETXyGTYM1roACDB85xy8LHxJ4vPS_df8kLc,5527
|
10
|
+
plantstar_shared/convert_bytes_to_object.py,sha256=MVOKqJJeUjvEKJL_ELNPkxZEgqwlk3zT8CwfVtpwOgU,409
|
10
11
|
plantstar_shared/convert_object_to_bytes.py,sha256=vVS3dKkPynOJ2NV2LgLHdEOZflK_0hhdS-NuU_gcfHs,206
|
11
12
|
plantstar_shared/errors.py,sha256=qEUHh2d7pqZHoag6YJjnVfRWzWAzjuyGZH7stT_-Nzk,341
|
12
13
|
plantstar_shared/global_definitions.py,sha256=mj59nU21DYza4XgZQxLX2lTvJYooN_-ZFrh8SVXFBRs,1153
|
@@ -14,8 +15,8 @@ plantstar_shared/is_valid_signed_string.py,sha256=5ZiEsPRz30J8yxN4A1dHq-hlz7VI9r
|
|
14
15
|
plantstar_shared/obtain_raw_data_processor_function_for_action_name.py,sha256=DYo307PraRRD8zGiSO6Fn03bZ4X9aDOYV9rwaRm8mXM,1134
|
15
16
|
plantstar_shared/syscon_image_field.py,sha256=GlTTudqFT5EsWM5sPRO0p5SDascX7gI1BEOeF1OG7Tw,441
|
16
17
|
plantstar_shared/syscon_json.py,sha256=8OG9_55d52V9e2fFNguDtQ_pnw1YwyYsg2pnUkhjW6g,4213
|
17
|
-
plantstar_shared/tcp_socket_utils.py,sha256=
|
18
|
-
plantstar_shared-2.0.3.0.2.
|
19
|
-
plantstar_shared-2.0.3.0.2.
|
20
|
-
plantstar_shared-2.0.3.0.2.
|
21
|
-
plantstar_shared-2.0.3.0.2.
|
18
|
+
plantstar_shared/tcp_socket_utils.py,sha256=sI5IJXMTsQuTPzm8V5T1nsY5aMF-78zGL69aIDLCD_A,2250
|
19
|
+
plantstar_shared-2.0.3.0.2.16.dist-info/METADATA,sha256=wyt2aQYCrws1rK0OYqoFDzyqevg1S6gaCVxDmJTM4_Q,659
|
20
|
+
plantstar_shared-2.0.3.0.2.16.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
21
|
+
plantstar_shared-2.0.3.0.2.16.dist-info/top_level.txt,sha256=9ZTCr_aP1GqYGt7EVmlSIUF72bdMZErapyhbik-MWVQ,17
|
22
|
+
plantstar_shared-2.0.3.0.2.16.dist-info/RECORD,,
|
File without changes
|
{plantstar_shared-2.0.3.0.2.15.dist-info → plantstar_shared-2.0.3.0.2.16.dist-info}/top_level.txt
RENAMED
File without changes
|