Skip to content
Snippets Groups Projects
Commit 56806a63 authored by Katy Saintin's avatar Katy Saintin
Browse files

cea : Update plugin for waveform management in Appliance

parent 07091515
Branches
Tags
No related merge requests found
......@@ -18,7 +18,7 @@
<dependency>
<groupId>heps.epics</groupId>
<artifactId>moonarch-appliance</artifactId>
<version>0.0.1</version>
<version>0.0.2-SNAPSHOT</version>
</dependency>
<dependency>
......
......@@ -37,8 +37,13 @@ public class MoonArchKey extends IrfuKey {
private static final String SAMPLING_ATTRIBUTE = "samplingPeriodInMs";
private static final String FACTOR_ATTRIBUTE = "samplingFactor";
private static final String NBEVENTS_ATTRIBUTE = "numberMaxOfEvents";
private static final String TYPE_PROP = "DataType";
private static final String INDEX_PROP = "INDEX";
private static final Map<String, IPVData> pvDataMap = new HashMap<>();
//For waveform
private static final Map<String, Integer> currentIndexMap = new HashMap<>();
// private static final String INFO = "Informations";
public MoonArchKey() {
......@@ -48,6 +53,7 @@ public class MoonArchKey extends IrfuKey {
public static IKey createKey(String filePath, Date startDate, Date endDate, int factor, long samplingPeriodInMs,
long nbEventMax) {
MoonArchKey moonArchKey = new MoonArchKey();
moonArchKey.clone();
registerFileProperty(moonArchKey, filePath);
moonArchKey.registerProperty(FACTOR_ATTRIBUTE, factor);
moonArchKey.registerProperty(SAMPLING_ATTRIBUTE, samplingPeriodInMs);
......@@ -91,6 +97,23 @@ public class MoonArchKey extends IrfuKey {
}
}
public static void createIndexKey(final IKey key,int index) {
String pvName = getPVName(key);
if(pvName != null) {
currentIndexMap.put(pvName, index);
}
}
public static int getIndexKey(final IKey key) {
int indexKey = 0;
String pvName = getPVName(key);
if(pvName != null) {
Integer integer = currentIndexMap.get(pvName);
indexKey = integer != null ? integer : 0;
}
return indexKey;
}
public static IKey createKey(String filePath) {
return createKey(filePath, null, null, 0, 0, 0);
}
......@@ -133,37 +156,49 @@ public class MoonArchKey extends IrfuKey {
String pvName = pvData.getPVName();
timeKey = new MoonArchKey();
alarmKey = new MoonArchKey();
alarmTimeKey = new MoonArchKey();
copySamplingParameter(key, timeKey);
copySamplingParameter(key, alarmKey);
copySamplingParameter(key, alarmTimeKey);
key.registerProperty(FILE_PATH, filePath);
timeKey.registerProperty(FILE_PATH, filePath);
alarmKey.registerProperty(FILE_PATH, filePath);
alarmTimeKey.registerProperty(FILE_PATH, filePath);
key.registerProperty(PV_NAME, pvName);
timeKey.registerProperty(PV_NAME, pvName);
alarmKey.registerProperty(PV_NAME, pvName);
alarmTimeKey.registerProperty(PV_NAME, pvName);
key.registerProperty(PV_DATA, pvData);
timeKey.registerProperty(PV_DATA, pvData);
alarmKey.registerProperty(PV_DATA, pvData);
alarmTimeKey.registerProperty(PV_DATA, pvData);
timeKey.registerProperty(TMS_DATA, true);
key.registerProperty(TMS_KEY, timeKey);
org.cdma.gui.databrowser.interfaces.DataType dataType = org.cdma.gui.databrowser.interfaces.DataType.SPECTRUM;
//Manage Alarm key only if its not a waveform
if(! pvData.isWaveForm()) {
alarmKey = new MoonArchKey();
alarmTimeKey = new MoonArchKey();
copySamplingParameter(key, alarmKey);
copySamplingParameter(key, alarmTimeKey);
alarmKey.registerProperty(FILE_PATH, filePath);
alarmTimeKey.registerProperty(FILE_PATH, filePath);
alarmKey.registerProperty(PV_NAME, pvName);
alarmTimeKey.registerProperty(PV_NAME, pvName);
alarmKey.registerProperty(PV_DATA, pvData);
alarmTimeKey.registerProperty(PV_DATA, pvData);
alarmKey.registerProperty(ALARM_DATA, true);
alarmTimeKey.registerProperty(ALARM_DATA, true);
alarmTimeKey.registerProperty(TMS_DATA, true);
alarmKey.registerProperty(TYPE_PROP, dataType);
alarmTimeKey.registerProperty(TYPE_PROP, dataType);
alarmKey.registerProperty(TMS_KEY, alarmTimeKey);
key.registerProperty(TMS_KEY, timeKey);
key.registerProperty(ALARM_KEY, alarmKey);
}
key.registerProperty(TYPE_PROP, dataType);
timeKey.registerProperty(TYPE_PROP, dataType);
}
}
public static String getFilePath(final IKey key) {
......
......@@ -17,6 +17,8 @@ import java.util.Map;
import fr.soleil.data.service.IDataSourceProducer;
import fr.soleil.data.service.IKey;
import fr.soleil.data.source.AbstractDataSource;
import heps.epics.moonarch.interfaces.IMOONEvent;
import heps.epics.moonarch.interfaces.IPVData;
public class MoonarchDataSourceProducer implements IDataSourceProducer {
......@@ -46,13 +48,23 @@ public class MoonarchDataSourceProducer implements IDataSourceProducer {
@Override
public int getRank(IKey arg0) {
// TODO Auto-generated method stub
return 0;
IPVData pvData = MoonArchKey.getPVData(arg0);
IMOONEvent firstEvent = pvData != null ? pvData.getFirstEvent() : null;
int rank = firstEvent != null && firstEvent.isWaveForm() ? 2 : 1;
return rank;
}
@Override
public int[] getShape(IKey arg0) {
// TODO Auto-generated method stub
return new int[0];
int[] shape = new int[0];
IPVData pvData = MoonArchKey.getPVData(arg0);
long numberOfEvents = pvData != null ? pvData.getNumberOfEvents() : 0;
IMOONEvent firstEvent = pvData != null ? pvData.getFirstEvent() : null;
if(firstEvent != null && firstEvent.isWaveForm()) {
double[] waveformValuesAtIndex = pvData.getWaveformValuesAtIndex(0);
shape = new int[] {(int)numberOfEvents, waveformValuesAtIndex.length};
}
return shape;
}
@Override
......
......@@ -19,6 +19,7 @@ import fr.soleil.data.container.matrix.LongMatrix;
import fr.soleil.data.service.GenericDescriptor;
import fr.soleil.data.service.IKey;
import fr.soleil.data.source.AbstractDataSource;
import heps.epics.moonarch.interfaces.IMOONEvent;
import heps.epics.moonarch.interfaces.IPVData;
public class MoonarchDoubleArrayDataSource extends AbstractDataSource<AbstractNumberMatrix<?>> {
......@@ -33,12 +34,19 @@ public class MoonarchDoubleArrayDataSource extends AbstractDataSource<AbstractNu
private int factor = 0;
private long samplingPeriod = 0;
private long nbEventsMax = 0;
private IKey currentKey = null;
boolean isAlarmKey = false;
boolean isWaveform = false;
private AbstractNumberMatrix<?> matrix = null;
private int currentIndex = 0;
public MoonarchDoubleArrayDataSource(IKey key) {
super(key);
currentKey = key;
pvData = MoonArchKey.getPVData(key);
currentIndex = MoonArchKey.getIndexKey(key);
IMOONEvent firstEvent = pvData.getFirstEvent();
isWaveform = firstEvent != null && firstEvent.isWaveForm();
isTimeKey = MoonArchKey.isTimeKey(key);
startDate = MoonArchKey.getStartDate(key);
endDate = MoonArchKey.getEndDate(key);
......@@ -59,22 +67,31 @@ public class MoonarchDoubleArrayDataSource extends AbstractDataSource<AbstractNu
@Override
public AbstractNumberMatrix<?> getData() throws Exception {
if (pvData != null && matrix == null) {
int index = MoonArchKey.getIndexKey(currentKey);
if (pvData != null && (matrix == null || currentIndex != index)) {
currentIndex = index;
matrix = isTimeKey ? new LongMatrix(Long.TYPE) : new DoubleMatrix(Double.TYPE);
// Always call pvValues to get startDate and endDate
// See issue https://drf-gitlab.cea.fr/LDISC/rdepics/issues/420
double[] fullPvValues = pvData.getPVValues(startDate, endDate, factor, samplingPeriod, nbEventsMax);
double[] fullPvValues = null;
if (isWaveform) {
fullPvValues = pvData.getWaveformValuesAtIndex(currentIndex);
} else {
fullPvValues = pvData.getPVValues(startDate, endDate, factor, samplingPeriod, nbEventsMax);
}
Object flatValues = null;
int size = 0;
if (isTimeKey) {
long[] pvTimeStamp = isAlarmKey ? pvData.getPVAlarmTimeStamp() : pvData.getPVTimeStamp();
long[] pvTimeStamp = isAlarmKey && !isWaveform ? pvData.getPVAlarmTimeStamp() : pvData.getPVTimeStamp();
size = pvTimeStamp.length;
flatValues = pvTimeStamp;
} else {
double[] pvValues = isAlarmKey ? pvData.getPVAlarmValues() : fullPvValues;
double[] pvValues = isAlarmKey && !isWaveform ? pvData.getPVAlarmValues() : fullPvValues;
size = pvValues.length;
flatValues = pvValues;
}
String pvName = pvData.getPVName();
if (isAlarmKey) {
pvName = "_Alarm";
......
......@@ -8,6 +8,7 @@
package org.cdma.gui.databrowser.impl.moonarch;
import java.io.File;
import java.util.Arrays;
import java.util.Date;
import java.util.Map;
import java.util.Set;
......@@ -84,8 +85,7 @@ public class MoonarchDataSourceBrowser extends AbstractDataSourceProducerBrowser
@Override
public IKey createKeyFromSource(String sourcePath) {
// TODO Auto-generated method stub
return null;
return MoonArchKey.createKey(sourcePath);
}
@Override
......@@ -143,6 +143,8 @@ public class MoonarchDataSourceBrowser extends AbstractDataSourceProducerBrowser
@Override
public IKey generateRegionKey(IKey key, int[] shape, int[] origine) {
int index = origine != null && origine.length > 0 ? origine[0] : 0;
MoonArchKey.createIndexKey(key, index);
return key;
}
......@@ -212,6 +214,14 @@ public class MoonarchDataSourceBrowser extends AbstractDataSourceProducerBrowser
informations.put(PV_INFO + string, key.getPropertyValue(string).toString());
}
}
//Display shape and format
int[] shape = getShape(key);
if(shape != null && shape.length > 0) {
informations.put(LABEL_INFO + "Size", Arrays.toString(shape));
}
return informations;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment