removed unecessary JythonGlobalVariableDictionary class

This commit is contained in:
2013-10-15 09:40:14 +02:00
parent 4b615d29a6
commit 48cda75405
2 changed files with 5 additions and 81 deletions

View File

@@ -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<String, JythonGlobalVariable> jVariableDictionary = new HashMap<String, JythonGlobalVariable>();
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<String, JythonGlobalVariable> map = new HashMap<String, JythonGlobalVariable>();
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);
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
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<String, JythonGlobalVariable> dictionary = new HashMap<String, JythonGlobalVariable>();
/**
* 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();
}
}