Removed context, process name and logger from Action API. Context specific tasks could be invoked via ActionManager.

This commit is contained in:
Alexander Nozik 2016-12-04 18:15:17 +03:00
parent 2f30be2e6b
commit 96c01df95a
14 changed files with 36 additions and 56 deletions

View File

@ -23,7 +23,7 @@ task debug(dependsOn: classes, type: JavaExec) {
task testRun(dependsOn: classes, type: JavaExec) { task testRun(dependsOn: classes, type: JavaExec) {
main mainClass main mainClass
args(["--cfgFile=D:/temp/test/numass-devices.xml", "--device=thermo-1"]) args(["--config=D:/temp/test/numass-devices.xml", "--device=thermo-1"])
classpath = sourceSets.main.runtimeClasspath classpath = sourceSets.main.runtimeClasspath
description "Start application using real device" description "Start application using real device"
group "debug" group "debug"

View File

@ -70,7 +70,7 @@ public class PKT8App extends Application {
if (Boolean.parseBoolean(getParameters().getNamed().getOrDefault("debug", "false"))) { if (Boolean.parseBoolean(getParameters().getNamed().getOrDefault("debug", "false"))) {
config = loadTestConfig(); config = loadTestConfig();
} else { } else {
config = MetaFileReader.read(new File(getParameters().getNamed().getOrDefault("cfgFile", DEFAULT_CONFIG_LOCATION))); config = MetaFileReader.read(new File(getParameters().getNamed().getOrDefault("config", DEFAULT_CONFIG_LOCATION)));
} }

View File

@ -1,10 +0,0 @@
apply plugin: 'application'
description = "Joint measurement for vacuum, msp and temperature measurements"
dependencies{
compile project(':numass-control:cryotemp')
compile project(':numass-control:msp')
compile project(':numass-control:vac')
compile project(':numass-storage:numass-server')
}

View File

@ -1,18 +0,0 @@
package inr.numass.control.miranda;/**
* Created by darksnake on 13-Oct-16.
*/
import javafx.application.Application;
import javafx.stage.Stage;
public class MirandaApp extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
}
}

View File

@ -10,7 +10,7 @@ import hep.dataforge.grind.Grind
import inr.numass.storage.NMPoint import inr.numass.storage.NMPoint
import inr.numass.storage.NumassData import inr.numass.storage.NumassData
import inr.numass.storage.NumassDataLoader import inr.numass.storage.NumassDataLoader
import inr.numass.utils.NMEventGeneratorWithPulser import inr.numass.utils.NMEventGenerator
import inr.numass.utils.PileUpSimulator import inr.numass.utils.PileUpSimulator
import inr.numass.utils.TritiumUtils import inr.numass.utils.TritiumUtils
import org.apache.commons.math3.random.JDKRandomGenerator import org.apache.commons.math3.random.JDKRandomGenerator
@ -18,7 +18,7 @@ import org.apache.commons.math3.random.JDKRandomGenerator
rnd = new JDKRandomGenerator(); rnd = new JDKRandomGenerator();
//Loading data //Loading data
File dataDir = new File("D:\\Work\\Numass\\data\\2016_10\\Fill_1\\set_28") File dataDir = new File("D:\\Work\\Numass\\data\\2016_10\\Fill_1\\set_24")
if (!dataDir.exists()) { if (!dataDir.exists()) {
println "dataDir directory does not exist" println "dataDir directory does not exist"
} }
@ -40,7 +40,8 @@ PileUpSimulator buildSimulator(NMPoint point, double cr, NMPoint reference = nul
def cfg = Grind.buildMeta(cr: cr) { def cfg = Grind.buildMeta(cr: cr) {
pulser(mean: 3450, sigma: 86.45, freq: 66.43) pulser(mean: 3450, sigma: 86.45, freq: 66.43)
} }
NMEventGeneratorWithPulser generator = new NMEventGeneratorWithPulser(rnd, cfg) // NMEventGenerator generator = new NMEventGeneratorWithPulser(rnd, cfg)
NMEventGenerator generator = new NMEventGenerator(rnd, cfg)
generator.loadSpectrum(point, reference, lowerChannel, upperChannel); generator.loadSpectrum(point, reference, lowerChannel, upperChannel);
return new PileUpSimulator(point.length * scale, rnd, generator).withUset(point.uset).generate(); return new PileUpSimulator(point.length * scale, rnd, generator).withUset(point.uset).generate();
} }

View File

@ -54,7 +54,7 @@ public class Numass {
)); ));
writer.println("***Allowed actions***"); writer.println("***Allowed actions***");
for (ActionDescriptor descriptor : ActionManager.buildFrom(context).listActions()) { for (ActionDescriptor descriptor : ActionManager.buildFrom(context).list()) {
writer.print(" "); writer.print(" ");
formatter.showDescription(descriptor); formatter.showDescription(descriptor);
} }

View File

@ -79,19 +79,19 @@ public class NumassPlugin extends BasicPlugin {
loadMath(MathPlugin.buildFrom(context)); loadMath(MathPlugin.buildFrom(context));
ActionManager actions = ActionManager.buildFrom(context); ActionManager actions = ActionManager.buildFrom(context);
actions.registerAction(SlicingAction.class); actions.register(SlicingAction.class);
actions.registerAction(PrepareDataAction.class); actions.register(PrepareDataAction.class);
actions.registerAction(ReadNumassDataAction.class); actions.register(ReadNumassDataAction.class);
actions.registerAction(MergeDataAction.class); actions.register(MergeDataAction.class);
actions.registerAction(FindBorderAction.class); actions.register(FindBorderAction.class);
actions.registerAction(MonitorCorrectAction.class); actions.register(MonitorCorrectAction.class);
actions.registerAction(SummaryAction.class); actions.register(SummaryAction.class);
actions.registerAction(PlotDataAction.class); actions.register(PlotDataAction.class);
actions.registerAction(PlotFitResultAction.class); actions.register(PlotFitResultAction.class);
actions.registerAction(ShowLossSpectrumAction.class); actions.register(ShowLossSpectrumAction.class);
actions.registerAction(AdjustErrorsAction.class); actions.register(AdjustErrorsAction.class);
actions.registerAction(ShowEnergySpectrumAction.class); actions.register(ShowEnergySpectrumAction.class);
actions.registerAction(SubstractSpectrumAction.class); actions.register(SubstractSpectrumAction.class);
} }
@Override @Override

View File

@ -38,7 +38,7 @@ public class ShowEnergySpectrumAction extends OneToOneAction<NumassData, Table>
List<NMPoint> points = input.getNMPoints(); List<NMPoint> points = input.getNMPoints();
if (points.isEmpty()) { if (points.isEmpty()) {
logger().error("Empty data"); getLogger(inputMeta).error("Empty data");
return null; return null;
} }

View File

@ -198,7 +198,7 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
} }
private List<ActionDescriptor> listActions() { private List<ActionDescriptor> listActions() {
return ActionManager.buildFrom(getContext()).listActions(); return ActionManager.buildFrom(getContext()).list();
} }
private ActionDescriptor getDescriptorForAction(String actionType) { private ActionDescriptor getDescriptorForAction(String actionType) {

View File

@ -41,7 +41,7 @@ public class NumassFitScanTask extends AbstractTask<FitState> {
} else { } else {
scanValues = config.getValue("scan.values", Value.of("[2.5e5, 1e6, 2.25e6, 4e6, 6.25e6, 9e6]")); scanValues = config.getValue("scan.values", Value.of("[2.5e5, 1e6, 2.25e6, 4e6, 6.25e6, 9e6]"));
} }
Action<Table, FitState> action = new FitAction().withContext(model.getContext()).withParentProcess(callback.workName()); Action<Table, FitState> action = new FitAction().withContext(model.getContext());
DataTree.Builder<FitState> resultBuilder = DataTree.builder(FitState.class); DataTree.Builder<FitState> resultBuilder = DataTree.builder(FitState.class);
DataNode<Table> sourceNode = data.getCheckedNode("prepare", Table.class); DataNode<Table> sourceNode = data.getCheckedNode("prepare", Table.class);

View File

@ -17,9 +17,11 @@
package inr.numass.workspace; package inr.numass.workspace;
import hep.dataforge.actions.Action; import hep.dataforge.actions.Action;
import hep.dataforge.actions.ActionUtils;
import hep.dataforge.data.DataNode; import hep.dataforge.data.DataNode;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.meta.MetaBuilder; import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.plotfit.PlotFitResultAction;
import hep.dataforge.stat.fit.FitAction; import hep.dataforge.stat.fit.FitAction;
import hep.dataforge.stat.fit.FitState; import hep.dataforge.stat.fit.FitState;
import hep.dataforge.tables.Table; import hep.dataforge.tables.Table;
@ -50,7 +52,12 @@ public class NumassFitTask extends SingleActionTask<Table, FitState> {
@Override @Override
protected Action getAction(TaskModel model) { protected Action getAction(TaskModel model) {
return new FitAction().withContext(model.getContext()); Action action = new FitAction().withContext(model.getContext());
if (model.meta().getBoolean("fit.plot", false)) {
return ActionUtils.compose(action, new PlotFitResultAction());
} else {
return action;
}
} }
@Override @Override

View File

@ -5,7 +5,7 @@
*/ */
package inr.numass.workspace; package inr.numass.workspace;
import hep.dataforge.actions.Action; import hep.dataforge.actions.GenericAction;
import hep.dataforge.computation.ProgressCallback; import hep.dataforge.computation.ProgressCallback;
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.data.*; import hep.dataforge.data.*;
@ -125,8 +125,8 @@ public class NumassPrepareTask extends AbstractTask<Table> {
return builder; return builder;
} }
private <T, R> DataNode<R> runAction(Action<T, R> action, ProgressCallback callback, Context context, DataNode<T> data, Meta meta) { private <T, R> DataNode<R> runAction(GenericAction<T, R> action, ProgressCallback callback, Context context, DataNode<T> data, Meta meta) {
return action.withContext(context).withParentProcess(callback.workName()).run(data, meta); return action.withContext(context).run(data, meta);
} }
@Override @Override

View File

@ -48,7 +48,7 @@ public class NumassTableFilterTask extends SingleActionTask<Table, Table> {
protected Table execute(String name, Laminate inputMeta, Table input) { protected Table execute(String name, Laminate inputMeta, Table input) {
double uLo = inputMeta.getDouble("filter.from", 0); double uLo = inputMeta.getDouble("filter.from", 0);
double uHi = inputMeta.getDouble("filter.to", Double.POSITIVE_INFINITY); double uHi = inputMeta.getDouble("filter.to", Double.POSITIVE_INFINITY);
getLogger().debug("Filtering finished"); getLogger(inputMeta).debug("Filtering finished");
return TableTransform.filter(input, "Uset", uLo, uHi); return TableTransform.filter(input, "Uset", uLo, uHi);
} }
} }

View File

@ -5,7 +5,7 @@ if (!hasProperty('mainClass')) {
} }
mainClassName = mainClass mainClassName = mainClass
version = "0.3.5" version = "0.3.6"
description = "The viewer for numass data" description = "The viewer for numass data"