Skip to content

Commit 73aceda

Browse files
committed
Consensys v1.5.4 build
1 parent 528a778 commit 73aceda

37 files changed

Lines changed: 1746 additions & 735 deletions
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
build.commands=org.eclipse.jdt.core.javabuilder
2-
connection.arguments=
3-
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
4-
connection.java.home=null
5-
connection.jvm.arguments=
6-
connection.project.dir=../ShimmerPCBasicExamples
7-
derived.resources=.gradle,build
8-
eclipse.preferences.version=1
9-
natures=org.eclipse.jdt.core.javanature
10-
project.path=\:ShimmerBluetoothManager
1+
build.commands=org.eclipse.jdt.core.javabuilder
2+
connection.arguments=
3+
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
4+
connection.java.home=null
5+
connection.jvm.arguments=
6+
connection.project.dir=../../Shimmer-Advance-API/ShimmerPCExamples
7+
derived.resources=.gradle,build
8+
eclipse.preferences.version=1
9+
natures=org.eclipse.jdt.core.javanature
10+
project.path=\:ShimmerBluetoothManager

ShimmerBluetoothManager/src/main/java/com/shimmerresearch/managers/bluetoothManager/ShimmerBluetoothManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ else if(deviceTypeDetected==DEVICE_TYPE.SWEATCH){
847847

848848
if(shimmerDevice!=null){
849849
if(shimmerVerObject!=null){
850-
shimmerDevice.setShimmerVersionInfoAndCreateSensorMap(shimmerVerObject);
850+
shimmerDevice.setShimmerVersionObjectAndCreateSensorMap(shimmerVerObject);
851851
}
852852
if(expansionBoardDetails!=null){
853853
shimmerDevice.setExpansionBoardDetailsAndCreateSensorMap(expansionBoardDetails);
@@ -915,7 +915,7 @@ else if(sVO.isSweatchDevice()){
915915
if(shimmerDeviceNew!=null){
916916
shimmerDeviceNew.setComPort(comPort);
917917
shimmerDeviceNew.setMacIdFromUart(bluetoothAddress);
918-
shimmerDeviceNew.setShimmerVersionInfoAndCreateSensorMap(sVO);
918+
shimmerDeviceNew.setShimmerVersionObjectAndCreateSensorMap(sVO);
919919

920920
//Temporarily added, not needed at the moment so commenting out
921921
// ExpansionBoardDetails expBrdDetails = shimmerRadioInitializer.readExpansionBoardID();

ShimmerBluetoothManager/src/main/java/com/shimmerresearch/thirdpartyDevices/noninOnyxII/NoninOnyxIIDevice.java

Lines changed: 31 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import com.shimmerresearch.sensors.AbstractSensor.SENSORS;
2929
import com.shimmerresearch.sensors.AbstractSensor;
3030
import com.shimmerresearch.sensors.SensorSystemTimeStamp;
31-
import com.shimmerresearch.sensors.ShimmerClock;
31+
import com.shimmerresearch.sensors.SensorShimmerClock;
3232

3333
//https://www.numed.co.uk/files/uploads/Product/Nonin%209560%20Bluetooth%20Specification.pdf
3434
public class NoninOnyxIIDevice extends ShimmerDevice implements SerialPortListener{
@@ -65,7 +65,7 @@ public void setDefaultShimmerConfiguration() {
6565
setMacIdFromUart(mUniqueID);
6666
setShimmerUserAssignedNameWithMac("Nonin");
6767

68-
setShimmerVersionInfoAndCreateSensorMap(SVO);
68+
setShimmerVersionObjectAndCreateSensorMap(SVO);
6969
}
7070

7171
@Override
@@ -232,49 +232,19 @@ protected void processMsgFromCallback(ShimmerMsg shimmerMSG) {
232232
* Shimmer Device Overrides end
233233
* ******************************************/
234234

235-
//TODO neaten below. Copy/Paste from Shimmer4
236235
protected void dataHandler(ObjectCluster ojc) {
237-
// sendCallBackMsg(ShimmerBluetooth.MSG_IDENTIFIER_DATA_PACKET, ojc);
238236
mDeviceCallbackAdapter.dataHandler(ojc);
239237
}
240238

241-
//TODO neaten below. Copy/Paste from ShimmerBluetooth
242239
@Override
243240
public boolean setBluetoothRadioState(BT_STATE state) {
244-
boolean changed = super.setBluetoothRadioState(state);
245-
mDeviceCallbackAdapter.setBluetoothRadioState(state);
246-
247-
// if(mBluetoothRadioState==BT_STATE.CONNECTED){
248-
// setIsConnected(true);
249-
// setIsInitialised(true);
250-
// setIsStreaming(false);
251-
// }
252-
// else if(mBluetoothRadioState==BT_STATE.STREAMING){
253-
// setIsStreaming(true);
254-
// }
255-
// else if((mBluetoothRadioState==BT_STATE.DISCONNECTED)
256-
// ||(mBluetoothRadioState==BT_STATE.CONNECTION_LOST)
257-
// ||(mBluetoothRadioState==BT_STATE.CONNECTION_FAILED)){
258-
// setIsConnected(false);
259-
// setIsStreaming(false);
260-
// setIsInitialised(false);
261-
// }
262-
//
263-
// CallbackObject callBackObject = new CallbackObject(ShimmerBluetooth.NOTIFICATION_SHIMMER_STATE_CHANGE, state, getMacIdFromUart(), getComPort());
264-
// sendCallBackMsg(ShimmerBluetooth.MSG_IDENTIFIER_STATE_CHANGE, callBackObject);
265-
return changed;
241+
boolean isChanged = super.setBluetoothRadioState(state);
242+
mDeviceCallbackAdapter.setBluetoothRadioState(state, isChanged);
243+
return isChanged;
266244
}
267245

268-
//TODO neaten below. Copy/Paste from Shimmer4
269246
public void isReadyForStreaming(){
270247
mDeviceCallbackAdapter.isReadyForStreaming();
271-
// setIsInitialised(true);
272-
//
273-
// CallbackObject callBackObject = new CallbackObject(ShimmerBluetooth.NOTIFICATION_SHIMMER_FULLY_INITIALIZED, getMacIdFromUart(), getComPort());
274-
// sendCallBackMsg(ShimmerBluetooth.MSG_IDENTIFIER_NOTIFICATION_MESSAGE, callBackObject);
275-
// if (getBluetoothRadioState()==BT_STATE.CONNECTING){
276-
// setBluetoothRadioState(BT_STATE.CONNECTED);
277-
// }
278248
}
279249

280250
//TODO neaten below. Copy/Paste from Shimmer4
@@ -302,30 +272,33 @@ public void eventConnected() {
302272
}
303273

304274
@Override
305-
public void calculatePacketReceptionRateCurrent(int timeDifference) {
306-
setPacketReceptionRateCurrent(calculatePacketLossCurrent(timeDifference, getSamplingRateShimmer()));
307-
CallbackObject callBackObject = new CallbackObject(ShimmerBluetooth.MSG_IDENTIFIER_PACKET_RECEPTION_RATE_CURRENT, getMacId(), getComPort(), getPacketReceptionRateCurrent());
308-
sendCallBackMsg(ShimmerBluetooth.MSG_IDENTIFIER_PACKET_RECEPTION_RATE_CURRENT, callBackObject);
309-
resetPacketReceptionCurrentCounters();
310-
}
311-
312-
//TODO neaten below. Copy/Paste from ShimmerGQ
313-
public double calculatePacketLossCurrent(long timeDifference, double samplingRate){
314-
mPacketExpectedCountCurrent = (long) ((double)((timeDifference/1000)*samplingRate));
315-
return calculatePacketLossCurrent(mPacketExpectedCountCurrent, mPacketReceivedCountCurrent);
316-
}
317-
318-
//TODO neaten below. Copy/Paste from ShimmerGQ
319-
public double calculatePacketLossCurrent(){
320-
return calculatePacketLossCurrent(mPacketExpectedCountCurrent, mPacketReceivedCountCurrent);
275+
public void calculatePacketReceptionRateCurrent(int intervalMs) {
276+
super.calculatePacketReceptionRateCurrent(intervalMs);
277+
mDeviceCallbackAdapter.sendCallbackPacketReceptionRateCurrent();
278+
279+
// setPacketReceptionRateCurrent(calculatePacketLossCurrent(intervalMs, getSamplingRateShimmer()));
280+
// CallbackObject callBackObject = new CallbackObject(ShimmerBluetooth.MSG_IDENTIFIER_PACKET_RECEPTION_RATE_CURRENT, getMacId(), getComPort(), getPacketReceptionRateCurrent());
281+
// sendCallBackMsg(ShimmerBluetooth.MSG_IDENTIFIER_PACKET_RECEPTION_RATE_CURRENT, callBackObject);
282+
// resetPacketReceptionCurrentCounters();
321283
}
322284

323-
//TODO neaten below. Copy/Paste from ShimmerGQ
324-
private double calculatePacketLossCurrent(long packetExpectedCount, long packetReceivedCount){
325-
setPacketReceptionRateCurrent((double)((packetReceivedCount)/(double)packetExpectedCount)*100);
326-
//TODO 2016-09-06 remove below because if it is going to be implemented it should be in the method setPacketReceptionRateCurrent()?
327-
setPacketReceptionRateCurrent(UtilShimmer.nudgeDouble(getPacketReceptionRateCurrent(), 0.0, 100.0));
328-
return getPacketReceptionRateCurrent();
329-
}
285+
// //TODO neaten below. Copy/Paste from ShimmerGQ
286+
// public double calculatePacketLossCurrent(long timeDifference, double samplingRate){
287+
// mPacketExpectedCountCurrent = (long) ((double)((timeDifference/1000)*samplingRate));
288+
// return calculatePacketLossCurrent(mPacketExpectedCountCurrent, mPacketReceivedCountCurrent);
289+
// }
290+
//
291+
// //TODO neaten below. Copy/Paste from ShimmerGQ
292+
// public double calculatePacketLossCurrent(){
293+
// return calculatePacketLossCurrent(mPacketExpectedCountCurrent, mPacketReceivedCountCurrent);
294+
// }
295+
//
296+
// //TODO neaten below. Copy/Paste from ShimmerGQ
297+
// private double calculatePacketLossCurrent(long packetExpectedCount, long packetReceivedCount){
298+
// setPacketReceptionRateCurrent((double)((packetReceivedCount)/(double)packetExpectedCount)*100);
299+
// //TODO 2016-09-06 remove below because if it is going to be implemented it should be in the method setPacketReceptionRateCurrent()?
300+
// setPacketReceptionRateCurrent(UtilShimmer.nudgeDouble(getPacketReceptionRateCurrent(), 0.0, 100.0));
301+
// return getPacketReceptionRateCurrent();
302+
// }
330303

331304
}

ShimmerDriver/.settings/org.eclipse.buildship.core.prefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ connection.arguments=
33
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
44
connection.java.home=null
55
connection.jvm.arguments=
6-
connection.project.dir=../../ConsensysApps/OtherConsensysApps
6+
connection.project.dir=../../Shimmer-Advance-API/ShimmerPCExamples
77
derived.resources=.gradle,build
88
eclipse.preferences.version=1
99
natures=org.eclipse.jdt.core.javanature

ShimmerDriver/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ dependencies {
232232
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
233233
testCompile group: 'junit', name: 'junit', version: '4.+'
234234
// https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java
235-
compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.3.0'
235+
compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.4.0'
236236

237237
//compile 'io.grpc:grpc-all:0.14.0'
238238
// https://mvnrepository.com/artifact/io.grpc/grpc-all
@@ -244,8 +244,8 @@ dependencies {
244244
compile group: 'joda-time', name: 'joda-time', version: '2.9.4'
245245
// https://mvnrepository.com/artifact/com.github.wendykierp/JTransforms
246246
compile group: 'com.github.wendykierp', name: 'JTransforms', version: '3.1'
247-
// https://mvnrepository.com/artifact/com.google.protobuf/protobuf-lite
248-
compile group: 'com.google.protobuf', name: 'protobuf-lite', version: '3.0.1'
247+
// // https://mvnrepository.com/artifact/com.google.protobuf/protobuf-lite
248+
// compile group: 'com.google.protobuf', name: 'protobuf-lite', version: '3.0.1'
249249

250250

251251
// The production code uses the SLF4J logging API at compile time

ShimmerDriver/src/main/java/com/shimmerresearch/algorithms/AbstractAlgorithm.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ public HashMap<String, Object> getAlgorithmSettings() {
490490
for(String configOptionKey:mConfigOptionsMap.keySet()){
491491
Object configValue = getSettings(configOptionKey);
492492
if(configValue!=null){
493-
consolePrintLn("getEnabledAlgorithmSettings\t" + configOptionKey);
493+
consolePrintLn("getEnabledAlgorithmSettings\t" + "\tConfigKey=" + configOptionKey + "\tConfigValue=" + configValue);
494494
mapOfAlgorithmSettings.put(configOptionKey, configValue);
495495
}
496496
}

ShimmerDriver/src/main/java/com/shimmerresearch/algorithms/AlgorithmDetails.java

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22

33
import java.io.Serializable;
44
import java.util.Arrays;
5+
import java.util.LinkedHashMap;
56
import java.util.List;
7+
import java.util.Map;
8+
import java.util.Map.Entry;
69
import java.util.ArrayList;
710

11+
import com.shimmerresearch.driver.ShimmerDevice;
812
import com.shimmerresearch.driverUtilities.ChannelDetails;
913
import com.shimmerresearch.driverUtilities.ChannelDetails.CHANNEL_TYPE;
14+
import com.shimmerresearch.driverUtilities.SensorDetails;
1015

1116
//TODO merge/replace with SensorDetails?
1217
public class AlgorithmDetails implements Serializable {
@@ -24,7 +29,7 @@ public class AlgorithmDetails implements Serializable {
2429
public long mDerivedSensorBitmapID = 0;
2530

2631
public List<Integer> mListOfRequiredSensors = new ArrayList<Integer>();
27-
public List<String> mListOfAssociatedSensors = new ArrayList<String>();
32+
public List<String> mListOfAssociatedSensorChannels = new ArrayList<String>();
2833
@Deprecated //TODO replace with compatible versions list
2934
public List<Integer> mListOfCompatableExpBoards = new ArrayList<Integer>();
3035

@@ -63,7 +68,7 @@ public AlgorithmDetails(
6368
/**
6469
* @param objectClusterName
6570
* @param guiFriendlyName
66-
* @param listOfAssociatedSensors
71+
* @param listOfAssociatedSensorChannels
6772
* @param groupName
6873
* @param listOfDerivedSensorBitmapId
6974
* @param listOfRequiredSensors
@@ -72,14 +77,14 @@ public AlgorithmDetails(
7277
public AlgorithmDetails(
7378
String objectClusterName,
7479
String guiFriendlyName,
75-
List<String> listOfAssociatedSensors,
80+
List<String> listOfAssociatedSensorChannels,
7681
long derivedSensorBitmapId,
7782
List<Integer> listOfRequiredSensors,
7883
String units){
7984
this(listOfRequiredSensors, units);
8085
mAlgorithmName = objectClusterName;
8186
mGuiFriendlyName = guiFriendlyName;
82-
mListOfAssociatedSensors = listOfAssociatedSensors;
87+
mListOfAssociatedSensorChannels = listOfAssociatedSensorChannels;
8388
mDerivedSensorBitmapID = derivedSensorBitmapId;
8489
mListOfChannelDetails.add(generateChannelDetails());
8590
}
@@ -88,7 +93,7 @@ public AlgorithmDetails(
8893
/**
8994
* @param objectClusterName
9095
* @param guiFriendlyName
91-
* @param listOfAssociatedSensors
96+
* @param listOfAssociatedSensorChannels
9297
* @param derivedSensorBitmapId
9398
* @param listOfRequiredSensors
9499
* @param units
@@ -97,12 +102,12 @@ public AlgorithmDetails(
97102
public AlgorithmDetails(
98103
String objectClusterName,
99104
String guiFriendlyName,
100-
List<String> listOfAssociatedSensors,
105+
List<String> listOfAssociatedSensorChannels,
101106
long derivedSensorBitmapId,
102107
List<Integer> listOfRequiredSensors,
103108
String units,
104109
List<ChannelDetails> listOfAlgortihmChannels){
105-
this(objectClusterName, guiFriendlyName, listOfAssociatedSensors, derivedSensorBitmapId, listOfRequiredSensors, units);
110+
this(objectClusterName, guiFriendlyName, listOfAssociatedSensorChannels, derivedSensorBitmapId, listOfRequiredSensors, units);
106111

107112
//2016-11-28 MN changed below to override mListOfChannelDetails as this() above attempts to create one from this class
108113
// mListOfChannelDetails.addAll(listOfAlgortihmChannels);
@@ -154,6 +159,37 @@ private ChannelDetails generateChannelDetails(){
154159
public List<ChannelDetails> getChannelDetails() {
155160
return mListOfChannelDetails;
156161
}
162+
163+
//TODO use the following check first in future?
164+
public static LinkedHashMap<String, AlgorithmDetails> loadAlgorithmsWhereSensorsAreAvailable(ShimmerDevice shimmerDevice, Map<String, AlgorithmDetails> algorithMap) {
165+
LinkedHashMap<String, AlgorithmDetails> mapOfSupportedAlgorithms = new LinkedHashMap<String, AlgorithmDetails>();
166+
167+
LinkedHashMap<Integer, SensorDetails> sensorMap = shimmerDevice.getSensorMap();
168+
169+
algorithmLoop:
170+
for(Entry<String, AlgorithmDetails> algorithmDetailsEntry:algorithMap.entrySet()){
171+
AlgorithmDetails algorithmDetails = algorithmDetailsEntry.getValue();
172+
173+
if(algorithmDetails.mSensorCheckMethod==SENSOR_CHECK_METHOD.ANY){
174+
for(Integer sensorMapKey:algorithmDetails.mListOfRequiredSensors){
175+
if(sensorMap.containsKey(sensorMapKey)){
176+
mapOfSupportedAlgorithms.put(algorithmDetailsEntry.getKey(), algorithmDetails);
177+
continue algorithmLoop;
178+
}
179+
}
180+
} else if(algorithmDetails.mSensorCheckMethod==SENSOR_CHECK_METHOD.ALL){
181+
for(Integer sensorMapKey:algorithmDetails.mListOfRequiredSensors){
182+
if(!sensorMap.containsKey(sensorMapKey)){
183+
continue algorithmLoop;
184+
}
185+
}
186+
mapOfSupportedAlgorithms.put(algorithmDetailsEntry.getKey(), algorithmDetails);
187+
}
188+
}
189+
190+
return mapOfSupportedAlgorithms;
191+
}
192+
157193

158194

159195
}

ShimmerDriver/src/main/java/com/shimmerresearch/algorithms/AlgorithmLoaderInterface.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
import java.util.LinkedHashMap;
44

55
import com.shimmerresearch.driver.ShimmerDevice;
6-
import com.shimmerresearch.driverUtilities.ExpansionBoardDetails;
7-
import com.shimmerresearch.driverUtilities.ShimmerVerObject;
6+
import com.shimmerresearch.driver.Configuration.COMMUNICATION_TYPE;
87

98
/** This interface allows dynamic loading of algorithms based on Shimmer version information. It also serves as a good location to load default settings into an
109
* @author Mark Nolan
1110
*
1211
*/
1312
public interface AlgorithmLoaderInterface {
1413

15-
public void initialiseSupportedAlgorithms(ShimmerDevice shimmerDevice);
14+
public void initialiseSupportedAlgorithms(ShimmerDevice shimmerDevice, COMMUNICATION_TYPE commType);
1615

17-
public LinkedHashMap<String, AlgorithmDetails> getMapOfSupportedAlgorithms(ShimmerVerObject svo, ExpansionBoardDetails eBD);
16+
public LinkedHashMap<String, AlgorithmDetails> getMapOfSupportedAlgorithms(ShimmerDevice shimmerDevice);
1817

1918
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.shimmerresearch.algorithms.gyroOnTheFlyCal;
2+
3+
import java.util.LinkedHashMap;
4+
5+
import com.shimmerresearch.algorithms.AlgorithmDetails;
6+
import com.shimmerresearch.algorithms.AlgorithmLoaderInterface;
7+
import com.shimmerresearch.driver.Configuration.COMMUNICATION_TYPE;
8+
import com.shimmerresearch.driver.ShimmerDevice;
9+
import com.shimmerresearch.driverUtilities.ExpansionBoardDetails;
10+
import com.shimmerresearch.driverUtilities.ShimmerVerObject;
11+
12+
public class GyroOnTheFlyCalLoader implements AlgorithmLoaderInterface {
13+
14+
@Override
15+
public void initialiseSupportedAlgorithms(ShimmerDevice shimmerDevice, COMMUNICATION_TYPE commType) {
16+
LinkedHashMap<String, AlgorithmDetails> mapOfSupportedAlgorithms = getMapOfSupportedAlgorithms(shimmerDevice);
17+
for (AlgorithmDetails algorithmDetails:mapOfSupportedAlgorithms.values()) {
18+
GyroOnTheFlyCalModule algorithmModule = new GyroOnTheFlyCalModule(shimmerDevice, algorithmDetails, shimmerDevice.getSamplingRateShimmer(commType));
19+
shimmerDevice.addAlgorithmModule(algorithmModule);
20+
}
21+
}
22+
23+
@Override
24+
public LinkedHashMap<String, AlgorithmDetails> getMapOfSupportedAlgorithms(ShimmerDevice shimmerDevice) {
25+
LinkedHashMap<String, AlgorithmDetails> mapOfSupportedAlgorithms = new LinkedHashMap<String, AlgorithmDetails>();
26+
mapOfSupportedAlgorithms = AlgorithmDetails.loadAlgorithmsWhereSensorsAreAvailable(shimmerDevice, GyroOnTheFlyCalModule.mAlgorithmMapRef);
27+
return mapOfSupportedAlgorithms;
28+
}
29+
30+
}

0 commit comments

Comments
 (0)