GitLab will be upgraded on June 23rd evening. During the upgrade the service will be unavailable, sorry for the inconvenience.

Commit 3d8e9757 authored by Laurent Claustre's avatar Laurent Claustre

Export to python API, Dacs handler and few functions

parent 80a7461a
Pipeline #11542 passed with stages
in 8 minutes and 5 seconds
......@@ -107,7 +107,7 @@ add_library(maxipix SHARED
src/MpxDetConfig.cpp
src/MpxCommon.cpp
src/MpxChipConfig.cpp
src/MpxDacs
src/MpxDacs.cpp
tools/src/INIReader.cpp
tools/ini.c
${MAXIPIX_INCS}
......
......@@ -107,7 +107,8 @@ public:
void getEnergy(double& energy){m_mpxDacs->getEnergy(energy); }
PriamAcq* priamAcq() {return &m_priamAcq; }
MpxDacs* dacs() {return m_mpxDacs;}
MaxipixReconstruction* getReconstructionTask(){return m_reconstructionTask;};
......
......@@ -28,6 +28,7 @@
#include "lima/Constants.h"
#include "lima/HwInterface.h"
#include "MpxVersion.h"
#include "MpxVersion.h"
#include "PriamAcq.h"
namespace lima {
......@@ -85,6 +86,9 @@ private:
void setValue(std::string& name, int value);
};
typedef std::map<std::string, int> DacCodeMapType;
typedef std::map<int, int> ThlNoiseMapType;
class MpxDacs {
DEB_CLASS_NAMESPC(DebModCamera, "Camera", "MpxDacs");
public:
......@@ -96,32 +100,30 @@ public:
void applyChipDacs(int chipid);
void getFsrString(int chipid, std::string& fsrString);
void setThlNoise(std::map<int,int>& noise);
void getThlNoise(std::map<int,int>& noise);
void setThlXray(std::map<int,int>& threshold);
void getThlXray(std::map<int,int>& threshold);
void setThlNoise(ThlNoiseMapType& noise);
void getThlNoise(ThlNoiseMapType& noise);
void setThlXray(ThlNoiseMapType& threshold);
void getThlXray(ThlNoiseMapType& threshold);
void setEnergyCalibration(double energy);
void getEnergyCalibration(double& energy);
void setEnergy(double energy);
void getEnergy(double& energy);
void setOneDac(int chipid, std::string name, int value);
void setDacs(int chipid, std::map<std::string,int>& dacs);
void setDacs(int chipid, DacCodeMapType& dacs);
void getOneDac(int chipid, std::string name, int& value);
void getDacs(int chipid, std::map<std::string,int>& dacs);
void getDacs(int chipid, DacCodeMapType& dacs);
std::vector<std::string> getListKeys();
private:
MpxDacs(const MpxDacs&);
MpxDacs& operator=(const MpxDacs&);
Version& m_version;
int m_nchip;
PriamAcq* m_pacq;
std::vector<int>* m_priamPorts;
double m_lastEnergy;
double m_energyCalib;
std::map<int,int> m_thlNoise;
std::map<int,int> m_thlXray;
ThlNoiseMapType m_thlNoise;
ThlNoiseMapType m_thlXray;
std::vector<MpxChipDacs*> m_chipDacs;
std::pair<int,int> getChipIdx(int chipid);
......
......@@ -84,6 +84,7 @@ public:
void getEnergy(double& energy /Out/);
Maxipix::PriamAcq* priamAcq();
Maxipix::MpxDacs* dacs();
};
};
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2019
// 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/>.
//###########################################################################
%MappedType std::map<std::string, int>
{
%TypeHeaderCode
#include <map>
#include <string>
#include "MpxDacs.h"
%End
%ConvertToTypeCode
PyObject *key, *value;
SIP_SSIZE_T pos;
if(sipIsErr == NULL)
{
bool aReturnFlag = PyDict_Check(sipPy);
pos = 0;
while(aReturnFlag && PyDict_Next(sipPy, &pos, &key, &value))
aReturnFlag = PyInt_Check(value) && sipCheckConvertFromPyStr(key);
return aReturnFlag;
}
*sipCppPtr = new std::map<std::string, int>();
pos = 0;
while(PyDict_Next(sipPy, &pos, &key, &value))
{
int anIndex = PyInt_AS_LONG(value);
std::pair<std::string, int> item(sipConvertFromPyStr(key), anIndex);
(*sipCppPtr)->insert(item);
}
return sipGetState(sipTransferObj);
%End
%ConvertFromTypeCode
PyObject* aReturnDictPt = PyDict_New();
std::map<std::string, int>::iterator mIter, mEnd = sipCpp->end();
for(mIter = sipCpp->begin(); mIter != mEnd; ++mIter)
{
PyObject *aKeyPt = sipConvertToPyStr(mIter->first);
PyObject *aValuePt = PyInt_FromLong(mIter->second);
PyDict_SetItem(aReturnDictPt,aKeyPt,aValuePt);
Py_DECREF(aKeyPt);Py_DECREF(aValuePt);
}
return aReturnDictPt;
%End
};
%MappedType std::map<int, int>
{
%TypeHeaderCode
#include <map>
#include "MpxDacs.h"
%End
%ConvertToTypeCode
PyObject *key, *value;
SIP_SSIZE_T pos;
if(sipIsErr == NULL)
{
bool aReturnFlag = PyDict_Check(sipPy);
pos = 0;
while(aReturnFlag && PyDict_Next(sipPy, &pos, &key, &value))
aReturnFlag = PyInt_Check(value) && PyInt_Check(key);
return aReturnFlag;
}
*sipCppPtr = new std::map<int, int>();
pos = 0;
while(PyDict_Next(sipPy, &pos, &key, &value))
{
int aValue = PyInt_AS_LONG(value);
int aKey = PyInt_AS_LONG(key);
std::pair<int, int> item(aKey, aValue);
(*sipCppPtr)->insert(item);
}
return sipGetState(sipTransferObj);
%End
%ConvertFromTypeCode
PyObject* aReturnDictPt = PyDict_New();
std::map<int, int>::iterator mIter, mEnd = sipCpp->end();
for(mIter = sipCpp->begin(); mIter != mEnd; ++mIter)
{
PyObject *aKeyPt = PyInt_FromLong(mIter->first);
PyObject *aValuePt = PyInt_FromLong(mIter->second);
PyDict_SetItem(aReturnDictPt,aKeyPt,aValuePt);
Py_DECREF(aKeyPt);Py_DECREF(aValuePt);
}
return aReturnDictPt;
%End
};
namespace Maxipix {
%TypeHeaderCode
#include <string>
#include <vector>
#include "MpxCommon.h"
#include "MpxDacs.h"
#include "PriamAcq.h"
#include "MpxVersion.h"
#include "lima/Constants.h"
using namespace lima;
%End
class MpxDacs {
public:
MpxDacs(lima::Maxipix::Version version, int nchip);
~MpxDacs();
void reset();
void setPriamPars(Maxipix::PriamAcq* priamAcq, std::vector<int>* priamPorts);
void applyChipDacs(int chipid);
void getFsrString(int chipid, std::string& fsrString /Out/);
void setThlNoise(std::map<int,int>& noise);
void getThlNoise(std::map<int,int>& noise /Out/);
void setThlXray(std::map<int,int>& threshold);
void getThlXray(std::map<int,int>& threshold /Out/);
void setEnergyCalibration(double energy);
void getEnergyCalibration(double& energy /Out/);
void setEnergy(double energy);
void getEnergy(double& energy /Out/);
void setOneDac(int chipid, std::string name, int value);
void setDacs(int chipid, std::map<std::string, int>& dacs /Out/);
void getOneDac(int chipid, std::string name, int& value);
void getDacs(int chipid, std::map<std::string, int>& dacs /Out/);
std::vector<std::string> getListKeys();
};
};
\ No newline at end of file
......@@ -739,22 +739,22 @@ void MpxDacs::getFsrString(int chipid, std::string& fsrString) {
m_chipDacs[p.first]->getFsrString(fsrString);
}
void MpxDacs::setThlNoise(std::map<int, int>& values) {
void MpxDacs::setThlNoise(ThlNoiseMapType& values) {
DEB_MEMBER_FUNCT();
m_thlNoise = values;
}
void MpxDacs::getThlNoise(std::map<int, int>& noise) {
void MpxDacs::getThlNoise(ThlNoiseMapType& noise) {
DEB_MEMBER_FUNCT();
noise = m_thlNoise;
}
void MpxDacs::setThlXray(std::map<int, int>& values) {
void MpxDacs::setThlXray(ThlNoiseMapType& values) {
DEB_MEMBER_FUNCT();
m_thlXray = values;
}
void MpxDacs::getThlXray(std::map<int, int>& threshold) {
void MpxDacs::getThlXray(ThlNoiseMapType& threshold) {
DEB_MEMBER_FUNCT();
threshold = m_thlXray;
}
......@@ -785,6 +785,11 @@ void MpxDacs::getEnergy(double& energy) {
energy = m_lastEnergy;
}
std::vector<std::string> MpxDacs::getListKeys() {
DEB_MEMBER_FUNCT();
return m_chipDacs[0]->getListKeys();
}
void MpxDacs::setOneDac(int chipid, std::string name, int value) {
DEB_MEMBER_FUNCT();
std::pair<int, int> p = getChipIdx(chipid);
......@@ -793,7 +798,7 @@ void MpxDacs::setOneDac(int chipid, std::string name, int value) {
}
}
void MpxDacs::setDacs(int chipid, std::map<std::string, int>& dacs) {
void MpxDacs::setDacs(int chipid, DacCodeMapType& dacs) {
DEB_MEMBER_FUNCT();
std::pair<int, int> p = getChipIdx(chipid);
for (int idx = p.first; idx < p.second; idx++) {
......@@ -820,7 +825,7 @@ void MpxDacs::getOneDac(int chipid, std::string name, int& value) {
value = dacs[0];
}
void MpxDacs::getDacs(int chipid, std::map<std::string, int>& res) {
void MpxDacs::getDacs(int chipid, DacCodeMapType& res) {
DEB_MEMBER_FUNCT();
std::pair<int, int> p = getChipIdx(chipid);
std::vector<std::map<std::string, int> > dacs;
......
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