Commit 8a722b0f authored by Jerome Locatelli's avatar Jerome Locatelli
Browse files

merge trunk to branch

parent 5022287b
<module name="usbpvcam"> <module name="usbpvcam">
<driver class="UsbPVCamDriver"/> <driver class="usbpvcam::UsbPVCamDriver"/>
<include path="$(NOMAD_HOME)/../NomadModules/src"/> <include path="$(NOMAD_HOME)/../NomadModules/src"/>
<link lib="raw1394"/> <link lib="raw1394"/>
<link lib="pvcam"/> <link lib="pvcam"/>
......
...@@ -21,20 +21,14 @@ ...@@ -21,20 +21,14 @@
#include "PerfectUsbPVCamDriver.h" #include "PerfectUsbPVCamDriver.h"
#include "UsbPVCamDriver.h" #include "UsbPVCamDriver.h"
#include "UsbPVCamDef.h" #include "UsbPVCamDef.h"
#include "drivers/legacy/def/DetectorDef.h"
#include "drivers/legacy/def/GateDef.h"
// Trace include namespace usbpvcam {
using namespace boost;
/* /*
* Constructor * Constructor
*/ */
PerfectUsbPVCamDriver::PerfectUsbPVCamDriver(UsbPVCamDriver* owner) : PerfectUsbPVCamDriver::PerfectUsbPVCamDriver(UsbPVCamDriver* owner) :
UsbPVCamState(owner) { UsbPVCamState(owner) {
/* Empty */ /* Empty */
} }
...@@ -51,24 +45,18 @@ void PerfectUsbPVCamDriver::init() { ...@@ -51,24 +45,18 @@ void PerfectUsbPVCamDriver::init() {
/* /*
* clearvme/daugther/UsbPVCam * clearvme/daugther/UsbPVCam
*/ */
void PerfectUsbPVCamDriver::clear() const { void PerfectUsbPVCamDriver::clear() {
// Read command // Read command
m_owner->updateValue(GATE_ACTUAL_TIME_DEVICE_CONTAINER, 0.0); owner()->time = 0;
m_owner->updateValue(GATE_ACTUAL_COUNTER1_DEVICE_CONTAINER, 0); owner()->counts = 0;
m_owner->updateValue(GATE_ACTUAL_COUNTER2_DEVICE_CONTAINER, 0); owner()->counts2 = 0;
m_owner->updateValue(GATE_ACTUAL_COUNTER3_DEVICE_CONTAINER, 0); owner()->counts3 = 0;
}
/*
* write
*/
void PerfectUsbPVCamDriver::write() const {
} }
/* /*
* writeParam * writeParam
*/ */
void PerfectUsbPVCamDriver::writeParam() const { void PerfectUsbPVCamDriver::writeParam() {
} }
/* /*
...@@ -76,7 +64,7 @@ void PerfectUsbPVCamDriver::writeParam() const { ...@@ -76,7 +64,7 @@ void PerfectUsbPVCamDriver::writeParam() const {
*/ */
void PerfectUsbPVCamDriver::synchroniseRead() { void PerfectUsbPVCamDriver::synchroniseRead() {
read(); read();
dynamic_cast<UsbPVCamDriver *> (m_owner)->m_SynchroniseReadTerminated = true; owner()->m_SynchroniseReadTerminated = true;
} }
/* /*
...@@ -84,11 +72,9 @@ void PerfectUsbPVCamDriver::synchroniseRead() { ...@@ -84,11 +72,9 @@ void PerfectUsbPVCamDriver::synchroniseRead() {
*/ */
void PerfectUsbPVCamDriver::read() { void PerfectUsbPVCamDriver::read() {
// Read command // Read command
uint32 size = static_cast<uint32> (any_cast<int32> ( int32 size = owner()->dataSize();
m_owner->getValue(DETECTOR_DATA_SIZE_DEVICE_CONTAINER)));
uint32 *tab = reinterpret_cast<uint32*> (any_cast<int32*> ( int32 *tab = owner()->data();
m_owner->getValue(DETECTOR_DATA_DEVICE_CONTAINER)));
int32 sum = 0; int32 sum = 0;
// if (m_FirstRead) { // if (m_FirstRead) {
...@@ -103,11 +89,12 @@ void PerfectUsbPVCamDriver::read() { ...@@ -103,11 +89,12 @@ void PerfectUsbPVCamDriver::read() {
// sum = sum + tab[i]; // sum = sum + tab[i];
// } // }
// } // }
for (uint32 i = 0; i < size; i++) { for (int32 i = 0; i < size; i++) {
tab[i] = i; tab[i] = i;
sum = sum + tab[i]; sum = sum + tab[i];
} }
owner()->sum = sum;
owner()->data.sendEvent();
} }
/* /*
...@@ -119,15 +106,14 @@ void PerfectUsbPVCamDriver::pause() { ...@@ -119,15 +106,14 @@ void PerfectUsbPVCamDriver::pause() {
/* /*
* continue * continue
*/ */
void PerfectUsbPVCamDriver::continu() { void PerfectUsbPVCamDriver::resume() {
} }
/* /*
* start * start
*/ */
void PerfectUsbPVCamDriver::start() { void PerfectUsbPVCamDriver::start() {
m_owner->updateValue(GATE_ACTUAL_TIME_DEVICE_CONTAINER, any_cast<float64> ( owner()->time = owner()->time.setpoint();
m_owner->getValue(GATE_WANTED_TIME_DEVICE_CONTAINER)));
} }
/* /*
...@@ -140,23 +126,19 @@ void PerfectUsbPVCamDriver::stop() { ...@@ -140,23 +126,19 @@ void PerfectUsbPVCamDriver::stop() {
* readStatus * readStatus
*/ */
void PerfectUsbPVCamDriver::readStatus() { void PerfectUsbPVCamDriver::readStatus() {
dynamic_cast<UsbPVCamDriver*> (m_owner)->m_StartActivated = false; owner()->startActivated = false;
// Status command // Status command
m_owner->updateValue(STATUS_DEVICE_CONTAINER, (int32 ) pvcam::READOUT_COMPLETE); owner()->computeGateStatus(pvcam::READOUT_COMPLETE);
// Set category status before ending, synchronism for controller owner()->computeAcquisitionStatus(0);
m_owner->setCategoryStatus(); owner()->computeDetectorStatus(0);
if (dynamic_cast<UsbPVCamDriver *> (m_owner)->m_SynchroniseReadActivated if (owner()->m_SynchroniseReadActivated == true) {
== true) { if (owner()->m_SynchroniseReadTerminated == true) {
if (dynamic_cast<UsbPVCamDriver *> (m_owner)->m_SynchroniseReadTerminated owner()->m_SynchroniseReadActivated = false;
== true) { owner()->m_SynchroniseReadTerminated = false;
dynamic_cast<UsbPVCamDriver *> (m_owner)->m_SynchroniseReadActivated owner()->commandProgression = PROGRESSION_END_DEVICE_CONTAINER;
= false;
dynamic_cast<UsbPVCamDriver *> (m_owner)->m_SynchroniseReadTerminated
= false;
m_owner->sendProgressEvent(PROGRESSION_END_DEVICE_CONTAINER);
} }
} else { } else {
m_owner->sendProgressEvent(PROGRESSION_END_DEVICE_CONTAINER); owner()->commandProgression = PROGRESSION_END_DEVICE_CONTAINER;
} }
} }
...@@ -165,3 +147,5 @@ void PerfectUsbPVCamDriver::readStatus() { ...@@ -165,3 +147,5 @@ void PerfectUsbPVCamDriver::readStatus() {
*/ */
void PerfectUsbPVCamDriver::readInfos() { void PerfectUsbPVCamDriver::readInfos() {
} }
}
...@@ -21,93 +21,86 @@ ...@@ -21,93 +21,86 @@
#include "UsbPVCamState.h" #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 { class PerfectUsbPVCamDriver: public UsbPVCamState {
public: public:
/** /*!
* Constructor. * \brief Constructor
* * \param[in] owner The device driver main class link
* @param Link to the class which used the state
*/ */
PerfectUsbPVCamDriver(UsbPVCamDriver* owner); PerfectUsbPVCamDriver(UsbPVCamDriver* owner);
/** /*!
* Destructor. * \brief Destructor
*/ */
virtual ~PerfectUsbPVCamDriver(); virtual ~PerfectUsbPVCamDriver();
/** /*!
* Initialisation of the device. * \brief Init command implementation
* Perform a Read of the gate counter.
*/ */
virtual void init(); virtual void init();
/** /*!
* Clear the gate. * \brief Clear command implementation
* Perform a clear of the device to the clear all counters.
*/ */
virtual void clear() const; virtual void clear();
/** /*!
* Write the gate. * \brief Write Param command implementation
* Perform a preset of the all counters and registers.
*/ */
virtual void write() const; virtual void writeParam();
/** /*!
* Write the gate. * \brief Read command implementation
* Perform a preset of the all counters and registers.
*/ */
virtual void writeParam() const; virtual void read();
/** /*!
* Read the gate. * \brief Synchronize Read command implementation
* Perform a Read of the gate counter.
*/ */
virtual void read();
virtual void synchroniseRead(); virtual void synchroniseRead();
/** /*!
* Start the gate. * \brief Start command implementation
* Perform a start of the device to the preset given in the the parameter.
*/ */
virtual void start(); virtual void start();
/** /*!
* Continue the gate. * \brief Resume command implementation
* Perform a start of the device to the preset given in the the parameter.
*/ */
virtual void continu(); virtual void resume();
/** /*!
* Set the gate to mode pause. * \brief Pause command implementation
* Set the gate to the pause mode.
*/ */
virtual void stop(); virtual void pause();
/** /*!
* Set the gate to mode pause. * \brief Stop command implementation
* Set the gate to the pause mode.
*/ */
virtual void pause(); virtual void stop();
/** /*!
* Read status of the gate. * \brief Read Infos command implementation
* Read the status on the gate.
*/ */
virtual void readStatus(); virtual void readStatus();
/** /*!
* Read the informations of the hardware. * \brief Read Infos command implementation
* Read the version, the date,the signatures and local device parameters.
*/ */
virtual void readInfos(); virtual void readInfos();
}; };
}
#endif //PERFECTUSBPVCAMDRIVER_H #endif //PERFECTUSBPVCAMDRIVER_H
...@@ -18,20 +18,16 @@ ...@@ -18,20 +18,16 @@
#include "RealUsbPVCamDriver.h" #include "RealUsbPVCamDriver.h"
#include "UsbPVCamDriver.h" #include "UsbPVCamDriver.h"
#include "drivers/legacy/def/GateDef.h"
#include "drivers/legacy/def/DetectorDef.h"
// Trace include
#include <cstdio> #include <cstdio>
namespace usbpvcam {
/* /*
* Constructor * Constructor
*/ */
RealUsbPVCamDriver::RealUsbPVCamDriver(UsbPVCamDriver* owner) : RealUsbPVCamDriver::RealUsbPVCamDriver(UsbPVCamDriver* owner) :
UsbPVCamState(owner) { UsbPVCamState(owner) {
/* Empty */ /* Empty */
} }
...@@ -73,20 +69,14 @@ void RealUsbPVCamDriver::init() { ...@@ -73,20 +69,14 @@ void RealUsbPVCamDriver::init() {
/* /*
* clear * clear
*/ */
void RealUsbPVCamDriver::clear() const { void RealUsbPVCamDriver::clear() {
memset(dynamic_cast<UsbPVCamDriver*> (m_owner)->m_Data, 0, dynamic_cast<UsbPVCamDriver*> (m_owner)->m_DataSize * sizeof(int32 )); memset(owner()->data(), 0, owner()->dataSize() * sizeof(int32));
}
/*
* write
*/
void RealUsbPVCamDriver::write() const {
} }
/* /*
* writeParam * writeParam
*/ */
void RealUsbPVCamDriver::writeParam() const { void RealUsbPVCamDriver::writeParam() {
} }
/* /*
...@@ -94,34 +84,33 @@ void RealUsbPVCamDriver::writeParam() const { ...@@ -94,34 +84,33 @@ void RealUsbPVCamDriver::writeParam() const {
*/ */
void RealUsbPVCamDriver::synchroniseRead() { void RealUsbPVCamDriver::synchroniseRead() {
uint16* datas = dynamic_cast<UsbPVCamDriver*> (m_owner)->m_DataShort; uint16* datas = owner()->m_DataShort;
/* /*
* Calculate the detector sum here * Calculate the detector sum here
*/ */
int32* data = dynamic_cast<UsbPVCamDriver*> (m_owner)->m_Data; int32* data = owner()->data();
int32* mask = dynamic_cast<UsbPVCamDriver*> (m_owner)->m_Mask; int32* mask = owner()->mask();
int32 dataSize = owner()->dataSize();
float64 sum = 0; float64 sum = 0;
if (datas!=NULL ){ if (datas != NULL) {
for(int32 i=0;i<dynamic_cast<UsbPVCamDriver*> (m_owner)->m_DataSize;++i) { for (int32 i = 0; i < dataSize; ++i) {
data[mask[i]] = datas[i]; data[mask[i]] = datas[i];
//data[i] = datas[i]; //data[i] = datas[i];
sum += (float64) data[i]; sum += (float64) data[i];
} }
} } else {
else{ cerr << "error mask " << endl;
cerr << "error mask "<< endl;
} }
m_owner->updateValue(DETECTOR_SUM_DEVICE_CONTAINER, sum); owner()->sum = sum;
m_owner->sendArrayEvent(DETECTOR_DATA_DEVICE_CONTAINER); owner()->data.sendEvent();
/* Finish the sequence */ /* Finish the sequence */
plExpFinishSeq(m_Handle, (void*)datas, 0); plExpFinishSeq(m_Handle, (void*) datas, 0);
/*Uninit the sequence */ /*Uninit the sequence */
//plExpUninitSeq(); //plExpUninitSeq();
owner()->m_SynchroniseReadTerminated = true;
dynamic_cast<UsbPVCamDriver *> (m_owner)->m_SynchroniseReadTerminated = true;
} }
/* /*
...@@ -135,12 +124,7 @@ void RealUsbPVCamDriver::read() { ...@@ -135,12 +124,7 @@ void RealUsbPVCamDriver::read() {
*/ */
void RealUsbPVCamDriver::start() { void RealUsbPVCamDriver::start() {
Trace::getInstance()->trace("DeviceContainer", "RealUsbPVCamDriver", uint32 exp_time = (uint32) (owner()->time.setpoint() * owner()->precision());
"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)));
unsigned long size; unsigned long size;
void *region = allocRegion(); void *region = allocRegion();
...@@ -159,10 +143,10 @@ void RealUsbPVCamDriver::start() { ...@@ -159,10 +143,10 @@ void RealUsbPVCamDriver::start() {
if (plExpInitSeq()) { if (plExpInitSeq()) {
if (plExpSetupSeq(m_Handle, 1, 1, region, pvcam::TIMED_MODE, exp_time, &size)) { if (plExpSetupSeq(m_Handle, 1, 1, region, pvcam::TIMED_MODE, exp_time, &size)) {
uint16* datas = dynamic_cast<UsbPVCamDriver*> (m_owner)->m_DataShort; uint16* datas = owner()->m_DataShort;
if (plExpStartSeq(m_Handle, (void*) datas)){ if (plExpStartSeq(m_Handle, (void*) datas)) {
m_TimeCounter.clear(); m_TimeCounter.clear();
}else{ } else {
print_pv_error(); print_pv_error();
} }
...@@ -177,31 +161,21 @@ void RealUsbPVCamDriver::start() { ...@@ -177,31 +161,21 @@ void RealUsbPVCamDriver::start() {
} }
/* /*
* continu * resume
*/ */
void RealUsbPVCamDriver::continu() { void RealUsbPVCamDriver::resume() {
Trace::getInstance()->trace("DeviceContainer", "RealUsbPVCamDriver",
"continu", Level::s_Info, "");
} }
/* /*
* pause * pause
*/ */
void RealUsbPVCamDriver::pause() { void RealUsbPVCamDriver::pause() {
Trace::getInstance()->trace("DeviceContainer", "RealUsbPVCamDriver",
"pause", Level::s_Info, "");
} }
/* /*
* stop * stop
*/ */
void RealUsbPVCamDriver::stop() { void RealUsbPVCamDriver::stop() {
Trace::getInstance()->trace("DeviceContainer", "RealUsbPVCamDriver",
"stop", Level::s_Info, "");
plExpAbort(m_Handle, pvcam::CCS_HALT_CLOSE_SHTR); plExpAbort(m_Handle, pvcam::CCS_HALT_CLOSE_SHTR);
} }
...@@ -217,45 +191,40 @@ void RealUsbPVCamDriver::readStatus() { ...@@ -217,45 +191,40 @@ void RealUsbPVCamDriver::readStatus() {
unsigned long not_needed; unsigned long not_needed;
plExpCheckStatus(m_Handle, &value, &not_needed); plExpCheckStatus(m_Handle, &value, &not_needed);
Trace::getInstance()->trace("DeviceContainer", "RealUsbPVCamDriver", // Status command
"readStatus", Level::s_Info, "value=%d", value); owner()->computeGateStatus(value);
owner()->computeAcquisitionStatus(0);
m_owner->updateValue(STATUS_DEVICE_CONTAINER, (int32 ) value); owner()->computeDetectorStatus(0);
// Set category status before ending, synchronism for controller
m_owner->setCategoryStatus();
if (dynamic_cast<UsbPVCamDriver*> (m_owner)->m_StartActivated == true) { if (owner()->startActivated() == true) {
if ((value == pvcam::READOUT_COMPLETE) || (value == pvcam::READOUT_FAILED)) { if ((value == pvcam::READOUT_COMPLETE) || (value == pvcam::READOUT_FAILED)) {
if (value == pvcam::READOUT_FAILED) { if (value == pvcam::READOUT_FAILED) {
cerr << "Data collection error: " << plErrorCode() << endl;