Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trick prints warning for checkpoints outside of freeze mode. #1682

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1eb292c
Trick prints warning for checkpoints outside of freeze mode.
Mrockwell2 Mar 28, 2024
ec6a437
Merge branch 'master' into 1461-only-allow-dumping-and-loading-checkp…
Mrockwell2 Mar 28, 2024
b7a65bb
Fixed small syntax error
Mrockwell2 Mar 28, 2024
9b9c830
Fixed small syntax error
Mrockwell2 Mar 28, 2024
7cb2e5f
Warnings no longer abort checkpoint actions due to test conflict
Mrockwell2 Mar 29, 2024
f71ce44
Moved sim_mode_to_string function to a more generic place.
Mrockwell2 Apr 2, 2024
0218314
Fixing simModeCharString
Mrockwell2 Apr 5, 2024
3604312
Cancel checkpoint if sim is running
Mrockwell2 Apr 5, 2024
ae586c1
Define dependencies for simModeCharString
Mrockwell2 Apr 5, 2024
8ebd937
Solve testing error
Mrockwell2 Apr 5, 2024
2a45c90
Edit SIM_stls input file to pass test
Mrockwell2 Apr 27, 2024
046c8ab
Updated checkpoint sim test input files
Mrockwell2 Apr 27, 2024
e77bb07
Corrected reference logs for checkpoint sim test.
Mrockwell2 Apr 27, 2024
155e3c5
Merge branch 'master' into 1461-edit-checkpoint-at-time
May 16, 2024
92fbacb
Fixing simModeCharString(SIM_MODE)
May 17, 2024
5b4e82c
Update checkpointing and the freeze loop
May 17, 2024
2638f88
Correct the ref_logs to properly reflect the expected outcomes.
May 17, 2024
ac82444
Updated SIM_stls test to pass with new checkpoint restrictions
May 17, 2024
08ed1e2
Limit automatic freeze and re-run to when simulation is in run mode
Mrockwell2 May 31, 2024
2d6b68e
Revert "Edit SIM_stls input file to pass test"
Mrockwell2 May 31, 2024
e538aec
Merge branch '1461-edit-checkpoint-at-time' into 1461-only-allow-dump…
Mrockwell2 May 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/trick/CheckPointRestart.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ namespace Trick {
*/
class CheckPointRestart : public Trick::Scheduler {

private:
/** Flag to track if an automatic freeze has been triggered */
bool auto_freeze = false; /* ** */

protected:
/** queue to hold jobs to be called before a checkpoint is dumped. */
Trick::ScheduledJobQueue checkpoint_queue ; /* ** */
Expand Down
10 changes: 10 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,10 @@ 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
Loading
Loading