improved cdump
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<dependency>
|
||||
<groupId>ch.psi</groupId>
|
||||
<artifactId>ch.psi.fda.core</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<version>0.0.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -74,7 +74,7 @@ public class CdumpListener implements PropertyChangeListener {
|
||||
int nelements = value.length;
|
||||
int n = nelements % numberOfElements;
|
||||
if (n != 0) {
|
||||
throw new RuntimeException("Array size is not a multiple of 65536");
|
||||
throw new RuntimeException("Array size is not a multiple of "+numberOfElements);
|
||||
}
|
||||
numberOfWaveforms = nelements / numberOfElements;
|
||||
for(int i=0;i<numberOfWaveforms;i++){
|
||||
@@ -90,7 +90,6 @@ public class CdumpListener implements PropertyChangeListener {
|
||||
for (int t = 0; t < numberOfWaveforms; t++) {
|
||||
m.getData().add(value[x + t * numberOfElements]);
|
||||
}
|
||||
|
||||
bus.post(m);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.google.common.eventbus.AsyncEventBus;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
import ch.psi.fda.messages.DataMessage;
|
||||
import ch.psi.fda.serializer.SerializerTXT;
|
||||
import ch.psi.jcae.ChannelService;
|
||||
import ch.psi.jcae.impl.DefaultChannelService;
|
||||
@@ -78,6 +80,12 @@ public class CdumpMain {
|
||||
serializer.setShowDimensionHeader(false);
|
||||
|
||||
eventbus.register(serializer);
|
||||
eventbus.register(new Object(){
|
||||
@Subscribe
|
||||
public void test(DataMessage m){
|
||||
System.out.println(m);
|
||||
}
|
||||
});
|
||||
|
||||
// Stop/abort handling of acquisition
|
||||
Signal.handle(new Signal("INT"), new SignalHandler() {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package ch.psi.fda.cdump.model;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import ch.psi.fda.edescriptor.EDescriptor;
|
||||
|
||||
@XmlRootElement(name="cdump")
|
||||
public class CdumpParameters implements EDescriptor {
|
||||
|
||||
private String name;
|
||||
private String samplingRate;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getSamplingRate() {
|
||||
return samplingRate;
|
||||
}
|
||||
public void setSamplingRate(String samplingRate) {
|
||||
this.samplingRate = samplingRate;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
*
|
||||
* Copyright 2011 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.cdump;
|
||||
|
||||
import gov.aps.jca.cas.ProcessVariable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import ch.psi.jcae.cas.CaServer;
|
||||
import ch.psi.jcae.cas.ProcessVariableInt;
|
||||
import ch.psi.jcae.cas.ProcessVariableIntWaveform;
|
||||
|
||||
public class CdumpTestIOC {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(CdumpTestIOC.class.getName());
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
List<ProcessVariable> processVariables = new ArrayList<ProcessVariable>();
|
||||
|
||||
// Data channel
|
||||
ProcessVariableIntWaveform pv = new ProcessVariableIntWaveform("CDUMP:WAVE", null, 8);
|
||||
processVariables.add(pv);
|
||||
|
||||
// This PV has the states READY (0) and GO (1)
|
||||
ProcessVariableInt pvControl = new ProcessVariableInt("CDUMP:CONTROL", null);
|
||||
processVariables.add(pvControl);
|
||||
|
||||
// Sampling rate channel
|
||||
//{"1Hz","2Hz", "5Hz", "10Hz", "20Hz", "50Hz", "100Hz", "200Hz", "500Hz", "1kHz", "2kHz", "5kHz", "10kHz", "20kHz", "50kHz", "100kHz"};
|
||||
ProcessVariableInt pvSamplingRate = new ProcessVariableInt("CDUMP:SAMPLING", null);
|
||||
processVariables.add(pvSamplingRate);
|
||||
|
||||
|
||||
CaServer s = new CaServer(processVariables);
|
||||
s.startAsDaemon();
|
||||
|
||||
Deque<int[]> deque = new LinkedList<int[]>();
|
||||
deque.push(new int[] { 1, 2, 3, 4, 11, 12, 13, 14 });
|
||||
deque.push(new int[] { 5, 6, 7, 8, 15, 16, 17, 18 });
|
||||
|
||||
while (true) {
|
||||
if (pvControl.getValue() == 1) { // if control channel is on GO
|
||||
int[] v = deque.pollFirst();
|
||||
logger.finest(Arrays.toString(v));
|
||||
pv.setValue(v);
|
||||
|
||||
deque.addLast(v);
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
4
ch.psi.fda.cdump/src/test/resources/cdump.properties
Normal file
4
ch.psi.fda.cdump/src/test/resources/cdump.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
ch.psi.fda.cdump.dataChannel=CDUMP:WAVE
|
||||
ch.psi.fda.cdump.controlChannel=CDUMP:CONTROL
|
||||
ch.psi.fda.cdump.samplingRateChannel=CDUMP:SAMPLING
|
||||
ch.psi.fda.cdump.nelements=4
|
||||
Reference in New Issue
Block a user