break;
}
}
// Read Values from Solver and store in Model
if (solved == SolveResult.Solved) {
TestCase tc = factory.createTestCase();
result.getTests().add(tc);
FunctionCall func = factory.createFunctionCall();
func.setName(tcgActivity.getName());
func.setActivity(tcgActivity);
tc.setFunction(func);
for (TCGVariable var : tcgActivity.getVariables()) {
Value v = factory.createValue();
v.setName(var.getName());
v.setVariable(var);
if (var.isIsParameter()) {
Double value = null;
try {
value = ampl.getParameter(var.getName());
} catch (IOException e) {
e.printStackTrace();
continue;
}
v.setValue(value);
switch (var.getUsage()) {
case IN_PARAMETER:
func.getParameters().add(v);
break;
case OUT_PARAMETER:
tc.getTestForValue().add(v);
break;
case INOUT_PARAMETER:
// XXX INOUT parameters currently can not be handled
// since there is only one value. For in/out
// Parameters a pre and a post Value would be
// necessary.
// func.getParameters().add(v); //@pre
// tc.getTestForValue().add(v); //post
break;
case RETURN_PARAMETER:
tc.getTestForValue().add(v);
break;
default:
break;
}
} else {
List<Double> trace = null;
try {
trace = ampl.getVariable(var.getName());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
continue;
}
v.setValue(trace.get(0));
tc.getInitValues().add(v);
Value vout = factory.createValue();
vout.setValue(trace.get(trace.size() - 1));
vout.setName(var.getName());
vout.setVariable(var);
tc.getTestForValue().add(vout);
}
}
}
}
return result;