mirror of
https://github.com/nasa/trick.git
synced 2024-12-18 20:57:55 +00:00
job_class_order no longer accidentally disables some system job classes (#1465)
This commit is contained in:
parent
9099792947
commit
19016b4817
@ -377,7 +377,10 @@ This section of the S_define (encapsulated by "job_class_order{...};) can be use
|
|||||||
scheduled loop job class order. The user may simply re-order the existing job classes that exist or
|
scheduled loop job class order. The user may simply re-order the existing job classes that exist or
|
||||||
can specify a new set of scheduled loop job classes. Job classes that are eligible for reassignment
|
can specify a new set of scheduled loop job classes. Job classes that are eligible for reassignment
|
||||||
are listed in Table SD_1 between automatic and automatic_last inclusive. The order they are shown
|
are listed in Table SD_1 between automatic and automatic_last inclusive. The order they are shown
|
||||||
in the table is the default ordering.
|
in the table is the default ordering. Note that if the user provides an ordering, classes that are
|
||||||
|
not included in the ordering (excluding automatic and automatic_last) will not be handled by any scheduler,
|
||||||
|
and therefore not executed in the sim.
|
||||||
|
|
||||||
|
|
||||||
```C++
|
```C++
|
||||||
job_class_order {
|
job_class_order {
|
||||||
|
@ -20,6 +20,8 @@ use Text::Balanced qw(extract_bracketed);
|
|||||||
use html ;
|
use html ;
|
||||||
use get_paths ;
|
use get_paths ;
|
||||||
|
|
||||||
|
no warnings ;
|
||||||
|
|
||||||
my ($integ_loop_def , $collect_def , $vcollect_def);
|
my ($integ_loop_def , $collect_def , $vcollect_def);
|
||||||
my ($job_class_order_def ) ;
|
my ($job_class_order_def ) ;
|
||||||
my ($sim_class_def , $sim_class_job_def , $instantiation_def , $create_connections_def) ;
|
my ($sim_class_def , $sim_class_job_def , $instantiation_def , $create_connections_def) ;
|
||||||
@ -943,6 +945,9 @@ sub preparse_job_class_order($$) {
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Scheduled loop classes that should not be reordered
|
||||||
|
my @non_reorderable_classes = qw(logging data_record system_checkpoint system_advance_sim_time system_moding integ_loop);
|
||||||
|
|
||||||
# get a list of classes
|
# get a list of classes
|
||||||
($class_text) = @{$job_class_order_structs}[0] =~ /{(.*?)}/sx ;
|
($class_text) = @{$job_class_order_structs}[0] =~ /{(.*?)}/sx ;
|
||||||
$class_text =~ s/^\s+|\s+$//gs ;
|
$class_text =~ s/^\s+|\s+$//gs ;
|
||||||
@ -955,26 +960,28 @@ sub preparse_job_class_order($$) {
|
|||||||
edit_and_exit("CP bad job class order" , "$s_define_file" , 1 ) ;
|
edit_and_exit("CP bad job class order" , "$s_define_file" , 1 ) ;
|
||||||
}
|
}
|
||||||
$temp_hash{$c}++ ;
|
$temp_hash{$c}++ ;
|
||||||
|
|
||||||
|
if ($c ~~ @non_reorderable_classes) {
|
||||||
|
trick_print($$sim_ref{fh}, "\nCP ERROR:\n Job class \"$c\" cannot be reordered by job_class_order.\n" , "title_red" , $$sim_ref{args}{v} ) ;
|
||||||
|
edit_and_exit("CP bad job class order" , "$s_define_file" , 1 ) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# save the new order
|
# save the new order
|
||||||
@{$$sim_ref{user_class_order}} = @class_list ;
|
@{$$sim_ref{user_class_order}} = @class_list ;
|
||||||
|
|
||||||
# push on the advance_sim_time class last if not specified
|
# push on classes important to trick system function if not specified
|
||||||
if ( !exists $temp_hash{data_record} ) {
|
if ( !exists $temp_hash{automatic} ) {
|
||||||
push @{$$sim_ref{user_class_order}} , "data_record" ;
|
unshift @{$$sim_ref{user_class_order}} , "automatic" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !exists $temp_hash{system_checkpoint} ) {
|
if ( !exists $temp_hash{automatic_last} ) {
|
||||||
push @{$$sim_ref{user_class_order}} , "system_checkpoint" ;
|
push @{$$sim_ref{user_class_order}} , "automatic_last" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !exists $temp_hash{system_advance_sim_time} ) {
|
# Push on the rest of the non-reorderable system job classes
|
||||||
push @{$$sim_ref{user_class_order}} , "system_advance_sim_time" ;
|
foreach my $c ( @non_reorderable_classes ) {
|
||||||
}
|
push @{$$sim_ref{user_class_order}} , $c ;
|
||||||
|
|
||||||
if ( !exists $temp_hash{system_moding} ) {
|
|
||||||
push @{$$sim_ref{user_class_order}} , "system_moding" ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
test/SIM_job_class_order/RUN_test/input.py
Normal file
3
test/SIM_job_class_order/RUN_test/input.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
|
trick.stop(10);
|
48
test/SIM_job_class_order/S_define
Normal file
48
test/SIM_job_class_order/S_define
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/************************TRICK HEADER*************************
|
||||||
|
PURPOSE:
|
||||||
|
()
|
||||||
|
LIBRARY DEPENDENCIES:
|
||||||
|
*************************************************************/
|
||||||
|
|
||||||
|
#include "sim_objects/default_trick_sys.sm"
|
||||||
|
|
||||||
|
##include "starter.h"
|
||||||
|
|
||||||
|
class StarterSimObject : public Trick::SimObject {
|
||||||
|
|
||||||
|
public:
|
||||||
|
Starter starter;
|
||||||
|
|
||||||
|
StarterSimObject() {
|
||||||
|
("top_of_frame") starter.top ();
|
||||||
|
|
||||||
|
(0.5, "scheduled") starter.sched ();
|
||||||
|
(0.5, "my_class") starter.custom ();
|
||||||
|
|
||||||
|
("derivative") starter.deriv();
|
||||||
|
("integration") trick_ret = starter.integ() ;
|
||||||
|
|
||||||
|
("automatic") starter.automatic();
|
||||||
|
("automatic_last") starter.automatic_last();
|
||||||
|
|
||||||
|
|
||||||
|
("end_of_frame") starter.end ();
|
||||||
|
|
||||||
|
("shutdown") starter.test_calls ();
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
StarterSimObject starterSimObject;
|
||||||
|
|
||||||
|
job_class_order {
|
||||||
|
my_class ,
|
||||||
|
scheduled
|
||||||
|
};
|
||||||
|
|
||||||
|
IntegLoop dyn_integloop(0.1) starterSimObject;
|
||||||
|
|
||||||
|
void create_connections() {
|
||||||
|
dyn_integloop.getIntegrator(Runge_Kutta_4, 2);
|
||||||
|
}
|
||||||
|
|
3
test/SIM_job_class_order/S_overrides.mk
Normal file
3
test/SIM_job_class_order/S_overrides.mk
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
TRICK_CFLAGS += -I./models
|
||||||
|
TRICK_CXXFLAGS += -I./models -std=c++11
|
76
test/SIM_job_class_order/models/starter.cpp
Normal file
76
test/SIM_job_class_order/models/starter.cpp
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
#include "starter.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include "trick/exec_proto.hh"
|
||||||
|
#include "trick/exec_proto.h"
|
||||||
|
|
||||||
|
void Starter::sched () {
|
||||||
|
sched_calls++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Starter::custom () {
|
||||||
|
custom_calls++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Starter::top () {
|
||||||
|
top_calls++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Starter::automatic () {
|
||||||
|
|
||||||
|
Trick::JobData * thisJob = exec_get_curr_job() ;
|
||||||
|
thisJob->set_next_call_time(exec_get_time_tics() + exec_get_time_tic_value());
|
||||||
|
automatic_calls++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Starter::automatic_last () {
|
||||||
|
|
||||||
|
Trick::JobData * thisJob = exec_get_curr_job() ;
|
||||||
|
thisJob->set_next_call_time(exec_get_time_tics() + exec_get_time_tic_value());
|
||||||
|
|
||||||
|
automatic_last_calls++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Starter::end() {
|
||||||
|
end_calls++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Starter::deriv() {
|
||||||
|
deriv_calls++;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Starter::integ() {
|
||||||
|
integ_calls++;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Starter::test_calls() {
|
||||||
|
if (top_calls == 0) {
|
||||||
|
exec_terminate_with_return(1, __FILE__, __LINE__, "top_of_frame job never called");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (custom_calls == 0) {
|
||||||
|
exec_terminate_with_return(1, __FILE__, __LINE__, "custom job never called");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sched_calls == 0) {
|
||||||
|
exec_terminate_with_return(1, __FILE__, __LINE__, "scheduled job never called");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (automatic_calls == 0) {
|
||||||
|
exec_terminate_with_return(1, __FILE__, __LINE__, "automatic job never called");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (automatic_last_calls == 0) {
|
||||||
|
exec_terminate_with_return(1, __FILE__, __LINE__, "automatic_last job never called");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deriv_calls == 0) {
|
||||||
|
exec_terminate_with_return(1, __FILE__, __LINE__, "derivative job never called");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (integ_calls == 0) {
|
||||||
|
exec_terminate_with_return(1, __FILE__, __LINE__, "integration job never called");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
33
test/SIM_job_class_order/models/starter.h
Normal file
33
test/SIM_job_class_order/models/starter.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*************************************************************************
|
||||||
|
PURPOSE: (Starter class)
|
||||||
|
LIBRARY DEPENDENCY:
|
||||||
|
(
|
||||||
|
(starter.cpp)
|
||||||
|
)
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class Starter {
|
||||||
|
public:
|
||||||
|
Starter() {}
|
||||||
|
|
||||||
|
void sched();
|
||||||
|
void custom();
|
||||||
|
void top();
|
||||||
|
void end();
|
||||||
|
void automatic();
|
||||||
|
void automatic_last();
|
||||||
|
void deriv();
|
||||||
|
int integ();
|
||||||
|
void test_calls();
|
||||||
|
|
||||||
|
int sched_calls = 0;
|
||||||
|
int custom_calls = 0;
|
||||||
|
int top_calls = 0;
|
||||||
|
int automatic_calls = 0;
|
||||||
|
int automatic_last_calls = 0;
|
||||||
|
int deriv_calls = 0;
|
||||||
|
int integ_calls = 0;
|
||||||
|
int end_calls = 0;
|
||||||
|
};
|
@ -196,6 +196,13 @@ SIM_earlyterm:
|
|||||||
runs:
|
runs:
|
||||||
RUN_test/input.py:
|
RUN_test/input.py:
|
||||||
returns: 0
|
returns: 0
|
||||||
|
SIM_job_class_order:
|
||||||
|
path: test/SIM_job_class_order
|
||||||
|
build_command: "trick-CP -t"
|
||||||
|
binary: "T_main_{cpu}_test.exe"
|
||||||
|
runs:
|
||||||
|
RUN_test/input.py:
|
||||||
|
returns: 0
|
||||||
|
|
||||||
# Special cases
|
# Special cases
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user