-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSensorMapsExample.java
More file actions
604 lines (509 loc) · 21.3 KB
/
Copy pathSensorMapsExample.java
File metadata and controls
604 lines (509 loc) · 21.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
package com.shimmerresearch.simpleexamples;
import javax.swing.JFrame;
import com.shimmerresearch.bluetooth.ShimmerBluetooth.BT_STATE;
import com.shimmerresearch.driver.BasicProcessWithCallBack;
import com.shimmerresearch.driver.CallbackObject;
import com.shimmerresearch.driver.Configuration;
import com.shimmerresearch.driver.Configuration.COMMUNICATION_TYPE;
import com.shimmerresearch.driver.ObjectCluster;
import com.shimmerresearch.driver.ShimmerDevice;
import com.shimmerresearch.driver.ShimmerMsg;
import com.shimmerresearch.driverUtilities.AssembleShimmerConfig;
import com.shimmerresearch.driverUtilities.BluetoothDeviceDetails;
import com.shimmerresearch.driverUtilities.SensorDetails;
import com.shimmerresearch.driverUtilities.ShimmerVerDetails.HW_ID;
import com.shimmerresearch.exceptions.ShimmerException;
import com.shimmerresearch.grpc.ShimmerGRPC;
import com.shimmerresearch.guiUtilities.configuration.EnableLowPowerModeDialog;
import com.shimmerresearch.guiUtilities.configuration.EnableSensorsDialog;
import com.shimmerresearch.guiUtilities.configuration.SensorConfigDialog;
import com.shimmerresearch.guiUtilities.configuration.SignalsToPlotDialog;
import com.shimmerresearch.guiUtilities.plot.BasicPlotManagerPC;
import com.shimmerresearch.pcDriver.ShimmerPC;
import com.shimmerresearch.sensors.lis2dw12.SensorLIS2DW12;
import com.shimmerresearch.sensors.lisxmdl.SensorLIS2MDL;
import com.shimmerresearch.sensors.lsm6dsv.SensorLSM6DSV;
import com.shimmerresearch.tools.LoggingPC;
import com.shimmerresearch.tools.bluetooth.BasicShimmerBluetoothManagerPc;
import com.shimmerresearch.verisense.VerisenseDevice;
import com.shimmerresearch.verisense.communication.SyncProgressDetails;
import com.shimmerresearch.verisense.communication.VerisenseProtocolByteCommunication;
import com.shimmerresearch.bluetooth.ShimmerBluetooth;
import info.monitorenter.gui.chart.Chart2D;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.imageio.ImageIO;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JTextPane;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.ActionEvent;
import javax.swing.JMenu;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import java.awt.Canvas;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.JComboBox;
public class SensorMapsExample extends BasicProcessWithCallBack {
private JFrame frame;
private JTextField textField;
JTextPane textPaneStatus;
static ShimmerDevice shimmerDevice;
static BasicShimmerBluetoothManagerPc btManager = new BasicShimmerBluetoothManagerPc();
BasicPlotManagerPC plotManager = new BasicPlotManagerPC();
static String btComport;
final Chart2D mChart = new Chart2D();
private JTextField textFieldSamplingRate;
static JLabel lblPRR;
static final String PREFIX_COM = "COM";
static final String PREFIX_DEV = "dev";
JComboBox<String> comboBox;
JLabel lblFilePath;
LoggingPC lpc;
JCheckBox chckbxWriteDataToFile;
String[] options = {"Shimmer3", "Verisense"};
/**
* Initialize the contents of the frame
* @wbp.parser.entryPoint
*/
public void initialize() {
frame = new JFrame("Shimmer SensorMaps Example");
frame.setBounds(100, 100, 1200, 591);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JLabel lblSetComPort = new JLabel("Set COM Port (e.g. COMX or /dev/rfcommX) or Mac Address (e.g. XX:XX:XX:XX:XX:XX , note this requires grpc and BLE)");
lblSetComPort.setBounds(10, 25, 1000, 23);
frame.getContentPane().add(lblSetComPort);
textField = new JTextField();
textField.setToolTipText("for example COM1, COM2, etc");
textField.setBounds(10, 56, 144, 29);
frame.getContentPane().add(textField);
textField.setColumns(10);
JButton btnConnect = new JButton("CONNECT");
btnConnect.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
btComport = textField.getText();
if (btComport.length()==17) {
if (comboBox.getSelectedItem().equals("Shimmer3")) {
BluetoothDeviceDetails bdd = new BluetoothDeviceDetails("", btComport, "Shimmer3BLE");
btManager.connectShimmer3BleGrpc(bdd);
} else if (comboBox.getSelectedItem().equals("Verisense")) {
BluetoothDeviceDetails bdd = new BluetoothDeviceDetails(btComport, btComport, "ShimmerGRPC");
btManager.connectVerisenseDevice(bdd);
}
} else {
btManager.connectShimmerThroughCommPort(btComport);
}
}
});
btnConnect.setToolTipText("attempt connection to Shimmer device");
btnConnect.setBounds(290, 56, 199, 31);
frame.getContentPane().add(btnConnect);
JButton btnDisconnect = new JButton("DISCONNECT");
btnDisconnect.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
btManager.disconnectShimmer(btComport);
}
});
btnDisconnect.setToolTipText("disconnect from Shimmer device");
btnDisconnect.setBounds(520, 56, 187, 31);
frame.getContentPane().add(btnDisconnect);
JLabel lblShimmerStatus = new JLabel("Shimmer Status");
lblShimmerStatus.setBounds(10, 139, 144, 23);
frame.getContentPane().add(lblShimmerStatus);
textPaneStatus = new JTextPane();
textPaneStatus.setBounds(10, 181, 144, 36);
frame.getContentPane().add(textPaneStatus);
JMenuBar menuBar = new JMenuBar();
menuBar.setBounds(0, 0, 1184, 23);
frame.getContentPane().add(menuBar);
JMenu mnTools = new JMenu("Tools");
menuBar.add(mnTools);
JMenuItem mntmSelectSensors = new JMenuItem("Select sensors");
mntmSelectSensors.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
ShimmerDevice SD = btManager.getShimmerDeviceBtConnected(btComport);
boolean connected = false;
if (SD!=null) {
if (SD instanceof VerisenseDevice) {
VerisenseDevice vd = (VerisenseDevice) SD;
if (vd.getBluetoothRadioState().equals(BT_STATE.CONNECTED)){
connected = true;
}
} else {
ShimmerBluetooth sb = (ShimmerBluetooth) SD;
if (sb.getBluetoothRadioState().equals(BT_STATE.CONNECTED)){
connected = true;
}
}
}
//Ensure the Shimmer is not streaming or SD logging before configuring it
if(connected) {
EnableSensorsDialog sensorsDialog = new EnableSensorsDialog(((ShimmerDevice)btManager.getShimmerDeviceBtConnected(btComport)),btManager);
sensorsDialog.showDialog();
} else {
JOptionPane.showMessageDialog(frame, "Device not in a connected state!", "Info", JOptionPane.WARNING_MESSAGE);
}
// EnableSensorsDialog sensorsDialog = new EnableSensorsDialog(shimmerDevice);
// sensorsDialog.initialize();
}
});
mnTools.add(mntmSelectSensors);
JMenuItem mntmDeviceConfiguration = new JMenuItem("Sensor configuration");
mntmDeviceConfiguration.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ShimmerDevice SD = btManager.getShimmerDeviceBtConnected(btComport);
boolean connected = false;
if (SD!=null) {
if (SD instanceof VerisenseDevice) {
VerisenseDevice vd = (VerisenseDevice) SD;
if (vd.getBluetoothRadioState().equals(BT_STATE.CONNECTED)){
connected = true;
}
} else {
ShimmerBluetooth sb = (ShimmerBluetooth) SD;
if (sb.getBluetoothRadioState().equals(BT_STATE.CONNECTED)){
connected = true;
}
}
}
if(connected) {
SensorConfigDialog configDialog = new SensorConfigDialog(((ShimmerDevice)btManager.getShimmerDeviceBtConnected(btComport)),btManager);
configDialog.showDialog();
} else {
JOptionPane.showMessageDialog(frame, "Device not in a connected state!", "Info", JOptionPane.WARNING_MESSAGE);
}
}
});
mnTools.add(mntmDeviceConfiguration);
JPanel plotPanel = new JPanel();
plotPanel.setBounds(10, 269, 1164, 272);
frame.getContentPane().add(plotPanel);
plotPanel.setLayout(null);
mChart.setLocation(12, 13);
mChart.setSize(1142, 246);
plotPanel.add(mChart);
plotManager.addChart(mChart);
JMenuItem mntmSignalsToPlot = new JMenuItem("Signals to plot");
mntmSignalsToPlot.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mChart.removeAll();
plotManager.removeAllSignals();
SignalsToPlotDialog signalsToPlotDialog = new SignalsToPlotDialog();
signalsToPlotDialog.initialize(((ShimmerDevice)btManager.getShimmerDeviceBtConnected(btComport)), plotManager, mChart);
}
});
mnTools.add(mntmSignalsToPlot);
JMenuItem mntmLowPowerMode = new JMenuItem("Low Power Mode");
mntmLowPowerMode.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ShimmerDevice SD = btManager.getShimmerDeviceBtConnected(btComport);
boolean connected = false;
if (SD!=null) {
if (SD instanceof VerisenseDevice) {
VerisenseDevice vd = (VerisenseDevice) SD;
if (vd.getBluetoothRadioState().equals(BT_STATE.CONNECTED)){
connected = true;
}
} else {
ShimmerBluetooth sb = (ShimmerBluetooth) SD;
if (sb.getBluetoothRadioState().equals(BT_STATE.CONNECTED)){
connected = true;
}
}
}
if(connected) {
EnableLowPowerModeDialog lpModeDialog = new EnableLowPowerModeDialog(((ShimmerDevice)btManager.getShimmerDeviceBtConnected(btComport)),btManager);
lpModeDialog.showDialog();
} else {
JOptionPane.showMessageDialog(frame, "Device not in a connected state!", "Info", JOptionPane.WARNING_MESSAGE);
}
}
});
mnTools.add(mntmLowPowerMode);
JButton btnStartStreaming = new JButton("START STREAMING");
btnStartStreaming.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if (chckbxWriteDataToFile.isSelected()) {
String ts = Long.toString(System.currentTimeMillis());
lpc = new LoggingPC(ts+"_test.csv");
}
try {
ShimmerDevice device = btManager.getShimmerDeviceBtConnectedFromMac(btComport);
if (btComport.contains(PREFIX_COM) || btComport.contains(PREFIX_DEV)) {
device = btManager.getShimmerDeviceBtConnected(btComport);
} else {
device = btManager.getShimmerDeviceBtConnectedFromMac(btComport);
}
if (device instanceof VerisenseDevice) {
((VerisenseDevice)device).startStreaming();
}else{
((ShimmerBluetooth)device).startStreaming();
}
} catch (ShimmerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
btnStartStreaming.setBounds(185, 181, 199, 31);
frame.getContentPane().add(btnStartStreaming);
JButton btnStopStreaming = new JButton("STOP STREAMING");
btnStopStreaming.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (lpc!=null) {
lpc.closeFile();
lpc=null;
}
ShimmerDevice device = btManager.getShimmerDeviceBtConnected(btComport);
try {
if (device instanceof VerisenseDevice) {
((VerisenseDevice)device).stopStreaming();
}else{
((ShimmerBluetooth)device).stopStreaming();
}
} catch (ShimmerException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
btnStopStreaming.setBounds(415, 181, 187, 31);
frame.getContentPane().add(btnStopStreaming);
JButton btnTakeSnapshot = new JButton("Take Snapshot");
btnTakeSnapshot.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try {
File outputfile = new File("saved.png");
ImageIO.write(mChart.snapShot(), "png", outputfile);
} catch (IOException e) {
}
}
});
btnTakeSnapshot.setBounds(625, 181, 187, 31);
frame.getContentPane().add(btnTakeSnapshot);
textFieldSamplingRate = new JTextField();
textFieldSamplingRate.setToolTipText("for example COM1, COM2, etc");
textFieldSamplingRate.setColumns(10);
textFieldSamplingRate.setBounds(10, 99, 144, 29);
frame.getContentPane().add(textFieldSamplingRate);
JButton btnWriteSamplingRate = new JButton("Write Sampling Rate (Shimmer3)");
btnWriteSamplingRate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ShimmerDevice sd = ((ShimmerDevice)btManager.getShimmerDeviceBtConnected(btComport));
ShimmerDevice cloned = sd.deepClone();
cloned.setSamplingRateShimmer(Double.parseDouble(textFieldSamplingRate.getText()));
AssembleShimmerConfig.generateSingleShimmerConfig(cloned, COMMUNICATION_TYPE.BLUETOOTH);
btManager.configureShimmer(cloned);
}
});
btnWriteSamplingRate.setToolTipText("attempt connection to Shimmer device");
btnWriteSamplingRate.setBounds(164, 98, 220, 31);
frame.getContentPane().add(btnWriteSamplingRate);
lblPRR = new JLabel("Packet Reception Rate: ");
lblPRR.setBounds(10, 228, 372, 14);
frame.getContentPane().add(lblPRR);
DefaultComboBoxModel<String> comboModel = new DefaultComboBoxModel<String>(options);
comboBox = new JComboBox<>(comboModel);
comboBox.setBounds(164, 59, 116, 22);
frame.getContentPane().add(comboBox);
JButton btnNewButton = new JButton("Sync (Verisense)");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
VerisenseDevice device = (VerisenseDevice)btManager.getShimmerDeviceBtConnected(btComport);
try {
((VerisenseProtocolByteCommunication)device.getMapOfVerisenseProtocolByteCommunication().get(COMMUNICATION_TYPE.BLUETOOTH)).readLoggedData();
} catch (ShimmerException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
btnNewButton.setBounds(415, 97, 187, 31);
frame.getContentPane().add(btnNewButton);
JButton btnEraseDataverisense = new JButton("Erase Data (Verisense)");
btnEraseDataverisense.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
VerisenseDevice device = (VerisenseDevice)btManager.getShimmerDeviceBtConnected(btComport);
try {
((VerisenseProtocolByteCommunication)device.getMapOfVerisenseProtocolByteCommunication().get(COMMUNICATION_TYPE.BLUETOOTH)).eraseDataTask();
} catch (ShimmerException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
btnEraseDataverisense.setBounds(632, 97, 187, 31);
frame.getContentPane().add(btnEraseDataverisense);
lblFilePath = new JLabel(" ");
lblFilePath.setBounds(12, 253, 611, 14);
frame.getContentPane().add(lblFilePath);
chckbxWriteDataToFile = new JCheckBox("Write Data to File");
chckbxWriteDataToFile.setBounds(829, 185, 116, 23);
chckbxWriteDataToFile.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if(e.getStateChange() == ItemEvent.SELECTED) {
} else {
}
}
});
frame.getContentPane().add(chckbxWriteDataToFile);
JButton btnStartSDLogging = new JButton("START SD");
btnStartSDLogging.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ShimmerDevice device = btManager.getShimmerDeviceBtConnectedFromMac(btComport);
if (btComport.contains(PREFIX_COM) || btComport.contains(PREFIX_DEV)) {
device = btManager.getShimmerDeviceBtConnected(btComport);
} else {
device = btManager.getShimmerDeviceBtConnectedFromMac(btComport);
}
if (device instanceof VerisenseDevice) {
((VerisenseDevice)device).startSDLogging();
}else{
((ShimmerBluetooth)device).startSDLogging();
}
}
});
btnStartSDLogging.setBounds(951, 181, 91, 31);
frame.getContentPane().add(btnStartSDLogging);
JButton btnStopSd = new JButton("STOP SD");
btnStopSd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ShimmerDevice device = btManager.getShimmerDeviceBtConnectedFromMac(btComport);
if (btComport.contains(PREFIX_COM) || btComport.contains(PREFIX_DEV)) {
device = btManager.getShimmerDeviceBtConnected(btComport);
} else {
device = btManager.getShimmerDeviceBtConnectedFromMac(btComport);
}
if (device instanceof VerisenseDevice) {
((VerisenseDevice)device).stopSDLogging();
}else{
((ShimmerBluetooth)device).stopSDLogging();
}
}
});
btnStopSd.setBounds(1043, 181, 82, 31);
frame.getContentPane().add(btnStopSd);
plotManager.setTitle("Plot");
}
public static void main(String args[]) {
SensorMapsExample s = new SensorMapsExample();
s.initialize();
s.frame.setVisible(true);
s.setWaitForData(btManager.callBackObject);
//s.setWaitForData(shimmer);
}
static Timer timer = null;
static class PRRTask extends TimerTask {
@Override
public void run() {
ShimmerDevice sd = ((ShimmerDevice)btManager.getShimmerDeviceBtConnected(btComport));
if (sd!=null) {
lblPRR.setText("Packet Reception Rate: " +Double.toString(sd.getPacketReceptionRateOverall()));
}
}
}
@Override
protected void processMsgFromCallback(ShimmerMsg shimmerMSG) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
int ind = shimmerMSG.mIdentifier;
Object object = (Object) shimmerMSG.mB;
if (ind == ShimmerPC.MSG_IDENTIFIER_STATE_CHANGE) {
CallbackObject callbackObject = (CallbackObject)object;
if (callbackObject.mState == BT_STATE.CONNECTING) {
textPaneStatus.setText("connecting...");
} else if (callbackObject.mState == BT_STATE.CONNECTED) {
if (timer!=null){
timer.cancel();
timer = new Timer();
}
textPaneStatus.setText("connected");
//shimmer = (ShimmerPC) btManager.getShimmerDeviceBtConnected(btComport);
// shimmerDevice = btManager.getShimmerDeviceBtConnected(btComport);
//shimmer.startStreaming();
} else if (callbackObject.mState == BT_STATE.STREAMING_LOGGED_DATA) {
if (timer!=null){
timer.cancel();
timer = new Timer();
}
textPaneStatus.setText("Syncing");
//shimmer = (ShimmerPC) btManager.getShimmerDeviceBtConnected(btComport);
// shimmerDevice = btManager.getShimmerDeviceBtConnected(btComport);
//shimmer.startStreaming();
} else if (callbackObject.mState == BT_STATE.DISCONNECTED
// || callbackObject.mState == BT_STATE.NONE
|| callbackObject.mState == BT_STATE.CONNECTION_LOST){
if (timer!=null) {
timer.cancel();
timer = null;
}
textPaneStatus.setText("disconnected");
}else if (callbackObject.mState == BT_STATE.STREAMING) {
if (timer!=null){
timer.cancel();
timer = new Timer();
} else {
timer = new Timer();
}
// Schedule a task to be executed after a delay of 2 seconds
timer.schedule(new PRRTask(), 0 , 2000);
}
} else if (ind == ShimmerPC.MSG_IDENTIFIER_NOTIFICATION_MESSAGE) {
CallbackObject callbackObject = (CallbackObject)object;
int msg = callbackObject.mIndicator;
if (msg== ShimmerPC.NOTIFICATION_SHIMMER_FULLY_INITIALIZED){
textPaneStatus.setText("device fully initialized");
ShimmerDevice device = btManager.getShimmerDeviceBtConnectedFromMac(btComport);
if (btComport.contains(PREFIX_COM) || btComport.contains(PREFIX_DEV)) {
device = btManager.getShimmerDeviceBtConnected(btComport);
} else {
device = btManager.getShimmerDeviceBtConnectedFromMac(btComport);
}
if (device instanceof VerisenseDevice) {
textFieldSamplingRate.setText(Double.toString(((VerisenseDevice)device).getSamplingRateShimmer()));
}else{
textFieldSamplingRate.setText(Double.toString(((ShimmerBluetooth)device).getSamplingRateShimmer()));
}
}
if (msg == ShimmerPC.NOTIFICATION_SHIMMER_STOP_STREAMING) {
textPaneStatus.setText("device stopped streaming");
} else if (msg == ShimmerPC.NOTIFICATION_SHIMMER_START_STREAMING) {
textPaneStatus.setText("device streaming");
} else {}
} else if (ind == ShimmerPC.MSG_IDENTIFIER_DATA_PACKET) {
System.out.println("Shimmer MSG_IDENTIFIER_DATA_PACKET");
ObjectCluster objc = (ObjectCluster) shimmerMSG.mB;
if (lpc!=null) {
lpc.logData(objc);
}
try {
plotManager.filterDataAndPlot(objc);
} catch (Exception e) {
e.printStackTrace();
}
} else if (ind == ShimmerPC.MSG_IDENTIFIER_PACKET_RECEPTION_RATE_OVERALL) {
} else if(ind == ShimmerPC.MSG_IDENTIFIER_SYNC_PROGRESS){
SyncProgressDetails mDetails = (SyncProgressDetails)((CallbackObject)shimmerMSG.mB).mMyObject;
String progress = "Payload Index : " + Double.toString(mDetails.mPayloadIndex) + ", Transfer Rate (bytes/s) : " + Double.toString(mDetails.mTransferRateBytes) ;
lblPRR.setText(progress);
lblFilePath.setText(mDetails.mBinFilePath);
}
}
}