Commit c49e2b19 authored by yoogx's avatar yoogx

* Add fflush(stdout) to force printf, minor reformatting

parent 7e5c5f96
......@@ -12,23 +12,25 @@ __po_hi_storage_file_t myfile_write;
void user_produce_pkts_init ()
{
printf ("*** INIT DATA PRODUCER ***\n");
fflush (stdout);
if (__po_hi_storage_file_open (FILENAME, &myfile_write) != __PO_HI_SUCCESS)
{
{
printf ("*** /!\\ ERROR WHEN OPENING THE FILE %s /!\\ ***\n", FILENAME);
}
fflush (stdout);
}
if (__po_hi_storage_file_create (&myfile_write) != __PO_HI_SUCCESS)
{
{
printf ("*** /!\\ ERROR WHEN CREATING THE FILE %s /!\\ ***\n", FILENAME);
}
fflush (stdout);
}
if (__po_hi_storage_file_open (FILENAME, &myfile_read) != __PO_HI_SUCCESS)
{
{
printf ("*** /!\\ ERROR WHEN OPENING THE FILE %s /!\\ ***\n", FILENAME);
}
fflush (stdout);
fflush (stdout);
}
}
void user_produce_pkts ()
......@@ -41,19 +43,17 @@ void user_produce_pkts ()
pkt.port = pinger_global_data_source;
printf ("*** PRODUCE PKT WITH VALUE *** %d\n", p);
fflush (stdout);
p++;
ret = __po_hi_storage_file_write (&myfile_write, &pkt, sizeof (__po_hi_request_t));
if (ret != __PO_HI_SUCCESS)
{
{
printf ("*** /!\\ ERROR WHEN WRITING A PACKET IN THE FILE (ret=%d) /!\\ ***\n", ret);
}
fflush (stdout);
}
fflush (stdout);
}
}
void user_do_ping_spg ()
{
......@@ -64,24 +64,22 @@ void user_do_ping_spg ()
ret = __po_hi_storage_file_read (&myfile_read, &pkt, sizeof (__po_hi_request_t));
if (ret != __PO_HI_SUCCESS)
{
printf ("*** /!\\ ERROR WHEN READING A PACKET FROM FILE /!\\ ***\n");
if (ret != __PO_HI_SUCCESS) {
printf ("*** /!\\ ERROR WHEN READING A PACKET FROM FILE /!\\ ***\n");
fflush (stdout);
if (ret == __PO_HI_UNAVAILABLE)
{
printf ("*** /!\\ ;_; NO PACKET AVAILABLE AT THIS TIME ;_; /!\\ ***\n");
}
}
else
{
printf ("*** SENDING PKT *** \n");
__po_hi_gqueue_store_out (node_a_pinger_k, pinger_local_data_source, &(pkt));
if (ret == __PO_HI_UNAVAILABLE) {
printf ("*** /!\\ ;_; NO PACKET AVAILABLE AT THIS TIME ;_; /!\\ ***\n");
fflush (stdout);
}
} else {
printf ("*** SENDING PKT *** \n");
fflush (stdout);
__po_hi_gqueue_store_out (node_a_pinger_k, pinger_local_data_source, &(pkt));
}
fflush (stdout);
}
void recover (void)
{
printf ("*** RECOVER ACTION ***\n");
......
......@@ -7,126 +7,136 @@ int job = 0;
void on_req(__po_hi_task_id self)
{
__po_hi_request_t request;
request.port = landing_gear_global_dummy_out;
printf("=== Starting gear op ===\n");
__po_hi_gqueue_store_out(self,landing_gear_local_dummy_out,&request);
__po_hi_request_t request;
request.port = landing_gear_global_dummy_out;
printf("=== Starting gear op ===\n");
fflush (stdout);
__po_hi_gqueue_store_out(self,landing_gear_local_dummy_out,&request);
}
void on_dummy(__po_hi_task_id self)
{
printf("=== Starting gear done ===\n");
printf("=== Starting gear done ===\n");
fflush (stdout);
}
void on_dummy_in(__po_hi_task_id self)
{
__po_hi_request_t request;
printf("=== Gear op done ===\n");
__po_hi_gqueue_store_out(self,landing_gear_local_ack,&request);
__po_hi_request_t request;
printf("=== Gear op done ===\n");
fflush (stdout);
__po_hi_gqueue_store_out(self,landing_gear_local_ack,&request);
}
void on_stall_warning (__po_hi_task_id self, int i)
{
if (i==1)
{
printf("=== STALL ALARM %d ====\n", i);
}
else
{
printf("=== False Alert %d ====\n", i);
}
if (i==1)
{
printf("=== STALL ALARM %d ====\n", i);
fflush (stdout);
}
else
{
printf("=== False Alert %d ====\n", i);
fflush (stdout);
}
}
void on_engine_failure(__po_hi_task_id self)
{
printf("=== ENGINE FAILURE ALARM ===\n");
printf("=== ENGINE FAILURE ALARM ===\n");
fflush (stdout);
}
void on_gear_cmd(__po_hi_task_id self)
{
__po_hi_request_t request;
__po_hi_gqueue_store_out(self,hci_local_gear_req,&request);
__po_hi_request_t request;
__po_hi_gqueue_store_out(self,hci_local_gear_req,&request);
}
void on_gear_ack(__po_hi_task_id self)
{
printf("=== Gear Locked ===\n");
printf("=== Gear Locked ===\n");
fflush (stdout);
}
void on_operator (__po_hi_task_id self)
{
__po_hi_request_t request;
__po_hi_gqueue_store_out(self,operator_local_gear_cmd,&request);
__po_hi_request_t request;
__po_hi_gqueue_store_out(self,operator_local_gear_cmd,&request);
}
void on_sensor_sim(__po_hi_task_id self)
{
int cr_v = 0;
int aoa_v = 4;
__po_hi_request_t request1;
__po_hi_request_t request2;
job++;
if ( (job%40) == 0 )
int cr_v = 0;
int aoa_v = 4;
__po_hi_request_t request1;
__po_hi_request_t request2;
job++;
if ( (job%40) == 0 )
{
request1.vars.sensor_sim_global_aoa.sensor_sim_global_aoa = 41;
request2.vars.sensor_sim_global_climb_rate.sensor_sim_global_climb_rate = 4;
__po_hi_gqueue_store_out(self,sensor_sim_local_aoa,&request1);
__po_hi_gqueue_store_out(self,sensor_sim_local_climb_rate,&request2);
printf("=== Sensor Sim setting soft stall ===\n");
fflush (stdout);
}
else
{
if ( (job%201) == 0 )
{
request1.vars.sensor_sim_global_aoa.sensor_sim_global_aoa = 41;
request2.vars.sensor_sim_global_climb_rate.sensor_sim_global_climb_rate = 4;
__po_hi_gqueue_store_out(self,sensor_sim_local_aoa,&request1);
__po_hi_gqueue_store_out(self,sensor_sim_local_climb_rate,&request2);
printf("=== Sensor Sim setting soft stall ===\n");
request1.vars.sensor_sim_global_aoa.sensor_sim_global_aoa = 25;
request2.vars.sensor_sim_global_climb_rate.sensor_sim_global_climb_rate = 9;
__po_hi_gqueue_store_out(self,sensor_sim_local_aoa,&request1);
__po_hi_gqueue_store_out(self,sensor_sim_local_climb_rate,&request2);
printf("=== Sensor Sim setting hard stall ===\n");
fflush (stdout);
}
else
else
{
if ( (job%201) == 0 )
{
request1.vars.sensor_sim_global_aoa.sensor_sim_global_aoa = 25;
request2.vars.sensor_sim_global_climb_rate.sensor_sim_global_climb_rate = 9;
__po_hi_gqueue_store_out(self,sensor_sim_local_aoa,&request1);
__po_hi_gqueue_store_out(self,sensor_sim_local_climb_rate,&request2);
printf("=== Sensor Sim setting hard stall ===\n");
}
else
{
if ( (job%401) == 0 )
{
__po_hi_gqueue_store_out(self,sensor_sim_local_engine_failure,&request1);
printf("=== Sensor Sim raising engine failure ===\n");
}
else
{
request1.vars.sensor_sim_global_aoa.sensor_sim_global_aoa = aoa_v;
request2.vars.sensor_sim_global_climb_rate.sensor_sim_global_climb_rate = cr_v;
__po_hi_gqueue_store_out(self,sensor_sim_local_aoa,&request1);
__po_hi_gqueue_store_out(self,sensor_sim_local_climb_rate,&request2);
}
}
if ( (job%401) == 0 )
{
__po_hi_gqueue_store_out(self,sensor_sim_local_engine_failure,&request1);
printf("=== Sensor Sim raising engine failure ===\n");
fflush (stdout);
}
else
{
request1.vars.sensor_sim_global_aoa.sensor_sim_global_aoa = aoa_v;
request2.vars.sensor_sim_global_climb_rate.sensor_sim_global_climb_rate = cr_v;
__po_hi_gqueue_store_out(self,sensor_sim_local_aoa,&request1);
__po_hi_gqueue_store_out(self,sensor_sim_local_climb_rate,&request2);
}
}
}
}
void on_stall_monitor(__po_hi_task_id self)
{
int aoa_v;
int cr_v;
__po_hi_request_t request;
__po_hi_gqueue_get_value(self,stall_monitor_local_aoa,&(request));
aoa_v = request.vars.sensor_sim_global_aoa.sensor_sim_global_aoa;
__po_hi_gqueue_get_value(self,stall_monitor_local_climb_rate,&(request));
cr_v = request.vars.sensor_sim_global_climb_rate.sensor_sim_global_climb_rate;
if (aoa_v > 40)
{
request.vars.stall_monitor_global_stall_warn.stall_monitor_global_stall_warn = 2;
__po_hi_gqueue_store_out(self,stall_monitor_local_stall_warn,&request);
}
else
int aoa_v;
int cr_v;
__po_hi_request_t request;
__po_hi_gqueue_get_value(self,stall_monitor_local_aoa,&(request));
aoa_v = request.vars.sensor_sim_global_aoa.sensor_sim_global_aoa;
__po_hi_gqueue_get_value(self,stall_monitor_local_climb_rate,&(request));
cr_v = request.vars.sensor_sim_global_climb_rate.sensor_sim_global_climb_rate;
if (aoa_v > 40)
{
request.vars.stall_monitor_global_stall_warn.stall_monitor_global_stall_warn = 2;
__po_hi_gqueue_store_out(self,stall_monitor_local_stall_warn,&request);
}
else
{
if ((aoa_v > 22 ) && (cr_v < 10))
{
if ((aoa_v > 22 ) && (cr_v < 10))
{
request.vars.stall_monitor_global_stall_warn.stall_monitor_global_stall_warn = 2;
__po_hi_gqueue_store_out(self,stall_monitor_local_stall_warn,&request);
}
request.vars.stall_monitor_global_stall_warn.stall_monitor_global_stall_warn = 2;
__po_hi_gqueue_store_out(self,stall_monitor_local_stall_warn,&request);
}
}
}
......@@ -13,9 +13,11 @@ void user_produce_spg (int* data)
printf ("At time %3lu:%3lu, produce : %d\n",
mytime.tv_sec % 3600, mytime.tv_nsec / 1000000,
produce_data);
fflush(stdout);
#else
*data = produce_data;
printf ("Produce %d\n", *data);
fflush(stdout);
#endif
produce_data++;
}
......@@ -26,8 +28,10 @@ void user_consume_spg (int data)
struct timespec mytime;
clock_gettime (CLOCK_REALTIME, &mytime);
printf( "At time %3lu:%3lu, consume : %d\n", mytime.tv_sec % 3600 , mytime.tv_nsec/1000000,data);
fflush(stdout);
#else
printf ("Consume %d\n", data);
fflush(stdout);
#endif
}
......@@ -16,11 +16,13 @@ void user_emit_boolean( int16_t* boolean)
}
*boolean = boolean_type_var;
printf ("Sending boolean : %d\n", *boolean);
fflush (stdout);
}
void user_receive_boolean (int16_t boolean)
{
printf ("Receiving boolean : %d\n", boolean);
fflush (stdout);
}
void user_emit_integer( int32_t* integer)
......@@ -28,9 +30,11 @@ void user_emit_integer( int32_t* integer)
integer_type_var++;
*integer = integer_type_var;
printf ("Emetting integer : %d\n", *integer);
fflush (stdout);
}
void user_receive_integer (int32_t integer)
{
printf ("Receiving integer : %d\n", integer);
fflush (stdout);
}
......@@ -8,27 +8,27 @@ float plant_period = 0.01;
void user_sunseekerplant
(float controller_input, float* outputfeedback)
{
float feedback_error;
float feedback;
float integrator_output;
float plant_output;
float preamp_output;
float transfer_fcn_update;
printf ("PLANT INPUT: %f\n", controller_input);
preamp_output = controller_input * (-2.0);
integrator_output = plant_integrator;
plant_output = 0.002 * plant_transfer_fcn;
feedback = plant_output * 0.0125;
*outputfeedback = integrator_output * 0.00125;
plant_integrator = plant_integrator + 0.001 * plant_output;
feedback_error = preamp_output - feedback;
transfer_fcn_update = 1000000 * feedback_error;
plant_transfer_fcn = plant_transfer_fcn + plant_period * transfer_fcn_update;
printf ("PLANT OUTPUT: %f ERROR : %f\n", *outputfeedback, feedback_error);
}
float feedback_error;
float feedback;
float integrator_output;
float plant_output;
float preamp_output;
float transfer_fcn_update;
printf ("PLANT INPUT: %f\n", controller_input);
fflush (stdout);
preamp_output = controller_input * (-2.0);
integrator_output = plant_integrator;
plant_output = 0.002 * plant_transfer_fcn;
feedback = plant_output * 0.0125;
*outputfeedback = integrator_output * 0.00125;
plant_integrator = plant_integrator + 0.001 * plant_output;
feedback_error = preamp_output - feedback;
transfer_fcn_update = 1000000.0 * feedback_error;
plant_transfer_fcn = plant_transfer_fcn + plant_period * transfer_fcn_update;
printf ("PLANT OUTPUT: %f ERROR : %f\n", *outputfeedback, feedback_error);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment