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. 20
      prism/src/prism/PrismCL.java
  2. 18
      prism/src/prism/ResultsCollection.java
  3. 8
      prism/src/simulator/networking/SimulatorNetworkHandler.java
  4. 20
      prism/src/userinterface/properties/GUIExperiment.java

20
prism/src/prism/PrismCL.java

@ -209,13 +209,9 @@ public class PrismCL implements PrismModelListener
// 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)
error(e.getMessage());
try {
for (j = 0; j < numPropertiesToCheck; j++) {
results[j].setMultipleErrors(definedMFConstants, null, e);
}
} catch (PrismException e2) {
error("Problem storing results");
}
// iterate to next model
undefinedMFConstants.iterateModel();
for (j = 0; j < numPropertiesToCheck; j++) {
@ -275,11 +271,7 @@ public class PrismCL implements PrismModelListener
} catch (PrismException e) {
// in case of (overall) error, report it, store as result for property, and proceed
error(e.getMessage());
try {
results[j].setMultipleErrors(definedMFConstants, null, e);
} catch (PrismException e2) {
error("Problem storing results");
}
continue;
} catch (InterruptedException e) {
// ignore - won't get interrupted
@ -313,16 +305,11 @@ public class PrismCL implements PrismModelListener
// in case of build failure during model checking, store as result for any const values and continue
if (modelBuildFail) {
try {
results[j].setMultipleErrors(definedMFConstants, null, modelBuildException);
} catch (PrismException e2) {
error("Problem storing results");
}
continue;
}
// store result of model checking
try {
results[j].setResult(definedMFConstants, definedPFConstants, res.getResult());
Object cex = res.getCounterexample();
if (cex != null) {
@ -332,9 +319,6 @@ public class PrismCL implements PrismModelListener
((cex.CexPathAsBDDs) cex).clear();
}
}
} catch (PrismException e) {
error("Problem storing results");
}
// if required, check result against expected value
if (test) {
@ -358,13 +342,9 @@ 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
if (modelBuildFail) {
try {
for (j++; j < numPropertiesToCheck; j++) {
results[j].setMultipleErrors(definedMFConstants, null, modelBuildException);
}
} catch (PrismException e2) {
error("Problem storing results");
}
// iterate to next model
undefinedMFConstants.iterateModel();
for (j = 0; j < numPropertiesToCheck; j++) {

18
prism/src/prism/ResultsCollection.java

@ -104,7 +104,7 @@ public class ResultsCollection
/**
* 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
int ret = root.setResult(values, result);
@ -125,7 +125,7 @@ public class ResultsCollection
/**
* 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
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
* 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
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
* 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
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.
* 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;
// if a value has been given for this node's constant, just store the result for this value
if (setThese.contains(constant.getName())) {
// get value of this node's constant
try {
val = setThese.getValueOf(constant.getName());
} catch (PrismLangException e) {
// Ignore - already checked above
}
// and convert to index
valIndex = constant.getValueIndex(val);
// store the value
@ -586,7 +590,7 @@ public class ResultsCollection
{
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;
val = result;

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

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

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

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

Loading…
Cancel
Save