Permalink
Browse files

Major overhaul for the tools; simplified the API a bit and made it ea…

…sier to write a tool that does its task without having to deal with threading, OSGi and the like.
  • Loading branch information...
1 parent bbbe23d commit 728eca13bc8c5f1b3df1174c5bec59def02feb95 @jawi committed Nov 4, 2011
Showing with 6,414 additions and 5,216 deletions.
  1. +1 −0 api/pom.xml
  2. +1 −1 api/src/main/java/nl/lxtreme/ols/api/DataAcquisitionService.java
  3. +55 −0 api/src/main/java/nl/lxtreme/ols/api/devices/AcquisitionTask.java
  4. +0 −85 api/src/main/java/nl/lxtreme/ols/api/devices/CaptureCallback.java
  5. +35 −15 api/src/main/java/nl/lxtreme/ols/api/devices/Device.java
  6. +0 −75 api/src/main/java/nl/lxtreme/ols/api/devices/DeviceController.java
  7. +11 −20 api/src/main/java/nl/lxtreme/ols/api/{ProgressCallback.java → task/Task.java}
  8. +10 −9 ...c/main/java/nl/lxtreme/ols/api/{tools/ToolExecutionService.java → task/TaskExecutionService.java}
  9. +60 −0 api/src/main/java/nl/lxtreme/ols/api/task/TaskStatusListener.java
  10. +16 −22 api/src/main/java/nl/lxtreme/ols/api/tools/{AnalysisCallback.java → Annotation.java}
  11. +18 −13 api/src/main/java/nl/lxtreme/ols/api/tools/AnnotationListener.java
  12. +45 −0 api/src/main/java/nl/lxtreme/ols/api/tools/DataAnnotation.java
  13. +25 −31 api/src/main/java/nl/lxtreme/ols/api/tools/Tool.java
  14. +16 −0 api/src/main/java/nl/lxtreme/ols/api/tools/ToolContext.java
  15. +2 −22 api/src/main/java/nl/lxtreme/ols/api/tools/ToolProgressListener.java
  16. +8 −19 ...e/ols/client/StatusChangeListener.java → api/src/main/java/nl/lxtreme/ols/api/tools/ToolTask.java
  17. +2 −1 build.sh
  18. +7 −6 client/src/main/java/nl/lxtreme/ols/client/Activator.java
  19. +174 −85 client/src/main/java/nl/lxtreme/ols/client/ClientController.java
  20. +1 −1 client/src/main/java/nl/lxtreme/ols/client/action/RunToolAction.java
  21. +1 −1 client/src/main/java/nl/lxtreme/ols/client/action/manager/ActionManagerFactory.java
  22. +0 −109 client/src/main/java/nl/lxtreme/ols/client/osgi/DataAcquisitionServiceTracker.java
  23. +386 −0 client/src/main/java/nl/lxtreme/ols/client/osgi/SimpleDataAcquisitionService.java
  24. +1 −1 device.generic/pom.xml
  25. +28 −96 device.generic/src/main/java/nl/lxtreme/ols/device/generic/GenericDevice.java
  26. +162 −0 device.generic/src/main/java/nl/lxtreme/ols/device/generic/GenericDeviceAcquisitionTask.java
  27. +0 −94 device.generic/src/main/java/nl/lxtreme/ols/device/generic/GenericDeviceController.java
  28. +2 −2 device.logicsniffer/pom.xml
  29. +1,019 −0 device.logicsniffer/src/main/java/org/sump/device/logicsniffer/LogicSnifferAcquisitionTask.java
  30. +2 −2 device.logicsniffer/src/main/java/org/sump/device/logicsniffer/LogicSnifferConfig.java
  31. +1 −1 device.logicsniffer/src/main/java/org/sump/device/logicsniffer/LogicSnifferConfigDialog.java
  32. +63 −909 device.logicsniffer/src/main/java/org/sump/device/logicsniffer/LogicSnifferDevice.java
  33. +0 −177 device.logicsniffer/src/main/java/org/sump/device/logicsniffer/LogicSnifferDeviceController.java
  34. +14 −14 device.logicsniffer/src/test/java/org/sump/device/logicsniffer/LogicSnifferConfigTest.java
  35. +15 −15 device.logicsniffer/src/test/java/org/sump/device/logicsniffer/LogicSnifferDeviceComponentTest.java
  36. +2 −2 device.logicsniffer/src/test/java/org/sump/device/logicsniffer/LogicSnifferEnabledGroupTest.java
  37. +2 −2 device.logicsniffer/src/test/java/org/sump/device/logicsniffer/LogicSnifferRleComponentTest.java
  38. +2 −2 ...e.logicsniffer/src/test/java/org/sump/device/logicsniffer/LogicSnifferRleTimingComponentTest.java
  39. +3 −3 device.logicsniffer/src/test/java/org/sump/device/logicsniffer/VirtualLogicSnifferDevice.java
  40. +1 −1 device.test/pom.xml
  41. +147 −0 device.test/src/main/java/nl/lxtreme/ols/device/test/TestAcquisitionTask.java
  42. +39 −83 device.test/src/main/java/nl/lxtreme/ols/device/test/TestDevice.java
  43. +0 −102 device.test/src/main/java/nl/lxtreme/ols/device/test/TestDeviceController.java
  44. +6 −1 ols.distribution/pom.xml
  45. +4 −4 ols.distribution/src/main/assembly/assembly.xml
  46. +6 −6 pom.xml
  47. +6 −6 service.acquisition/src/main/java/nl/lxtreme/ols/acquisition/BackgroundDataAcquisitionService.java
  48. +17 −17 ...ce.acquisition/src/test/java/nl/lxtreme/ols/acquisition/BackgroundDataAcquisitionServiceTest.java
  49. +60 −0 service.taskexecution/pom.xml
  50. +72 −0 service.taskexecution/src/main/java/nl/lxtreme/ols/task/execution/Activator.java
  51. +138 −0 ...ice.taskexecution/src/main/java/nl/lxtreme/ols/task/execution/BackgroundTaskExecutionService.java
  52. +98 −0 service.taskexecution/src/main/java/nl/lxtreme/ols/task/execution/TaskStatusListenerHelper.java
  53. +296 −0 ...taskexecution/src/test/java/nl/lxtreme/ols/task/execution/BackgroundTaskExecutionServiceTest.java
  54. +26 −24 test.util/src/main/java/nl/lxtreme/ols/test/data/DataTestUtils.java
  55. +30 −16 tool.1wire/src/main/java/nl/lxtreme/ols/tool/onewire/OneWireAnalyser.java
  56. +79 −60 tool.1wire/src/main/java/nl/lxtreme/ols/tool/onewire/OneWireAnalyserDialog.java
  57. +84 −67 ...src/main/java/nl/lxtreme/ols/tool/onewire/{OneWireAnalyserWorker.java → OneWireAnalyserTask.java}
  58. +8 −4 tool.1wire/src/test/java/nl/lxtreme/ols/tool/onewire/OneWireAnalyserWorkerTest.java
  59. +37 −13 tool.asm45/src/main/java/nl/lxtreme/ols/tool/asm45/Asm45Analyser.java
  60. +107 −100 ...asm45/src/main/java/nl/lxtreme/ols/tool/asm45/{Asm45AnalyserWorker.java → Asm45AnalyserTask.java}
  61. +134 −114 tool.asm45/src/main/java/nl/lxtreme/ols/tool/asm45/Asm45ProtocolAnalysisDialog.java
  62. +8 −4 tool.asm45/src/test/java/nl/lxtreme/ols/tool/asm45/Asm45AnalyserWorkerContentTest.java
  63. +9 −5 tool.asm45/src/test/java/nl/lxtreme/ols/tool/asm45/Asm45AnalyserWorkerDataFilesTest.java
  64. +1 −1 tool.base/pom.xml
  65. +115 −0 tool.base/src/main/java/nl/lxtreme/ols/tool/base/AnnotationListenerServiceTracker.java
  66. +0 −44 tool.base/src/main/java/nl/lxtreme/ols/tool/base/AsyncToolDialog.java
  67. +0 −271 tool.base/src/main/java/nl/lxtreme/ols/tool/base/BaseAsyncTool.java
  68. +0 −561 tool.base/src/main/java/nl/lxtreme/ols/tool/base/BaseAsyncToolDialog.java
  69. +0 −298 tool.base/src/main/java/nl/lxtreme/ols/tool/base/BaseAsyncToolWorker.java
  70. +0 −203 tool.base/src/main/java/nl/lxtreme/ols/tool/base/BaseTool.java
  71. +251 −49 tool.base/src/main/java/nl/lxtreme/ols/tool/base/BaseToolDialog.java
  72. +65 −0 tool.base/src/main/java/nl/lxtreme/ols/tool/base/ExportAware.java
  73. +86 −0 tool.base/src/main/java/nl/lxtreme/ols/tool/base/TaskExecutionServiceTracker.java
  74. +13 −13 tool.base/src/main/java/nl/lxtreme/ols/tool/base/ToolDialog.java
  75. +84 −0 tool.base/src/main/java/nl/lxtreme/ols/tool/base/ToolProgressListenerServiceTracker.java
  76. +306 −0 tool.base/src/main/java/nl/lxtreme/ols/tool/base/ToolUtils.java
  77. +76 −0 tool.base/src/main/java/nl/lxtreme/ols/tool/base/annotation/ChannelLabelAnnotation.java
  78. +88 −0 tool.base/src/main/java/nl/lxtreme/ols/tool/base/annotation/SampleDataAnnotation.java
  79. +28 −25 tool.i2c/src/main/java/nl/lxtreme/ols/tool/i2c/I2CAnalyser.java
  80. +147 −105 tool.i2c/src/main/java/nl/lxtreme/ols/tool/i2c/{I2CAnalyserWorker.java → I2CAnalyserTask.java}
  81. +162 −120 tool.i2c/src/main/java/nl/lxtreme/ols/tool/i2c/I2CProtocolAnalysisDialog.java
  82. +8 −4 tool.i2c/src/test/java/nl/lxtreme/ols/tool/i2c/I2CAnalyserWorkerContentTest.java
  83. +9 −5 tool.i2c/src/test/java/nl/lxtreme/ols/tool/i2c/I2CAnalyserWorkerDataFilesTest.java
  84. +36 −12 tool.jtag/src/main/java/nl/lxtreme/ols/tool/jtag/JTAGAnalyser.java
  85. +72 −57 tool.jtag/src/main/java/nl/lxtreme/ols/tool/jtag/{JTAGAnalyserWorker.java → JTAGAnalyserTask.java}
  86. +133 −111 tool.jtag/src/main/java/nl/lxtreme/ols/tool/jtag/JTAGProtocolAnalysisDialog.java
  87. +33 −28 ...a/nl/lxtreme/ols/tool/measure/{ClockFrequencyMeasureWorker.java → ClockFrequencyMeasureTask.java}
  88. +72 −225 tool.measure/src/main/java/nl/lxtreme/ols/tool/measure/MeasurementDialog.java
  89. +44 −9 tool.measure/src/main/java/nl/lxtreme/ols/tool/measure/MeasurementTool.java
  90. +7 −6 ...asure/src/test/java/nl/lxtreme/ols/tool/measure/ClockFrequencyMeasureWorkerGeneratedDataTest.java
  91. +8 −7 tool.measure/src/test/java/nl/lxtreme/ols/tool/measure/ClockFrequencyMeasureWorkerResourceTest.java
  92. +29 −21 tool.spi/src/main/java/nl/lxtreme/ols/tool/spi/SPIAnalyser.java
  93. +121 −82 tool.spi/src/main/java/nl/lxtreme/ols/tool/spi/{SPIAnalyserWorker.java → SPIAnalyserTask.java}
  94. +172 −118 tool.spi/src/main/java/nl/lxtreme/ols/tool/spi/SPIProtocolAnalysisDialog.java
  95. +9 −5 tool.spi/src/test/java/nl/lxtreme/ols/tool/spi/SPIAnalyserWorkerContentTest.java
  96. +8 −4 tool.spi/src/test/java/nl/lxtreme/ols/tool/spi/SPIAnalyserWorkerDataFilesTest.java
  97. +36 −12 tool.state/src/main/java/nl/lxtreme/ols/tool/state/StateAnalyser.java
  98. +71 −20 tool.state/src/main/java/nl/lxtreme/ols/tool/state/StateAnalysisDialog.java
  99. +34 −32 ...state/src/main/java/nl/lxtreme/ols/tool/state/{StateAnalysisWorker.java → StateAnalysisTask.java}
  100. +36 −12 tool.uart/src/main/java/nl/lxtreme/ols/tool/uart/UARTAnalyser.java
  101. +146 −123 tool.uart/src/main/java/nl/lxtreme/ols/tool/uart/{UARTAnalyserWorker.java → UARTAnalyserTask.java}
  102. +185 −167 tool.uart/src/main/java/nl/lxtreme/ols/tool/uart/UARTProtocolAnalysisDialog.java
  103. +8 −4 tool.uart/src/test/java/nl/lxtreme/ols/tool/uart/UARTAnalyserWorkerDataFilesTest.java
  104. +112 −0 util/src/main/java/nl/lxtreme/ols/util/AccumulatingRunnable.java
  105. +1 −0 util/src/main/java/nl/lxtreme/ols/util/swing/SwingComponentUtils.java
View
1 api/pom.xml
@@ -54,6 +54,7 @@
nl.lxtreme.ols.api.data.export,
nl.lxtreme.ols.api.data.project,
nl.lxtreme.ols.api.devices,
+ nl.lxtreme.ols.api.task,
nl.lxtreme.ols.api.tools,
nl.lxtreme.ols.api.ui</Export-Package>
</instructions>
View
2 api/src/main/java/nl/lxtreme/ols/api/DataAcquisitionService.java
@@ -61,5 +61,5 @@
* @throws IllegalArgumentException
* in case the given device was <code>null</code>.
*/
- void acquireData( DeviceController aDeviceController ) throws IOException;
+ void acquireData( Device aDeviceController ) throws IOException;
}
View
55 api/src/main/java/nl/lxtreme/ols/api/devices/AcquisitionTask.java
@@ -0,0 +1,55 @@
+/*
+ * OpenBench LogicSniffer / SUMP project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Copyright (C) 2006-2010 Michael Poppitz, www.sump.org
+ * Copyright (C) 2010 J.W. Janssen, www.lxtreme.nl
+ */
+package nl.lxtreme.ols.api.devices;
+
+
+import java.io.*;
+import nl.lxtreme.ols.api.acquisition.*;
+import nl.lxtreme.ols.api.task.*;
+
+
+/**
+ * Denotes a device that we can talk to by calling {@link #call()} on it. The
+ * implementation of that method should do all necessary tasks to acquire data
+ * from the device and return that data in the form of an
+ * {@link AcquisitionResult} object.
+ */
+public interface AcquisitionTask extends Task<AcquisitionResult>, Closeable
+{
+ // METHODS
+
+ /**
+ * Closes the device.
+ *
+ * @throws IOException
+ * in case of I/O problems closing the device.
+ */
+ void close() throws IOException;
+
+ /**
+ * Opens the device for acquisition.
+ *
+ * @throws IOException
+ * in case of I/O problems closing the device.
+ */
+ void open() throws IOException;
+
+}
View
85 api/src/main/java/nl/lxtreme/ols/api/devices/CaptureCallback.java
@@ -1,85 +0,0 @@
-/*
- * OpenBench LogicSniffer / SUMP project
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
- *
- *
- * Copyright (C) 2010-2011 - J.W. Janssen, http://www.lxtreme.nl
- */
-package nl.lxtreme.ols.api.devices;
-
-
-import java.util.*;
-
-import nl.lxtreme.ols.api.*;
-import nl.lxtreme.ols.api.acquisition.*;
-import nl.lxtreme.ols.api.data.*;
-
-
-/**
- * Denotes a callback for receiving captured data and keeping notified of the
- * capture progress.
- */
-public interface CaptureCallback extends ProgressCallback
-{
- // METHODS
-
- /**
- * Called when the capture was aborted.
- *
- * @param aReason
- * a reason why this run might be aborted, can be any kind of string
- * message, such as an exception message, user message, etc. Can be
- * <code>null</code>.
- */
- public void captureAborted( final String aReason );
-
- /**
- * Called upon completion of the capture process.
- *
- * @param aData
- * the captured data, never <code>null</code>.
- */
- public void captureComplete( final AcquisitionResult aData );
-
- /**
- * Called when the capture is just started.
- * <p>
- * This method will be called before any other methods of this interface.
- * </p>
- *
- * @param aSampleRate
- * the sample rate of the capture, in Hertz (Hz);
- * @param aChannelCount
- * the number of channels in a single sample (1..32);
- * @param aChannelMask
- * the bitmask used to mask out the relevant channels.
- */
- public void captureStarted( final int aSampleRate, final int aChannelCount, final int aChannelMask );
-
- /**
- * Called when a number of samples are captured.
- * <p>
- * There is no guarantee this method will be called at all! However, if
- * called, it will always be in order.
- * </p>
- *
- * @param aSamples
- * the captured samples, never <code>null</code>.
- */
- public void samplesCaptured( final List<Sample> aSamples );
-}
-
-/* EOF */
View
50 api/src/main/java/nl/lxtreme/ols/api/devices/Device.java
@@ -15,42 +15,62 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*
- * Copyright (C) 2006-2010 Michael Poppitz, www.sump.org
- * Copyright (C) 2010 J.W. Janssen, www.lxtreme.nl
+ *
+ * Copyright (C) 2010-2011 - J.W. Janssen, http://www.lxtreme.nl
*/
package nl.lxtreme.ols.api.devices;
import java.io.*;
-import java.util.concurrent.*;
import nl.lxtreme.ols.api.acquisition.*;
/**
- * Denotes a device that we can talk to by calling {@link #call()} on it. The
- * implementation of that method should do all necessary tasks to acquire data
- * from the device and return that data in the form of an
- * {@link AcquisitionResult} object.
+ * Interface for implementing device controllers. Each supported device must
+ * implement at least this interface.
*/
-public interface Device extends Callable<AcquisitionResult>, Closeable
+public interface Device
{
// METHODS
/**
- * Closes the device.
+ * Creates a new {@link AcquisitionTask} for acquiring data from the device.
*
+ * @param aProgressListener
+ * the acquisition progress listener the acquisition task can use to
+ * report its progress, cannot be <code>null</code>.
* @throws IOException
- * in case of I/O problems closing the device.
+ * in case of I/O problems during the creation of the acquisition
+ * task.
*/
- void close() throws IOException;
+ public AcquisitionTask createAcquisitionTask( AcquisitionProgressListener aProgressListener ) throws IOException;
/**
- * Opens the device.
+ * Returns a descriptive name of this device controller.
*
- * @throws IOException
- * in case of I/O problems closing the device.
+ * @return name of the controller, cannot be <code>null</code>.
+ */
+ public String getName();
+
+ /**
+ * Returns whether this device is already set up or not.
+ *
+ * @return <code>true</code> if there is a "valid" setup for this device,
+ * <code>false</code> otherwise.
*/
- void open() throws IOException;
+ public boolean isSetup();
+ /**
+ * Allows this device controller to set up the device by means of presenting
+ * an UI.
+ *
+ * @param aParent
+ * the parent window that can be used to display (modal) dialogs, can
+ * be <code>null</code>.
+ * @return <code>true</code> if the setup is successfully completed (the user
+ * acknowledged the setup), <code>false</code> if the setup is aborted
+ * by the user.
+ */
+ public boolean setupCapture( final java.awt.Window aParent );
}
View
75 api/src/main/java/nl/lxtreme/ols/api/devices/DeviceController.java
@@ -1,75 +0,0 @@
-/*
- * OpenBench LogicSniffer / SUMP project
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
- *
- *
- * Copyright (C) 2010-2011 - J.W. Janssen, http://www.lxtreme.nl
- */
-package nl.lxtreme.ols.api.devices;
-
-
-import java.io.*;
-
-import nl.lxtreme.ols.api.acquisition.*;
-
-
-/**
- * Interface for implementing device controllers. Each supported device must
- * implement at least this interface.
- */
-public interface DeviceController
-{
- // METHODS
-
- /**
- * Tells the device to start acquiring data.
- *
- * @param aProgressListener
- * the acquisition progress listener the device can use to report its
- * progress, cannot be <code>null</code>.
- * @throws IOException
- * in case of I/O problems during the capturing of data.
- */
- public Device createDevice( AcquisitionProgressListener aProgressListener ) throws IOException;
-
- /**
- * Returns a descriptive name of this device controller.
- *
- * @return name of the controller, cannot be <code>null</code>.
- */
- public String getName();
-
- /**
- * Returns whether this device is already set up or not.
- *
- * @return <code>true</code> if there is a "valid" setup for this device,
- * <code>false</code> otherwise.
- */
- public boolean isSetup();
-
- /**
- * Allows this device controller to set up the device by means of presenting
- * an UI.
- *
- * @param aParent
- * the parent window that can be used to display (modal) dialogs, can
- * be <code>null</code>.
- * @return <code>true</code> if the setup is successfully completed (the user
- * acknowledged the setup), <code>false</code> if the setup is aborted
- * by the user.
- */
- public boolean setupCapture( final java.awt.Window aParent );
-}
View
31 .../nl/lxtreme/ols/api/ProgressCallback.java → ...in/java/nl/lxtreme/ols/api/task/Task.java
@@ -15,31 +15,22 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*
- *
- * Copyright (C) 2010-2011 - J.W. Janssen, http://www.lxtreme.nl
+ * Copyright (C) 2006-2010 Michael Poppitz, www.sump.org
+ * Copyright (C) 2010 J.W. Janssen, www.lxtreme.nl
*/
-package nl.lxtreme.ols.api;
+package nl.lxtreme.ols.api.task;
+
+
+import java.util.concurrent.*;
/**
- * Provides a callback interface for reporting back the progress of any process
- * (capture, tool analysis).
+ * Denotes a task that can be executed asynchronously.
*
- * @deprecated
+ * @param RESULT_TYPE
+ * the return type of this task.
*/
-@Deprecated
-public interface ProgressCallback
+public interface Task<RESULT_TYPE> extends Callable<RESULT_TYPE>
{
- // METHODS
-
- /**
- * Called to update the capture progress.
- *
- * @param aPercentage
- * the (new) percentage of the capture progress.
- */
- void updateProgress( final int aPercentage );
-
+ // No additional methods...
}
-
-/* EOF */
View
19 ...e/ols/api/tools/ToolExecutionService.java → ...me/ols/api/task/TaskExecutionService.java
@@ -18,26 +18,27 @@
* Copyright (C) 2006-2010 Michael Poppitz, www.sump.org
* Copyright (C) 2010 J.W. Janssen, www.lxtreme.nl
*/
-package nl.lxtreme.ols.api.tools;
+package nl.lxtreme.ols.api.task;
import java.util.concurrent.*;
/**
- * Provides a service that can be used to invoke tools in a background thread.
+ * Provides a service that can execute tasks.
*/
-public interface ToolExecutionService
+public interface TaskExecutionService
{
// METHODS
/**
- * Ensures that the given tool is invoked in the background.
+ * Executes the given task.
*
- * @param aTool
- * the tool to invoke, cannot be <code>null</code>.
- * @return a {@link Future} that can be used to control the execution of the
- * tool, for example, to cancel its execution.
+ * @param aTask
+ * the task to execute, cannot be <code>null</code>.
+ * @return a {@link Future} that can be used to track the result of the task,
+ * can not be <code>null</code>.
*/
- Future<Void> execute( Tool aTool );
+ <RESULT_TYPE> Future<RESULT_TYPE> execute( Task<RESULT_TYPE> aTask );
+
}
View
60 api/src/main/java/nl/lxtreme/ols/api/task/TaskStatusListener.java
@@ -0,0 +1,60 @@
+/*
+ * OpenBench LogicSniffer / SUMP project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Copyright (C) 2006-2010 Michael Poppitz, www.sump.org
+ * Copyright (C) 2010 J.W. Janssen, www.lxtreme.nl
+ */
+package nl.lxtreme.ols.api.task;
+
+
+/**
+ * Callback interface to listen for state changes of tasks.
+ */
+public interface TaskStatusListener
+{
+ // METHODS
+
+ /**
+ * Called when a task is ended normally.
+ *
+ * @param aTask
+ * the task that is ended, never <code>null</code>;
+ * @param aResult
+ * the result of the task, can be <code>null</code>.
+ */
+ <RT> void taskEnded( Task<RT> aTask, RT aResult );
+
+ /**
+ * Called when a task is started.
+ *
+ * @param aTask
+ * the task that is started, never <code>null</code>;
+ * @param aException
+ * the exception that was thrown when the task failed, never
+ * <code>null</code>.
+ */
+ <RT> void taskFailed( Task<RT> aTask, Exception aException );
+
+ /**
+ * Called when a task is started.
+ *
+ * @param aTask
+ * the task that is started, never <code>null</code>.
+ */
+ <RT> void taskStarted( Task<RT> aTask );
+
+}
View
38 ...treme/ols/api/tools/AnalysisCallback.java → .../nl/lxtreme/ols/api/tools/Annotation.java
@@ -15,42 +15,36 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*
- *
- * Copyright (C) 2010-2011 - J.W. Janssen, http://www.lxtreme.nl
+ * Copyright (C) 2006-2010 Michael Poppitz, www.sump.org
+ * Copyright (C) 2010 J.W. Janssen, www.lxtreme.nl
*/
package nl.lxtreme.ols.api.tools;
-import nl.lxtreme.ols.api.*;
-import nl.lxtreme.ols.api.acquisition.*;
-
-
/**
- * Denotes a callback for use in {@link Tool}s.
- *
- * @deprecated
+ * Denotes an annotation.
*/
-@Deprecated
-public interface AnalysisCallback extends ProgressCallback
+public interface Annotation<ANNOTATION_TYPE>
{
// METHODS
/**
- * Called upon abnormal termination of the analysis.
+ * Returns the actual annotation.
+ * <p>
+ * The given annotation type is generic, meaning it can be of <em>any</em>
+ * type. One constraint that <b>all</b> annotation types must adhere is that
+ * they have a proper {@link Object#toString()} implementation.
+ * </p>
*
- * @param aReason
- * an optional reason why the analysis might be aborted, can be
- * <code>null</code> or empty.
+ * @return an annotation, never <code>null</code>.
*/
- void analysisAborted( final String aReason );
+ ANNOTATION_TYPE getAnnotation();
/**
- * Called when the analysis is complete.
+ * Returns the channel index of the channel to annotate.
*
- * @param aNewCapturedData
- * the (optional) new captured data, can be <code>null</code>.
+ * @return a channel index, >= 0 && < 32.
*/
- void analysisComplete( final AcquisitionResult aNewCapturedData );
-}
+ int getChannel();
-/* EOF */
+}
View
31 api/src/main/java/nl/lxtreme/ols/api/tools/AnnotationListener.java
@@ -25,30 +25,35 @@
* Can be used to create a service that listens for the addition/removal of
* annotation on channel data.
*/
-public interface AnnotationListener<TYPE>
+public interface AnnotationListener
{
// METHODS
/**
- * Adds a single annotation.
- *
- * @param aChannelIdx
- * @param aStartIndex
- * @param aEndIndex
- * @param aAnnotation
+ * Called when all annotations for all channels need to be cleared.
+ * <p>
+ * Called <em>before</em> any annotation is added.
+ * </p>
*/
- void addAnnotation( int aChannelIdx, int aStartIdx, int aEndIdx, TYPE aAnnotation );
+ void clearAnnotations();
/**
+ * Called when the annotations for a single channel need to be cleared.
+ * <p>
+ * Called <em>before</em> any annotation is added.
+ * </p>
+ *
* @param aChannelIdx
- * @param aStartIdx
- * @param aEndIdx
+ * the channel index to clear the annotation for, >= 0 && < 32.
*/
- void removeAnnotation( int aChannelIdx, int aStartIdx, int aEndIdx );
+ void clearAnnotations( int aChannelIdx );
/**
+ * Called for each annotation.
+ *
* @param aAnnotation
- * @return
+ * the (new) annotation, cannot be <code>null</code>.
*/
- boolean supportsAnnotation( Object aAnnotation );
+ void onAnnotation( Annotation<?> aAnnotation );
+
}
View
45 api/src/main/java/nl/lxtreme/ols/api/tools/DataAnnotation.java
@@ -0,0 +1,45 @@
+/*
+ * OpenBench LogicSniffer / SUMP project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Copyright (C) 2006-2010 Michael Poppitz, www.sump.org
+ * Copyright (C) 2010 J.W. Janssen, www.lxtreme.nl
+ */
+package nl.lxtreme.ols.api.tools;
+
+
+/**
+ * Denotes an annotation for data, which normally covers a certain range of
+ * samples.
+ */
+public interface DataAnnotation<ANNOTATION_TYPE> extends Annotation<ANNOTATION_TYPE>
+{
+ // METHODS
+
+ /**
+ * Returns the index of the last sample included in this annotation.
+ *
+ * @return a sample index, >= 0.
+ */
+ public int getEndSampleIndex();
+
+ /**
+ * Returns the index of the first sample included in this annotation.
+ *
+ * @return a sample index, >= 0.
+ */
+ public int getStartSampleIndex();
+}
View
56 api/src/main/java/nl/lxtreme/ols/api/tools/Tool.java
@@ -23,8 +23,6 @@
import java.awt.*;
-import nl.lxtreme.ols.api.data.*;
-
/**
* Interface for pluggable tools.
@@ -36,11 +34,24 @@
* @author Michael "Mr. Sump" Poppitz
* @author J.W. Janssen
*/
-public interface Tool
+public interface Tool<RESULT_TYPE>
{
// METHODS
/**
+ * Factory method for creating a new {@link ToolTask} instance.
+ *
+ * @param aContext
+ * the tool context to use within the tool taks, cannot be
+ * <code>null</code>;
+ * @param aProgressListener
+ * the tool progress listener the tool can use to report its
+ * progress, cannot be <code>null</code>.
+ */
+ ToolTask<RESULT_TYPE> createToolTask( ToolContext aContext, ToolProgressListener aProgressListener,
+ final AnnotationListener aAnnotationListener );
+
+ /**
* Returns the category for this tool.
* <p>
* Each tool <em>must</em> provide a category in order to be grouped
@@ -63,36 +74,19 @@
String getName();
/**
- * This method is invoked when the tool is selected from the Tools menu. It
- * should request any missing information using a dialog and perform the
- * tool's actual task.
- * <p>
- * This method is to be called from the Event Dispatch Thread! It should be
- * able to make use of normal Swing components without having to take care
- * about which Thread it is called from.
- * </p>
+ * Allows this tool controller to set up the tool by means of presenting an
+ * UI.
*
- * @param aOwner
- * the "owner" window that can be used when showing dialogs, can be
- * <code>null</code>;
- * @param aData
- * currently displayed capture results, cannot be <code>null</code>;
+ * @param aParent
+ * the parent window that can be used to display (modal) dialogs, can
+ * be <code>null</code>;
* @param aContext
- * the tool context, can be <code>null</code> if no context is
- * available;
- * @param aCallback
- * the callback to report the status of the tool to, cannot be
- * <code>null</code>.
+ * the context in which the tool should be run, cannot be
+ * <code>null</code>;
+ * @return <code>true</code> if the setup is successfully completed (the user
+ * acknowledged the setup), <code>false</code> if the setup is aborted
+ * by the user.
*/
- void process( final Window aOwner, final DataContainer aData, final ToolContext aContext,
- final AnalysisCallback aCallback );
-
- // /**
- // * Called when the tool is invoked to do its job.
- // *
- // * @param aContext
- // * the tool context to use, cannot be <code>null</code>.
- // */
- // void invoke( ToolContext aContext );
+ void invoke( final Window aParent, final ToolContext aContext );
}
View
16 api/src/main/java/nl/lxtreme/ols/api/tools/ToolContext.java
@@ -21,6 +21,9 @@
package nl.lxtreme.ols.api.tools;
+import nl.lxtreme.ols.api.acquisition.*;
+
+
/**
* Denotes the context in which a tool is to be run.
* <p>
@@ -40,6 +43,19 @@
int getChannels();
/**
+ * @param aSelectedIndex
+ * @return
+ */
+ Long getCursorPosition( int aSelectedIndex );
+
+ /**
+ * Returns the acquisition result for use in the tool.
+ *
+ * @return the data to be analyzed, never <code>null</code>.
+ */
+ AcquisitionResult getData();
+
+ /**
* Returns a bitmask of enabled channels in the sample data.
*
* @return a bitmask of enabled channels, for example, 0xFF for the first 8
View
24 api/src/main/java/nl/lxtreme/ols/api/tools/ToolProgressListener.java
@@ -21,9 +21,6 @@
package nl.lxtreme.ols.api.tools;
-import java.util.concurrent.*;
-
-
/**
* Can be used to listen to the progress of the invocation of a tool.
*/
@@ -32,24 +29,7 @@
// METHODS
/**
- * Called when the tool is invoked and has ended its work.
- *
- * @param aTool
- * the tool that is ended, cannot be <code>null</code>;
- * @param aFuture
- * the future that contains the execution status of the tool, cannot
- * be <code>null</code>.
- */
- void toolEnded( Tool aTool, Future<Void> aFuture );
-
- /**
- * Called when the tool is invoked and is about to starts its work.
- *
- * @param aTool
- * the tool that is started, cannot be <code>null</code>;
- * @param aFuture
- * the future that contains the execution status of the tool, cannot
- * be <code>null</code>.
+ * @param aPercentage
*/
- void toolStarted( Tool aTool, Future<Void> aFuture );
+ void setProgress( int aPercentage );
}
View
27 ...reme/ols/client/StatusChangeListener.java → ...va/nl/lxtreme/ols/api/tools/ToolTask.java
@@ -15,31 +15,20 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*
- *
- * Copyright (C) 2010-2011 - J.W. Janssen, http://www.lxtreme.nl
+ * Copyright (C) 2006-2010 Michael Poppitz, www.sump.org
+ * Copyright (C) 2010 J.W. Janssen, www.lxtreme.nl
*/
-package nl.lxtreme.ols.client;
+package nl.lxtreme.ols.api.tools;
-import java.util.*;
+import nl.lxtreme.ols.api.task.*;
/**
- * Simple interface for a "event" mechanism that allows the diagram to update
- * the main windows status bar.
- *
- * @version 0.6
- * @author Michael "Mr. Sump" Poppitz
+ * Denotes a task that is performed by a tool, such as decoding data from
+ * acquired data.
*/
-public interface StatusChangeListener extends EventListener
+public interface ToolTask<RESULT_TYPE> extends Task<RESULT_TYPE>
{
- // METHODS
-
- /**
- * Called when the status bar text needs to change.
- *
- * @param status
- * new status bar text
- */
- public void statusChanged( String aStatus );
+ // No additional methods
}
View
3 build.sh
@@ -2,4 +2,5 @@
mvn -Dpackage.osx.skip=true $@
cd ols.distribution/target
-unzip ols-v*-full.zip plugins/
+unzip ols*-full.zip plugins/ -d ../../eclipse/run/
+rm -rf ../../eclipse/run/felix-cache
View
13 client/src/main/java/nl/lxtreme/ols/client/Activator.java
@@ -85,7 +85,7 @@
private LogReaderTracker logReaderTracker;
private ComponentProviderTracker menuTracker;
private PreferenceServiceTracker preferencesServiceTracker;
- private DataAcquisitionServiceTracker dataAcquisitionServiceTracker;
+ private SimpleDataAcquisitionService dataAcquisitionServiceTracker;
private ClientController clientController;
// METHODS
@@ -126,14 +126,14 @@ protected boolean matchesMagicValue( final ManifestHeader aHeaderEntry, final St
private static BundleObserver createDeviceBundleObserver()
{
return new BundleServiceObserver( OLS_DEVICE_MAGIC_KEY, OLS_DEVICE_MAGIC_VALUE, OLS_DEVICE_CLASS_KEY,
- DeviceController.class.getName() )
+ Device.class.getName() )
{
@Override
protected Dictionary<?, ?> getServiceProperties( final Bundle aBundle, final Object aService,
final ManifestHeader... aEntries )
{
Properties result = new Properties();
- result.put( Action.NAME, ( ( DeviceController )aService ).getName() );
+ result.put( Action.NAME, ( ( Device )aService ).getName() );
return result;
}
};
@@ -175,7 +175,7 @@ private static BundleObserver createToolBundleObserver()
final ManifestHeader... aEntries )
{
Properties result = new Properties();
- result.put( Action.NAME, ( ( Tool )aService ).getName() );
+ result.put( Action.NAME, ( ( Tool<?> )aService ).getName() );
return result;
}
};
@@ -194,7 +194,7 @@ public void start( final BundleContext aContext ) throws Exception
// Restore the implicit user settings...
loadImplicitUserSettings( this.projectManager );
- this.dataAcquisitionServiceTracker = new DataAcquisitionServiceTracker( aContext );
+ this.dataAcquisitionServiceTracker = new SimpleDataAcquisitionService( aContext );
this.dataAcquisitionServiceTracker.open();
this.clientController = new ClientController( aContext );
@@ -222,7 +222,8 @@ public void start( final BundleContext aContext ) throws Exception
// Register the client controller as listener for many events...
aContext.registerService(
new String[] { AcquisitionDataListener.class.getName(), AcquisitionProgressListener.class.getName(),
- AcquisitionStatusListener.class.getName() }, this.clientController, null );
+ AcquisitionStatusListener.class.getName(), AnnotationListener.class.getName() }, this.clientController,
+ null );
// Make sure we're running on the EDT to ensure the Swing threading model is
// correctly defined...
View
259 client/src/main/java/nl/lxtreme/ols/client/ClientController.java
@@ -24,6 +24,7 @@
import java.awt.*;
import java.io.*;
import java.util.*;
+import java.util.List;
import java.util.logging.*;
import javax.swing.*;
@@ -52,21 +53,35 @@
* Denotes a front-end controller for the client.
*/
public final class ClientController implements ActionProvider, AcquisitionProgressListener, AcquisitionStatusListener,
- AcquisitionDataListener, AnalysisCallback, IClientController
+ AcquisitionDataListener, AnnotationListener, IClientController
{
// INNER TYPES
/**
+ *
+ */
+ final class AccumulatingRepaintingRunnable extends AccumulatingRunnable<Void>
+ {
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void run( final List<Void> aArgs )
+ {
+ repaintMainFrame();
+ }
+ }
+
+ /**
* Provides a default tool context implementation.
*/
static final class DefaultToolContext implements ToolContext
{
// VARIABLES
+ private final DataContainer data;
private final int startSampleIdx;
private final int endSampleIdx;
- private final int channels;
- private final int enabledChannels;
// CONSTRUCTORS
@@ -77,18 +92,14 @@
* the starting sample index;
* @param aEndSampleIdx
* the ending sample index;
- * @param aChannels
- * the available channels in the acquisition result;
- * @param aEnabledChannels
- * the enabled channels in the acquisition result.
+ * @param aData
+ * the acquisition result.
*/
- public DefaultToolContext( final int aStartSampleIdx, final int aEndSampleIdx, final int aChannels,
- final int aEnabledChannels )
+ public DefaultToolContext( final int aStartSampleIdx, final int aEndSampleIdx, final DataContainer aData )
{
this.startSampleIdx = aStartSampleIdx;
this.endSampleIdx = aEndSampleIdx;
- this.channels = aChannels;
- this.enabledChannels = aEnabledChannels;
+ this.data = aData;
}
/**
@@ -97,7 +108,25 @@ public DefaultToolContext( final int aStartSampleIdx, final int aEndSampleIdx, f
@Override
public int getChannels()
{
- return this.channels;
+ return this.data.getChannels();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Long getCursorPosition( final int aIndex )
+ {
+ return this.data.getCursorPosition( aIndex );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public AcquisitionResult getData()
+ {
+ return this.data;
}
/**
@@ -106,7 +135,7 @@ public int getChannels()
@Override
public int getEnabledChannels()
{
- return this.enabledChannels;
+ return this.data.getEnabledChannels();
}
/**
@@ -137,6 +166,24 @@ public int getStartSampleIndex()
}
}
+ /**
+ * A runnable implementation that accumulates several calls to avoid an
+ * avalanche of events on the EDT.
+ */
+ final class ProgressUpdatingRunnable extends AccumulatingRunnable<Integer>
+ {
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void run( final List<Integer> aArgs )
+ {
+ final Integer percentage = aArgs.get( aArgs.size() - 1 );
+ setProgressOnEDT( percentage.intValue() );
+ updateActionsOnEDT();
+ }
+ }
+
// CONSTANTS
private static final Logger LOG = Logger.getLogger( ClientController.class.getName() );
@@ -153,6 +200,8 @@ public int getStartSampleIndex()
private DataAcquisitionService dataAcquisitionService;
private final EventListenerList evenListeners;
+ private final ProgressUpdatingRunnable progressAccumulatingRunnable;
+ private final AccumulatingRepaintingRunnable repaintAccumulatingRunnable;
private volatile MainFrame mainFrame;
private volatile String selectedDevice;
@@ -177,6 +226,9 @@ public ClientController( final BundleContext aBundleContext )
this.evenListeners = new EventListenerList();
this.actionManager = ActionManagerFactory.createActionManager( this );
+
+ this.progressAccumulatingRunnable = new ProgressUpdatingRunnable();
+ this.repaintAccumulatingRunnable = new AccumulatingRepaintingRunnable();
}
// METHODS
@@ -220,8 +272,7 @@ else if ( aStatus.isFailed() )
@Override
public void acquisitionInProgress( final int aPercentage )
{
- setProgressOnEDT( aPercentage );
- updateActionsOnEDT();
+ this.progressAccumulatingRunnable.add( Integer.valueOf( aPercentage ) );
}
/**
@@ -273,38 +324,9 @@ public void run()
}
/**
- * @see nl.lxtreme.ols.api.tools.AnalysisCallback#analysisAborted(java.lang.String)
- */
- @Override
- public void analysisAborted( final String aReason )
- {
- setStatusOnEDT( "Analysis aborted! {0}", aReason );
-
- updateActionsOnEDT();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void analysisComplete( final AcquisitionResult aNewData )
- {
- if ( aNewData != null )
- {
- this.dataContainer.setCapturedData( aNewData );
- }
- if ( this.mainFrame != null )
- {
- repaintMainFrame();
- }
-
- setStatusOnEDT( "" );
- updateActionsOnEDT();
- }
-
- /**
* @see nl.lxtreme.ols.client.IClientController#cancelCapture()
*/
+ @Override
public void cancelCapture()
{
final DataAcquisitionService acquisitionService = getDataAcquisitionService();
@@ -319,29 +341,29 @@ public void cancelCapture()
/**
* {@inheritDoc}
*/
+ @Override
public boolean captureData( final Window aParent )
{
final DataAcquisitionService acquisitionService = getDataAcquisitionService();
- final DeviceController devCtrl = getDeviceController();
- if ( ( devCtrl == null ) || ( acquisitionService == null ) )
+ final Device device = getDevice();
+ if ( ( device == null ) || ( acquisitionService == null ) )
{
return false;
}
try
{
- if ( devCtrl.setupCapture( aParent ) )
+ if ( device.setupCapture( aParent ) )
{
- setStatusOnEDT( "Capture from {0} started at {1,date,medium} {1,time,medium} ...", devCtrl.getName(),
- new Date() );
+ setStatusOnEDT( "Capture from {0} started at {1,date,medium} {1,time,medium} ...", device.getName(), new Date() );
- acquisitionService.acquireData( devCtrl );
+ acquisitionService.acquireData( device );
return true;
}
return false;
}
- catch ( IOException exception )
+ catch ( final IOException exception )
{
setStatusOnEDT( "I/O problem: " + exception.getMessage() );
@@ -362,6 +384,7 @@ public boolean captureData( final Window aParent )
/**
* {@inheritDoc}
*/
+ @Override
public void clearAllCursors()
{
for ( int i = 0; i < Ols.MAX_CURSORS; i++ )
@@ -376,6 +399,28 @@ public void clearAllCursors()
/**
* {@inheritDoc}
*/
+ @Override
+ public void clearAnnotations()
+ {
+ for ( int i = 0; i < Ols.MAX_CHANNELS; i++ )
+ {
+ clearAnnotations( i );
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void clearAnnotations( final int aChannelIdx )
+ {
+ this.dataContainer.clearChannelAnnotations( aChannelIdx );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void createNewProject()
{
this.projectManager.createNewProject();
@@ -391,6 +436,7 @@ public void createNewProject()
/**
* {@inheritDoc}
*/
+ @Override
public void exit()
{
try
@@ -400,15 +446,15 @@ public void exit()
// next time...
this.bundleContext.getBundle( 0 ).stop( Bundle.STOP_TRANSIENT );
}
- catch ( IllegalStateException ex )
+ catch ( final IllegalStateException ex )
{
LOG.warning( "Bundle context no longer valid while shutting down client?!" );
// The bundle context is no longer valid; we're going to exit anyway, so
// lets ignore this exception for now...
System.exit( -1 );
}
- catch ( BundleException be )
+ catch ( final BundleException be )
{
LOG.warning( "Bundle context no longer valid while shutting down client?!" );
@@ -419,6 +465,7 @@ public void exit()
/**
* {@inheritDoc}
*/
+ @Override
public void exportTo( final String aExporterName, final File aExportFile ) throws IOException
{
if ( this.mainFrame == null )
@@ -448,6 +495,7 @@ public void exportTo( final String aExporterName, final File aExportFile ) throw
/**
* @see nl.lxtreme.ols.client.ActionProvider#getAction(java.lang.String)
*/
+ @Override
public Action getAction( final String aID )
{
return this.actionManager.getAction( aID );
@@ -456,6 +504,7 @@ public Action getAction( final String aID )
/**
* {@inheritDoc}
*/
+ @Override
public DataContainer getDataContainer()
{
return this.dataContainer;
@@ -466,7 +515,7 @@ public DataContainer getDataContainer()
*
* @return the current device controller, can be <code>null</code>.
*/
- public final DeviceController getDeviceController()
+ public final Device getDevice()
{
if ( this.selectedDevice != null )
{
@@ -484,7 +533,7 @@ public final DeviceController getDeviceController()
*/
public String[] getDeviceNames()
{
- return getAllServiceNamesFor( DeviceController.class );
+ return getAllServiceNamesFor( Device.class );
}
/**
@@ -548,6 +597,7 @@ public final DiagramSettings getDiagramSettings()
/**
* {@inheritDoc}
*/
+ @Override
public File getProjectFilename()
{
return this.projectManager.getCurrentProject().getFilename();
@@ -567,6 +617,7 @@ public File getProjectFilename()
/**
* {@inheritDoc}
*/
+ @Override
public void gotoCursorPosition( final int aCursorIdx )
{
if ( ( this.mainFrame != null ) && this.dataContainer.isCursorsEnabled() )
@@ -582,6 +633,7 @@ public void gotoCursorPosition( final int aCursorIdx )
/**
* {@inheritDoc}
*/
+ @Override
public void gotoFirstAvailableCursor()
{
if ( ( this.mainFrame != null ) && this.dataContainer.isCursorsEnabled() )
@@ -604,6 +656,7 @@ public void gotoFirstAvailableCursor()
/**
* {@inheritDoc}
*/
+ @Override
public void gotoLastAvailableCursor()
{
if ( ( this.mainFrame != null ) && this.dataContainer.isCursorsEnabled() )
@@ -626,6 +679,7 @@ public void gotoLastAvailableCursor()
/**
* {@inheritDoc}
*/
+ @Override
public void gotoTriggerPosition()
{
if ( ( this.mainFrame != null ) && this.dataContainer.hasTriggerData() )
@@ -638,6 +692,7 @@ public void gotoTriggerPosition()
/**
* {@inheritDoc}
*/
+ @Override
public boolean isDeviceSelected()
{
return this.selectedDevice != null;
@@ -646,14 +701,16 @@ public boolean isDeviceSelected()
/**
* {@inheritDoc}
*/
+ @Override
public boolean isDeviceSetup()
{
- return isDeviceSelected() && getDeviceController().isSetup();
+ return isDeviceSelected() && getDevice().isSetup();
}
/**
* {@inheritDoc}
*/
+ @Override
public boolean isProjectChanged()
{
return this.projectManager.getCurrentProject().isChanged();
@@ -662,6 +719,29 @@ public boolean isProjectChanged()
/**
* {@inheritDoc}
*/
+ @Override
+ public void onAnnotation( final Annotation<?> aAnnotation )
+ {
+ if ( aAnnotation instanceof DataAnnotation )
+ {
+ final DataAnnotation<?> dataAnnotation = ( DataAnnotation<?> )aAnnotation;
+
+ this.dataContainer.addChannelAnnotation( dataAnnotation.getChannel(), dataAnnotation.getStartSampleIndex(),
+ dataAnnotation.getEndSampleIndex(), dataAnnotation.getAnnotation() );
+
+ // Accumulate repaint events to avoid an avalanche of events on the EDT...
+ this.repaintAccumulatingRunnable.add( ( Void )null );
+ }
+ else
+ {
+ this.dataContainer.setChannelLabel( aAnnotation.getChannel(), aAnnotation.toString() );
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void openDataFile( final File aFile ) throws IOException
{
final FileReader reader = new FileReader( aFile );
@@ -690,6 +770,7 @@ public void openDataFile( final File aFile ) throws IOException
/**
* {@inheritDoc}
*/
+ @Override
public void openProjectFile( final File aFile ) throws IOException
{
FileInputStream fis = null;
@@ -716,6 +797,7 @@ public void openProjectFile( final File aFile ) throws IOException
/**
* {@inheritDoc}
*/
+ @Override
public void removeCursor( final int aCursorIdx )
{
if ( this.mainFrame != null )
@@ -769,10 +851,11 @@ public void run()
/**
* {@inheritDoc}
*/
+ @Override
public boolean repeatCaptureData( final Window aParent )
{
final DataAcquisitionService acquisitionService = getDataAcquisitionService();
- final DeviceController devCtrl = getDeviceController();
+ final Device devCtrl = getDevice();
if ( ( devCtrl == null ) || ( acquisitionService == null ) )
{
return false;
@@ -786,7 +869,7 @@ public boolean repeatCaptureData( final Window aParent )
return true;
}
- catch ( IOException exception )
+ catch ( final IOException exception )
{
setStatusOnEDT( "I/O problem: " + exception.getMessage() );
@@ -811,14 +894,15 @@ public boolean repeatCaptureData( final Window aParent )
* @param aParent
* the parent window to use, can be <code>null</code>.
*/
+ @Override
public void runTool( final String aToolName, final Window aParent )
{
if ( LOG.isLoggable( Level.INFO ) )
{
LOG.log( Level.INFO, "Running tool: \"{0}\" ...", aToolName );
}
- final Tool tool = getTool( aToolName );
+ final Tool<?> tool = getTool( aToolName );
if ( tool == null )
{
JOptionPane.showMessageDialog( aParent, "No such tool found: " + aToolName, "Error ...",
@@ -827,7 +911,7 @@ public void runTool( final String aToolName, final Window aParent )
else
{
final ToolContext context = createToolContext();
- tool.process( aParent, this.dataContainer, context, this );
+ tool.invoke( aParent, context );
}
updateActionsOnEDT();
@@ -836,6 +920,7 @@ public void runTool( final String aToolName, final Window aParent )
/**
* {@inheritDoc}
*/
+ @Override
public void saveDataFile( final File aFile ) throws IOException
{
final FileWriter writer = new FileWriter( aFile );
@@ -857,6 +942,7 @@ public void saveDataFile( final File aFile ) throws IOException
/**
* {@inheritDoc}
*/
+ @Override
public void saveProjectFile( final String aName, final File aFile ) throws IOException
{
FileOutputStream out = null;
@@ -895,6 +981,7 @@ public void selectDevice( final String aDeviceName )
* <code>true</code> if the cursors should be enabled,
* <code>false</code> otherwise.
*/
+ @Override
public void setCursorMode( final boolean aState )
{
this.dataContainer.setCursorEnabled( aState );
@@ -907,6 +994,7 @@ public void setCursorMode( final boolean aState )
/**
* {@inheritDoc}
*/
+ @Override
public void setCursorPosition( final int aCursorIdx, final Point aLocation )
{
// Implicitly enable cursor mode, the user already had made its
@@ -949,6 +1037,7 @@ public void setMainFrame( final MainFrame aMainFrame )
* Shows the "about OLS" dialog on screen. the parent window to use, can be
* <code>null</code>.
*/
+ @Override
public void showAboutBox()
{
if ( this.mainFrame != null )
@@ -960,9 +1049,10 @@ public void showAboutBox()
/**
* {@inheritDoc}
*/
+ @Override
public void showBundlesDialog( final Window aOwner )
{
- BundlesDialog dialog = new BundlesDialog( aOwner, this.bundleContext );
+ final BundlesDialog dialog = new BundlesDialog( aOwner, this.bundleContext );
if ( dialog.showDialog() )
{
dialog.dispose();
@@ -972,11 +1062,12 @@ public void showBundlesDialog( final Window aOwner )
/**
* {@inheritDoc}
*/
+ @Override
public void showChannelLabelsDialog( final Window aParent )
{
if ( this.mainFrame != null )
{
- DiagramLabelsDialog dialog = new DiagramLabelsDialog( aParent, this.dataContainer.getChannelLabels() );
+ final DiagramLabelsDialog dialog = new DiagramLabelsDialog( aParent, this.dataContainer.getChannelLabels() );
if ( dialog.showDialog() )
{
final String[] channelLabels = dialog.getChannelLabels();
@@ -990,11 +1081,12 @@ public void showChannelLabelsDialog( final Window aParent )
/**
* {@inheritDoc}
*/
+ @Override
public void showDiagramModeSettingsDialog( final Window aParent )
{
if ( this.mainFrame != null )
{
- ModeSettingsDialog dialog = new ModeSettingsDialog( aParent, getDiagramSettings() );
+ final ModeSettingsDialog dialog = new ModeSettingsDialog( aParent, getDiagramSettings() );
if ( dialog.showDialog() )
{
final DiagramSettings settings = dialog.getDiagramSettings();
@@ -1009,9 +1101,10 @@ public void showDiagramModeSettingsDialog( final Window aParent )
/**
* {@inheritDoc}
*/
+ @Override
public void showPreferencesDialog( final Window aParent )
{
- GeneralSettingsDialog dialog = new GeneralSettingsDialog( aParent, getDiagramSettings() );
+ final GeneralSettingsDialog dialog = new GeneralSettingsDialog( aParent, getDiagramSettings() );
if ( dialog.showDialog() )
{
final DiagramSettings settings = dialog.getDiagramSettings();
@@ -1023,18 +1116,9 @@ public void showPreferencesDialog( final Window aParent )
}
/**
- * @see nl.lxtreme.ols.api.ProgressCallback#updateProgress(int)
- */
- @Override
- public void updateProgress( final int aPercentage )
- {
- setProgressOnEDT( aPercentage );
- updateActionsOnEDT();
- }
-
- /**
* {@inheritDoc}
*/
+ @Override
public void zoomDefault()
{
if ( this.mainFrame != null )
@@ -1048,6 +1132,7 @@ public void zoomDefault()
/**
* {@inheritDoc}
*/
+ @Override
public void zoomIn()
{
if ( this.mainFrame != null )
@@ -1061,6 +1146,7 @@ public void zoomIn()
/**
* {@inheritDoc}
*/
+ @Override
public void zoomOut()
{
if ( this.mainFrame != null )
@@ -1074,6 +1160,7 @@ public void zoomOut()
/**
* {@inheritDoc}
*/
+ @Override
public void zoomToFit()
{
if ( this.mainFrame != null )
@@ -1129,6 +1216,7 @@ final void setProgressOnEDT( final int aPercentage )
{
SwingComponentUtils.invokeOnEDT( new Runnable()
{
+ @Override
public void run()
{
ClientController.this.mainFrame.setProgress( aPercentage );
@@ -1175,14 +1263,15 @@ final void updateActionsOnEDT()
{
SwingComponentUtils.invokeOnEDT( new Runnable()
{
+ @Override
public void run()
{
final DataAcquisitionService acquisitionService = getDataAcquisitionService();
- final DeviceController deviceCtrl = getDeviceController();
+ final Device device = getDevice();
- final boolean deviceControllerSet = deviceCtrl != null;
+ final boolean deviceControllerSet = ( device != null );
final boolean deviceCapturing = ( acquisitionService != null ) && acquisitionService.isAcquiring();
- final boolean deviceSetup = deviceControllerSet && !deviceCapturing && deviceCtrl.isSetup();
+ final boolean deviceSetup = deviceControllerSet && !deviceCapturing && device.isSetup();
getAction( CaptureAction.ID ).setEnabled( deviceControllerSet );
getAction( CancelCaptureAction.ID ).setEnabled( deviceCapturing );
@@ -1232,14 +1321,14 @@ public void run()
// Update the tools...
final IManagedAction[] toolActions = ClientController.this.actionManager.getActionByType( RunToolAction.class );
- for ( IManagedAction toolAction : toolActions )
+ for ( final IManagedAction toolAction : toolActions )
{
toolAction.setEnabled( dataAvailable );
}
// Update the exporters...
final IManagedAction[] exportActions = ClientController.this.actionManager.getActionByType( ExportAction.class );
- for ( IManagedAction exportAction : exportActions )
+ for ( final IManagedAction exportAction : exportActions )
{
exportAction.setEnabled( dataAvailable );
}
@@ -1296,7 +1385,7 @@ private ToolContext createToolContext()
enabledChannels = NumberUtils.getBitMask( channels );
}
- return new DefaultToolContext( startOfDecode, endOfDecode, channels, enabledChannels );
+ return new DefaultToolContext( startOfDecode, endOfDecode, this.dataContainer );
}
/**
@@ -1338,7 +1427,7 @@ private void fireCursorChangedEvent( final int aCursorIdx, final int aMouseXpos
*/
private String[] getAllServiceNamesFor( final Class<?> aServiceClass )
{
- String[] result = this.osgiHelper.getAllServicePropertiesFor( Action.NAME, aServiceClass );
+ final String[] result = this.osgiHelper.getAllServicePropertiesFor( Action.NAME, aServiceClass );
Arrays.sort( result );
return result;
}
@@ -1356,9 +1445,9 @@ private DataAcquisitionService getDataAcquisitionService()
/**
* {@inheritDoc}
*/
- private DeviceController getDeviceController( final String aName ) throws IllegalArgumentException
+ private Device getDeviceController( final String aName ) throws IllegalArgumentException
{
- return this.osgiHelper.getService( DeviceController.class, Action.NAME, aName );
+ return this.osgiHelper.getService( Device.class, Action.NAME, aName );
}
/**
@@ -1372,7 +1461,7 @@ private Exporter getExporter( final String aName ) throws IllegalArgumentExcepti
/**
* {@inheritDoc}
*/
- private Tool getTool( final String aName ) throws IllegalArgumentException
+ private Tool<?> getTool( final String aName ) throws IllegalArgumentException
{
return this.osgiHelper.getService( Tool.class, Action.NAME, aName );
}
View
2 client/src/main/java/nl/lxtreme/ols/client/action/RunToolAction.java
@@ -86,7 +86,7 @@ public static final String getID( final String aToolName )
* a tool instance, cannot be <code>null</code>.
* @return a tool action identifier, never <code>null</code>.
*/
- public static final String getID( final Tool aTool )
+ public static final String getID( final Tool<?> aTool )
{
if ( aTool == null )
{
View
2 client/src/main/java/nl/lxtreme/ols/client/action/manager/ActionManagerFactory.java
@@ -76,7 +76,7 @@ private static void fillActionManager( final ActionManager aActionManager, final
aActionManager.add( new SaveDataFileAction( aController ) ).setEnabled( false );
aActionManager.add( new ExitAction( aController ) );
- aActionManager.add( new CaptureAction( aController ) );
+ aActionManager.add( new CaptureAction( aController ) ).setEnabled( false );
aActionManager.add( new CancelCaptureAction( aController ) ).setEnabled( false );
aActionManager.add( new RepeatCaptureAction( aController ) ).setEnabled( false );
View
109 client/src/main/java/nl/lxtreme/ols/client/osgi/DataAcquisitionServiceTracker.java
@@ -1,109 +0,0 @@
-/*
- * OpenBench LogicSniffer / SUMP project
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
- *
- * Copyright (C) 2006-2010 Michael Poppitz, www.sump.org
- * Copyright (C) 2010 J.W. Janssen, www.lxtreme.nl
- */
-package nl.lxtreme.ols.client.osgi;
-
-
-import java.io.*;
-import java.util.logging.*;
-
-import nl.lxtreme.ols.api.*;
-import nl.lxtreme.ols.api.devices.*;
-
-import org.osgi.framework.*;
-import org.osgi.util.tracker.*;
-
-
-/**
- *
- */
-public class DataAcquisitionServiceTracker extends ServiceTracker implements DataAcquisitionService
-{
- // CONSTANTS
-
- private static final Logger LOG = Logger.getLogger( DataAcquisitionServiceTracker.class.getName() );
-
- // CONSTRUCTORS
-
- /**
- * Creates a new DataAcquisitionServiceTracker instance.
- *
- * @param aContext
- * the bundle context to use.
- */
- public DataAcquisitionServiceTracker( final BundleContext aContext )
- {
- super( aContext, DataAcquisitionService.class.getName(), null /* aCustomizer */);
- }
-
- // METHODS
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void acquireData( final DeviceController aDeviceController ) throws IOException
- {
- final DataAcquisitionService dataAcquisitionService = ( DataAcquisitionService )getService();
- if ( dataAcquisitionService != null )
- {
- dataAcquisitionService.acquireData( aDeviceController );
- }
- else
- {
- LOG.warning( "No data acquisition service found!" );
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void cancelAcquisition() throws IllegalStateException
- {
- final DataAcquisitionService dataAcquisitionService = ( DataAcquisitionService )getService();
- if ( dataAcquisitionService != null )
- {
- dataAcquisitionService.cancelAcquisition();
- }
- else
- {
- LOG.warning( "No data acquisition service found!" );
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isAcquiring()
- {
- final DataAcquisitionService dataAcquisitionService = ( DataAcquisitionService )getService();
- if ( dataAcquisitionService != null )
- {
- return dataAcquisitionService.isAcquiring();
- }
- else
- {
- LOG.warning( "No data acquisition service found!" );
- }
- return false;
- }
-}
View
386 client/src/main/java/nl/lxtreme/ols/client/osgi/SimpleDataAcquisitionService.java
@@ -0,0 +1,386 @@
+/*
+ * OpenBench LogicSniffer / SUMP project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Copyright (C) 2006-2010 Michael Poppitz, www.sump.org
+ * Copyright (C) 2010 J.W. Janssen, www.lxtreme.nl
+ */
+package nl.lxtreme.ols.client.osgi;
+
+
+import java.io.*;
+import java.util.concurrent.*;
+import java.util.logging.*;
+
+import nl.lxtreme.ols.api.*;
+import nl.lxtreme.ols.api.acquisition.*;
+import nl.lxtreme.ols.api.acquisition.AcquisitionResultStatus.ResultStatus;
+import nl.lxtreme.ols.api.devices.*;
+import nl.lxtreme.ols.api.task.*;
+import nl.lxtreme.ols.util.osgi.*;
+
+import org.osgi.framework.*;
+
+
+/**
+ *
+ */
+public class SimpleDataAcquisitionService implements DataAcquisitionService, TaskStatusListener
+{
+ // INNER TYPES
+
+ /**
+ *
+ */
+ static final class DataAcquisitionDataListener implements AcquisitionDataListener
+ {
+ // VARIABLES
+
+ private final WhiteboardHelper<AcquisitionDataListener> acquisitionDataListenerHelper;
+
+ // CONSTRUCTORS
+
+ /**
+ * Creates a new DataAcquisitionDataListener instance.
+ */
+ public DataAcquisitionDataListener( final BundleContext aContext )
+ {
+ this.acquisitionDataListenerHelper = new WhiteboardHelper<AcquisitionDataListener>( aContext,
+ AcquisitionDataListener.class );
+ }
+
+ // METHODS
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void acquisitionComplete( final AcquisitionResult aData )
+ {
+ this.acquisitionDataListenerHelper.accept( new WhiteboardHelper.Visitor<AcquisitionDataListener>()
+ {
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void visit( final AcquisitionDataListener aService )
+ {
+ aService.acquisitionComplete( aData );
+ }
+ } );
+ }
+
+ /**
+ *
+ */
+ public void close()
+ {
+ this.acquisitionDataListenerHelper.close();
+ }
+
+ /**
+ *
+ */
+ public void open()
+ {
+ this.acquisitionDataListenerHelper.open( true /* trackAllServices */);
+ }
+ }
+
+ /**
+ * Helper for propagating {@link AcquisitionProgressListener} events to their
+ * implementors.
+ */
+ static final class DataAcquisitionProgressListener implements AcquisitionProgressListener
+ {
+ // VARIABLES
+
+ private final WhiteboardHelper<AcquisitionProgressListener> acquisitionProgressListenerHelper;
+
+ // CONSTRUCTORS
+
+ /**
+ * Creates a new DataAcquisitionProgressListener instance.
+ */
+ public DataAcquisitionProgressListener( final BundleContext aContext )
+ {
+ this.acquisitionProgressListenerHelper = new WhiteboardHelper<AcquisitionProgressListener>( aContext,
+ AcquisitionProgressListener.class );
+ }
+
+ // METHODS
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void acquisitionInProgress( final int aPercentage )
+ {
+ this.acquisitionProgressListenerHelper.accept( new WhiteboardHelper.Visitor<AcquisitionProgressListener>()
+ {
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void visit( final AcquisitionProgressListener aService )
+ {
+ aService.acquisitionInProgress( aPercentage );
+ }
+ } );
+ }
+
+ /**
+ *
+ */
+ public void close()
+ {
+ this.acquisitionProgressListenerHelper.close();
+ }
+
+ /**
+ *
+ */
+ public void open()
+ {
+ this.acquisitionProgressListenerHelper.open( true /* trackAllServices */);
+ }
+ }
+
+ /**
+ *
+ */
+ static final class DataAcquisitionStatusListener implements AcquisitionStatusListener
+ {
+ // VARIABLES
+
+ private final WhiteboardHelper<AcquisitionStatusListener> acquisitionStatusListenerHelper;
+
+ // CONSTRUCTORS
+
+ /**
+ * Creates a new DataAcquisitionStatusListener instance.
+ */
+ public DataAcquisitionStatusListener( final BundleContext aContext )
+ {
+ this.acquisitionStatusListenerHelper = new WhiteboardHelper<AcquisitionStatusListener>( aContext,
+ AcquisitionStatusListener.class );
+ }
+
+ // METHODS
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void acquisitionEnded( final AcquisitionResultStatus aStatus )
+ {
+ this.acquisitionStatusListenerHelper.accept( new WhiteboardHelper.Visitor<AcquisitionStatusListener>()
+ {
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+