- Timestamp:
- 09/09/11 06:23:36 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDcalcCoverage.java
r130 r171 13 13 import de.ugoe.cs.util.console.Console; 14 14 15 /** 16 * <p> 17 * Command to calculate the coverage of a test suite. 18 * </p> 19 * 20 * @author Steffen Herbold 21 * @version 1.0 22 */ 15 23 public class CMDcalcCoverage implements Command { 16 24 25 /* 26 * (non-Javadoc) 27 * 28 * @see de.ugoe.cs.util.console.Command#run(java.util.List) 29 */ 17 30 @SuppressWarnings("unchecked") 18 31 @Override 19 32 public void run(List<Object> parameters) { 20 String modelname; 33 String modelname; 21 34 String[] sequenceNames; 22 35 int minLength; … … 28 41 minLength = Integer.parseInt((String) parameters.get(2)); 29 42 maxLength = Integer.parseInt((String) parameters.get(3)); 30 if ( parameters.size()==5) {43 if (parameters.size() == 5) { 31 44 observedName = (String) parameters.get(1); 32 45 } 33 } 34 catch (Exception e) { 46 } catch (Exception e) { 35 47 throw new InvalidParameterException(); 36 48 } 37 38 IStochasticProcess process = null; 49 50 IStochasticProcess process = null; 39 51 Collection<List<? extends Event<?>>> observedSequences = null; 40 52 Collection<List<? extends Event<?>>> sequences = null; 41 Object dataObjectProcess = GlobalDataContainer.getInstance().getData(modelname); 42 Object dataObjectObserved = GlobalDataContainer.getInstance().getData(observedName); 43 if( dataObjectProcess==null ) { 53 Object dataObjectProcess = GlobalDataContainer.getInstance().getData( 54 modelname); 55 Object dataObjectObserved = GlobalDataContainer.getInstance().getData( 56 observedName); 57 if (dataObjectProcess == null) { 44 58 Console.printerrln("Model " + modelname + " not found in storage."); 45 59 return; 46 60 } 47 if( !(dataObjectProcess instanceof IStochasticProcess) ) { 48 Console.printerrln("Object " + modelname + " not of type IStochasticProcess!"); 61 if (!(dataObjectProcess instanceof IStochasticProcess)) { 62 Console.printerrln("Object " + modelname 63 + " not of type IStochasticProcess!"); 49 64 return; 50 65 } 51 if ( dataObjectObserved==null) {66 if (dataObjectObserved == null) { 52 67 Console.printerrln("Observed sequences not found in storage."); 53 68 return; 54 69 } 55 if ( !(dataObjectObserved instanceof Collection<?>)) {70 if (!(dataObjectObserved instanceof Collection<?>)) { 56 71 // weak instance check! 57 72 Console.printerrln("Object " + observedName + " not a Collection!"); … … 60 75 process = (IStochasticProcess) dataObjectProcess; 61 76 observedSequences = (Collection<List<? extends Event<?>>>) dataObjectObserved; 62 63 77 64 78 Console.print("seqName"); 65 for ( int length=minLength ; length<=maxLength; length++) {79 for (int length = minLength; length <= maxLength; length++) { 66 80 Console.print(";numObs_" + length); 67 81 Console.print(";numCov_" + length); … … 78 92 } 79 93 Console.println(""); 80 for( String sequenceName : sequenceNames ) { 81 Object dataObjectSequences = GlobalDataContainer.getInstance().getData(sequenceName); 82 if( dataObjectSequences==null ) { 83 Console.println("Sequences " + sequenceName + " not found in storage."); 84 } 85 else if( !(dataObjectSequences instanceof Collection<?>) ) { 86 // cannot really perform type check at runtime! this is an approximative substitute 87 Console.printerrln("Object " + sequenceName + "not of type Collection<?>!"); 94 for (String sequenceName : sequenceNames) { 95 Object dataObjectSequences = GlobalDataContainer.getInstance() 96 .getData(sequenceName); 97 if (dataObjectSequences == null) { 98 Console.println("Sequences " + sequenceName 99 + " not found in storage."); 100 } else if (!(dataObjectSequences instanceof Collection<?>)) { 101 // cannot really perform type check at runtime! this is an 102 // approximative substitute 103 Console.printerrln("Object " + sequenceName 104 + "not of type Collection<?>!"); 88 105 return; 89 106 } 90 107 sequences = (Collection<List<? extends Event<?>>>) dataObjectSequences; 91 108 Console.print(sequenceName); 92 for( int length=minLength ; length<=maxLength ; length++) { 93 CoverageCalculatorProcess covCalcProc = new CoverageCalculatorProcess(process, sequences, length); 94 CoverageCalculatorObserved covCalcObs = new CoverageCalculatorObserved(observedSequences, sequences, length); 109 for (int length = minLength; length <= maxLength; length++) { 110 CoverageCalculatorProcess covCalcProc = new CoverageCalculatorProcess( 111 process, sequences, length); 112 CoverageCalculatorObserved covCalcObs = new CoverageCalculatorObserved( 113 observedSequences, sequences, length); 95 114 Console.print(";" + covCalcObs.getNumObserved()); 96 115 Console.print(";" + covCalcObs.getNumCovered()); … … 101 120 Console.print(";" + covCalcProc.getCoveragePossibleWeight()); 102 121 Console.print(";" + covCalcObs.getCoverageObserved()); 103 Console.print(";" + covCalcObs.getCoverageObservedWeigth(process)); 122 Console.print(";" 123 + covCalcObs.getCoverageObservedWeigth(process)); 104 124 Console.print(";" + covCalcObs.getNewPercentage()); 105 125 Console.print(";" + covCalcObs.getCoveragePossibleNew(process)); 106 Console.print(";" + covCalcObs.getCoveragePossibleNewWeight(process)); 126 Console.print(";" 127 + covCalcObs.getCoveragePossibleNewWeight(process)); 107 128 } 108 129 Console.println(""); … … 110 131 } 111 132 133 /* 134 * (non-Javadoc) 135 * 136 * @see de.ugoe.cs.util.console.Command#help() 137 */ 112 138 @Override 113 139 public void help() {
Note: See TracChangeset
for help on using the changeset viewer.