String toolName = controlToolName;
Object tool = context.get(toolName);
assertTrue(tool instanceof ControlTool, "no control tool: %s", toolName);
ControlTool controlTool = (ControlTool) tool;
// setTemplate or setModule
if (template != null) {
controlTool.setTemplate(template);
} else if (module != null) {
controlTool.setModule(module);
}
// setParameter
ParameterParser params = rundata.getParameters();
for (String key : params.keySet()) {
Object[] values = params.getObjects(key);
switch (values.length) {
case 0:
break;
case 1:
controlTool.setParameter(key, values[0]);
break;
default:
controlTool.setParameter(key, values);
break;
}
}
return controlTool;