CSCI 5801 - Software Engg - Assignment 2
CSCI 5801 - Software Engg - Assignment 2
state0 and state1 are two instances of WorldState that store the previous state and state and the current state respectively. Methods: updateAlt(WorldState state, WorldState state0) (void) : Updates the values of previous and current altitudes. calcThresholdOff() (boolean): computes the threshold off value as 1.1 times the hysteresis value. CrossThreshold() (boolean): returns true if the plane has crossed the threshold OFF value. IsAbove() (boolean): returns true if the plane is flying between threshold OFF and threshold ON values. IsBelow() (boolean): returns true if the plane is below the threshold ON value.
ASW class:
Variables: -dataFile (String) : denotes name of the file -filename (String) : denotes asw.batch file -interval (int) : denotes time in milliseconds -batch_op (String) : denotes output of the batch text file. -EnvHost (String) : used for the host port running the hardware interface. -EnvPort (String) : used for the host port running the hardware interface. -Batchmode (boolean): indicates default mode of running for ASW -envhandler (EnvironmentHandler) : used to handle the environment -TIME_LAG_Alt (int) : used to determine the time lag in checking the value of the altitude. -TIME_LAG_DOI (int): used to determine the response time of the DOI in showing its status to the ASW.
-AltTracker (AltitudeTracker) : altTracker is an object of AltitudeTracker and is used to give appropriate values of altitude to the ASW as and when it needs. -flag_AQ (int), flag_DOI (int): These flags are maintained respectively for AltitudeQuality and DOI -(int) flag_IC, flag1_IC,flagx, flagy : //Flags used to operate on issueCommand -(int) flagAbv : flagAbv = 1 indicates that the plane has moved from below the threshold ON to between the threshold ON and threshold OFF values. Similarly flagAbv = 0 indicates that the plane has moved from above the threshold OFF value to in between the threshold ON and threshold OFF value. Methods: -public boolean isTimeLagPassed(WorldState state, WorldState state0) This method checks to see if the altitude can be determined in 2000millisec. If the altitude cannot be determined for more than this time, then a fault is indicated by raising an alarm. It is assumed here that the altitude cannot be determined if the quality is bad or unknown. -private void process(WorldState state) Writing functionality for Reset. This resets the values to their intial states. But this does not however, reset the Jsliders for altitude and threshold back to their initial values although it sets the altitude and threshold to their initial values of -1. -private void issueCommand(WorldState state, WorldState state0) This method first verifies if the Input signal is issued or not. If ASW isn't inhibited, then it either powers on or powers off the DOI depending upon whether it is below the Threshold_ON value or in between the threshold_ON and threshold_OFF value or above the threshold_OFF value. -private boolean checkResponseFromDOI(WorldState state) As the name indicates, this method checks the response from the DOI. If the DOI does not indicate that it is poweredON or OFF for more than 2000 milliseconds, then a fault is indicated and an alarm is raised.
-private void turnOnAlarm(WorldState state) Turns on the alarm -private void turnOnDOI(WorldState state) Turns on the DOI -private void turnOffDOI(WorldState state) Turns off the DOI
Test Documentation
The unit testing was done using the J Unit testing framework to perform statement coverage. There are two classes AltitudeTrackerTest and ASWTest corresponding to AltitudeTracker and ASWTest (The classes which were modified to implement ASW). The AltitudeTrackerTest contains methods which calls the methods of AltitudeTracker class individually to perform unit testing and statement coverage. The test methods have the corresponding method name preceded by test. The ASWTest contains methods which call the methods of ASW class individually to perform unit testing and statement coverage. The test methods have the corresponding method name preceded by test. AltitudeTrackerTest methods: Tests the method public void testUpdateAlt(): Tests the UpdateAlt() method. This checks if the altitude of the WorldState instance is updated or not. public void testCalcThresholdOff(): Tests the method CalcThresholdOff().This checks if the threshold is calculated or not. public void testCrossThreshold() : Tests the method CrossThreshold(). This checks If the threshold is crossed or not. public void testIsAbove(): Tests the method testIsAbove(). This checks if the plane is above threshold or not. public void testIsBelow(): Tests the method testIsBelow().This checks if the plane is below threshold or not.
Running Tests:
You will have to unzip the file before running any of the methods.
If attempting to run your tests results in a NoClassDefFoundError, then something is missing from your CLASSPATH. Invoke the runner: java org.junit.runner.JUnitCore <test class name>