Commit 280aaca6 authored by ahoms's avatar ahoms

* added static set/getXXXXFlagsNameList and enable/DisableXXXXFlags

* using DebTypeXXXX (instead of DebXXXX) for symmetry with other enums
* added static const Flags DebParams::AllFlags
* changed DebType/Fmt/Mod enums to flags; removed DebFlag global helper
* added destructors in Frelon classes
* fixed bug in Frelon::Camera::getEspiaDev creating temp. Espia::SerialLine
* fixed warnings/errors in OCopyStream constructors



git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@180 45c4679d-1946-429d-baad-37912b19538b
parent 9a59ec6c
......@@ -11,8 +11,11 @@ namespace Frelon
class Camera
{
DEB_CLASS_NAMESPC(DebModFrelon, "Camera", "Frelon");
public:
Camera(Espia::SerialLine& espia_ser_line);
~Camera();
SerialLine& getSerialLine();
......
......@@ -15,6 +15,7 @@ class Camera
public:
Camera(Espia::SerialLine& espia_ser_line);
~Camera();
Frelon::SerialLine& getSerialLine();
......
......@@ -14,10 +14,18 @@ const double Camera::MaxReadoutTime = 0.7;
Camera::Camera(Espia::SerialLine& espia_ser_line)
: m_ser_line(espia_ser_line)
{
DEB_CONSTRUCTOR();
m_trig_mode = IntTrig;
readRegister(NbFrames, m_nb_frames);
}
Camera::~Camera()
{
DEB_DESTRUCTOR();
}
SerialLine& Camera::getSerialLine()
{
return m_ser_line;
......@@ -25,38 +33,64 @@ SerialLine& Camera::getSerialLine()
Espia::Dev& Camera::getEspiaDev()
{
Espia::SerialLine ser_line = m_ser_line.getEspiaSerialLine();
Espia::SerialLine& ser_line = m_ser_line.getEspiaSerialLine();
Espia::Dev& dev = ser_line.getDev();
return dev;
}
void Camera::sendCmd(Cmd cmd)
{
DEB_MEMBER_FUNCT();
const string& cmd_str = CmdStrMap[cmd];
DEB_PARAM_VAR2(int(cmd), cmd_str);
if (cmd_str.empty()) {
DEB_ERROR() << "Invalid command cmd=" << cmd;
throw LIMA_HW_EXC(InvalidValue, "Invalid command");
}
string resp;
m_ser_line.sendFmtCmd(CmdStrMap[cmd], resp);
m_ser_line.sendFmtCmd(cmd_str, resp);
}
void Camera::writeRegister(Reg reg, int val)
{
DEB_MEMBER_FUNCT();
const string& reg_str = RegStrMap[reg];
DEB_PARAM_VAR3(int(reg), reg_str, val);
if (reg_str.empty()) {
DEB_ERROR() << "Invalid register reg=" << reg;
throw LIMA_HW_EXC(InvalidValue, "Invalid register");
}
ostringstream cmd;
cmd << RegStrMap[reg] << val;
cmd << reg_str << val;
string resp;
m_ser_line.sendFmtCmd(cmd.str(), resp);
}
void Camera::readRegister(Reg reg, int& val)
{
string resp, cmd = RegStrMap[reg] + "?";
m_ser_line.sendFmtCmd(cmd, resp);
DEB_MEMBER_FUNCT();
const string& reg_str = RegStrMap[reg];
DEB_PARAM_VAR2(int(reg), reg_str);
if (reg_str.empty()) {
DEB_ERROR() << "Invalid register reg=" << reg;
throw LIMA_HW_EXC(InvalidValue, "Invalid register");
}
string resp;
m_ser_line.sendFmtCmd(reg_str + "?", resp);
istringstream is(resp);
is >> val;
}
void Camera::hardReset()
{
DEB_MEMBER_FUNCT();
Espia::Dev& dev = getEspiaDev();
dev.resetLink();
DEB_TRACE() << "Reseting the camera";
sendCmd(Reset);
}
......
......@@ -197,8 +197,31 @@ void set_hw_roi(HwRoiCtrlObj *hw_roi, const Roi& set_roi, Roi& real_roi,
<< "soft_roi=" << soft_roi << endl;
}
void print_deb_flags()
{
DebParams::Flags deb_flags;
cout << hex << showbase;
deb_flags = DebParams::getTypeFlags();
cout << "TypeFlags=" << deb_flags << endl;
deb_flags = DebParams::getFormatFlags();
cout << "FormatFlags=" << deb_flags << endl;
deb_flags = DebParams::getModuleFlags();
cout << "ModuleFlags=" << deb_flags << endl;
cout << dec << noshowbase;
DebParams::NameList name_list;
name_list = DebParams::getTypeFlagsNameList();
cout << "TypeFlagsNameList=" << name_list << endl;
name_list = DebParams::getFormatFlagsNameList();
cout << "FormatFlagsNameList=" << name_list << endl;
name_list = DebParams::getModuleFlagsNameList();
cout << "ModuleFlagsNameList=" << name_list << endl;
}
void test_frelon_hw_inter(bool do_reset)
{
print_deb_flags();
Espia::Dev dev(0);
Espia::Acq acq(dev);
Espia::BufferMgr buffer_cb_mgr(acq);
......@@ -206,6 +229,9 @@ void test_frelon_hw_inter(bool do_reset)
Frelon::Camera cam(ser_line);
BufferCtrlMgr buffer_mgr(buffer_cb_mgr);
DebParams::disableModuleFlags(DebModEspiaSerial);
print_deb_flags();
cout << "Creating the Hw Interface ... " << endl;
Frelon::Interface hw_inter(acq, buffer_mgr, cam);
cout << " Done!" << endl;
......@@ -328,6 +354,9 @@ void test_frelon_hw_inter(bool do_reset)
hw_inter.stopAcq();
print_status(hw_inter);
DebParams::disableTypeFlags(DebTypeFunct);
print_deb_flags();
set_roi = Roi(Point(267, 267), Size(501, 501));
set_hw_roi(hw_roi, set_roi, real_roi, soft_roi);
effect_frame_dim.setSize(real_roi.getSize());
......@@ -349,6 +378,9 @@ void test_frelon_hw_inter(bool do_reset)
hw_sync->setNbFrames(3);
DebParams::disableModuleFlags(DebModEspia);
print_deb_flags();
print_status(hw_inter);
acq_finished.resetFinished();
hw_inter.startAcq();
......@@ -357,6 +389,11 @@ void test_frelon_hw_inter(bool do_reset)
print_status(hw_inter);
hw_inter.stopAcq();
print_status(hw_inter);
DebParams::enableTypeFlags (DebParams::AllFlags);
DebParams::enableFormatFlags(DebParams::AllFlags);
DebParams::enableModuleFlags(DebParams::AllFlags);
print_deb_flags();
}
int main(int argc, char *argv[])
......
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