Commit b0df3073 authored by teresa's avatar teresa

Preliminary version for Mythen detector

parent d34d9e7e
src-dirs = src
test-dirs =
include ../../global.inc
ROPERSCIENTIFIC
-------
.. image:: xxx.jpg
Intoduction
```````````
Server for the control of a Mythen detector.
Module configuration
````````````````````
The minimum configuration file is *config.inc* :
.. code-block:: sh
COMPILE_CORE=1
COMPILE_SIMULATOR=0
COMPILE_SPS_IMAGE=1
COMPILE_ESPIA=0
COMPILE_FRELON=0
COMPILE_MAXIPIX=0
COMPILE_PILATUS=0
COMPILE_ROPERSCIENTIFIC =0
COMPILE_MYTHEN =1
COMPILE_CBF_SAVING=0
export COMPILE_CORE COMPILE_SPS_IMAGE COMPILE_SIMULATOR \
COMPILE_ESPIA COMPILE_FRELON COMPILE_MAXIPIX COMPILE_PILATUS \
COMPILE_ROPERSCIENTIFIC COMPILE_MYTHEN COMPILE_CBF_SAVING
Installation
````````````
Configuration
````````````
#ifndef MYTHEN_H
#define MYTHEN_H
#define _LINUX
#ifdef __x86_64
#define _x64
#else
#define _x86
#endif
#include <mythenDetector.h>
#define GET_ACTION mythenDetector::GET_ACTION
#define PUT_ACTION mythenDetector::PUT_ACTION
#define READOUT_ACTION mythenDetector::READOUT_ACTION
#define MAX_ARGS 256
#define L_STRING 4096
#define M_STRING 1024
#define NSTRIP (attr_NModules_write*1280)
#define MAXSTR 30720
#define S_DIM 4
const string settings_s[S_DIM] = {"standard", "fast", "highgain", "undefined"};
#define T_DIM 5
const string trimmode_s[T_DIM] = {"noise", "beam", "improve", "fix", "offline"};
#endif
#ifndef MYTHENCAMERA_H
#define MYTHENCAMERA_H
#include "Mythen.h"
#include "Debug.h"
#include "Constants.h"
#include "HwMaxImageSizeCallback.h"
#include "HwBufferMgr.h"
#include "ThreadUtils.h"
namespace lima
{
namespace Mythen
{
class Camera : public HwMaxImageSizeCallbackGen
// class Camera
{
friend class Interface;
DEB_CLASS_NAMESPC(DebModCamera,"Camera","Mythen");
public:
enum Status {
Ready, Exposure, Readout, Latency,
};
Camera(std::string HostName, int PortNb = 1952, int DetectorId = 0);
~Camera();
double exposure() const;
void setExposure(double expo);
bool isMonochrome() const;
Status getStatus();
int getNbAcquiredFrames() const {return m_acq_frame_nb;}
VideoMode getVideoMode() const;
void setVideoMode(VideoMode);
void startAcq();
void stopAcq();
void prepareAcq();
void reset();
void setNbFrames(int nb_frames);
void getNbFrames(int& nb_frames);
int cam_sim_mode;
HwBufferCtrlObj* getBufferMgr();
int getTrigMode();
void setTrigMode(int mode);
std::string getInternalAcqMode();
void setInternalAcqMode(std::string mode);
int getMaxWidth();
int getMaxHeight();
void setBin(const Bin& bin);
void getBin(Bin& bin);
void checkBin(Bin& bin);
void new_mythen_detector();
void mythen_set(std::string);
std::string mythen_get(mythenDetector myDetector, char *parameter);
void refresh_fname();
bool isGoodString(std::string);
int probeHost(); // Probe that hostname:port accepts connections
bool getBusyFlag(); // 'true' if Mythen is busy
void setBusyFlag(bool); // set Mythen busy flag
void SetRefreshFlag(); // Set RefreshFlag=true, which will cause refresh() to be called
std::string MythenExecuteLine(int);
std::string MythenExecuteLine(std::string, int);
std::string MythenExecuteLine(std::string, std::string, int);
void setPositions(std::string positions);
std::string getPositions();
void setTrimEnergies(std::string trimenergies);
std::string getTrimEnergies();
void setThreshold(short threshold);
short getThreshold();
void Refresh();
int getIntParameter(std::string parameter);
void setIntParameter(std::string parameter, int value);
std::string getIntParameterList(void);
float getFloatParameter(std::string parameter);
void setFloatParameter(std::string parameter, float value);
std::string getFloatParameterList(void);
std::string getStringParameter(std::string parameter);
void setStringParameter(std::string parameter, std::string value);
std::string getStringParameterList(void);
private:
class CameraThread : public CmdThread{
public:
enum { // Status
Ready = MaxThreadStatus, Exposure, Readout, Latency,
};
enum { // Cmd
StartAcq = MaxThreadCmd, StopAcq, StartStartAcq, Refresh
};
CameraThread(Camera& cam);
virtual void start();
int getNbAcquiredFrames();
bool m_force_stop;
protected:
virtual void init();
virtual void execCmd(int cmd);
private:
void execStartAcq();
void execStartStartAcq();
void execRefresh();
Camera* m_cam;
};
friend class CameraThread;
void _allocBuffer();
SoftBufferCtrlMgr m_buffer_ctrl_mgr;
bool m_cam_connected;
char m_sensor_type[64];
int m_maxwidth, m_maxheight;
// unsigned long *m_frame;
unsigned long m_data[MAXSTR]; // image data (max 1280 strips * 24 modules)
VideoMode m_video_mode;
int m_acq_frame_nb;
bool m_continue_acq;
double m_exposure;
char m_error_msg[200];
int m_camera_busy;
int m_error_code;
int m_nb_frames;
mythenDetector *m_detector;
bool ACBusyFlag; // Acquire Busy Flag
bool BTBusyFlag; // Bus Test Busy Flag
bool DTBusyFlag; // Digital Test Busy Flag
bool MStopFlag; // Merge Stop Flag (if true, will force MergeThread to stop)
bool SBusyFlag; // Settings Busy Flag
bool RBusyFlag; // Refresh Busy Flag
bool m_refresh_flag; // If true, will force refresh() to be run
bool check_input(std::string, const std::string*, int);
unsigned short m_size;
std::string m_host_name;
int m_port_nb;
int m_detector_id;
int m_trigger_mode;
int m_int_acq_mode;
int m_max_width;
int m_max_height;
CameraThread m_thread;
CameraThread m_start_thread;
CameraThread m_refresh_thread;
int m_file_in_progress;
std::string m_positions;
std::string m_trimenergies;
short m_threshold;
bool m_flat_field_enabled;
std::string m_flat_field_filename;
float m_rate_corr_deadtime;
std::string m_bad_channels_filename;
std::string m_ang_conv_filename;
float m_global_offset;
float m_fine_offset;
float m_bin_size;
std::string m_calibration_dir;
int m_threaded;
int m_n_modules;
int m_n_max_modules;
std::string m_module_serial_number;
int m_module_firmware_version;
int m_detector_serial_number;
int m_detector_firmware_version;
int m_detector_software_version;
int m_mythen_software_version;
std::string m_settings;
float m_frame_period;
float m_delay_after_trigger;
int m_gates_per_frame;
int m_frames_per_cycle;
int m_n_cycles;
int m_n_probes;
int m_dynamic_range;
int m_online;
std::string m_out_dir;
std::string m_out_filename;
int m_out_fileindex;
std::string m_flags;
std::string m_trim_dir;
};
}
}
#endif
#ifndef MYTHENINTERFACE_H
#define MYTHENINTERFACE_H
#include "HwInterface.h"
#include "HwBufferMgr.h"
#include "Debug.h"
#include "HwInterface.h"
#include "MythenCamera.h"
using namespace lima;
using namespace std;
namespace lima
{
namespace Mythen
{
class Interface;
/*******************************************************************
* \class DetInfoCtrlObj
* \brief Control object providing Mythen detector info interface
*******************************************************************/
class DetInfoCtrlObj : public HwDetInfoCtrlObj
{
DEB_CLASS_NAMESPC(DebModCamera, "DetInfoCtrlObj", "Mythen");
public:
DetInfoCtrlObj(Camera& cam);
virtual ~DetInfoCtrlObj();
virtual void getMaxImageSize(Size& max_image_size);
virtual void getDetectorImageSize(Size& det_image_size);
virtual void getDefImageType(ImageType& def_image_type);
virtual void getCurrImageType(ImageType& curr_image_type);
virtual void setCurrImageType(ImageType curr_image_type);
virtual void getPixelSize(double& pixel_size);
virtual void getDetectorType(std::string& det_type);
virtual void getDetectorModel(std::string& det_model);
virtual void registerMaxImageSizeCallback(HwMaxImageSizeCallback& cb);
virtual void unregisterMaxImageSizeCallback(HwMaxImageSizeCallback& cb);
private:
class MaxImageSizeCallbackGen: public HwMaxImageSizeCallbackGen
{
protected:
virtual void setMaxImageSizeCallbackActive(bool cb_active);
};
Camera& m_cam;
MaxImageSizeCallbackGen m_mis_cb_gen;
};
/*******************************************************************
* \class BufferCtrlObj
* \brief Control object providing Mythen buffering interface
*******************************************************************/
class BufferCtrlObj : public HwBufferCtrlObj
{
DEB_CLASS_NAMESPC(DebModCamera, "BufferCtrlObj", "Mythen");
public:
BufferCtrlObj(Camera& cam);
virtual ~BufferCtrlObj();
virtual void setFrameDim(const FrameDim& frame_dim);
virtual void getFrameDim( FrameDim& frame_dim);
virtual void setNbBuffers(int nb_buffers);
virtual void getNbBuffers(int& nb_buffers);
virtual void setNbConcatFrames(int nb_concat_frames);
virtual void getNbConcatFrames(int& nb_concat_frames);
virtual void getMaxNbBuffers(int& max_nb_buffers);
virtual void *getBufferPtr(int buffer_nb, int concat_frame_nb = 0);
virtual void *getFramePtr(int acq_frame_nb);
virtual void getStartTimestamp(Timestamp& start_ts);
virtual void getFrameInfo(int acq_frame_nb, HwFrameInfoType& info);
virtual void registerFrameCallback(HwFrameCallback& frame_cb);
virtual void unregisterFrameCallback(HwFrameCallback& frame_cb);
private:
// BufferCtrlMgr m_buffer_mgr;
Camera& m_cam;
};
/*******************************************************************
* \class SyncCtrlObj
* \brief Control object providing Mythen synchronization interface
*******************************************************************/
class SyncCtrlObj : public HwSyncCtrlObj
{
DEB_CLASS_NAMESPC(DebModCamera, "SyncCtrlObj", "Mythen");
public:
SyncCtrlObj(Camera& cam, HwBufferCtrlObj& buffer_ctrl, DetInfoCtrlObj& det);
virtual ~SyncCtrlObj();
virtual bool checkTrigMode(TrigMode trig_mode);
virtual void setTrigMode(TrigMode trig_mode);
virtual void getTrigMode(TrigMode& trig_mode);
virtual void setExpTime(double exp_time);
virtual void getExpTime(double& exp_time);
virtual void setLatTime(double lat_time);
virtual void getLatTime(double& lat_time);
virtual void setNbHwFrames(int nb_frames);
virtual void getNbHwFrames(int& nb_frames);
virtual void getValidRanges(ValidRangesType& valid_ranges);
void prepareAcq();
private:
Camera& m_cam;
};
/*******************************************************************
* \class BinCtrlObj
* \brief Control object providing Mythen binning interface
*******************************************************************/
class BinCtrlObj : public HwBinCtrlObj
{
public:
BinCtrlObj(Camera& cam);
virtual ~BinCtrlObj();
virtual void setBin(const Bin& bin);
virtual void getBin(Bin& bin);
virtual void checkBin(Bin& bin);
private:
Camera& m_cam;
};
/*******************************************************************
* \class Interface
* \brief Mythen hardware interface
*******************************************************************/
class Interface : public HwInterface
{
DEB_CLASS_NAMESPC(DebModCamera, "MythenInterface", "Mythen");
public:
Interface(Camera& cam);
virtual ~Interface();
//- From HwInterface
virtual void getCapList(CapList&) const;
virtual void reset(ResetLevel reset_level);
virtual void prepareAcq();
virtual void startAcq();
virtual void stopAcq();
virtual void getStatus(StatusType& status);
virtual int getNbAcquiredFrames();
virtual int getNbHwAcquiredFrames();
private:
Camera& m_cam;
CapList m_cap_list;
DetInfoCtrlObj m_det_info;
BufferCtrlObj m_buffer;
SyncCtrlObj m_sync;
BinCtrlObj m_bin;
};
} // namespace Mythen
} // namespace lima
#endif // MYTHENINTERFACE_H
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.soleil.lib.Lima</groupId>
<artifactId>Camera</artifactId>
<version>1.0.3-SNAPSHOT</version>
</parent>
<groupId>fr.soleil.lib.Lima.Camera</groupId>
<artifactId>Mythen-${aol}-shared-${mode}</artifactId>
<packaging>nar</packaging>
<name>Mythen</name> <!-- use for the name of executable -->
<description>This module controls the Mythen detector</description>
<build>
<plugins>
<plugin>
<groupId>org.freehep</groupId>
<artifactId>freehep-nar-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
############################################################################
# This file is part of LImA, a Library for Image Acquisition
#
# Copyright (C) : 2009-2011
# European Synchrotron Radiation Facility
# BP 220, Grenoble 38043
# FRANCE
#
# This 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 3 of the License, or
# (at your option) any later version.
#
# This software 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, see <http://www.gnu.org/licenses/>.
############################################################################
import os, sys, imp, glob
root_name = __path__[0]
mod_name = os.path.basename(root_name)
def version_code(s):
return map(int, s.strip('v').split('.'))
def version_cmp(x, y):
return cmp(version_code(x), version_code(y))
env_var_name = 'LIMA_%s_VERSION' % mod_name.upper()
try:
version = os.environ[env_var_name]
except KeyError:
version = 'LAST'
req_version = version
if version.upper() == 'LAST':
version_dirs = [x for x in os.listdir(root_name) if x.startswith('v')]
version_dirs.sort(version_cmp)
version = version_dirs[-1]
else:
if version[0] != 'v':
version = 'v' + version
mod_path = os.path.join(root_name, version)
if not (os.path.isdir(mod_path) or os.path.islink(mod_path)):
raise ImportError('Invalid %s: %s' % (env_var_name, req_version))
__path__.append(mod_path)
from Lima.Mythen.limamythen import Mythen as _P
globals().update(_P.__dict__)
del root_name, mod_name, mod_path, x, env_var_name
del version, req_version, version_dirs, version_code, version_cmp
del os, sys, imp, glob
namespace Mythen
{
class Camera
{
%TypeHeaderCode
#include <MythenCamera.h>
%End
public:
Camera(std::string, int, int);
~Camera();
bool isMonochrome() const;
int getNbAcquiredFrames() const;
VideoMode getVideoMode() const;
void setVideoMode(VideoMode);
void setNbFrames(int );
void getNbFrames(int&);
void startAcq();
void stopAcq();
void prepareAcq();
void reset();
std::string getInternalAcqMode();
void setInternalAcqMode(std::string );
std::string getPositions();
void setPositions(std::string);
std::string getTrimEnergies();
void setTrimEnergies(std::string);
short getThreshold();
void setThreshold(short);
void Refresh();
int getIntParameter(std::string);
void setIntParameter(std::string, int);
std::string getIntParameterList();
float getFloatParameter(std::string);
void setFloatParameter(std::string, float);
std::string getFloatParameterList();
std::string getStringParameter(std::string);
void setStringParameter(std::string, std::string);
std::string getStringParameterList();
};
};
namespace Mythen
{
class Interface : HwInterface
{
%TypeHeaderCode
#include <MythenInterface.h>
%End
public:
Interface(Mythen::Camera&);
virtual ~Interface();
virtual void getCapList(std::vector<HwCap> &cap_list /Out/) const;
virtual void reset(ResetLevel reset_level);
virtual void prepareAcq();
virtual void startAcq();
virtual void stopAcq();
virtual void getStatus(StatusType& status /Out/);
virtual int getNbHwAcquiredFrames();
virtual int getNbAcquiredFrames();
};
};
mythen-objs = MythenInterface.o MythenCamera.o
SRCS = $(mythen-objs:.o=.cpp)
CXXFLAGS += -I/usr/local/include/slsdetector -I../include -I../../../hardware/include -I../../../common/include \
-pthread -fPIC -g
all: Mythen.o
Mythen.o: $(mythen-objs)
$(LD) -o $@ -r $+
clean:
rm -f *.o *.P
%.o : %.cpp
$(COMPILE.cpp) -MD $(CXXFLAGS) -o $@ $<
@cp $*.d $*.P; \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
rm -f $*.d
-include $(SRCS:.cpp=.P)
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment