Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Instrument Control
NomadSpecialModules
Commits
8a722b0f
Commit
8a722b0f
authored
Jun 25, 2014
by
Jerome Locatelli
Browse files
merge trunk to branch
parent
5022287b
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/drivers/princeton/usbpvcam/Module.xml
View file @
8a722b0f
<module
name=
"usbpvcam"
>
<driver
class=
"UsbPVCamDriver"
/>
<driver
class=
"
usbpvcam::
UsbPVCamDriver"
/>
<include
path=
"$(NOMAD_HOME)/../NomadModules/src"
/>
<link
lib=
"raw1394"
/>
<link
lib=
"pvcam"
/>
...
...
src/drivers/princeton/usbpvcam/PerfectUsbPVCamDriver.cpp
View file @
8a722b0f
...
...
@@ -21,20 +21,14 @@
#include
"PerfectUsbPVCamDriver.h"
#include
"UsbPVCamDriver.h"
#include
"UsbPVCamDef.h"
#include
"drivers/legacy/def/DetectorDef.h"
#include
"drivers/legacy/def/GateDef.h"
// Trace include
using
namespace
boost
;
namespace
usbpvcam
{
/*
* Constructor
*/
PerfectUsbPVCamDriver
::
PerfectUsbPVCamDriver
(
UsbPVCamDriver
*
owner
)
:
UsbPVCamState
(
owner
)
{
UsbPVCamState
(
owner
)
{
/* Empty */
}
...
...
@@ -51,24 +45,18 @@ void PerfectUsbPVCamDriver::init() {
/*
* clearvme/daugther/UsbPVCam
*/
void
PerfectUsbPVCamDriver
::
clear
()
const
{
void
PerfectUsbPVCamDriver
::
clear
()
{
// Read command
m_owner
->
updateValue
(
GATE_ACTUAL_TIME_DEVICE_CONTAINER
,
0.0
);
m_owner
->
updateValue
(
GATE_ACTUAL_COUNTER1_DEVICE_CONTAINER
,
0
);
m_owner
->
updateValue
(
GATE_ACTUAL_COUNTER2_DEVICE_CONTAINER
,
0
);
m_owner
->
updateValue
(
GATE_ACTUAL_COUNTER3_DEVICE_CONTAINER
,
0
);
}
/*
* write
*/
void
PerfectUsbPVCamDriver
::
write
()
const
{
owner
()
->
time
=
0
;
owner
()
->
counts
=
0
;
owner
()
->
counts2
=
0
;
owner
()
->
counts3
=
0
;
}
/*
* writeParam
*/
void
PerfectUsbPVCamDriver
::
writeParam
()
const
{
void
PerfectUsbPVCamDriver
::
writeParam
()
{
}
/*
...
...
@@ -76,7 +64,7 @@ void PerfectUsbPVCamDriver::writeParam() const {
*/
void
PerfectUsbPVCamDriver
::
synchroniseRead
()
{
read
();
dynamic_cast
<
UsbPVCamDriver
*>
(
m_
owner
)
->
m_SynchroniseReadTerminated
=
true
;
owner
(
)
->
m_SynchroniseReadTerminated
=
true
;
}
/*
...
...
@@ -84,11 +72,9 @@ void PerfectUsbPVCamDriver::synchroniseRead() {
*/
void
PerfectUsbPVCamDriver
::
read
()
{
// Read command
uint32
size
=
static_cast
<
uint32
>
(
any_cast
<
int32
>
(
m_owner
->
getValue
(
DETECTOR_DATA_SIZE_DEVICE_CONTAINER
)));
int32
size
=
owner
()
->
dataSize
();
uint32
*
tab
=
reinterpret_cast
<
uint32
*>
(
any_cast
<
int32
*>
(
m_owner
->
getValue
(
DETECTOR_DATA_DEVICE_CONTAINER
)));
int32
*
tab
=
owner
()
->
data
();
int32
sum
=
0
;
// if (m_FirstRead) {
...
...
@@ -103,11 +89,12 @@ void PerfectUsbPVCamDriver::read() {
// sum = sum + tab[i];
// }
// }
for
(
u
int32
i
=
0
;
i
<
size
;
i
++
)
{
for
(
int32
i
=
0
;
i
<
size
;
i
++
)
{
tab
[
i
]
=
i
;
sum
=
sum
+
tab
[
i
];
}
owner
()
->
sum
=
sum
;
owner
()
->
data
.
sendEvent
();
}
/*
...
...
@@ -119,15 +106,14 @@ void PerfectUsbPVCamDriver::pause() {
/*
* continue
*/
void
PerfectUsbPVCamDriver
::
continu
()
{
void
PerfectUsbPVCamDriver
::
resume
()
{
}
/*
* start
*/
void
PerfectUsbPVCamDriver
::
start
()
{
m_owner
->
updateValue
(
GATE_ACTUAL_TIME_DEVICE_CONTAINER
,
any_cast
<
float64
>
(
m_owner
->
getValue
(
GATE_WANTED_TIME_DEVICE_CONTAINER
)));
owner
()
->
time
=
owner
()
->
time
.
setpoint
();
}
/*
...
...
@@ -140,23 +126,19 @@ void PerfectUsbPVCamDriver::stop() {
* readStatus
*/
void
PerfectUsbPVCamDriver
::
readStatus
()
{
dynamic_cast
<
UsbPVCamDriver
*>
(
m_
owner
)
->
m_S
tartActivated
=
false
;
owner
(
)
->
s
tartActivated
=
false
;
// Status command
m_owner
->
updateValue
(
STATUS_DEVICE_CONTAINER
,
(
int32
)
pvcam
::
READOUT_COMPLETE
);
// Set category status before ending, synchronism for controller
m_owner
->
setCategoryStatus
();
if
(
dynamic_cast
<
UsbPVCamDriver
*>
(
m_owner
)
->
m_SynchroniseReadActivated
==
true
)
{
if
(
dynamic_cast
<
UsbPVCamDriver
*>
(
m_owner
)
->
m_SynchroniseReadTerminated
==
true
)
{
dynamic_cast
<
UsbPVCamDriver
*>
(
m_owner
)
->
m_SynchroniseReadActivated
=
false
;
dynamic_cast
<
UsbPVCamDriver
*>
(
m_owner
)
->
m_SynchroniseReadTerminated
=
false
;
m_owner
->
sendProgressEvent
(
PROGRESSION_END_DEVICE_CONTAINER
);
owner
()
->
computeGateStatus
(
pvcam
::
READOUT_COMPLETE
);
owner
()
->
computeAcquisitionStatus
(
0
);
owner
()
->
computeDetectorStatus
(
0
);
if
(
owner
()
->
m_SynchroniseReadActivated
==
true
)
{
if
(
owner
()
->
m_SynchroniseReadTerminated
==
true
)
{
owner
()
->
m_SynchroniseReadActivated
=
false
;
owner
()
->
m_SynchroniseReadTerminated
=
false
;
owner
()
->
commandProgression
=
PROGRESSION_END_DEVICE_CONTAINER
;
}
}
else
{
m_
owner
->
se
ndProgress
Event
(
PROGRESSION_END_DEVICE_CONTAINER
)
;
owner
()
->
comma
ndProgress
ion
=
PROGRESSION_END_DEVICE_CONTAINER
;
}
}
...
...
@@ -165,3 +147,5 @@ void PerfectUsbPVCamDriver::readStatus() {
*/
void
PerfectUsbPVCamDriver
::
readInfos
()
{
}
}
src/drivers/princeton/usbpvcam/PerfectUsbPVCamDriver.h
View file @
8a722b0f
...
...
@@ -21,93 +21,86 @@
#include
"UsbPVCamState.h"
class
UsbPVCamDriver
;
namespace
usbpvcam
{
/**
* Real Implementation part of the vme card called UsbPVCam made in Princeton. It needs a board called Men A201.
/*!
* \class PerfectUsbPVCamDriver
* \brief Perfect implementation class for the UsbPVCam device driver
*
* This class is a perfect implementation of UsbPVCam device driver.
* On start command, all actual values become target's ones.
*/
class
PerfectUsbPVCamDriver
:
public
UsbPVCamState
{
public:
/**
* Constructor.
*
* @param Link to the class which used the state
/*!
* \brief Constructor
* \param[in] owner The device driver main class link
*/
PerfectUsbPVCamDriver
(
UsbPVCamDriver
*
owner
);
/*
*
* Destructor
.
/*
!
*
\brief
Destructor
*/
virtual
~
PerfectUsbPVCamDriver
();
/**
* Initialisation of the device.
* Perform a Read of the gate counter.
/*!
* \brief Init command implementation
*/
virtual
void
init
();
/**
* Clear the gate.
* Perform a clear of the device to the clear all counters.
/*!
* \brief Clear command implementation
*/
virtual
void
clear
()
const
;
virtual
void
clear
();
/**
* Write the gate.
* Perform a preset of the all counters and registers.
/*!
* \brief Write Param command implementation
*/
virtual
void
write
()
const
;
virtual
void
write
Param
()
;
/**
* Write the gate.
* Perform a preset of the all counters and registers.
/*!
* \brief Read command implementation
*/
virtual
void
writeParam
()
const
;
virtual
void
read
()
;
/**
* Read the gate.
* Perform a Read of the gate counter.
/*!
* \brief Synchronize Read command implementation
*/
virtual
void
read
();
virtual
void
synchroniseRead
();
/**
* Start the gate.
* Perform a start of the device to the preset given in the the parameter.
/*!
* \brief Start command implementation
*/
virtual
void
start
();
/**
* Continue the gate.
* Perform a start of the device to the preset given in the the parameter.
/*!
* \brief Resume command implementation
*/
virtual
void
continu
();
virtual
void
resume
();
/**
* Set the gate to mode pause.
* Set the gate to the pause mode.
/*!
* \brief Pause command implementation
*/
virtual
void
stop
();
virtual
void
pause
();
/**
* Set the gate to mode pause.
* Set the gate to the pause mode.
/*!
* \brief Stop command implementation
*/
virtual
void
pause
();
virtual
void
stop
();
/**
* Read status of the gate.
* Read the status on the gate.
/*!
* \brief Read Infos command implementation
*/
virtual
void
readStatus
();
/**
* Read the informations of the hardware.
* Read the version, the date,the signatures and local device parameters.
/*!
* \brief Read Infos command implementation
*/
virtual
void
readInfos
();
};
}
#endif //PERFECTUSBPVCAMDRIVER_H
src/drivers/princeton/usbpvcam/RealUsbPVCamDriver.cpp
View file @
8a722b0f
...
...
@@ -18,20 +18,16 @@
#include
"RealUsbPVCamDriver.h"
#include
"UsbPVCamDriver.h"
#include
"drivers/legacy/def/GateDef.h"
#include
"drivers/legacy/def/DetectorDef.h"
// Trace include
#include
<cstdio>
namespace
usbpvcam
{
/*
* Constructor
*/
RealUsbPVCamDriver
::
RealUsbPVCamDriver
(
UsbPVCamDriver
*
owner
)
:
UsbPVCamState
(
owner
)
{
UsbPVCamState
(
owner
)
{
/* Empty */
}
...
...
@@ -73,20 +69,14 @@ void RealUsbPVCamDriver::init() {
/*
* clear
*/
void
RealUsbPVCamDriver
::
clear
()
const
{
memset
(
dynamic_cast
<
UsbPVCamDriver
*>
(
m_owner
)
->
m_Data
,
0
,
dynamic_cast
<
UsbPVCamDriver
*>
(
m_owner
)
->
m_DataSize
*
sizeof
(
int32
));
}
/*
* write
*/
void
RealUsbPVCamDriver
::
write
()
const
{
void
RealUsbPVCamDriver
::
clear
()
{
memset
(
owner
()
->
data
(),
0
,
owner
()
->
dataSize
()
*
sizeof
(
int32
));
}
/*
* writeParam
*/
void
RealUsbPVCamDriver
::
writeParam
()
const
{
void
RealUsbPVCamDriver
::
writeParam
()
{
}
/*
...
...
@@ -94,34 +84,33 @@ void RealUsbPVCamDriver::writeParam() const {
*/
void
RealUsbPVCamDriver
::
synchroniseRead
()
{
uint16
*
datas
=
dynamic_cast
<
UsbPVCamDriver
*>
(
m_
owner
)
->
m_DataShort
;
uint16
*
datas
=
owner
(
)
->
m_DataShort
;
/*
* Calculate the detector sum here
*/
int32
*
data
=
dynamic_cast
<
UsbPVCamDriver
*>
(
m_owner
)
->
m_Data
;
int32
*
mask
=
dynamic_cast
<
UsbPVCamDriver
*>
(
m_owner
)
->
m_Mask
;
int32
*
data
=
owner
()
->
data
();
int32
*
mask
=
owner
()
->
mask
();
int32
dataSize
=
owner
()
->
dataSize
();
float64
sum
=
0
;
if
(
datas
!=
NULL
){
for
(
int32
i
=
0
;
i
<
dynamic_cast
<
UsbPVCamDriver
*>
(
m_owner
)
->
m_D
ataSize
;
++
i
)
{
if
(
datas
!=
NULL
)
{
for
(
int32
i
=
0
;
i
<
d
ataSize
;
++
i
)
{
data
[
mask
[
i
]]
=
datas
[
i
];
//data[i] = datas[i];
sum
+=
(
float64
)
data
[
i
];
}
}
else
{
cerr
<<
"error mask "
<<
endl
;
}
else
{
cerr
<<
"error mask "
<<
endl
;
}
m_
owner
->
updateValue
(
DETECTOR_SUM_DEVICE_CONTAINER
,
sum
)
;
m_
owner
->
sendArrayEvent
(
DETECTOR_DATA_DEVICE_CONTAINER
);
owner
()
->
sum
=
sum
;
owner
()
->
data
.
sendEvent
(
);
/* Finish the sequence */
plExpFinishSeq
(
m_Handle
,
(
void
*
)
datas
,
0
);
plExpFinishSeq
(
m_Handle
,
(
void
*
)
datas
,
0
);
/*Uninit the sequence */
//plExpUninitSeq();
dynamic_cast
<
UsbPVCamDriver
*>
(
m_owner
)
->
m_SynchroniseReadTerminated
=
true
;
//plExpUninitSeq();
owner
()
->
m_SynchroniseReadTerminated
=
true
;
}
/*
...
...
@@ -135,12 +124,7 @@ void RealUsbPVCamDriver::read() {
*/
void
RealUsbPVCamDriver
::
start
()
{
Trace
::
getInstance
()
->
trace
(
"DeviceContainer"
,
"RealUsbPVCamDriver"
,
"start"
,
Level
::
s_Info
,
""
);
uint32
exp_time
=
(
uint32
)
(
any_cast
<
float64
>
(
m_owner
->
getValue
(
GATE_WANTED_TIME_DEVICE_CONTAINER
))
*
any_cast
<
int32
>
(
m_owner
->
getValue
(
GATE_PRECISION_DEVICE_CONTAINER
)));
uint32
exp_time
=
(
uint32
)
(
owner
()
->
time
.
setpoint
()
*
owner
()
->
precision
());
unsigned
long
size
;
void
*
region
=
allocRegion
();
...
...
@@ -159,10 +143,10 @@ void RealUsbPVCamDriver::start() {
if
(
plExpInitSeq
())
{
if
(
plExpSetupSeq
(
m_Handle
,
1
,
1
,
region
,
pvcam
::
TIMED_MODE
,
exp_time
,
&
size
))
{
uint16
*
datas
=
dynamic_cast
<
UsbPVCamDriver
*>
(
m_
owner
)
->
m_DataShort
;
if
(
plExpStartSeq
(
m_Handle
,
(
void
*
)
datas
)){
m_TimeCounter
.
clear
();
}
else
{
uint16
*
datas
=
owner
(
)
->
m_DataShort
;
if
(
plExpStartSeq
(
m_Handle
,
(
void
*
)
datas
))
{
m_TimeCounter
.
clear
();
}
else
{
print_pv_error
();
}
...
...
@@ -177,31 +161,21 @@ void RealUsbPVCamDriver::start() {
}
/*
*
continu
*
resume
*/
void
RealUsbPVCamDriver
::
continu
()
{
Trace
::
getInstance
()
->
trace
(
"DeviceContainer"
,
"RealUsbPVCamDriver"
,
"continu"
,
Level
::
s_Info
,
""
);
void
RealUsbPVCamDriver
::
resume
()
{
}
/*
* pause
*/
void
RealUsbPVCamDriver
::
pause
()
{
Trace
::
getInstance
()
->
trace
(
"DeviceContainer"
,
"RealUsbPVCamDriver"
,
"pause"
,
Level
::
s_Info
,
""
);
}
/*
* stop
*/
void
RealUsbPVCamDriver
::
stop
()
{
Trace
::
getInstance
()
->
trace
(
"DeviceContainer"
,
"RealUsbPVCamDriver"
,
"stop"
,
Level
::
s_Info
,
""
);
plExpAbort
(
m_Handle
,
pvcam
::
CCS_HALT_CLOSE_SHTR
);
}
...
...
@@ -217,45 +191,40 @@ void RealUsbPVCamDriver::readStatus() {
unsigned
long
not_needed
;
plExpCheckStatus
(
m_Handle
,
&
value
,
&
not_needed
);
Trace
::
getInstance
()
->
trace
(
"DeviceContainer"
,
"RealUsbPVCamDriver"
,
"readStatus"
,
Level
::
s_Info
,
"value=%d"
,
value
);
m_owner
->
updateValue
(
STATUS_DEVICE_CONTAINER
,
(
int32
)
value
);
// Set category status before ending, synchronism for controller
m_owner
->
setCategoryStatus
();
// Status command
owner
()
->
computeGateStatus
(
value
);
owner
()
->
computeAcquisitionStatus
(
0
);
owner
()
->
computeDetectorStatus
(
0
);
if
(
dynamic_cast
<
UsbPVCamDriver
*>
(
m_
owner
)
->
m_S
tartActivated
==
true
)
{
if
(
owner
(
)
->
s
tartActivated
()
==
true
)
{
if
((
value
==
pvcam
::
READOUT_COMPLETE
)
||
(
value
==
pvcam
::
READOUT_FAILED
))
{
if
(
value
==
pvcam
::
READOUT_FAILED
)
{
cerr
<<
"Data collection error: "
<<
plErrorCode
()
<<
endl
;
}
dynamic_cast
<
UsbPVCamDriver
*>
(
m_owner
)
->
m_StartActivated
=
false
;
plExpAbort
(
m_Handle
,
pvcam
::
CCS_HALT_CLOSE_SHTR
);
owner
()
->
startActivated
=
false
;
synchroniseRead
();
m_
owner
->
updateValue
(
GATE_ACTUAL_TIME_DEVICE_CONTAINER
,
m_owner
->
getValue
(
GATE_WANTED_TIME_DEVICE_CONTAINER
)
);
m_
owner
->
se
ndProgress
Event
(
PROGRESSION_END_DEVICE_CONTAINER
)
;
owner
()
->
time
=
owner
()
->
time
.
setpoint
(
);
owner
()
->
comma
ndProgress
ion
=
PROGRESSION_END_DEVICE_CONTAINER
;
}
else
{
float64
aTime
=
m_TimeCounter
.
getTime
();
if
(
aTime
<=
any_cast
<
float64
>
(
m_owner
->
getValue
(
GATE_WANTED_TIME_DEVICE_CONTAINER
)
))
{
m_
owner
->
updateValue
(
GATE_ACTUAL_TIME_DEVICE_CONTAINER
,
aTime
)
;
if
(
aTime
<=
owner
()
->
time
.
setpoint
(
))
{
owner
()
->
time
=
aTime
;
}
dynamic_cast
<
UsbPVCamDriver
*>
(
m_
owner
)
->
calculateProgression
();
owner
(
)
->
calculateProgression
();
}
}
else
{
if
(
dynamic_cast
<
UsbPVCamDriver
*>
(
m_owner
)
->
m_SynchroniseReadActivated
==
true
)
{
if
(
dynamic_cast
<
UsbPVCamDriver
*>
(
m_owner
)
->
m_SynchroniseReadTerminated
==
true
)
{
dynamic_cast
<
UsbPVCamDriver
*>
(
m_owner
)
->
m_SynchroniseReadActivated
=
false
;
dynamic_cast
<
UsbPVCamDriver
*>
(
m_owner
)
->
m_SynchroniseReadTerminated
=
false
;
m_owner
->
sendProgressEvent
(
PROGRESSION_END_DEVICE_CONTAINER
);
if
(
owner
()
->
m_SynchroniseReadActivated
==
true
)
{
if
(
owner
()
->
m_SynchroniseReadTerminated
==
true
)
{
owner
()
->
m_SynchroniseReadActivated
=
false
;
owner
()
->
m_SynchroniseReadTerminated
=
false
;
owner
()
->
commandProgression
=
PROGRESSION_END_DEVICE_CONTAINER
;
}
}
else
{
m_
owner
->
se
ndProgress
Event
(
PROGRESSION_END_DEVICE_CONTAINER
)
;
owner
()
->
comma
ndProgress
ion
=
PROGRESSION_END_DEVICE_CONTAINER
;
}
}
// }
// }
}
...
...
@@ -276,3 +245,5 @@ void RealUsbPVCamDriver::print_pv_error() {
plErrorMessage
(
i
,
msg
);
printf
(
" [%i]%s
\n
"
,
i
,
msg
);
}
}
src/drivers/princeton/usbpvcam/RealUsbPVCamDriver.h
View file @
8a722b0f
...
...
@@ -22,103 +22,83 @@
#include
"UsbPVCamState.h"
#include
"UsbPVCamDef.h"
#include
"Utilities/Counter.h"
class
UsbPVCamDriver
;
namespace
usbpvcam
{
/**
* Real Implementation part of the vme card called UsbPVCam made in Princeton. It needs a board called Men A201.
/*!
* \class RealUsbPVCamDriver
* \brief Real implementation class for the UsbPVCam device driver
*
* This class is a real implementation of UsbPVCam device driver.
*/
class
RealUsbPVCamDriver
:
public
UsbPVCamState
{
public:
class
BadGateMode
:
public
NotOk
{
public:
BadGateMode
(
const
std
::
string
&
type
,
const
std
::
string
&
name
,
Publisher
*
publisher
,
const
std
::
string
&
info
)
:
NotOk
(
type
,
name
,
publisher
,
BAD_GATE_MODE_ERROR
,
info
)
{
}
;
};
/**
* Constructor.
*
* @param Link to the class which used the state
/*!
* \brief Constructor
* \param[in] owner The device driver main class link
*/
RealUsbPVCamDriver
(
UsbPVCamDriver
*
owner
);
/*
*
* Destructor
.
/*
!
*
\brief
Destructor
*/
virtual
~
RealUsbPVCamDriver
();
/**
* Initialisation of the device.
* Not used yet.
/*!
* \brief Init command implementation
*/
virtual
void
init
();
/**
* Clear the gate.
* Perform a clear of the device to the clear all counters.
/*!
* \brief Clear command implementation
*/
virtual
void
clear
()
const
;
virtual
void
clear
();
/**
* Write the gate.
* Perform a preset of the all counters and registers.
/*!
* \brief Write Param command implementation
*/
virtual
void
write
()
const
;
virtual
void
write
Param
()
;
/**
* Write the gate.
* Perform a preset of the all counters and registers.
/*!
* \brief Read command implementation
*/
virtual
void
writeParam
()
const
;
virtual
void
read
()
;
/**
* Read the gate.
* Perform a Read of the gate counter.
/*!
* \brief Synchronize Read command implementation
*/