Skip to content
Snippets Groups Projects
Commit c58c3334 authored by Raphael GIRARDOT's avatar Raphael GIRARDOT
Browse files

code readapted to changes in CometeTrend (CONTROLGUI-401)

parent 33a98a73
No related branches found
No related tags found
No related merge requests found
......@@ -23,9 +23,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import org.cdma.gui.databrowser.interfaces.AxisType;
import fr.soleil.comete.bean.trend.controller.CometeTrendController;
import fr.soleil.comete.bean.trend.model.TrendFile;
import fr.soleil.comete.definition.widget.properties.ChartProperties;
import fr.soleil.comete.definition.widget.properties.PlotProperties;
......@@ -39,20 +41,25 @@ import fr.soleil.data.service.IKey;
public class TangoFile {
private final List<IKey> simpleKeyList = new ArrayList<>();
private final List<HistoryKey> trendKeyList = new ArrayList<>();
private final List<IKey> simpleKeyList;
private final List<HistoryKey> trendKeyList;
private BufferedReader br = null;
private final Map<IKey, PlotProperties> plotPropertiesMap = new HashMap<>();
private final Map<IKey, PlotProperties> plotPropertiesMap;
private final Map<String, IKey> keyMap;
private final ChartProperties chartProperties;
private AxisType axisType;
private TrendFile trendFile;
public TangoFile(String fileName) throws IOException {
simpleKeyList = new ArrayList<>();
trendKeyList = new ArrayList<>();
plotPropertiesMap = new HashMap<>();
keyMap = new ConcurrentHashMap<>();
// First test with ATKTrend
TrendFile trendFile = new TrendFile(fileName);
trendFile = new TrendFile(fileName, false);
chartProperties = trendFile.getChartProperties();
Collection<Entry<String, PlotProperties>> knownPlotProperties = trendFile.getKnownPlotProperties();
......@@ -62,9 +69,10 @@ public class TangoFile {
for (Entry<String, PlotProperties> entry : knownPlotProperties) {
String key = entry.getKey();
plotProperties = entry.getValue();
IKey hkey = trendFile.convertToKey(key);
IKey hkey = convertToKey(key);
if ((hkey instanceof HistoryKey) && (plotProperties.getAxisChoice() != TrendFile.AXIS_NONE)) {
trendKeyList.add((HistoryKey) hkey);
HistoryKey historyKey = (HistoryKey) hkey;
trendKeyList.add(historyKey);
plotPropertiesMap.put(hkey, plotProperties);
int index = key.lastIndexOf('/');
if (index > 0) {
......@@ -105,6 +113,7 @@ public class TangoFile {
TangoKeyTool.registerAttribute(tangoKey, deviceName, attributeName);
TangoKeyTool.registerRefreshed(tangoKey, false);
historyKey = new HistoryKey(tangoKey);
}
trendKeyList.add(historyKey);
}
}
......@@ -112,6 +121,36 @@ public class TangoFile {
}
}
protected IKey createTangoKey(String attributeName) {
IKey tangoKey = new TangoKey();
TangoKeyTool.registerAttribute(tangoKey, attributeName);
TangoKeyTool.registerRefreshed(tangoKey, false);
return tangoKey;
}
protected IKey convertToKey(String value) {
IKey key;
if (value == null) {
key = null;
} else {
key = keyMap.get(value);
if (key == null) {
IKey basicKey = null;
String completeAttributeName = CometeTrendController.parseAttributeCompleteName(value);
if ((value != null) && !value.trim().isEmpty()) {
basicKey = createTangoKey(completeAttributeName);
}
if (basicKey != null) {
HistoryKey hkey = new HistoryKey(basicKey);
hkey.setUseSuffix(false);
key = hkey;
}
if (key != null) {
keyMap.put(value, key);
}
}
}
return key;
}
public void close() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment