Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Instrument Control
NomadSpecialModules
Commits
0556f6c7
Commit
0556f6c7
authored
Aug 18, 2016
by
Cristina Cocho
Browse files
Avoid having big delays when using QE65000
parent
fcc56f7d
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/drivers/oceanoptics/QE65000Driver.cpp
View file @
0556f6c7
...
...
@@ -38,6 +38,7 @@ QE65000Driver::QE65000Driver(const std::string& name) : DeviceDriver(name) {
//Init Properties
integrationTime
.
init
(
this
,
SAVE
,
"integration_time"
);
isActive
.
init
(
this
,
SAVE
,
"isActive"
);
openError
.
init
(
this
,
NOSAVE
,
"open_error"
);
xData
.
init
(
this
,
NOSAVE
,
"x_data"
);
yData
.
init
(
this
,
NOSAVE
,
"y_data"
);
size
.
init
(
this
,
SAVE
,
"size"
);
...
...
@@ -45,12 +46,14 @@ QE65000Driver::QE65000Driver(const std::string& name) : DeviceDriver(name) {
//Init functions
registerFunction
(
NONE_FUNCTION
);
initCommand
(
driver
::
INIT_COMMAND
);
//Root device -> it is directly plugged in port USB of the PC
updateValue
(
DEVICE_TYPE_DEVICE_CONTAINER
,
std
::
string
(
ROOT_DEVICE_TYPE_DEVICE_CONTAINER
));
//Register the Spy and Observer commands necessary to do the updates.
//
registerSpyCommand(driver::STATUS_COMMAND, 1);
//
registerObserverCommand(driver::STATUS_COMMAND, 20);
registerSpyCommand
(
driver
::
STATUS_COMMAND
,
1
);
registerObserverCommand
(
driver
::
STATUS_COMMAND
,
20
);
}
...
...
@@ -58,15 +61,9 @@ QE65000Driver::~QE65000Driver() {
}
void
QE65000Driver
::
execute
(
const
std
::
string
&
aCommand
)
{
//Get the state where to execute the accion
QE65000State
*
currentState
=
dynamic_cast
<
QE65000State
*>
(
getCurrentState
());
// if ((aCommand != COMMAND_STOP_DEVICE_CONTAINER) && (aCommand != COMMAND_START_DEVICE_CONTAINER)) {
// //cout << "sending unknown state" << endl;
// sendProgressEvent(PROGRESSION_UNKNOWNSTATE_DEVICE_CONTAINER);
// }
if
(
aCommand
==
driver
::
START_COMMAND
)
{
//begin reading
currentState
->
start
();
...
...
src/drivers/oceanoptics/QE65000Driver.h
View file @
0556f6c7
...
...
@@ -20,6 +20,7 @@
#define QE65000DRIVER_H_
#include <Driver.h>
#include "drivers/legacy/def/DriverErrorDef.h"
namespace
oceanoptics
{
...
...
@@ -27,11 +28,13 @@ class QE65000Driver : public DeviceDriver {
public:
static
const
std
::
string
TYPE
;
static
const
int32
PLUGGED
;
static
const
int32
UNPLUGGED
;
Property
<
int32
>
integrationTime
;
//Time in microseconds!!
Property
<
bool
>
isActive
;
Property
<
bool
>
openError
;
ArrayProperty
<
float64
>
yData
;
ArrayProperty
<
float64
>
xData
;
...
...
src/drivers/oceanoptics/RealQE65000Driver.cpp
View file @
0556f6c7
...
...
@@ -22,8 +22,6 @@
#include <iomanip>
#include "api/seabreezeapi/SeaBreezeAPI.h"
#include "api/SeaBreezeWrapper.h"
#include <common/base/Date.h>
using
namespace
std
;
...
...
@@ -41,6 +39,8 @@ RealQE65000Driver::~RealQE65000Driver() {
}
void
RealQE65000Driver
::
init
()
{
owner
()
->
commandProgression
=
10
;
//Get deviceID necessary to use library methods
sbapi_initialize
();
sbapi_probe_devices
();
...
...
@@ -53,23 +53,27 @@ void RealQE65000Driver::init() {
if
(
result
==
0
)
{
int32
error
=
0
;
owner
()
->
size
=
sbapi_spectrometer_get_formatted_spectrum_length
(
deviceId
,
spectrometerId
,
&
error
);
owner
()
->
openError
=
false
;
}
else
{
owner
()
->
openError
=
true
;
}
sbapi_close_device
(
deviceId
,
&
error
);
//compulsory to have!
owner
()
->
commandProgression
=
PROGRESSION_END_DEVICE_CONTAINER
;
owner
()
->
commandProgression
=
PROGRESSION_END_DEVICE_CONTAINER
;
}
void
RealQE65000Driver
::
start
()
{
int32
error
=
0
;
owner
()
->
openError
=
false
;
//Delete current arrays
delete
[]
owner
()
->
xData
()
;
delete
[]
owner
()
->
y
Data
();
common
::
Date
startTime
=
common
::
Dat
e
();
cout
<<
"starting spectro "
<<
owner
()
->
integrationTime
()
<<
endl
;
if
(
owner
()
->
xData
()
)
{
delete
[]
owner
()
->
x
Data
();
}
else
if
(
owner
()
->
yData
())
{
delete
[]
owner
()
->
y
Dat
a
();
}
//Modification of 17/08/2016 -> really slow access to the following methods. Call them only in init method.
// //Get deviceID necessary to use library methods
// sbapi_initialize();
// sbapi_probe_devices();
...
...
@@ -77,6 +81,8 @@ void RealQE65000Driver::start() {
// //Retrieve necessary ids
// getDeviceID();
// getSpectroID();
//End of modification of 17/08/2016
//Open device
int32
result
=
sbapi_open_device
(
deviceId
,
&
error
);
if
(
result
==
0
)
{
...
...
@@ -93,34 +99,34 @@ void RealQE65000Driver::start() {
owner
()
->
commandProgression
=
PROGRESSION_END_DEVICE_CONTAINER
;
sbapi_close_device
(
deviceId
,
&
error
);
}
else
{
cout
<<
"error opening the device"
<<
endl
;
owner
()
->
openError
=
true
;
//throw CannotOpenDevice(owner()->getType(), owner()->getName(), owner(), "Cannot open QE65000 spectrometer");
}
common
::
Date
time1
=
common
::
Date
();
common
::
Duration
duration
=
time1
-
startTime
;
cout
<<
"end of spectro "
<<
duration
.
getMilliseconds
()
<<
endl
;
}
void
RealQE65000Driver
::
stop
()
{
cout
<<
"in stop Realqe65000"
<<
endl
;
owner
()
->
commandProgression
=
PROGRESSION_END_DEVICE_CONTAINER
;
}
/**
* Check the status of the spectrometer: plugged or unplugged
* Check the status of the spectrometer: plugged or unplugged
. NOT USED !
*/
void
RealQE65000Driver
::
readStatus
()
{
cout
<<
"reading qe65000 status"
<<
endl
;
//time consuming methods
// sbapi_initialize();
// sbapi_probe_devices();
// int32 numberOfDevices = sbapi_get_number_of_device_ids();
// if (numberOfDevices != 0) {
// owner()->status.update(QE65000Driver::PLUGGED);
//
// } else {
// owner()->status.update(QE65000Driver::UNPLUGGED);
// }
//end of time consuming methods
int32
numberOfDevices
=
sbapi_get_number_of_device_ids
();
if
(
numberOfDevices
!=
0
)
{
owner
()
->
status
.
update
(
QE65000Driver
::
PLUGGED
);
}
else
{
owner
()
->
status
.
update
(
QE65000Driver
::
UNPLUGGED
);
}
}
void
RealQE65000Driver
::
getDeviceID
()
{
...
...
@@ -128,11 +134,14 @@ void RealQE65000Driver::getDeviceID() {
int32
numberOfDevices
=
sbapi_get_number_of_device_ids
();
//Provides the number of devices that have either been probed or manually specified
if
(
numberOfDevices
==
0
)
{
// error uhuuu
owner
()
->
status
.
update
(
QE65000Driver
::
UNPLUGGED
);
owner
()
->
commandProgression
=
PROGRESSION_END_DEVICE_CONTAINER
;
return
;
}
else
if
(
numberOfDevices
>
1
)
{
// we will only use one by now...
cout
<<
"more than one device"
<<
endl
;
owner
()
->
status
.
update
(
QE65000Driver
::
PLUGGED
);
}
sbapi_get_device_ids
(
&
deviceId
,
1
);
//Only one device...
...
...
src/drivers/oceanoptics/RealQE65000Driver.h
View file @
0556f6c7
...
...
@@ -26,6 +26,17 @@ namespace oceanoptics {
class
RealQE65000Driver
:
public
QE65000State
{
public:
/*
* Cannot open open device
*/
// class CannotOpenDevice: public NotOk {
// public:
// CannotOpenDevice(const std::string& type, const std::string& name, Publisher* publisher, const std::string& info) :
// NotOk(type, name, publisher, OPEN_DEVICE_ERROR, info) {
// }
// };
RealQE65000Driver
(
QE65000Driver
*
owner
);
virtual
~
RealQE65000Driver
();
...
...
src/drivers/oceanoptics/gui/QE65000/QE65000.properties
View file @
0556f6c7
QE650001.integration_time
=
Integration Time:
\ No newline at end of file
QE650001.integration_time
=
Integration Time:
QE650001.initCommand
=
INIT
\ No newline at end of file
src/drivers/oceanoptics/gui/QE65000/QE65000View.xml
View file @
0556f6c7
<plugin>
<controller
type=
"QE65000"
role=
"QE650001"
/>
<label
role=
"QE650001"
property=
"integration_time"
prefix=
"QE650001.integration_time"
/>
<newLine/>
<button
role=
"QE650001"
command=
"init"
prefix=
"QE650001.initCommand"
/>
</plugin>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment