Commit 356d976c authored by Abdelali Elaazzouzi's avatar Abdelali Elaazzouzi
Browse files

New drivers for Camera For D50

parent 21494bfd
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef IKONDEF_H
#define IKONDEF_H
namespace ikon {
enum
{
READOUT_NOT_ACTIVE = 0,
EXPOSURE_IN_PROGRESS,
READOUT_IN_PROGRESS,
READOUT_COMPLETE,
FRAME_AVAILABLE = READOUT_COMPLETE,
READOUT_FAILED,
ACQUISITION_IN_PROGRESS,
MAX_CAMERA_STATUS
};
enum
{ ATTR_CURRENT, ATTR_COUNT, ATTR_TYPE, ATTR_MIN, ATTR_MAX, ATTR_DEFAULT,
ATTR_INCREMENT, ATTR_ACCESS, ATTR_AVAIL
};
enum
{
TIMED_MODE,
STROBED_MODE,
BULB_MODE,
TRIGGER_FIRST_MODE,
FLASH_MODE,
VARIABLE_TIMED_MODE,
INT_STROBE_MODE
};
enum
{ CCS_NO_CHANGE, CCS_HALT, CCS_HALT_CLOSE_SHTR, CCS_CLEAR,
CCS_CLEAR_CLOSE_SHTR, CCS_OPEN_SHTR, CCS_CLEAR_OPEN_SHTR
};
#define CAM_NAME_LEN 32
#define PARAM_SER_SIZE ((2<<16) + (6<<24) + 58)
#define PARAM_PAR_SIZE ((2<<16) + (6<<24) + 57)
#define ERROR_MSG_LEN 255
#define DEFAULT_TIME 0.1
#define DEFAULT_HEIGHT 2048
#define DEFAULT_WIDTH 2048
}
#endif //IKONDEF_H
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "IKonDriver.h"
#include <math.h>
#include "IKonDef.h"
#include "IKonState.h"
#include "PerfectIKonDriver.h"
#include "RealIKonDriver.h"
using namespace std;
namespace ikon {
const std::string IKonDriver::TYPE = "IKon";
const std::string IKonDriver::ON_COMMAND = "on";
const std::string IKonDriver::OFF_COMMAND = "off";
/*
* Constructor
*/
IKonDriver::IKonDriver(const string& name) :
acquisition::NoTofAcquisitionCommon(name),acquisition::KineticAcquisitionCommon(name),
acquisition::TimeGateCommon(name),
acquisition::DetectorCommon(name),temperature::TemperatureCommon(name) {
registerStates(new RealIKonDriver(this), new PerfectIKonDriver(this), new PerfectIKonDriver(this));
/*
* Init the device command list
*/
height.init(this, SAVE, "height");
width.init(this, SAVE, "width");
bind.init(this, SAVE, "bind");
hflip.init(this, SAVE, "hflip");
vflip.init(this, SAVE, "vflip");
rotate.init(this, SAVE, "rotate");
acqmode.init(this, SAVE, "acqmode");
cooling.init(this, SAVE, "cooling");
readout.init(this, SAVE, "readout");
shutopentime.init(this, SAVE, "shutopentime");
shutclosetime.init(this, SAVE, "shutclosetime");
shutmode.init(this, SAVE, "shutmode");
hsspeed.init(this, SAVE, "hhspeed");
gain.init(this, SAVE, "gain");
bclamp.init(this, SAVE, "bclamp");
initCommand(driver::INIT_COMMAND);
initCommand(driver::READ_COMMAND);
initCommand(driver::SYNCHRONIZE_READ_COMMAND);
initCommand(driver::START_COMMAND);
initCommand(driver::RESUME_COMMAND);
initCommand(driver::PAUSE_COMMAND);
initCommand(driver::STOP_COMMAND);
initCommand(driver::STATUS_COMMAND);
initCommand(driver::READ_INFOS_COMMAND);
initCommand(DetectorCommon::CLEAR_COMMAND);
initCommand(DetectorCommon::REGROUP_COMMAND);
initCommand(AcquisitionCommon::WRITE_PARAMETERS_COMMAND);
initCommand(driver::INIT_COMMAND);
initCommand(ON_COMMAND);
initCommand(OFF_COMMAND);
// Init functions
registerParentFunction(NONE_FUNCTION);
registerFunction(NONE_FUNCTION);
deviceType = ROOT_DEVICE_TYPE_DEVICE_CONTAINER;
m_SynchroniseReadActivated = false;
m_SynchroniseReadTerminated = false;
m_DataShort = NULL;
registerObserverCommand(COMMAND_STATUS_DEVICE_CONTAINER, 50);
registerObserverCommand(COMMAND_READ_DEVICE_CONTAINER, 50);
registerSpyCommand(COMMAND_READ_DEVICE_CONTAINER, 5);
}
/*
* Destructor
*/
IKonDriver::~IKonDriver() {
}
/*
* refreshDataSizeProperty
*/
void IKonDriver::refreshDataSizeProperty(int32 value) throw (CannotSetValue) {
if (m_DataShort != NULL) {
delete[] m_DataShort;
}
m_DataShort = new uint16[value];
if (m_DataShort == NULL) {
sendErrorEvent(NOTENOUGH_MEMORY_ERROR, "Can't create data table");
throw CannotSetValue();
}
DetectorCommon::refreshDataSizeProperty(value);
}
/*
* refreshModeProperty
*/
void IKonDriver::refreshModeProperty(int32 value) throw (CannotSetValue) {
if (value != acquisition::GateCommon::TIME_MODE) {
throw CannotSetValue();
}
}
/*
* execute
*/
void IKonDriver::execute(const std::string& aCommand) {
if ((aCommand != driver::PAUSE_COMMAND) && (aCommand != driver::STOP_COMMAND) && (aCommand != driver::STATUS_COMMAND)
&& (aCommand != driver::READ_COMMAND)) {
commandProgression = PROGRESSION_UNKNOWNSTATE_DEVICE_CONTAINER;
}
IKonState* currentState = dynamic_cast<IKonState*>(getCurrentState());
// Check command
if (aCommand == driver::INIT_COMMAND) {
// Init command
currentState->init();
} else if (aCommand == driver::READ_COMMAND) {
// Read command
currentState->read();
} else if (aCommand == driver::SYNCHRONIZE_READ_COMMAND) {
// Read command
m_SynchroniseReadActivated = true;
m_SynchroniseReadTerminated = false;
currentState->synchroniseRead();
} else if (aCommand == driver::START_COMMAND) {
// Start command
startActivated = true;
currentState->start();
} else if (aCommand == driver::RESUME_COMMAND) {
// Continue command
currentState->resume();
} else if (aCommand == driver::PAUSE_COMMAND) {
// Stop command
currentState->pause();
} else if (aCommand == driver::STOP_COMMAND) {
// Stop command
currentState->stop();
startActivated = false;
} else if (aCommand == driver::STATUS_COMMAND) {
// Status command
currentState->readStatus();
} else if (aCommand == driver::READ_INFOS_COMMAND) {
// Info command
currentState->readInfos();
} else if (aCommand == DetectorCommon::CLEAR_COMMAND) {
// Move command
sum = 0;
currentState->clear();
} else if (aCommand == AcquisitionCommon::WRITE_PARAMETERS_COMMAND) {
// Write command
currentState->writeParam();
} else if (aCommand == ON_COMMAND) {
// on command
currentState->setCooler(1);
} else if (aCommand ==OFF_COMMAND) {
// off command
currentState->setCooler(0);
} else {
//Error bad command
//Todo , normaly it will be detect it device action driver
}
}
/*
* calculateProgression
*/
void IKonDriver::calculateProgression() {
int32 progression = 0;
float64 setpoint = 0.0;
float64 actual = 0.0;
setpoint = time.setpoint();
actual = time();
if (setpoint == 0.0) {
commandProgression = PROGRESSION_END_DEVICE_CONTAINER;
} else {
progression = (int32) (actual / setpoint * PROGRESSION_RATIO_DEVICE_CONTAINER);
// Be sure that progression > 0%
if (progression < PROGRESSION_UNKNOWNSTATE_DEVICE_CONTAINER)
progression = 0;
// Be sure that only Phased status put 100%
if (progression >= PROGRESSION_END_DEVICE_CONTAINER)
progression = PROGRESSION_END_DEVICE_CONTAINER - 1;
commandProgression = progression;
}
}
/*
* IKonDriver
*/
void IKonDriver::computeGateStatus(int32 value) {
int32 valueout = 0;
if ((value == ikon::EXPOSURE_IN_PROGRESS) || (value == ikon::READOUT_IN_PROGRESS)
|| (value == ikon::ACQUISITION_IN_PROGRESS)) {
valueout |= GateCommon::RUNNING_STATUS;
} else if (value == ikon::READOUT_COMPLETE) {
valueout |= GateCommon::END_STATUS;
}
gateStatus.update(valueout);
}
/*
* IKonDriver
*/
void IKonDriver::computeDetectorStatus(int32 value) {
int32 valueout = 0;
detectorStatus.update(valueout);
}
/*
* IKonDriver
*/
void IKonDriver::computeAcquisitionStatus(int32 value) {
int32 valueout = 0;
acquisitionStatus.update(valueout);
}
}
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef IKONDRIVER_H
#define IKONDRIVER_H
#include <Driver.h>
#include "controllers/common/acquisition/gate/TimeGateCommon.h"
#include "controllers/common/acquisition/mode/NoTofAcquisitionCommon.h"
#include "controllers/common/acquisition/mode/TofAcquisitionCommon.h"
#include "controllers/common/acquisition/mode/KineticAcquisitionCommon.h"
#include "controllers/common/acquisition/detector/DetectorCommon.h"
#include "controllers/common/sample_environment/temperature/TemperatureCommon.h"
namespace ikon {
/**
* Global Implementation of the vme card called IKon made in Ill. It needs a board called Men A201.
*/
class IKonDriver: public acquisition::NoTofAcquisitionCommon,
public acquisition::TimeGateCommon,
public acquisition::KineticAcquisitionCommon,
public acquisition::DetectorCommon,
public temperature::TemperatureCommon{
friend class RealIKonDriver;
friend class PerfectIKonDriver;
friend class SimulatedIKonDriver;
public:
//! Driver type value
static const std::string TYPE;
static const std::string ON_COMMAND ;
static const std::string OFF_COMMAND;
/*!
* \brief Constructor
* \param[in] name the name of the device driver
*/
IKonDriver(const std::string& name);
/*!
* \brief Destructor
*/
virtual ~IKonDriver();
/*!
* \brief Method called for executing a command
*
* \param[in] command the command to apply on the controller
*/
virtual void execute(const std::string& aCommand);
/*!
* \brief Calculate the progression state.
*/
void calculateProgression();
Property<int32> height;
Property<int32> width;
Property<int32> hflip;
Property<int32> vflip;
Property<int32> acqmode;
Property<int32> bind;
Property<int32> rotate;
Property<int32> cooling;
Property<int32> readout;
Property<int32> shutopentime;
Property<int32> shutclosetime;
Property<int32> shutmode;
Property<int32> hsspeed;
Property<int32> bclamp;
Property<int32> gain;
private:
/*!
* \brief Method called before changing the data size property value
* \param[in] value the property value
* \throws CannotSetValue the value isn't corrected, or property couldn't be changed
*/
virtual void refreshDataSizeProperty(int32 value) throw (CannotSetValue);
virtual void refreshModeProperty(int32 value) throw (CannotSetValue);
/*!
* \brief compute global gate status
* \param[in] value the driver status
*/
virtual void computeGateStatus(int32 value);
/*!
* \brief compute global acquisition status
* \param[in] value the driver status
*/
virtual void computeAcquisitionStatus(int32 value);
/*!
* \brief compute global detector status
* \param[in] value the driver status
*/
virtual void computeDetectorStatus(int32 value);
uint16* m_DataShort;
/**
* flag for synchronise read
*/
bool m_SynchroniseReadActivated;
bool m_SynchroniseReadTerminated;
};
}
#endif //IKONDRIVER_H
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef IKONSTATE_H
#define IKONSTATE_H
#include <Driver.h>
#include "IKonDriver.h"
namespace ikon {
/*!
* \class IKonState
* \brief Virtual class for implement State pattern
*
* Define all methods that perfect, simulated and real classes have to implement
*/
class IKonState: public DriverState<IKonDriver> {
public:
/*!
* \brief Constructor
* \param[in] owner The device driver main class link
*/
IKonState(IKonDriver* owner) :
DriverState<IKonDriver>(owner) {
}
/*!
* \brief Destructor
*/
virtual ~IKonState() {
}
/*!
* \brief Clear command implementation
*/
virtual void clear() = 0;
/*!
* \brief Write Param command implementation
*/
virtual void writeParam() = 0;
/*!
* \brief Read command implementation
*/
virtual void read() = 0;
/*!
* \brief Synchronize Read command implementation
*/
virtual void synchroniseRead() = 0;
/*!
* \brief Start command implementation
*/
virtual void start() = 0;
/*!
* \brief Resume command implementation
*/
virtual void resume() = 0;
/*!
* \brief Pause command implementation
*/
virtual void pause() = 0;
/*!
* \brief Stop command implementation
*/
virtual void stop() = 0;
/*!
* \brief Read Infos command implementation
*/
virtual void readStatus() = 0;
/*!
* \brief Read Infos command implementation
*/
virtual void readInfos() = 0;
virtual void setCooler(int status)=0;
};
}
#endif //IKONSTATE_H
<module name="ikon">
<driver class="ikon::IKonDriver"/>
<include path="$(NOMAD_HOME)/../NomadModules/src"/>
<link lib="andor"/>
</module>
\ No newline at end of file
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "PerfectIKonDriver.h"
#include <stdlib.h>
#include "IKonDef.h"
#include "IKonDriver.h"
namespace ikon {
/*
* Constructor
*/
PerfectIKonDriver::PerfectIKonDriver(IKonDriver* owner) :
IKonState(owner) {
/* Empty */
}
/*
* Destructor
*/
PerfectIKonDriver::~PerfectIKonDriver() {
/* Empty */
}
void PerfectIKonDriver::init() {
}
/*
* clearvme/daugther/IKon
*/
void PerfectIKonDriver::clear() {
// Read command
owner()->time = 0;
owner()->counts = 0;
owner()->counts2 = 0;
owner()->counts3 = 0;
}
/*
* writeParam
*/