Skip to content
Snippets Groups Projects
Commit fd196db8 authored by jtkenny's avatar jtkenny
Browse files

LogHandler works

parent bb228cf7
No related branches found
No related tags found
5 merge requests!106Adding Pycrocart 2.1,!104adding cflib to this branch,!103Updating develop to current state of master branch,!98Pycrocart 2.1 will,!94Merge cflib adapter into main
...@@ -61,10 +61,10 @@ class LogfileHandler: ...@@ -61,10 +61,10 @@ class LogfileHandler:
def refresh_logging_configs(self): def refresh_logging_configs(self):
raise Exception return self.read_all_active_blocks()
def load_logging_configs() : def load_logging_configs(self):
raise Exception return self.read_all_active_blocks()
def clear_logging_configs(self): def clear_logging_configs(self):
""" Stop logging and clear configuration. Used when refreshing """ Stop logging and clear configuration. Used when refreshing
...@@ -115,17 +115,29 @@ class LogfileHandler: ...@@ -115,17 +115,29 @@ class LogfileHandler:
if len(formatLine) == 0 or formatLine[0] == '#': if len(formatLine) == 0 or formatLine[0] == '#':
continue continue
elif formatLine == "START BLOCK": elif formatLine == "START BLOCK":
print(line)
data = [] data = []
for i in range(0,6): i = 0
newLine = logBlockFile.readline().strip() newLine = logBlockFile.readline().strip()
while newLine != "END BLOCK":
print(newLine)
if newLine == "" or newLine == "END BLOCK": if newLine == "" or newLine == "END BLOCK":
print("New Line: " + newLine)
raise Exception("loggingBlocks.txt is not formatted correctly") raise Exception("loggingBlocks.txt is not formatted correctly")
if i == 0 or i == 2: if i == 0 or i == 2:
data.append(int(newLine)) data.append(int(newLine))
else: else:
data.append(newLine) data.append(newLine)
if len(data) != 6 or logBlockFile.readline().strip() != "END BLOCK": newLine = logBlockFile.readline().strip()
i += 1
if logBlockFile.readline().strip() == "START BLOCK":
print(data)
raise Exception("loggingBlocks.txt is not formatted correctly") raise Exception("loggingBlocks.txt is not formatted correctly")
config = LogConfig(data[1], data[2])
for i in range(3, len(data)):
config.add_variable(data[i])
config.create()
active_blocks.append(config)
return active_blocks
File added
File added
File added
File added
File added
...@@ -4,6 +4,7 @@ from queue import Queue ...@@ -4,6 +4,7 @@ from queue import Queue
from threading import Thread from threading import Thread
from groundstation_socket import GroundstationSocket, MessageTypeID from groundstation_socket import GroundstationSocket, MessageTypeID
from crazyflie_connection import CrazyflieConnection from crazyflie_connection import CrazyflieConnection
from LogfileHandler import LogfileHandler
class main(): class main():
...@@ -75,6 +76,8 @@ class main(): ...@@ -75,6 +76,8 @@ class main():
if __name__ == '__main__': if __name__ == '__main__':
main().start() lf = LogfileHandler()
lf.read_all_active_blocks()
#main().start()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment