Skip to content

Commit

Permalink
Merge e77bb07 into e4f6774
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrockwell2 committed Apr 27, 2024
2 parents e4f6774 + e77bb07 commit fea380e
Show file tree
Hide file tree
Showing 29 changed files with 405 additions and 19 deletions.
9 changes: 9 additions & 0 deletions include/trick/sim_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#ifndef SIMMODE_HH
#define SIMMODE_HH

#ifdef __cplusplus
extern "C" {
#endif

typedef enum {

NoCmd = 0 , /* NoCmd */
Expand All @@ -38,4 +42,9 @@ typedef enum {

} SIM_MODE ;

const char * simModeCharString(SIM_MODE mode);

#ifdef __cplusplus
}
#endif
#endif
20 changes: 19 additions & 1 deletion test/SIM_checkpoint_data_recording/RUN_test/dump.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
import trick
from trick.unit_test import *
from threading import Timer

# This was just here for convenience to dump the checkpoints.

def dump_checkpoint(sim_time):
mode = trick.exec_get_mode()
cur_time = trick.exec_get_sim_time()

if(mode == 1 and cur_time == sim_time):
trick.checkpoint()
trick.exec_run()
elif cur_time > sim_time:
return
else:
Timer(0.1, dump_checkpoint, (sim_time,)).start()

def checkpoint(time):
Timer(1.0, dump_checkpoint, (time,)).start()

trick.freeze(time)

def main():
exec(open("Modified_data/foo.dr").read())

trick.checkpoint(5.0)
checkpoint(5.0)

trick.stop(10.0)

Expand Down
20 changes: 19 additions & 1 deletion test/SIM_checkpoint_data_recording/RUN_test1/dump.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
import trick
from trick.unit_test import *
from threading import Timer

# This was just here for convenience to dump the checkpoints.

def dump_checkpoint(sim_time):
mode = trick.exec_get_mode()
cur_time = trick.exec_get_sim_time()

if(mode == 1 and cur_time == sim_time):
trick.checkpoint()
trick.exec_run()
elif cur_time > sim_time:
return
else:
Timer(0.1, dump_checkpoint, (sim_time,)).start()

def checkpoint(time):
Timer(1.0, dump_checkpoint, (time,)).start()

trick.freeze(time)

def main():
exec(open("Modified_data/foo.dr").read())

trick.checkpoint(5.0)
checkpoint(5.0)

trick.stop(10.0)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
sys.exec.out.time {s},testSimObject.my_foo.a {1},testSimObject.my_foo.b {1}
5,6,12
5.1,6,12
5.2,6,12
5.3,6,12
Expand Down
22 changes: 21 additions & 1 deletion test/SIM_checkpoint_data_recording/RUN_test1/unit_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
import trick
from threading import Timer

def load_checkpoint(path, sim_time, tries=10):
mode = trick.exec_get_mode()
cur_time = trick.exec_get_sim_time()

if(mode == 1 and cur_time == sim_time):
trick.load_checkpoint(path)
trick.exec_run()
elif cur_time > sim_time or tries <= 0:
print("Issue with loading checkpoint from input file!")
return
else:
Timer(0.1, load_checkpoint, (path, sim_time, tries - 1,)).start()

def load_checkpoint_at(path, time):
Timer(1.0, load_checkpoint, (path, time)).start()

trick.freeze(time)

def main():
trick.add_read(5.0, 'trick.load_checkpoint("RUN_test1/chkpnt_5.000000")') # This checkpoint has data recording
chkpnt_path = "RUN_test1/chkpnt_5.000000"
load_checkpoint_at(chkpnt_path, 5.0)

trick.stop(10.0)

if __name__ == "__main__":
Expand Down
20 changes: 19 additions & 1 deletion test/SIM_checkpoint_data_recording/RUN_test2/dump.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
import trick
from trick.unit_test import *
from threading import Timer

# This was just here for convenience to dump the checkpoints.

def dump_checkpoint(sim_time):
mode = trick.exec_get_mode()
cur_time = trick.exec_get_sim_time()

if(mode == 1 and cur_time == sim_time):
trick.checkpoint()
trick.exec_run()
elif cur_time > sim_time:
return
else:
Timer(0.1, dump_checkpoint, (sim_time,)).start()

def checkpoint(time):
Timer(1.0, dump_checkpoint, (time,)).start()

trick.freeze(time)

def main():
trick.checkpoint(5.0)
checkpoint(5.0)

trick.stop(10.0)

Expand Down
21 changes: 20 additions & 1 deletion test/SIM_checkpoint_data_recording/RUN_test2/unit_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
import trick
from threading import Timer

def load_checkpoint(path, sim_time, tries=10):
mode = trick.exec_get_mode()
cur_time = trick.exec_get_sim_time()

if(mode == 1 and cur_time == sim_time):
trick.load_checkpoint(path)
trick.exec_run()
elif cur_time > sim_time or tries <= 0:
print("Issue with loading checkpoint from input file!")
return
else:
Timer(0.1, load_checkpoint, (path, sim_time, tries - 1,)).start()

def load_checkpoint_at(path, time):
Timer(1.0, load_checkpoint, (path, time)).start()

trick.freeze(time)

def main():
exec(open("Modified_data/foo.dr").read())

trick.add_read(5.0, 'trick.load_checkpoint("RUN_test2/chkpnt_5.000000")') # this checkpoint does not contain data recording
load_checkpoint_at("RUN_test2/chkpnt_5.000000", 5.0) # this checkpoint does not contain data recording

trick.stop(10.0)

Expand Down
20 changes: 19 additions & 1 deletion test/SIM_checkpoint_data_recording/RUN_test3/dump.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
import trick
from trick.unit_test import *
from threading import Timer

# This was just here for convenience to dump the checkpoints.

def dump_checkpoint(sim_time):
mode = trick.exec_get_mode()
cur_time = trick.exec_get_sim_time()

if(mode == 1 and cur_time == sim_time):
trick.checkpoint()
trick.exec_run()
elif cur_time > sim_time:
return
else:
Timer(0.1, dump_checkpoint, (sim_time,)).start()

def checkpoint(time):
Timer(1.0, dump_checkpoint, (time,)).start()

trick.freeze(time)

def main():
exec(open("Modified_data/foo.dr").read())

trick.checkpoint(5.0)
checkpoint(5.0)

trick.stop(10.0)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
sys.exec.out.time {s},testSimObject.my_foo.a {1},testSimObject.my_foo.b {1}
5,6,12
5.1,6,12
5.2,6,12
5.3,6,12
Expand Down
21 changes: 20 additions & 1 deletion test/SIM_checkpoint_data_recording/RUN_test3/unit_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
import trick
from threading import Timer

def load_checkpoint(path, sim_time, tries=10):
mode = trick.exec_get_mode()
cur_time = trick.exec_get_sim_time()

if(mode == 1 and cur_time == sim_time):
trick.load_checkpoint(path)
trick.exec_run()
elif cur_time > sim_time or tries <= 0:
print("Issue with loading checkpoint from input file!")
return
else:
Timer(0.1, load_checkpoint, (path, sim_time, tries - 1,)).start()

def load_checkpoint_at(path, time):
Timer(1.0, load_checkpoint, (path, time)).start()

trick.freeze(time)

def main():

exec(open("Modified_data/foo.dr").read())

trick.add_read(5.0, 'trick.load_checkpoint("RUN_test3/chkpnt_5.000000")') # contains data recording
load_checkpoint_at("RUN_test3/chkpnt_5.000000", 5.0) # contains data recording

trick.stop(10.0)

Expand Down
20 changes: 19 additions & 1 deletion test/SIM_checkpoint_data_recording/RUN_test4/dump.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
import trick
from trick.unit_test import *
from threading import Timer

# This was just here for convenience to dump the checkpoints.

def dump_checkpoint(sim_time):
mode = trick.exec_get_mode()
cur_time = trick.exec_get_sim_time()

if(mode == 1 and cur_time == sim_time):
trick.checkpoint()
trick.exec_run()
elif cur_time > sim_time:
return
else:
Timer(0.1, dump_checkpoint, (sim_time,)).start()

def checkpoint(time):
Timer(1.0, dump_checkpoint, (time,)).start()

trick.freeze(time)

def main():
exec(open("Modified_data/foo.dr").read())

trick.checkpoint(2.0)
checkpoint(2.0)

trick.stop(10.0)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
sys.exec.out.time {s},testSimObject.my_foo.a {1},testSimObject.my_foo.b {1}
2,3,6
2.1,3,6
2.2,3,6
2.3,3,6
Expand Down
21 changes: 20 additions & 1 deletion test/SIM_checkpoint_data_recording/RUN_test4/unit_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
import trick
from threading import Timer

def load_checkpoint(path, sim_time, tries=10):
mode = trick.exec_get_mode()
cur_time = trick.exec_get_sim_time()

if(mode == 1 and cur_time == sim_time):
trick.load_checkpoint(path)
trick.exec_run()
elif cur_time > sim_time or tries <= 0:
print("Issue with loading checkpoint from input file!")
return
else:
Timer(0.1, load_checkpoint, (path, sim_time, tries - 1,)).start()

def load_checkpoint_at(path, time):
Timer(1.0, load_checkpoint, (path, time)).start()

trick.freeze(time)

def main():

exec(open("Modified_data/foo.dr").read())

trick.add_read(5.0, 'trick.load_checkpoint("RUN_test4/chkpnt_2.000000")') # contains data recording, starts at t=2
load_checkpoint_at("RUN_test4/chkpnt_2.000000", 5.0) # contains data recording, starts at t=2

trick.stop(10.0)

Expand Down
21 changes: 19 additions & 2 deletions test/SIM_checkpoint_data_recording/RUN_test5/dump.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
import trick
from trick.unit_test import *
from threading import Timer

# This was just here for convenience to dump the checkpoints.

def dump_checkpoint(sim_time):
mode = trick.exec_get_mode()
cur_time = trick.exec_get_sim_time()

if(mode == 1 and cur_time == sim_time):
trick.checkpoint()
trick.exec_run()
elif cur_time > sim_time:
return
else:
Timer(0.1, dump_checkpoint, (sim_time,)).start()

def checkpoint(time):
Timer(1.0, dump_checkpoint, (time,)).start()

trick.freeze(time)

def main():
exec(open("Modified_data/foo.dr").read())

trick.checkpoint(7.0)
checkpoint(7.0)

trick.stop(10.0)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
sys.exec.out.time {s},testSimObject.my_foo.a {1},testSimObject.my_foo.b {1}
7,8,16
7.1,8,16
7.2,8,16
7.3,8,16
Expand Down
21 changes: 20 additions & 1 deletion test/SIM_checkpoint_data_recording/RUN_test5/unit_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
import trick
from threading import Timer

def load_checkpoint(path, sim_time, tries=10):
mode = trick.exec_get_mode()
cur_time = trick.exec_get_sim_time()

if(mode == 1 and cur_time == sim_time):
trick.load_checkpoint(path)
trick.exec_run()
elif cur_time > sim_time or tries <= 0:
print("Issue with loading checkpoint from input file!")
return
else:
Timer(0.1, load_checkpoint, (path, sim_time, tries - 1,)).start()

def load_checkpoint_at(path, time):
Timer(1.0, load_checkpoint, (path, time)).start()

trick.freeze(time)

def main():

exec(open("Modified_data/foo.dr").read())

trick.add_read(5.0, 'trick.load_checkpoint("RUN_test5/chkpnt_7.000000")') # contains data recording, starts at t=7
load_checkpoint_at("RUN_test5/chkpnt_7.000000", 5.0) # contains data recording, starts at t=7

trick.stop(10.0)

Expand Down

0 comments on commit fea380e

Please sign in to comment.