Correlation can accept standard command line options.
This commit is contained in:
@@ -35,62 +35,80 @@ public class Correlation extends Panel {
|
||||
plot.getAxis(Plot.AxisId.Y).setLabel(null);
|
||||
}
|
||||
|
||||
boolean hasArg(String arg) {
|
||||
return App.hasArgument(arg) || App.hasAdditionalArgument(arg);
|
||||
}
|
||||
|
||||
String getArg(String arg) {
|
||||
if (App.hasArgument(arg)){
|
||||
return App.getArgumentValue(arg);
|
||||
}
|
||||
return App.getAdditionalArgumentValue(arg);
|
||||
}
|
||||
boolean getBoolArg(String arg) {
|
||||
if (App.hasArgument(arg)){
|
||||
return App.getBoolArgumentValue(arg);
|
||||
}
|
||||
return App.getBoolAdditionalArgumentValue(arg);
|
||||
}
|
||||
|
||||
|
||||
//Overridable callbacks
|
||||
@Override
|
||||
public void onInitialize(int runCount) {
|
||||
if (runCount==0){
|
||||
super.onInitialize(runCount);
|
||||
if (App.hasAdditionalArgument("dx")) {
|
||||
textDevX.setText(App.getAdditionalArgumentValue("dx"));
|
||||
if (hasArg("dx")) {
|
||||
textDevX.setText(getArg("dx"));
|
||||
}
|
||||
if (App.hasAdditionalArgument("dy")) {
|
||||
textDevY.setText(App.getAdditionalArgumentValue("dy"));
|
||||
if (hasArg("dy")) {
|
||||
textDevY.setText(getArg("dy"));
|
||||
}
|
||||
try{
|
||||
if (App.hasAdditionalArgument("dxtype")) {
|
||||
comboTypeX.setSelectedIndex(Integer.valueOf(App.getAdditionalArgumentValue("dxtype")));
|
||||
if (hasArg("dxtype")) {
|
||||
comboTypeX.setSelectedIndex(Integer.valueOf(getArg("dxtype")));
|
||||
}
|
||||
} catch (Exception ex){
|
||||
System.err.println(ex.getMessage());
|
||||
}
|
||||
try{
|
||||
if (App.hasAdditionalArgument("dytype")) {
|
||||
comboTypeY.setSelectedIndex(Integer.valueOf(App.getAdditionalArgumentValue("dytype")));
|
||||
if (hasArg("dytype")) {
|
||||
comboTypeY.setSelectedIndex(Integer.valueOf(getArg("dytype")));
|
||||
}
|
||||
} catch (Exception ex){
|
||||
System.err.println(ex.getMessage());
|
||||
}
|
||||
try{
|
||||
if (App.hasAdditionalArgument("interval")) {
|
||||
spinnerInterval.setValue(Double.valueOf(App.getAdditionalArgumentValue("interval")));
|
||||
if (hasArg("interval")) {
|
||||
spinnerInterval.setValue(Double.valueOf(getArg("interval")));
|
||||
}
|
||||
} catch (Exception ex){
|
||||
System.err.println(ex.getMessage());
|
||||
}
|
||||
try{
|
||||
if (App.hasAdditionalArgument("window")) {
|
||||
spinnerWindow.setValue(Integer.valueOf(App.getAdditionalArgumentValue("window")));
|
||||
if (hasArg("window")) {
|
||||
spinnerWindow.setValue(Integer.valueOf(getArg("window")));
|
||||
}
|
||||
} catch (Exception ex){
|
||||
System.err.println(ex.getMessage());
|
||||
}
|
||||
try{
|
||||
if (App.hasAdditionalArgument("align")) {
|
||||
checkAlign.setSelected(App.getBoolAdditionalArgumentValue("align"));
|
||||
if (hasArg("align")) {
|
||||
checkAlign.setSelected(getBoolArg("align"));
|
||||
}
|
||||
} catch (Exception ex){
|
||||
System.err.println(ex.getMessage());
|
||||
}
|
||||
try{
|
||||
if (App.hasAdditionalArgument("linear")) {
|
||||
checkLinear.setSelected(App.getBoolAdditionalArgumentValue("linear"));
|
||||
if (hasArg("linear")) {
|
||||
checkLinear.setSelected(getBoolArg("linear"));
|
||||
}
|
||||
} catch (Exception ex){
|
||||
System.err.println(ex.getMessage());
|
||||
}
|
||||
try{
|
||||
if (App.hasAdditionalArgument("quadratic")) {
|
||||
checkQuadratic.setSelected(App.getBoolAdditionalArgumentValue("quadratic"));
|
||||
if (hasArg("quadratic")) {
|
||||
checkQuadratic.setSelected(getBoolArg("quadratic"));
|
||||
}
|
||||
} catch (Exception ex){
|
||||
System.err.println(ex.getMessage());
|
||||
@@ -101,7 +119,7 @@ public class Correlation extends Panel {
|
||||
comboTypeYActionPerformed(null);
|
||||
|
||||
if (runCount==0){
|
||||
if (App.hasArgument("start")) {
|
||||
if (hasArg("start")) {
|
||||
buttonStartActionPerformed(null);
|
||||
}
|
||||
}
|
||||
|
||||
29
correlation/src/main/pkg/plugins/CorrelationOptions.java
Normal file
29
correlation/src/main/pkg/plugins/CorrelationOptions.java
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
import ch.psi.pshell.app.Option;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public enum CorrelationOptions implements Option {
|
||||
DX,
|
||||
DXTYPE,
|
||||
DY,
|
||||
DYTYPE,
|
||||
INTERVAL,
|
||||
WINDOW,
|
||||
ALIGN,
|
||||
LINEAR,
|
||||
QUADRATIC;
|
||||
|
||||
public static void add(){
|
||||
DX.add("dx", "Channel for X");
|
||||
DXTYPE.add("dxtype", "Channel X type (0=epics, 1=bsread, 2=camserver)");
|
||||
DY.add("dy", "Channel for Y");
|
||||
DYTYPE.add("dytype", "Channel Y type (0=epics, 1=bsread, 2=camserver)");
|
||||
INTERVAL.add("interval", "Time interval between samples in seconds");
|
||||
WINDOW.add("window", "Number of samples");
|
||||
ALIGN.add("align", "Enforce same pulse ID for bsread and camserver channels");
|
||||
LINEAR.add("linear", "Enable linear fit");
|
||||
QUADRATIC.add("quadratic", "Enable quadratic fit");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user