mirror of
https://gitlab.com/manzerbredes/esds.git
synced 2025-04-06 10:06:28 +02:00
Improve debug
This commit is contained in:
parent
bc4ce548db
commit
0e1e51d1ee
2 changed files with 11 additions and 6 deletions
|
@ -13,11 +13,13 @@ class Debug:
|
||||||
self.loop_count=0
|
self.loop_count=0
|
||||||
self.logs=list()
|
self.logs=list()
|
||||||
header={
|
header={
|
||||||
|
"debug_version": 1,
|
||||||
"python_version" : sys.version,
|
"python_version" : sys.version,
|
||||||
"simulation_started_at": simulator.startat,
|
"simulation_started_at": simulator.startat,
|
||||||
"number_of_nodes": len(simulator.nodes),
|
"number_of_nodes": len(simulator.nodes),
|
||||||
"manual_breakpoints": breakpoints,
|
"manual_breakpoints": breakpoints,
|
||||||
"auto_breakpoint": breakpoints_every
|
"auto_breakpoint": breakpoints_every,
|
||||||
|
"interferences": interferences
|
||||||
}
|
}
|
||||||
self.write(header,append=False)
|
self.write(header,append=False)
|
||||||
|
|
||||||
|
@ -27,7 +29,7 @@ class Debug:
|
||||||
def write(self,data, append=True):
|
def write(self,data, append=True):
|
||||||
mode="a" if append else "w"
|
mode="a" if append else "w"
|
||||||
with open(self.file_path, mode) as f:
|
with open(self.file_path, mode) as f:
|
||||||
f.write(json.dumps(data,default=serialize_int64))
|
f.write(json.dumps(data,default=serialize_int64,separators=(",",":")))
|
||||||
f.write("\n")
|
f.write("\n")
|
||||||
|
|
||||||
def get_network_interfaces(self):
|
def get_network_interfaces(self):
|
||||||
|
|
|
@ -375,9 +375,6 @@ class Simulator:
|
||||||
# Synchronize blocking api calls
|
# Synchronize blocking api calls
|
||||||
for node in self.nodes:
|
for node in self.nodes:
|
||||||
self.sync_node_blocking(node)
|
self.sync_node_blocking(node)
|
||||||
# Generate debug logs
|
|
||||||
if debug:
|
|
||||||
self.debug.debug()
|
|
||||||
# Simulation end
|
# Simulation end
|
||||||
if len(self.events) <= 0 or len(self.events) == 1 and self.events[0,0] == 3:
|
if len(self.events) <= 0 or len(self.events) == 1 and self.events[0,0] == 3:
|
||||||
# Notify nodes that wait for the end of the simulation
|
# Notify nodes that wait for the end of the simulation
|
||||||
|
@ -390,7 +387,9 @@ class Simulator:
|
||||||
else:
|
else:
|
||||||
node.rqueue.put(("sim_end",RCode.SUCCESS))
|
node.rqueue.put(("sim_end",RCode.SUCCESS))
|
||||||
break # End the event processing loop
|
break # End the event processing loop
|
||||||
|
# Generate debug logs
|
||||||
|
if debug:
|
||||||
|
self.debug.debug()
|
||||||
# Update simulation time
|
# Update simulation time
|
||||||
self.time=self.events[0,1]
|
self.time=self.events[0,1]
|
||||||
self.time_truncated=format(self.time,self.precision) # refresh truncated time
|
self.time_truncated=format(self.time,self.precision) # refresh truncated time
|
||||||
|
@ -458,3 +457,7 @@ class Simulator:
|
||||||
|
|
||||||
##### Simulation ends
|
##### Simulation ends
|
||||||
self.log("Simulation ends")
|
self.log("Simulation ends")
|
||||||
|
|
||||||
|
##### Final debug call
|
||||||
|
if debug:
|
||||||
|
self.debug.debug()
|
||||||
|
|
Loading…
Add table
Reference in a new issue