Browse Source

Less exceptions thrown from ResultCollection error setting methods, with knock-on effect (cleaner code) in various calling sites.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@4598 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 14 years ago
parent
commit
01c3826d8d
  1. 46
      prism/src/prism/PrismCL.java
  2. 20
      prism/src/prism/ResultsCollection.java
  3. 10
      prism/src/simulator/networking/SimulatorNetworkHandler.java
  4. 28
      prism/src/userinterface/properties/GUIExperiment.java

46
prism/src/prism/PrismCL.java

@ -209,12 +209,8 @@ public class PrismCL implements PrismModelListener
// in case of error, report it, store as result for any properties, and go on to the next model // in case of error, report it, store as result for any properties, and go on to the next model
// (might happen for example if overflow or another numerical problem is detected at this stage) // (might happen for example if overflow or another numerical problem is detected at this stage)
error(e.getMessage()); error(e.getMessage());
try {
for (j = 0; j < numPropertiesToCheck; j++) {
results[j].setMultipleErrors(definedMFConstants, null, e);
}
} catch (PrismException e2) {
error("Problem storing results");
for (j = 0; j < numPropertiesToCheck; j++) {
results[j].setMultipleErrors(definedMFConstants, null, e);
} }
// iterate to next model // iterate to next model
undefinedMFConstants.iterateModel(); undefinedMFConstants.iterateModel();
@ -275,11 +271,7 @@ public class PrismCL implements PrismModelListener
} catch (PrismException e) { } catch (PrismException e) {
// in case of (overall) error, report it, store as result for property, and proceed // in case of (overall) error, report it, store as result for property, and proceed
error(e.getMessage()); error(e.getMessage());
try {
results[j].setMultipleErrors(definedMFConstants, null, e);
} catch (PrismException e2) {
error("Problem storing results");
}
results[j].setMultipleErrors(definedMFConstants, null, e);
continue; continue;
} catch (InterruptedException e) { } catch (InterruptedException e) {
// ignore - won't get interrupted // ignore - won't get interrupted
@ -313,27 +305,19 @@ public class PrismCL implements PrismModelListener
// in case of build failure during model checking, store as result for any const values and continue // in case of build failure during model checking, store as result for any const values and continue
if (modelBuildFail) { if (modelBuildFail) {
try {
results[j].setMultipleErrors(definedMFConstants, null, modelBuildException);
} catch (PrismException e2) {
error("Problem storing results");
}
results[j].setMultipleErrors(definedMFConstants, null, modelBuildException);
continue; continue;
} }
// store result of model checking // store result of model checking
try {
results[j].setResult(definedMFConstants, definedPFConstants, res.getResult());
Object cex = res.getCounterexample();
if (cex != null) {
mainLog.println("\nCounterexample/witness:");
mainLog.println(cex);
if (cex instanceof cex.CexPathAsBDDs){
((cex.CexPathAsBDDs) cex).clear();
}
results[j].setResult(definedMFConstants, definedPFConstants, res.getResult());
Object cex = res.getCounterexample();
if (cex != null) {
mainLog.println("\nCounterexample/witness:");
mainLog.println(cex);
if (cex instanceof cex.CexPathAsBDDs) {
((cex.CexPathAsBDDs) cex).clear();
} }
} catch (PrismException e) {
error("Problem storing results");
} }
// if required, check result against expected value // if required, check result against expected value
@ -358,12 +342,8 @@ public class PrismCL implements PrismModelListener
// in case of build failure during model checking, store as result for any further properties, and go on to the next model // in case of build failure during model checking, store as result for any further properties, and go on to the next model
if (modelBuildFail) { if (modelBuildFail) {
try {
for (j++; j < numPropertiesToCheck; j++) {
results[j].setMultipleErrors(definedMFConstants, null, modelBuildException);
}
} catch (PrismException e2) {
error("Problem storing results");
for (j++; j < numPropertiesToCheck; j++) {
results[j].setMultipleErrors(definedMFConstants, null, modelBuildException);
} }
// iterate to next model // iterate to next model
undefinedMFConstants.iterateModel(); undefinedMFConstants.iterateModel();

20
prism/src/prism/ResultsCollection.java

@ -104,7 +104,7 @@ public class ResultsCollection
/** /**
* Sets the result for a particular set of values. * Sets the result for a particular set of values.
*/ */
public int setResult(Values values, Object result) throws PrismException
public int setResult(Values values, Object result)
{ {
// store result // store result
int ret = root.setResult(values, result); int ret = root.setResult(values, result);
@ -125,7 +125,7 @@ public class ResultsCollection
/** /**
* Sets the result for a particular set of values. * Sets the result for a particular set of values.
*/ */
public int setResult(Values mfValues, Values pfValues, Object result) throws PrismException
public int setResult(Values mfValues, Values pfValues, Object result)
{ {
// merge mfValues and pfValues // merge mfValues and pfValues
Values merged = new Values(); Values merged = new Values();
@ -143,7 +143,7 @@ public class ResultsCollection
* Note: individual errors can be set using setResult(). That method could easily be adapted to store * Note: individual errors can be set using setResult(). That method could easily be adapted to store
* multiple values but the DisplayableData aspect isn't sorted yet. * multiple values but the DisplayableData aspect isn't sorted yet.
*/ */
public int setMultipleErrors(Values values, Exception error) throws PrismException
public int setMultipleErrors(Values values, Exception error)
{ {
// store result // store result
int ret = root.setResult(values, error); int ret = root.setResult(values, error);
@ -161,7 +161,7 @@ public class ResultsCollection
* Note: individual errors can be set using setResult(). That method could easily be adapted to store * Note: individual errors can be set using setResult(). That method could easily be adapted to store
* multiple values but the DisplayableData aspect isn't sorted yet. * multiple values but the DisplayableData aspect isn't sorted yet.
*/ */
public int setMultipleErrors(Values mfValues, Values pfValues, Exception error) throws PrismException
public int setMultipleErrors(Values mfValues, Values pfValues, Exception error)
{ {
// merge mfValues and pfValues // merge mfValues and pfValues
Values merged = new Values(); Values merged = new Values();
@ -360,15 +360,19 @@ public class ResultsCollection
* If any constants are left undefined, the same result will be set for all values of each constant. * If any constants are left undefined, the same result will be set for all values of each constant.
* Returns the total number of values which were set for the the first time. * Returns the total number of values which were set for the the first time.
*/ */
public int setResult(Values setThese, Object result) throws PrismException
public int setResult(Values setThese, Object result)
{ {
Object val;
Object val = null;
int valIndex, ret, i, n; int valIndex, ret, i, n;
// if a value has been given for this node's constant, just store the result for this value // if a value has been given for this node's constant, just store the result for this value
if (setThese.contains(constant.getName())) { if (setThese.contains(constant.getName())) {
// get value of this node's constant // get value of this node's constant
val = setThese.getValueOf(constant.getName());
try {
val = setThese.getValueOf(constant.getName());
} catch (PrismLangException e) {
// Ignore - already checked above
}
// and convert to index // and convert to index
valIndex = constant.getValueIndex(val); valIndex = constant.getValueIndex(val);
// store the value // store the value
@ -586,7 +590,7 @@ public class ResultsCollection
{ {
private Object val = null; private Object val = null;
public int setResult(Values setThese, Object result) throws PrismException
public int setResult(Values setThese, Object result)
{ {
int ret = (val == null) ? 1 : 0; int ret = (val == null) ? 1 : 0;
val = result; val = result;

10
prism/src/simulator/networking/SimulatorNetworkHandler.java

@ -480,15 +480,7 @@ public class SimulatorNetworkHandler extends Observable implements EntityResolve
Values pcs = (Values)propertyConstantRanges.get(i); Values pcs = (Values)propertyConstantRanges.get(i);
double res = srf.getResult(i); double res = srf.getResult(i);
Object result = (res < 0.0)?null:new Double(res); Object result = (res < 0.0)?null:new Double(res);
try
{
resultsCollection.setResult(modelConstants, pcs, result);
}
catch(PrismException e)
{
//do nothing
}
resultsCollection.setResult(modelConstants, pcs, result);
} }
} }

28
prism/src/userinterface/properties/GUIExperiment.java

@ -164,12 +164,12 @@ public class GUIExperiment
table.repaint(); table.repaint();
} }
public synchronized void setResult(Values mfValues, Values pfValues, Result res) throws PrismException
public synchronized void setResult(Values mfValues, Values pfValues, Result res)
{ {
results.setResult(mfValues, pfValues, res.getResult()); results.setResult(mfValues, pfValues, res.getResult());
} }
public synchronized void setMultipleErrors(Values mfValues, Values pfValues, Exception e) throws PrismException
public synchronized void setMultipleErrors(Values mfValues, Values pfValues, Exception e)
{ {
results.setMultipleErrors(mfValues, pfValues, e); results.setMultipleErrors(mfValues, pfValues, e);
} }
@ -233,11 +233,7 @@ public class GUIExperiment
} catch (PrismException e) { } catch (PrismException e) {
// in case of error, report it (in log only), store as result, and go on to the next model // in case of error, report it (in log only), store as result, and go on to the next model
errorLog(e.getMessage()); errorLog(e.getMessage());
try {
setMultipleErrors(definedMFConstants, null, e);
} catch (PrismException e2) {
error("Problem storing results");
}
setMultipleErrors(definedMFConstants, null, e);
undefinedConstants.iterateModel(); undefinedConstants.iterateModel();
continue; continue;
} }
@ -251,11 +247,7 @@ public class GUIExperiment
} catch (PrismException e) { } catch (PrismException e) {
// in case of error, report it (in log only), store as result, and go on to the next model // in case of error, report it (in log only), store as result, and go on to the next model
errorLog(e.getMessage()); errorLog(e.getMessage());
try {
setMultipleErrors(definedMFConstants, null, e);
} catch (PrismException e2) {
error("Problem storing results");
}
setMultipleErrors(definedMFConstants, null, e);
undefinedConstants.iterateModel(); undefinedConstants.iterateModel();
continue; continue;
} }
@ -302,11 +294,7 @@ public class GUIExperiment
} catch (PrismException e) { } catch (PrismException e) {
// in case of error, report it (in log only), store as result, and go on to the next model // in case of error, report it (in log only), store as result, and go on to the next model
errorLog(e.getMessage()); errorLog(e.getMessage());
try {
setMultipleErrors(definedMFConstants, null, e);
} catch (PrismException e2) {
error("Problem storing results");
}
setMultipleErrors(definedMFConstants, null, e);
undefinedConstants.iterateModel(); undefinedConstants.iterateModel();
continue; continue;
} }
@ -351,11 +339,7 @@ public class GUIExperiment
{ {
public void run() public void run()
{ {
try {
GUIExperiment.this.setResult(definedMFConstants, definedPFConstants, res);
} catch (PrismException e) {
error("Problem storing results");
}
GUIExperiment.this.setResult(definedMFConstants, definedPFConstants, res);
} }
}); });

Loading…
Cancel
Save