1 #include <portability.h>
51 #if (defined(REAL_TIME_BEHAVIOR) || defined(ATTENTION_LAPSE))
55 struct timeval *current_real_time;
58 #ifdef ATTENTION_LAPSE
61 int64_t lapse_duration;
91 const char* warning =
"Soar cannot recover from this error. \nYou will have to restart Soar to run an agent.\nData is still available for inspection, but may be corrupt.\nIf a log was open, it has been closed for safety.";
93 print (thisAgent,
"%s", msg);
94 print (thisAgent,
"%s", warning);
96 fprintf (stderr,
"%s",msg);
97 fprintf (stderr,
"%s",warning);
102 f = fopen(
"soarerror",
"w");
103 fprintf (f,
"%s",msg);
104 fprintf (f,
"%s",warning);
176 print (thisAgent,
"Internal error: tried to set bad sysparam #: %d\n", param_number);
179 thisAgent->
sysparams[param_number] = new_value;
183 reinterpret_cast<soar_call_data>(param_number));
210 #ifdef ATTENTION_LAPSE
255 void *prod_to_remove_pwatch_of)
257 return (c->
first == static_cast<production *>(prod_to_remove_pwatch_of));
334 #ifndef NO_TIMING_STUFF
338 #ifdef DETAILED_TIMER_STATS
340 thisAgent->timers_gds.reset();
351 #ifdef DETAILED_TIMER_STATS
352 thisAgent->timers_ownership_cpu_time[i].reset();
353 thisAgent->timers_chunking_cpu_time[i].reset();
354 thisAgent->timers_match_cpu_time[i].reset();
355 thisAgent->timers_gds_cpu_time[i].reset();
360 #endif // NO_TIMING_STUFF
368 #ifndef NO_TIMING_STUFF
379 #endif // NO_TIMING_STUFF
385 int64_t cur_TRACE_CONTEXT_DECISIONS_SYSPARAM;
386 int64_t cur_TRACE_PHASES_SYSPARAM;
387 int64_t cur_TRACE_FIRINGS_OF_DEFAULT_PRODS_SYSPARAM;
388 int64_t cur_TRACE_FIRINGS_OF_USER_PRODS_SYSPARAM;
389 int64_t cur_TRACE_FIRINGS_WME_TRACE_TYPE_SYSPARAM;
390 int64_t cur_TRACE_FIRINGS_PREFERENCES_SYSPARAM;
391 int64_t cur_TRACE_WM_CHANGES_SYSPARAM;
392 int64_t cur_TRACE_GDS_SYSPARAM;
431 if ( wma_was_enabled )
534 "\nSystem halted. Use (init-soar) before running Soar again.");
535 xml_generate_error(thisAgent,
"System halted. Use (init-soar) before running Soar again.");
569 print_phase (thisAgent,
"\n--- Input Phase --- \n",0);
577 #ifndef NO_TIMING_STUFF
589 #ifdef REAL_TIME_BEHAVIOR
590 test_for_input_delay(thisAgent);
592 #ifdef ATTENTION_LAPSE
593 determine_lapsing(thisAgent);
614 print_phase (thisAgent,
"\n--- END Input Phase --- \n",1);
616 #ifndef NO_TIMING_STUFF
629 #ifndef NO_TIMING_STUFF
641 print_phase(thisAgent,
"\n--- Proposal Phase ---\n",0);
720 print_phase(thisAgent,
"\n--- END Proposal Phase ---\n",1);
730 #ifndef NO_TIMING_STUFF
746 #ifndef NO_TIMING_STUFF
763 #ifndef NO_TIMING_STUFF
779 #ifndef NO_TIMING_STUFF
785 reinterpret_cast<soar_call_data>(
WM_PHASE) );
793 reinterpret_cast<soar_call_data>(
WM_PHASE) );
797 #ifndef NO_TIMING_STUFF
810 #ifndef NO_TIMING_STUFF
822 print_phase (thisAgent,
"\n--- Application Phase ---\n",0);
895 print_phase(thisAgent,
"\n--- END Application Phase ---\n",1);
905 #ifndef NO_TIMING_STUFF
916 print_phase (thisAgent,
"\n--- Output Phase ---\n",0);
918 #ifndef NO_TIMING_STUFF
988 if ( ( (*p)->instantiations ==
NIL ) && ( !(*p)->rl_rule || ( (
static_cast<int64_t
>( (*p)->rl_update_count ) == 0 ) && ( (*p)->rl_ref_count == 0 ) ) ) )
1017 #ifndef NO_TIMING_STUFF
1024 uint64_t dc_time_usec = 0;
1025 #ifndef NO_TIMING_STUFF
1062 #endif // NO_TIMING_STUFF
1082 stats_db_store(thisAgent, dc_time_usec, dc_wm_changes, dc_firing_counts);
1087 print_phase (thisAgent,
"\n--- END Output Phase ---\n",1);
1099 print_phase (thisAgent,
"\n--- Decision Phase ---\n",0);
1101 #ifndef NO_TIMING_STUFF
1142 #ifdef AGRESSIVE_ONC
1166 print_phase (thisAgent,
"\n--- END Decision Phase ---\n",1);
1172 #ifndef NO_TIMING_STUFF
1181 #endif //AGRESSIVE_ONC
1188 print_phase (thisAgent,
"\n--- END Decision Phase ---\n",1);
1197 #ifndef NO_TIMING_STUFF
1208 assert(
false &&
"Invalid phase enumeration value!");
1224 reinterpret_cast<soar_call_data>(thisAgent->
current_phase) );
1245 #ifndef NO_TIMING_STUFF
1256 #ifndef NO_TIMING_STUFF
1267 #ifndef NO_TIMING_STUFF
1277 #ifndef NO_TIMING_STUFF
1286 int64_t e_cycles_at_start, d_cycles_at_start, elapsed_cycles = 0;
1291 #ifndef NO_TIMING_STUFF
1299 elapsed_cycles = -1;
1300 save_go_type = thisAgent->
go_type;
1303 if (d_cycles_at_start == 0) d_cycles_at_start++;
1306 if (n==elapsed_cycles)
break;
1309 thisAgent->
go_type = save_go_type;
1311 #ifndef NO_TIMING_STUFF
1320 Bool was_output_phase;
1325 #ifndef NO_TIMING_STUFF
1334 if (was_output_phase) {
1346 #ifndef NO_TIMING_STUFF
1355 int64_t d_cycles_at_start;
1359 #ifndef NO_TIMING_STUFF
1367 if (d_cycles_at_start == 0)
1368 d_cycles_at_start++;
1370 if (n == static_cast<int64_t>(thisAgent->
d_cycle_count-d_cycles_at_start))
break;
1373 #ifndef NO_TIMING_STUFF
1389 Bool was_decision_phase;
1393 #ifndef NO_TIMING_STUFF
1400 while (!thisAgent->
stop_soar && (count < n)) {
1403 if (was_decision_phase)
1406 #ifndef NO_TIMING_STUFF
1418 Bool was_decision_phase;
1422 #ifndef NO_TIMING_STUFF
1429 while (!thisAgent->
stop_soar && (count < n)) {
1432 if (was_decision_phase) {
1439 #ifndef NO_TIMING_STUFF
1462 Bool old_print_prompt_flag;
1487 assert( thisAgent->
top_goal == 0 &&
1488 "There should be no top goal when init_agent_memory is called!");