samedi 30 avril 2016

Shortened method to reduce statements in an Ada procedure?

I am creating a procedure that uses an if statement to perform a descission.


I have 4 variables: Altitude, Velocity, Angle and Temperature.

The procedure is as follows:

procedure Test3 is

begin if (Integer(Status_System.Altitude_Measured)) >= Critical_Altitude and (Integer(Status_System.Velocity_Measured)) >= Critical_Velocity and (Integer(Status_System.Angle_Measured)) >= Critical_Angle and (Integer(Status_System.Temperature_Measured)) >= Critical_Temperature then DT_Put ("message 1");
else null; end if; end Test3;

This procedure is bassicaly taking the idea that if all the critcal values for the variables are met for each and every variable then it will print a message.

I want to be able to have a shorter way of paring up the statements so I can do the following:

if I have 4 variables: Altitude, velocity, angle and temperature and I want to have a statement that says, If atleast 3 of these varibles (doesnt matter which three) are all exceeding their critical values then display a message.

Is it even possible to do this? I would hate to think That i would have to write each and every possible combination for the if statements.

so In short an if statement that says atleast 3 of the variables shown are at their criticle value so print a message.

the same would be good for atleast 2 of these variables aswell.

Aucun commentaire:

Enregistrer un commentaire