return super.getNextPage(currentPage, wizard);
}
@Override
public void finish(IWizard wizard) {
BaseExperiment exp = new BaseExperiment();
// SimSystem.getTempDirectory()
SimSystem.report(Level.INFO, "Starting the experiment from the workflow");
// read model from
// ISymbolicModel<?> model = (ISymbolicModel<?>) wizard.getValue("model");
/** The model location (temporary file of model description). */
URI modelLocation = null;
modelLocation = wizard.getValue(ModelEditor.MODEL_LOCATION);
// Entity.report("Will use model " + modelLocation);
// Entity.report("Will not use model " + wizard.getValue("modellocation"));
Map<String, ?> state =
wizard.getValue(ModelParameterEditor.MODEL_PARAMETERS);
Object user = wizard.getValue(ModelParameterEditor.USER_PARAMETERS);
exp.setModelLocation(modelLocation);
exp.setName("Tut. WF Exp.: " + Files.getFileName(modelLocation));
exp.setExperimentVariables(new ExperimentVariables());
ArrayList<Object> al = new ArrayList<>();
al.add(state);
// set model parameters
if (state != null) {
exp.getFixedModelParameters().putAll(state);
}
al = new ArrayList<>();
al.add(user);
exp.getExperimentVariables().addVariable(
new ExperimentVariable<>("user.parameters",
new SequenceModifier<>(al)));
ParameterBlock afp = new ParameterBlock();
afp.addSubBlock(AbstractModelInstrumenterFactory.MODELURI, modelLocation);
List<ModelInstrumenterFactory> modelInstrFacs = null;
List<ComputationInstrumenterFactory> simInstrFacs = null;
boolean modelInstrumenter = true;
boolean simInstumenter = true;
try {
modelInstrFacs =
SimSystem.getRegistry().getFactoryList(
AbstractModelInstrumenterFactory.class, afp);
} catch (NoFactoryFoundException nffe) {
modelInstrumenter = false;
}
try {
simInstrFacs =
SimSystem.getRegistry().getFactoryList(
AbstractComputationInstrumenterFactory.class, afp);
} catch (NoFactoryFoundException nffe) {
simInstumenter = false;
SimSystem.report(Level.INFO, null, "No instrumenter found for model: "
+ modelLocation, null);
}
if (simInstumenter || modelInstrumenter) {
List<Factory> instrFacs = new ArrayList<>();
if (modelInstrFacs != null) {
instrFacs.addAll(modelInstrFacs);
}
if (simInstrFacs != null) {
instrFacs.addAll(simInstrFacs);
}
FactorySelectionDialog<Factory<?>> diag =
new FactorySelectionDialog(null, instrFacs, null,
"Select Instrumentation", true);
diag.setVisible(true);
if (diag.isOkButtonPressed()) {
List<ParameterizedFactory<Factory<?>>> selected =
diag.getSelectedFactoriesAndParameters();
ParameterizedFactory<Factory<?>> sel = new ParameterizedFactory<>();
if (selected.size() > 0) {
sel = selected.get(0);
}
if (sel.getFactory() instanceof ModelInstrumenterFactory) {
ModelInstrumenterFactory min =
(ModelInstrumenterFactory) sel.getFactory();
exp.setModelInstrumenterFactory(new ParameterizedFactory<>(min,sel.getParameters()));
}
if (sel.getFactory() instanceof ComputationInstrumenterFactory) {
ComputationInstrumenterFactory min =
(ComputationInstrumenterFactory) sel.getFactory();
exp.setComputationInstrumenterFactory(new ParameterizedFactory<>(min,sel.getParameters()));
}
}
// for (ModelInstrumenterFactory m : instrFacs) {
// if (m.getClass().getName().compareTo(sel.toString()) == 0) min = m;
// }