|
@@ -8,6 +8,8 @@
|
|
|
|
|
|
import csv
|
|
|
from enum import Enum
|
|
|
+import logging
|
|
|
+import re
|
|
|
|
|
|
class TableColumnHeaderType(Enum):
|
|
|
Signal = 0
|
|
@@ -25,25 +27,41 @@ class TableColumnHeaderType(Enum):
|
|
|
|
|
|
class SignalInitValueTableCheck:
|
|
|
|
|
|
- Column_Need_Check = [TableColumnHeaderType.Signal.value,
|
|
|
- TableColumnHeaderType.Type.value,
|
|
|
- TableColumnHeaderType.Bit.value,
|
|
|
- TableColumnHeaderType.RawValue.value]
|
|
|
+ Column_Need_Check = [TableColumnHeaderType.Signal,
|
|
|
+ TableColumnHeaderType.Type,
|
|
|
+ TableColumnHeaderType.Bit,
|
|
|
+ TableColumnHeaderType.RawValue]
|
|
|
|
|
|
- Type_Mapping = {
|
|
|
- 'Boolean': bool,
|
|
|
- 'UInt': ,
|
|
|
- 'SInt': ,
|
|
|
- 'Composite':,
|
|
|
- 'Bytes':
|
|
|
- }
|
|
|
+ # Type_Mapping = {
|
|
|
+ # 'Boolean': bool,
|
|
|
+ # 'UInt': ,
|
|
|
+ # 'SInt': ,
|
|
|
+ # 'Composite':,
|
|
|
+ # 'Bytes':
|
|
|
+ # }
|
|
|
|
|
|
def __init__(self, project_path: str):
|
|
|
pass
|
|
|
|
|
|
|
|
|
- def check_row(self, row: list):
|
|
|
- pass
|
|
|
+ def check_row(self, row: dict) -> bool:
|
|
|
+ # raw missing validation
|
|
|
+
|
|
|
+ # type validation, between[Boolean Composite SInt UInt Bytes]
|
|
|
+ signal_value_type = row[TableColumnHeaderType.Type.name]
|
|
|
+
|
|
|
+ try:
|
|
|
+ # bit length validation
|
|
|
+ signal_bit_len = int(row[TableColumnHeaderType.Bit.name])
|
|
|
+
|
|
|
+ # raw value range validation
|
|
|
+ except ValueError as e:
|
|
|
+ logging.error(f'Signal Bit Transform Failed! Origin bit str is {row[TableColumnHeaderType.Bit.name]}')
|
|
|
+ signal_bit_len = 0
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
def get_signal_init_value_table(self) -> list:
|
|
|
pass
|
|
@@ -60,11 +78,21 @@ class SignalInitValueTableCheck:
|
|
|
if not is_header_readed:
|
|
|
is_header_readed = True
|
|
|
continue
|
|
|
-
|
|
|
- table_data.append([row[column] for column in SignalInitValueTableCheck.Column_Need_Check])
|
|
|
+ row_data = dict()
|
|
|
+ for col in SignalInitValueTableCheck.Column_Need_Check:
|
|
|
+ row_data[col.name] = row[col.value]
|
|
|
+ table_data.append(row_data)
|
|
|
|
|
|
return table_data
|
|
|
|
|
|
+ def get_range_by_bit_length(self, bit_len: int, is_signed: bool = False):
|
|
|
+ # [0, 2^n-1] 2^n = 1<<n
|
|
|
+ # [-2^{n-1}, 2^{n-1}-1]
|
|
|
+ if is_signed:
|
|
|
+ return (-(1<<(bit_len-1)), (1<<(bit_len-1))-1)
|
|
|
+ else:
|
|
|
+ return (0, (1<<bit_len)-1)
|
|
|
+
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
matrix_path = r'D:\01_Work\02_WP\EP39_EREV\branch\src\MatrixAssistant_V2.0\EP39_EREV_SIMU+_GW\20220729-qy1-EP39EREV_SIMU+_GW_Rx_初值表.csv'
|