diff --git a/DataBrowserPlugins/IrfuPlugin/src/main/java/fr/cea/irfu/epics/AbstractEpicsDataSource.java b/DataBrowserPlugins/IrfuPlugin/src/main/java/fr/cea/irfu/epics/AbstractEpicsDataSource.java index 6f713b51291a9e51d7e4e8ef4fcfbf70e020a91b..810ede9ddc7a963cc0e1d933bad619b1f66663df 100644 --- a/DataBrowserPlugins/IrfuPlugin/src/main/java/fr/cea/irfu/epics/AbstractEpicsDataSource.java +++ b/DataBrowserPlugins/IrfuPlugin/src/main/java/fr/cea/irfu/epics/AbstractEpicsDataSource.java @@ -15,47 +15,41 @@ import fr.cea.irfu.interfaces.AbstractIrfuDataSource; import fr.cea.irfu.interfaces.ParameterAccessor; import fr.soleil.data.service.IKey; import heps.epics.ca.client.ProcessVariableManager; -import heps.epics.ca.interfaces.ICafeProcessVariable; public abstract class AbstractEpicsDataSource<T> extends AbstractIrfuDataSource<T> { private static EpicsParameterAccessor accessor = null; - + public AbstractEpicsDataSource(IKey key) { super(key); - //setData(getData()); + // setData(getData()); } @Override protected ParameterAccessor createParamAccessor(String host) { - if(accessor == null) { + if (accessor == null) { accessor = new EpicsParameterAccessor(host); } - + return accessor; } - + @Override protected Object readData() { - Object readValue = null; - ICafeProcessVariable<?> pv = ProcessVariableManager.getInstance().getPv(pvName); - if(pv != null ) { - readValue = pv.getValue(); - } + Object readValue = EpicsDataSourceProducer.getValue(pvName); return readValue; } - + @Override protected void writeData(Object val) { try { ProcessVariableManager.getInstance().writeValue(pvName, val); - + } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } - + } - } diff --git a/DataBrowserPlugins/IrfuPlugin/src/main/java/fr/cea/irfu/epics/EpicsDataSourceProducer.java b/DataBrowserPlugins/IrfuPlugin/src/main/java/fr/cea/irfu/epics/EpicsDataSourceProducer.java index f8fa229abb06afc549c7ad71c44242b36ec05809..515853ec280d154f23517b25316589e3aac5da50 100644 --- a/DataBrowserPlugins/IrfuPlugin/src/main/java/fr/cea/irfu/epics/EpicsDataSourceProducer.java +++ b/DataBrowserPlugins/IrfuPlugin/src/main/java/fr/cea/irfu/epics/EpicsDataSourceProducer.java @@ -16,22 +16,27 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import fr.soleil.data.exception.UnhandledDataTypeException; +import fr.soleil.data.service.IConstantSourceProducer; import fr.soleil.data.service.IDataSourceProducer; import fr.soleil.data.service.IKey; import fr.soleil.data.source.AbstractDataSource; import heps.epics.ca.client.ProcessVariableManager; import heps.epics.ca.interfaces.DataType; +import heps.epics.ca.interfaces.ICafeArrayProcessVariable; +import heps.epics.ca.interfaces.ICafeProcessVariable; import heps.epics.ca.interfaces.ICafeProcessVariableListener; import heps.epics.ca.interfaces.IRecord; import heps.epics.ca.interfaces.ISimpleRecord; import heps.epics.ca.interfaces.IocEvent; -public class EpicsDataSourceProducer implements IDataSourceProducer, ICafeProcessVariableListener { +public class EpicsDataSourceProducer implements IDataSourceProducer, IConstantSourceProducer, ICafeProcessVariableListener { public static final String EPICS_ID = "EPICS_ID"; private static final Map<IKey, AbstractEpicsDataSource<?>> dataSourceMap = new HashMap<IKey, AbstractEpicsDataSource<?>>(); private static final Map<String, IKey> keyMap = new HashMap<>(); private static List<String> pvList = new ArrayList<>(); + private static Map<String, Object> valueMap = new HashMap<>(); @Override public AbstractDataSource<?> createDataSource(IKey arg0) { @@ -40,62 +45,70 @@ public class EpicsDataSourceProducer implements IDataSourceProducer, ICafeProces if (dataSource == null) { IKey parseKey = parseKey(arg0); if (parseKey != null) { - ISimpleRecord record = EpicsKey.getRecord(parseKey); - if (record.isBoolean()) { - dataSource = new EpicsBooleanDataSource(parseKey); + // Manage spectrum data https://drf-gitlab.cea.fr/LDISC/rdepics/-/issues/592 + org.cdma.gui.databrowser.interfaces.DataType dataType2 = EpicsKey.getDataType(arg0); + if (dataType2 == org.cdma.gui.databrowser.interfaces.DataType.SPECTRUM) {// SPECTRUM + dataSource = new EpicsDoubleArrayDataSource(parseKey); } else { - - System.out.println("createDataSource " + EpicsKey.getKeyName(parseKey)); - DataType dataType = EpicsKey.getFormat(parseKey); - System.out.println("dataType " + dataType); - switch (dataType) { - case DWORD: - case WORD: - case DOUBLE: - //dataSource = new EpicsDoubleDataSource(parseKey); - //break; - case FLOAT: - case FLOAT32: - case FLOAT32_BE: - case FLOAT32_LE: - case FLOAT64: - case FLOAT64_BE: - case FLOAT64_LE: - //dataSource = new EpicsFloatDataSource(parseKey); - //break; - - case LONG: - case INT: - case INT16: - case INT16SM: - case INT32: - case INT32_BE: - case INT32_LE: - case INT8: - case DINT: - case UINT16: - case UINT32: - case UINT8: - //dataSource = new EpicsFloatDataSource(parseKey); - //break; - - case SHORT: - //dataSource = new EpicsShortDataSource(parseKey); - dataSource = new EpicsDoubleDataSource(parseKey); - break; - - default: - dataSource = new EpicsStringDataSource(parseKey); - break; + ISimpleRecord record = EpicsKey.getRecord(parseKey); + if (record.isBoolean()) { + dataSource = new EpicsBooleanDataSource(parseKey); + } else { + + System.out.println("createDataSource " + EpicsKey.getKeyName(parseKey)); + DataType dataType = EpicsKey.getFormat(parseKey); + System.out.println("dataType " + dataType); + switch (dataType) { + case DWORD: + case WORD: + case DOUBLE: + // dataSource = new EpicsDoubleDataSource(parseKey); + // break; + case FLOAT: + case FLOAT32: + case FLOAT32_BE: + case FLOAT32_LE: + case FLOAT64: + case FLOAT64_BE: + case FLOAT64_LE: + // dataSource = new EpicsFloatDataSource(parseKey); + // break; + + case LONG: + case INT: + case INT16: + case INT16SM: + case INT32: + case INT32_BE: + case INT32_LE: + case INT8: + case DINT: + case UINT16: + case UINT32: + case UINT8: + // dataSource = new EpicsFloatDataSource(parseKey); + // break; + + case SHORT: + // dataSource = new EpicsShortDataSource(parseKey); + dataSource = new EpicsDoubleDataSource(parseKey); + break; + + default: + dataSource = new EpicsStringDataSource(parseKey); + break; + } } } + dataSourceMap.put(parseKey, dataSource); String pvName = EpicsKey.getKeyName(arg0); keyMap.put(pvName, parseKey); if (pvName != null && !pvList.contains(pvName)) { pvList.add(pvName); } - + + ProcessVariableManager.GENERATE_LOGS = false; ProcessVariableManager.getInstance().readAsynchroneValue(this, pvList); } } @@ -136,7 +149,8 @@ public class EpicsDataSourceProducer implements IDataSourceProducer, ICafeProces public boolean isSourceSettable(IKey key) { boolean settable = false; ISimpleRecord record = EpicsKey.getRecord(key); - settable = record != null && (!record.isReadOnly() || (record instanceof IRecord && ((IRecord)record).getLinkedRecord() != null)); + settable = record != null && (!record.isReadOnly() + || (record instanceof IRecord && ((IRecord) record).getLinkedRecord() != null)); return settable; } @@ -150,26 +164,87 @@ public class EpicsDataSourceProducer implements IDataSourceProducer, ICafeProces // System.out.println("key="+ muscadeKey); return epicsKey; } - + @Override public void processVariableChange(IocEvent event) { String message = event.getMessage(); - //System.out.println("processVariableChange " + message); + + Object source = event.getSource(); + //System.out.println("processVariableChange " + source); + + if(source instanceof ICafeProcessVariable) { + if (source instanceof ICafeArrayProcessVariable) { + ICafeArrayProcessVariable arrayPV = (ICafeArrayProcessVariable) source; + double[] readValue = arrayPV.getValueAsDoubleArray(); + if (readValue != null && readValue.length > 0) { + valueMap.put(message, readValue); + } + } + else { + Object readValue = ((ICafeProcessVariable<?>)source).getValue(); + valueMap.put(message, readValue); + } + } + IKey iKey = keyMap.get(message); if (iKey != null) { AbstractEpicsDataSource<?> abstractEpicsDataSource = dataSourceMap.get(iKey); - if(abstractEpicsDataSource != null) { + if (abstractEpicsDataSource != null) { abstractEpicsDataSource.refreshData(); } } } + public static Object getValue(String pvName) { + return valueMap.get(pvName); + } + public static boolean isDataSourceOpened(IKey key) { boolean opened = false; - String keyName = EpicsKey.getKeyName(key); - opened = keyName != null && keyMap.containsKey(keyName); + ISimpleRecord record = EpicsKey.getRecord(key); + String name = record != null ? record.getName() : null; + opened = name != null && keyMap.containsKey(name); return opened; - + + } + + public static void closeDataSource(IKey key) { + if (isDataSourceOpened(key)) { + ISimpleRecord record = EpicsKey.getRecord(key); + String keyName = record != null ? record.getName() : null; + if (keyName != null) { + IKey iKey = keyMap.get(keyName); + // AbstractEpicsDataSource<?> abstractEpicsDataSource = dataSourceMap.get(iKey); + dataSourceMap.remove(iKey); + pvList.remove(keyName); + keyMap.remove(keyName); + ProcessVariableManager.getInstance().deleteRecord(keyName); + } + } + } + + @Override + public AbstractDataSource<?> createDataSource(IKey arg0, boolean arg1) throws UnhandledDataTypeException { + return createDataSource( arg0); + } + + @Override + public AbstractDataSource<?> getExistingSource(IKey arg0) { + AbstractDataSource<?> datasource = null; + if (isDataSourceOpened(arg0)) { + ISimpleRecord record = EpicsKey.getRecord(arg0); + String keyName = record != null ? record.getName() : null; + if (keyName != null) { + IKey iKey = keyMap.get(keyName); + datasource = dataSourceMap.get(iKey); + } + } + return datasource; + } + + @Override + public void removeDataSource(IKey arg0) { + closeDataSource(arg0); } } diff --git a/DataBrowserPlugins/IrfuPlugin/src/main/java/fr/cea/irfu/epics/EpicsDoubleArrayDataSource.java b/DataBrowserPlugins/IrfuPlugin/src/main/java/fr/cea/irfu/epics/EpicsDoubleArrayDataSource.java new file mode 100644 index 0000000000000000000000000000000000000000..246b628a19703f49a0dd0744933d56fd66e048c6 --- /dev/null +++ b/DataBrowserPlugins/IrfuPlugin/src/main/java/fr/cea/irfu/epics/EpicsDoubleArrayDataSource.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2019 by CEA . + * The full license specifying the redistribution, modification, usage and other rights + * and obligations is included with the distribution of this project in the file "license.txt" + * + * THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND, NOT EVEN + * + * THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE + * ASSUMES NO RESPONSIBILITY FOR ANY CONSEQUENCE RESULTING FROM THE USE, + * MODIFICATION,OR REDISTRIBUTION OF THIS SOFTWARE. + ******************************************************************************/ +package fr.cea.irfu.epics; + +import fr.soleil.data.container.matrix.AbstractNumberMatrix; +import fr.soleil.data.container.matrix.DoubleMatrix; +import fr.soleil.data.service.GenericDescriptor; +import fr.soleil.data.service.IKey; + +public class EpicsDoubleArrayDataSource extends AbstractEpicsDataSource<AbstractNumberMatrix<?>> { + + private AbstractNumberMatrix<?> matrix = null; + + protected static final GenericDescriptor DEFAULT_DATA_TYPE = new GenericDescriptor(AbstractNumberMatrix.class, + new GenericDescriptor(Number.class)); + + public EpicsDoubleArrayDataSource(IKey key) { + super(key); + } + + public String getFormat() { + return "%5.2f"; + } + + @Override + public GenericDescriptor getDataType() { + return DEFAULT_DATA_TYPE; + } + + @Override + protected AbstractNumberMatrix<?> convertValue(Object value) { + + if (matrix == null) { + // TODO manage other format + matrix = new DoubleMatrix(Double.TYPE); + matrix.setName(pvName); + } + // See issue https://drf-gitlab.cea.fr/LDISC/rdepics/issues/420 + double[] fullPvValues = value instanceof double[] ? (double[]) value : null; + //System.out.println("fullPvValues =" + Arrays.toString(fullPvValues)); + if (fullPvValues != null && fullPvValues.length > 0) { + try { + matrix.setFlatValue(fullPvValues, 1, fullPvValues.length); + } catch (Exception e) { + } + } + + return matrix; + } + +} diff --git a/DataBrowserPlugins/IrfuPlugin/src/main/java/fr/cea/irfu/epics/EpicsKey.java b/DataBrowserPlugins/IrfuPlugin/src/main/java/fr/cea/irfu/epics/EpicsKey.java index 71a6f13e79184ecaea2b470ee6057d464327d927..f16037fd16d417b23906bcf73b9af8b3a1e9135a 100644 --- a/DataBrowserPlugins/IrfuPlugin/src/main/java/fr/cea/irfu/epics/EpicsKey.java +++ b/DataBrowserPlugins/IrfuPlugin/src/main/java/fr/cea/irfu/epics/EpicsKey.java @@ -13,6 +13,7 @@ package fr.cea.irfu.epics; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -21,14 +22,14 @@ import fr.soleil.data.service.IKey; import heps.epics.ca.interfaces.DataType; import heps.epics.ca.interfaces.IRecord; import heps.epics.ca.interfaces.ISimpleRecord; - +import heps.epics.ca.ioc.FieldEnumeration.RecordType; public class EpicsKey extends IrfuKey { private static final String RECORD_PROP = "record"; private static final String WRITE_KEY = "writeKey"; private static final String producerId = EpicsDataSourceProducer.EPICS_ID; - + private static final Map<String, org.cdma.gui.databrowser.interfaces.DataType> recordTypeMap = new HashMap<>(); public EpicsKey() { super(producerId); @@ -42,7 +43,7 @@ public class EpicsKey extends IrfuKey { iKey.registerProperty(HOST_PROP, host); iKey.registerProperty(NAME_PROP, deviceName); deviceMap.put(deviceName.toLowerCase(), iKey); - ((IrfuKey)iKey).setInformationKey(deviceName); + ((IrfuKey) iKey).setInformationKey(deviceName); } return iKey; } @@ -57,7 +58,7 @@ public class EpicsKey extends IrfuKey { return aparameterList; } - public static void createPvListForEpicsFile(final IKey deviceKey ,Map<String, ? extends ISimpleRecord> recordMap) { + public static void createPvListForEpicsFile(final IKey deviceKey, Map<String, ? extends ISimpleRecord> recordMap) { if (recordMap != null) { if (deviceKey.containProperty(NAME_PROP)) { Object name = deviceKey.getPropertyValue(NAME_PROP); @@ -73,17 +74,18 @@ public class EpicsKey extends IrfuKey { // Suppression des records ao ou bo qui sont linkes avec des ai bi Collection<? extends ISimpleRecord> paramList = recordMap.values(); for (ISimpleRecord param : paramList) { - createParameterKey = createParameterKey(deviceKey,param ); + createParameterKey = createParameterKey(deviceKey, param); if (!aparameterList.contains(createParameterKey)) { - boolean simpleKey = (param instanceof IRecord && ((IRecord)param).getGeneratedRecord() == null) || !(param instanceof IRecord); - + boolean simpleKey = (param instanceof IRecord && ((IRecord) param).getGeneratedRecord() == null) + || !(param instanceof IRecord); + if (param.isReadOnly() || simpleKey) { aparameterList.add(createParameterKey); } - - if(param instanceof IRecord && ((IRecord)param).getLinkedRecord() != null){ - writeKey = createParameterKey(deviceKey,((IRecord)param).getLinkedRecord()); - createParameterKey.registerProperty(WRITE_KEY,writeKey); + + if (param instanceof IRecord && ((IRecord) param).getLinkedRecord() != null) { + writeKey = createParameterKey(deviceKey, ((IRecord) param).getLinkedRecord()); + createParameterKey.registerProperty(WRITE_KEY, writeKey); } } } @@ -91,6 +93,34 @@ public class EpicsKey extends IrfuKey { } } + public static org.cdma.gui.databrowser.interfaces.DataType getDataType(final IKey key) { + org.cdma.gui.databrowser.interfaces.DataType dataType = org.cdma.gui.databrowser.interfaces.DataType.SCALAR; + // Manage spectrum format see issue + // https://drf-gitlab.cea.fr/LDISC/rdepics/-/issues/592 + ISimpleRecord record = getRecord(key); + String pvName = record != null ? record.getName() : null; + if (pvName != null && !pvName.trim().isEmpty()) { + dataType = recordTypeMap.get(pvName); + if (dataType == null) { + // Read the value + try { + // System.out.println("variableName=" + variableName); + //Can take a while and freeze the application + RecordType recordType = record.getRecordType(); + //System.out.println("recordType=" + recordType); + dataType = recordType == RecordType.waveForm ? org.cdma.gui.databrowser.interfaces.DataType.SPECTRUM : org.cdma.gui.databrowser.interfaces.DataType.SCALAR; + } catch (Exception e) { + dataType = org.cdma.gui.databrowser.interfaces.DataType.SCALAR; + } + + if(dataType != null) { + recordTypeMap.put(pvName, dataType); + } + } + } + return dataType; + } + public static String getKeyName(final IKey key) { String name = null; if (key != null && key.containProperty(NAME_PROP)) { @@ -106,7 +136,7 @@ public class EpicsKey extends IrfuKey { } return format; } - + public static ISimpleRecord getRecord(final IKey key) { ISimpleRecord rec = null; if (key != null && key.containProperty(RECORD_PROP)) { @@ -115,7 +145,6 @@ public class EpicsKey extends IrfuKey { return rec; } - public static IKey getDeviceKey(final IKey key) { IKey deviceKey = null; if (key instanceof EpicsKey) { @@ -136,12 +165,12 @@ public class EpicsKey extends IrfuKey { } return host; } - + public static IKey getSettableKey(final IKey key) { IKey settableKey = null; if (key != null) { Object setKey = key.getPropertyValue(WRITE_KEY); - settableKey = setKey instanceof IKey ? (IKey)setKey : key; + settableKey = setKey instanceof IKey ? (IKey) setKey : key; } return settableKey; } @@ -152,7 +181,7 @@ public class EpicsKey extends IrfuKey { iKey.registerProperty(NAME_PROP, record.getName()); iKey.registerProperty(FORMAT_PROP, record.getDataType()); iKey.registerProperty(RECORD_PROP, record); - ((IrfuKey)iKey).setInformationKey(record.getName()); + ((IrfuKey) iKey).setInformationKey(record.getName()); return iKey; } diff --git a/DataBrowserPlugins/IrfuPlugin/src/main/java/fr/cea/irfu/interfaces/IrfuKey.java b/DataBrowserPlugins/IrfuPlugin/src/main/java/fr/cea/irfu/interfaces/IrfuKey.java index 22b115a886f6388511d68313caa3e9a8b498748d..8318c9e7f92fe72aba4de19e3fb7a773cb46e13f 100644 --- a/DataBrowserPlugins/IrfuPlugin/src/main/java/fr/cea/irfu/interfaces/IrfuKey.java +++ b/DataBrowserPlugins/IrfuPlugin/src/main/java/fr/cea/irfu/interfaces/IrfuKey.java @@ -18,7 +18,7 @@ import java.util.Map; import fr.soleil.data.service.BasicKey; import fr.soleil.data.service.IKey; -public class IrfuKey extends BasicKey { +public class IrfuKey extends BasicKey implements Comparable<IKey> { // ProducerId private final static Map<String, Map<String, IKey>> deviceKeyMap = new HashMap<>(); @@ -83,6 +83,7 @@ public class IrfuKey extends BasicKey { @Override public String getInformationKey() { + //new Exception("getInformationKey").printStackTrace(); String informationKey = ""; // IKey deviceKey = getDeviceKey(this); String keyName = getKeyName(this); @@ -94,4 +95,12 @@ public class IrfuKey extends BasicKey { return informationKey; } + @Override + public int compareTo(IKey o) { + String tmpInformation = this.getInformationKey(); + return tmpInformation.compareTo(o.getInformationKey()); + } + + + } diff --git a/DataBrowserPlugins/IrfuPlugin/src/main/java/org/cdma/gui/databrowser/impl/epics/EpicsDataSourceBrowser.java b/DataBrowserPlugins/IrfuPlugin/src/main/java/org/cdma/gui/databrowser/impl/epics/EpicsDataSourceBrowser.java index 5414e17072c9c7c3331540083c9af4a6adcda4d9..61dd5d1e260b33c38a70d7edfa665f1d5e7fa6fc 100644 --- a/DataBrowserPlugins/IrfuPlugin/src/main/java/org/cdma/gui/databrowser/impl/epics/EpicsDataSourceBrowser.java +++ b/DataBrowserPlugins/IrfuPlugin/src/main/java/org/cdma/gui/databrowser/impl/epics/EpicsDataSourceBrowser.java @@ -96,7 +96,7 @@ public class EpicsDataSourceBrowser extends AbstractDataSourceProducerBrowser { @Override public ITreeNode createNode(IKey key) throws DataBrowserException { ITreeNode sourceNode = null; - //System.out.println("createNode=" + key); + // System.out.println("createNode=" + key); if (key instanceof EpicsKey) { List<IKey> parameterListForDevice = EpicsKey.getParameterListForDevice(key); if ((parameterListForDevice != null) && (!parameterListForDevice.isEmpty())) { @@ -107,9 +107,8 @@ public class EpicsDataSourceBrowser extends AbstractDataSourceProducerBrowser { ITreeNode parameterNode = new GroupTreeNode(); parameterNode.setName("records"); sourceNode.addNodes(parameterNode); - ITreeNode trendsNode = new GroupTreeNode(); - trendsNode.setName("trends"); - sourceNode.addNodes(trendsNode); + ITreeNode trendsNode = null; + // TODO Gestion des trends plus tard // ITreeNode trendNode = new GroupTreeNode(); // trendNode.setName("trend"); @@ -130,12 +129,20 @@ public class EpicsDataSourceBrowser extends AbstractDataSourceProducerBrowser { child.setData(paramKey); parameterNode.addNodes(child); - historicKey = new HistoryKey(paramKey); - child = new ItemTreeNode(); - child.setName(paramName + "_trend"); - child.setData(historicKey); - - trendsNode.addNodes(child); + DataType keyType = getKeyType(paramKey); + //Do not create trend for spectrum + if (keyType == DataType.SCALAR) { + historicKey = new HistoryKey(paramKey); + child = new ItemTreeNode(); + child.setName(paramName + "_trend"); + child.setData(historicKey); + if (trendsNode == null) { + trendsNode = new GroupTreeNode(); + trendsNode.setName("trends"); + sourceNode.addNodes(trendsNode); + } + trendsNode.addNodes(child); + } } } @@ -147,9 +154,9 @@ public class EpicsDataSourceBrowser extends AbstractDataSourceProducerBrowser { @Override public boolean canRead(String sourcePath) { boolean canRead = false; - if(sourcePath != null && !sourcePath.isEmpty()) { - File file =new File(sourcePath); - canRead =file.exists() && file.isFile() && file.canRead() && file.getName().toLowerCase().endsWith(".db"); + if (sourcePath != null && !sourcePath.isEmpty()) { + File file = new File(sourcePath); + canRead = file.exists() && file.isFile() && file.canRead() && file.getName().toLowerCase().endsWith(".db"); } return canRead; } @@ -225,25 +232,26 @@ public class EpicsDataSourceBrowser extends AbstractDataSourceProducerBrowser { @Override public boolean isSourceOpened(IKey sourceKey) { - // TODO Auto-generated method stub return EpicsDataSourceProducer.isDataSourceOpened(sourceKey); } @Override public void closeSource(IKey sourceKey) { - // TODO Auto-generated method stub - + // Close refreshing + EpicsDataSourceProducer.closeDataSource(sourceKey); } @Override public DataType getKeyType(IKey key) { - // TODO gerer les autres formats + // Manage waveform see https://drf-gitlab.cea.fr/LDISC/rdepics/-/issues/592 DataType dataType = DataType.SCALAR; if (key instanceof HistoryKey) { IKey history = ((HistoryKey) key).getHistory(); if (producer.isSourceCreatable(history)) { dataType = DataType.SPECTRUM; } + } else { + dataType = EpicsKey.getDataType(key); } return dataType; } @@ -282,7 +290,7 @@ public class EpicsDataSourceBrowser extends AbstractDataSourceProducerBrowser { Object propertyValue = null; for (String field : fieldKeys) { propertyValue = record.getFieldValue(field); - if(propertyValue != null) { + if (propertyValue != null) { informations.put(LABEL_FIELD + field, String.valueOf(propertyValue)); } } diff --git a/DataBrowserPlugins/IrfuPlugin/src/main/java/org/cdma/gui/databrowser/impl/epics/EpicsDataSourceSeeker.java b/DataBrowserPlugins/IrfuPlugin/src/main/java/org/cdma/gui/databrowser/impl/epics/EpicsDataSourceSeeker.java index 9202682e057b6d6e5fa631beb94e15dac1d54881..ebead991c9023a03121e3076b64b48d71a7c1e98 100644 --- a/DataBrowserPlugins/IrfuPlugin/src/main/java/org/cdma/gui/databrowser/impl/epics/EpicsDataSourceSeeker.java +++ b/DataBrowserPlugins/IrfuPlugin/src/main/java/org/cdma/gui/databrowser/impl/epics/EpicsDataSourceSeeker.java @@ -102,7 +102,7 @@ public class EpicsDataSourceSeeker extends AbstractFileDataSourceSeeker { // Creation d'une cle parent avec le host String text = hostField.getText(); - String host = text != null && !text.isEmpty() ? text : LOCAL_HOST; + String host = text != null && !text.isEmpty() ? text.trim() : LOCAL_HOST; File selectedFile = getFileChooser().getSelectedFile(); if (acceptFile(selectedFile)) { @@ -136,11 +136,11 @@ public class EpicsDataSourceSeeker extends AbstractFileDataSourceSeeker { String userSourceName = null; Map<String, ISimpleRecord> recordMap = null; for (String recordname : split) { - if (!foundPV(recordname)) { - recordForName = PlcParserApi.getRecordForName(recordname); + if (!foundPV(recordname.trim())) { + recordForName = PlcParserApi.getRecordForName(recordname.trim()); if (recordForName == null) { ProcessVariableManager.getInstance(host);//Init cacontext with host - ISimpleRecord createRecord = ProcessVariableManager.getInstance().createRecord(recordname); + ISimpleRecord createRecord = ProcessVariableManager.getInstance().createRecord(recordname.trim()); if(createRecord != null) { if (userSourceKey == null) { userSourceName = USER_PVLIST + lastIndex;