|
@@ -37,16 +37,16 @@ class LogParser(Parser):
|
|
|
@staticmethod
|
|
|
def print_entry(entry: tuple, index: int):
|
|
|
timestamp = time.ctime(entry[0]/1000 - LogParser.utc_offset)
|
|
|
- ans = f"[LOG] {index}: {LogParser.events[entry[1]]}, {timestamp}, state: {entry[2]}, channel: {entry[3]}, value: {entry[4]}"
|
|
|
+ ans = f"[LOG] {index:05}: {LogParser.events[entry[1]]}, {timestamp}, state: {entry[2]}, channel: {entry[3]}, value: {entry[4]}"
|
|
|
print(Fore.CYAN + ans)
|
|
|
|
|
|
|
|
|
class ArchiveParser(Parser):
|
|
|
|
|
|
@staticmethod
|
|
|
- def print_entry(entry: tuple, index: int):
|
|
|
+ def print_entry(entry: tuple, channel: int, index: int):
|
|
|
timestamp = time.ctime(entry[0]/1000 - LogParser.utc_offset)
|
|
|
- ans = f"[ARCHIVE] {index}: {timestamp}, value: {entry[1]}"
|
|
|
+ ans = f"[ARCHIVE] {index:05}: {timestamp}, value: {entry[1]}"
|
|
|
print(Fore.CYAN + ans)
|
|
|
|
|
|
|
|
@@ -96,6 +96,7 @@ class LogReader:
|
|
|
|
|
|
|
|
|
class DigitalLogReader(LogReader):
|
|
|
+
|
|
|
def __init__(self, modbus: Modbus):
|
|
|
super().__init__(modbus)
|
|
|
|
|
@@ -119,8 +120,9 @@ class DigitalLogReader(LogReader):
|
|
|
data = self.modbus.read_file_record(LOG_ENTRY, 0, index, 1)
|
|
|
LogParser.print_entry(struct.unpack('<QBBBfB', data[5:21]), index)
|
|
|
|
|
|
- # def print_archive_entry(self, index):
|
|
|
-
|
|
|
+ def print_archive_entry(self, channel, index):
|
|
|
+ data = self.modbus.read_file_record(ARCHIVE_ENTRY, channel, index, 1)
|
|
|
+ ArchiveParser.print_entry(struct.unpack('<QBB', data[5:15]), channel, index)
|
|
|
|
|
|
def get_random_log_entry(self):
|
|
|
data = self.modbus.read_file_record(LOG_ENTRY, 0, randint(1, self.log_entries_number), 1)
|
|
@@ -138,14 +140,12 @@ class DigitalLogReader(LogReader):
|
|
|
|
|
|
def get_all_archive(self):
|
|
|
self.get_log_info()
|
|
|
- # print(self.archive_entries_number)
|
|
|
for channel in range(0, len(self.archive_entries_number)):
|
|
|
- # print(f"Archive channel {channel} {self.archive_entries_number[channel]}")
|
|
|
- # print(self.archive_entries_number[channel])
|
|
|
if (self.archive_entries_number[channel]):
|
|
|
- print(f"Archive channel {channel}")
|
|
|
+ print(Fore.LIGHTGREEN_EX + f"Archive channel: {channel}")
|
|
|
for i in range(0, self.archive_entries_number[channel]):
|
|
|
- print(self.get_archive_entry(channel, i+1))
|
|
|
+ self.print_archive_entry(channel, i + 1)
|
|
|
+
|
|
|
|
|
|
def get_all_log(self):
|
|
|
self.get_log_info()
|