From 48cda75405e33c06dea799e03a3bc70e281b8ce8 Mon Sep 17 00:00:00 2001 From: Simon Ebner Date: Tue, 15 Oct 2013 09:40:14 +0200 Subject: [PATCH] removed unecessary JythonGlobalVariableDictionary class --- .../main/java/ch/psi/fda/aq/Acquisition.java | 11 ++- .../JythonGlobalVariableDictionary.java | 75 ------------------- 2 files changed, 5 insertions(+), 81 deletions(-) delete mode 100644 ch.psi.fda/src/main/java/ch/psi/fda/core/scripting/JythonGlobalVariableDictionary.java diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/aq/Acquisition.java b/ch.psi.fda/src/main/java/ch/psi/fda/aq/Acquisition.java index 48f06fd..828a73c 100644 --- a/ch.psi.fda/src/main/java/ch/psi/fda/aq/Acquisition.java +++ b/ch.psi.fda/src/main/java/ch/psi/fda/aq/Acquisition.java @@ -67,7 +67,6 @@ import ch.psi.fda.core.loops.otf.TemplateOTF; import ch.psi.fda.core.manipulator.JythonManipulation; import ch.psi.fda.core.messages.DataMessageMetadata; import ch.psi.fda.core.scripting.JythonGlobalVariable; -import ch.psi.fda.core.scripting.JythonGlobalVariableDictionary; import ch.psi.fda.core.scripting.JythonParameterMapping; import ch.psi.fda.core.scripting.JythonParameterMappingChannel; import ch.psi.fda.core.scripting.JythonParameterMappingGlobalVariable; @@ -153,6 +152,8 @@ public class Acquisition { private Configuration configModel; + private HashMap jVariableDictionary = new HashMap(); + public Acquisition(ChannelService cservice){ this.cservice = cservice; this.configuration = AcquisitionConfiguration.getInstance(); @@ -358,7 +359,7 @@ public class Acquisition { } // Clear global variables Jython - JythonGlobalVariableDictionary.getInstance().clear(); + jVariableDictionary.clear(); // Destroy the CA context cservice.destroy(); @@ -464,7 +465,6 @@ public class Acquisition { } // handling manipulations - JythonGlobalVariableDictionary dict = JythonGlobalVariableDictionary.getInstance(); for(ch.psi.fda.model.v1.Manipulation m : scan.getManipulation()){ if(m instanceof ScriptManipulation){ ScriptManipulation sm = (ScriptManipulation) m; @@ -493,7 +493,7 @@ public class Acquisition { else if(pm instanceof VariableParameterMapping){ VariableParameterMapping vp = (VariableParameterMapping) pm; Variable v = (Variable)vp.getName(); - JythonGlobalVariable var = dict.getVariable(v.getName()); + JythonGlobalVariable var = jVariableDictionary.get(v.getName()); var.setValue(v.getValue()); mapping.add(new JythonParameterMappingGlobalVariable(vp.getVariable(), var)); } @@ -933,12 +933,11 @@ public class Acquisition { */ private JythonFunction mapFunction(Function f){ HashMap map = new HashMap(); - JythonGlobalVariableDictionary dict = JythonGlobalVariableDictionary.getInstance(); for(ParameterMapping m: f.getMapping()){ if(m instanceof VariableParameterMapping){ VariableParameterMapping vp = (VariableParameterMapping)m; Variable v = (Variable)vp.getName(); - JythonGlobalVariable var = dict.getVariable(v.getName()); + JythonGlobalVariable var = jVariableDictionary.get(v.getName()); var.setValue(v.getValue()); map.put(vp.getVariable(), var); } diff --git a/ch.psi.fda/src/main/java/ch/psi/fda/core/scripting/JythonGlobalVariableDictionary.java b/ch.psi.fda/src/main/java/ch/psi/fda/core/scripting/JythonGlobalVariableDictionary.java deleted file mode 100644 index 10a4ccb..0000000 --- a/ch.psi.fda/src/main/java/ch/psi/fda/core/scripting/JythonGlobalVariableDictionary.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * - * Copyright 2010 Paul Scherrer Institute. All rights reserved. - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This code is distributed in the hope that it will be useful, - * but without any warranty; without even the implied warranty of - * merchantability or fitness for a particular purpose. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this code. If not, see . - * - */ - -package ch.psi.fda.core.scripting; - -import java.util.HashMap; - -/** - * Singleton dictionary class - * - * @author ebner - * - */ -public class JythonGlobalVariableDictionary { - - private static JythonGlobalVariableDictionary instance = new JythonGlobalVariableDictionary(); - private HashMap dictionary = new HashMap(); - - /** - * Private constructor - */ - private JythonGlobalVariableDictionary(){ - } - - /** - * Get singleton instance of the dictionary - * @return - */ - public static JythonGlobalVariableDictionary getInstance(){ - return instance; - } - - - /** - * Get variable from dictionary. If the variable does not exist it will be created. - * @param name - * @return - */ - public JythonGlobalVariable getVariable(String name){ - JythonGlobalVariable variable; - if(dictionary.containsKey(name)){ - variable = dictionary.get(name); - } - else{ - variable = new JythonGlobalVariable(); - variable.setName(name); - dictionary.put(name, variable); - } - - return variable; - } - - /** - * Clear variable dictionary - */ - public void clear(){ - dictionary.clear(); - } -}