Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added variable time psuedo sensor device

This is variable time is how the dataharvest sensors work,
and we might need to start using that technique for other sensors
in order to correctly represent the real time the data is collected.

git-svn-id: https://svn.concord.org/svn/projects/trunk/common/java/sensor/sensor@25487 6e01202a-0783-4428-890a-84243c50cc2b
  • Loading branch information...
commit eb4d5c6df0746d567cfbb48dd483172f434916e3 1 parent 1809430
scytacki authored
1  src/main/java/org/concord/sensor/device/impl/DeviceID.java
@@ -27,6 +27,7 @@
27 27 public interface DeviceID
28 28 {
29 29 public final static int PSEUDO_DEVICE = 0;
  30 + public final static int PSEUDO_DEVICE_VARIABLE_TIME = 1;
30 31 public final static int VERNIER_GO_LINK = 10;
31 32 public final static int VERNIER_LAB_PRO = 11;
32 33 public final static int VERNIER_LAB_QUEST = 12;
1  src/main/java/org/concord/sensor/device/impl/JavaDeviceFactory.java
@@ -112,6 +112,7 @@ public SensorDevice createDevice(DeviceConfig config)
112 112
113 113 switch(id) {
114 114 case PSEUDO_DEVICE:
  115 + case PSEUDO_DEVICE_VARIABLE_TIME:
115 116 className = "org.concord.sensor.pseudo.PseudoSensorDevice";
116 117 break;
117 118 case VERNIER_GO_LINK:
20 src/main/java/org/concord/sensor/pseudo/PseudoSensorDevice.java
@@ -34,6 +34,7 @@
34 34 import org.concord.sensor.device.DeviceIdAware;
35 35 import org.concord.sensor.device.DeviceReader;
36 36 import org.concord.sensor.device.impl.AbstractSensorDevice;
  37 +import org.concord.sensor.device.impl.DeviceID;
37 38 import org.concord.sensor.device.impl.SerialPortParams;
38 39 import org.concord.sensor.impl.ExperimentConfigImpl;
39 40 import org.concord.sensor.impl.Range;
@@ -72,6 +73,11 @@ public void open(String openString)
72 73 // we have no real sensors so we dont' need to open anything
73 74 }
74 75
  76 + protected boolean hasVariableTime()
  77 + {
  78 + return deviceId == DeviceID.PSEUDO_DEVICE_VARIABLE_TIME;
  79 + }
  80 +
75 81 /* (non-Javadoc)
76 82 * @see org.concord.sensor.device.SensorDevice#configure(org.concord.sensor.ExperimentRequest)
77 83 */
@@ -82,7 +88,11 @@ public ExperimentConfig configure(ExperimentRequest request)
82 88 currentConfig = new ExperimentConfigImpl();
83 89 currentConfig.setValid(true);
84 90 currentConfig.setDeviceName("Psuedo Device");
85   - currentConfig.setExactPeriod(true);
  91 + if(hasVariableTime()){
  92 + currentConfig.setExactPeriod(false);
  93 + } else {
  94 + currentConfig.setExactPeriod(true);
  95 + }
86 96 currentConfig.setPeriod(0.1f);
87 97 currentConfig.setDataReadPeriod(0.1f);
88 98
@@ -128,6 +138,14 @@ public int read(float[] values, int offset, int nextSampleOffset,
128 138 // was X but we are only return a single value every time, so if the
129 139 // read takes longer than X then we will be behind. But for testing
130 140 // purposes this should be ok
  141 + if(hasVariableTime()){
  142 + // we pass our 'precise' time here, this will make testing repeatable
  143 + // however that might trigger some bug situations so feel free to make this
  144 + // less precise as long at it is repeatable, perhaps with some fixed variations
  145 + // off of the precise value
  146 + values[offset++] = time;
  147 + }
  148 +
131 149 for(int i=0; i<sensConfigs.length; i++) {
132 150 float sinOffset = sensConfigs[i].getSinOffset();
133 151 float sinMagnitude = sensConfigs[i].getSinMagnitude();

0 comments on commit eb4d5c6

Please sign in to comment.
Something went wrong with that request. Please try again.