Utility Module
- JciHitachi.utility.bin_concat(int_1, int_2, int_1_byte=None, int_2_byte=None)[source]
Concatenate two integer. Steps:
Zero fill integers according to the given byte.
Concatenate two integers in binary.
- Parameters:
int_1 (int) – Left partition.
int_2 (int) – Right partition.
int_1_byte (int, optional) – If None is given, int_1 will be zero filled to the number which can be devided exactly by 8, otherwise int_1 will be zero filled to int_1_byte*8, by default None.
int_2_byte (int, optional) – If None is given, int_2 will be zero filled to the number which can be devided exactly by 8, otherwise int_2 will be zero filled to int_2_byte*8, by default None.
- Returns:
Concatenated value.
- Return type:
int
- JciHitachi.utility.cast_bytes(v, nbytes)[source]
Cast byte(s) from v.
- Parameters:
v (int) – Value to be casted.
nbytes (int) – Number of bytes will be casted.
- Returns:
Casted value.
- Return type:
int
- JciHitachi.utility.convert_hash(v)[source]
Convert md5 from string. Steps:
Use hashlib to convert md5.
Perform “And 255” then “Or 256” to ensure the length of hashed code is limited within 511 (0b111111111).
- Parameters:
v (str) – Value to be converted.
- Returns:
Converted hash code.
- Return type:
str
- JciHitachi.utility.extract_bytes(v, start, end)[source]
Extract bytes scope, from start(left) to end(right). Steps:
Right shift end bytes.
Perform cast_bytes to extract the scope of start-end.
- Parameters:
v (int) – Value to be extracted.
start (int) – Starting byte.
end (int) – Ending byte.
- Returns:
Extracted value.
- Return type:
int