Skip to content

Commit

Permalink
Fix for issue #8 raised by Woodz "The copy constructor at CwaBlock.ja…
Browse files Browse the repository at this point in the history
…va#L130 is incorrect as it only copies some of the fields. The temperature, battery, light, events and number of samples are left as the default 0 value".
  • Loading branch information
danielgjackson committed Mar 24, 2015
1 parent c266139 commit 2513b47
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions Software/AX3/cwa-convert/java/src/newcastle/cwa/CwaBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,28 @@ public class CwaBlock implements Cloneable {
byteBuffer = ByteBuffer.wrap(source.byteBuffer.array().clone());
bufferValid = source.bufferValid;
dataBlockOk = source.dataBlockOk;
sampleValues = source.sampleValues.clone();
sampleTimes = source.sampleTimes.clone();
deviceId = source.deviceId;
sessionId = source.sessionId;
deviceId = source.deviceId;
light = source.light;
temp = source.temp;
batt = source.batt;
events = source.events;
sampleCount = source.sampleCount;
sampleTimes = source.sampleTimes.clone();
sampleValues = source.sampleValues.clone();
} else {
byteBuffer = ByteBuffer.wrap(new byte[BLOCK_SIZE]);
bufferValid = false;
dataBlockOk = false;
sampleValues = new short[0];
sampleTimes = new long[0];
deviceId = -1;
sessionId = -1;
deviceId = -1;
light = -1;
temp = -1;
batt = -1;
events = 0;
sampleCount = 0;
sampleTimes = new long[0];
sampleValues = new short[0];
}
byteBuffer.order(ByteOrder.LITTLE_ENDIAN); // All little endian values

Expand Down

0 comments on commit 2513b47

Please sign in to comment.