Commit c6aaca8b authored by ahoms's avatar ahoms
Browse files

* added camera/common/espia with basic Espia object

* using std::string everywhere instead of String



git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@51 45c4679d-1946-429d-baad-37912b19538b
parent b49be161
.PHONY: simulator
.PHONY: simulator common
all: simulator
all: simulator common
simulator:
make -C simulator
common:
make -C common
.PHONY: espia
all: espia
espia:
make -C espia
#ifndef ESPIA_H
#define ESPIA_H
#include "Exceptions.h"
#include "espia_lib.h"
#include <string>
namespace lima
{
class Espia
{
public:
enum {
Invalid = -1,
};
Espia(int dev_nr);
~Espia();
void serWrite(const std::string& buffer,
int block_size = 0, double block_delay = 0,
bool no_wait = false);
void serRead(std::string& buffer, int& len, double timeout);
void serReadStr(std::string& buffer, int& len,
const std::string& term, double timeout);
static void throwError(int ret, std::string file, std::string func,
int line);
private:
void open(int dev_nr);
void close();
int m_dev_nr;
espia_t m_dev;
};
#define ESPIA_CHECK_CALL(ret) \
do { \
int aux_ret = (ret); \
if (aux_ret < 0) \
Espia::throwError(aux_ret, __FILE__, \
__FUNCTION__, __LINE__); \
} while (0)
} // namespace lima
#endif // ESPIA_H
#include "Espia.h"
using namespace lima;
using namespace std;
#define CHECK_CALL(ret) ESPIA_CHECK_CALL(ret)
Espia::Espia(int dev_nr)
: m_dev_nr(Invalid), m_dev(ESPIA_DEV_INVAL)
{
open(dev_nr);
}
Espia::~Espia()
{
close();
}
void Espia::open(int dev_nr)
{
if (dev_nr == m_dev_nr)
return;
close();
CHECK_CALL(espia_open(dev_nr, &m_dev));
m_dev_nr = dev_nr;
}
void Espia::close()
{
if (m_dev_nr == Invalid)
return;
CHECK_CALL(espia_close(m_dev));
m_dev = ESPIA_DEV_INVAL;
m_dev_nr = Invalid;
}
void Espia::throwError(int ret, string file, string func, int line)
{
string err_desc = string("Espia: ") + espia_strerror(ret);
throw Exception(Hardware, Error, err_desc, file, func, line);
}
ESPIA_DRV_BASE = /segfs/bliss/source/driver/linux-2.6/espia
ESPIA_DRV_INC = $(ESPIA_DRV_BASE)/src
CXXFLAGS = -I../include -I../../../../hardware/include \
-I../../../../common/include -I$(ESPIA_DRV_INC)
all: clean Espia.o
clean:
rm -f *.o
#include "SimuHwInterface.h"
using namespace lima;
using namespace std;
/*******************************************************************
* \brief SimuDetInfoCtrlObj constructor
......@@ -53,12 +54,12 @@ void SimuDetInfoCtrlObj::getPixelSize(double& pixel_size)
pixel_size = 1e-6;
}
void SimuDetInfoCtrlObj::getDetectorType(std::string& det_type)
void SimuDetInfoCtrlObj::getDetectorType(string& det_type)
{
det_type = "Simulator";
}
void SimuDetInfoCtrlObj::getDetectorModel(std::string& det_model)
void SimuDetInfoCtrlObj::getDetectorModel(string& det_model)
{
det_model = "PeakGenerator";
}
......
......@@ -15,17 +15,16 @@ class BufferSave {
Raw, EDF,
};
typedef std::string String;
BufferSave( FileFormat format = Raw, const String& prefix = "img",
int idx = 0, const String& suffix = "",
BufferSave( FileFormat format = Raw,
const std::string& prefix = "img",
int idx = 0, const std::string& suffix = "",
bool overwrite = false , int tot_file_frames = 1);
~BufferSave( );
void writeFrame( const HwFrameInfoType& finfo );
void setPrefix(const String& prefix);
void getPrefix(String& prefix) const;
void setPrefix(const std::string& prefix);
void getPrefix(std::string& prefix) const;
void setFormat(FileFormat format);
void getFormat(FileFormat& format) const;
......@@ -36,21 +35,21 @@ class BufferSave {
void setTotFileFrames(int tot_file_frames);
void getTotFileFrames(int& tot_file_frames) const;
void getOpenFileName(String& file_name) const;
void getOpenFileName(std::string& file_name) const;
bool isFileOpen() const;
private:
String getDefSuffix() const;
std::string getDefSuffix() const;
void openFile();
void closeFile();
void writeEdfHeader( const HwFrameInfoType& finfo );
FileFormat m_format;
String m_prefix;
std::string m_prefix;
int m_idx;
String m_suffix;
String m_file_name;
std::string m_suffix;
std::string m_file_name;
bool m_overwrite;
int m_written_frames;
int m_tot_file_frames;
......
#ifndef EXCEPTIONS_H
#define EXCEPTIONS_H
#include <string>
#include <string.h>
#include <ostream>
namespace lima
......@@ -19,20 +19,18 @@ enum ErrorType {
class Exception
{
public:
typedef std::string String;
Exception(Layer layer, ErrorType err_type, std::string err_desc,
std::string file_name, std::string funct_name, int line_nr);
Exception(Layer layer, ErrorType err_type, String err_desc,
String file_name, String funct_name, int line_nr);
String getErrMsg() const;
std::string getErrMsg() const;
private:
Layer m_layer;
ErrorType m_err_type;
String m_err_desc;
String m_file_name;
String m_funct_name;
std::string m_err_desc;
std::string m_file_name;
std::string m_funct_name;
int m_line_nr;
};
......
......@@ -15,8 +15,8 @@ using namespace std;
#define EDF_HEADER_BUFFER_LEN (10 * EDF_HEADER_LEN)
BufferSave::BufferSave( FileFormat format, const String& prefix, int idx,
const String& suffix, bool overwrite,
BufferSave::BufferSave( FileFormat format, const string& prefix, int idx,
const string& suffix, bool overwrite,
int tot_file_frames )
: m_format(format), m_prefix(prefix), m_idx(idx), m_suffix(suffix),
m_overwrite(overwrite), m_tot_file_frames(tot_file_frames)
......@@ -33,7 +33,7 @@ BufferSave::~BufferSave( )
closeFile();
}
BufferSave::String BufferSave::getDefSuffix() const
string BufferSave::getDefSuffix() const
{
return (m_format == EDF) ? ".edf" : ".raw";
}
......@@ -139,7 +139,7 @@ bool BufferSave::isFileOpen() const
return bool(m_fout);
}
void BufferSave::setPrefix(const String& prefix)
void BufferSave::setPrefix(const string& prefix)
{
if (prefix == m_prefix)
return;
......@@ -150,7 +150,7 @@ void BufferSave::setPrefix(const String& prefix)
m_prefix = prefix;
}
void BufferSave::getPrefix(String& prefix) const
void BufferSave::getPrefix(string& prefix) const
{
prefix = m_prefix;
}
......
......@@ -5,15 +5,15 @@
using namespace lima;
using namespace std;
Exception::Exception(Layer layer, ErrorType err_type, String err_desc,
String file_name, String funct_name, int line_nr)
Exception::Exception(Layer layer, ErrorType err_type, string err_desc,
string file_name, string funct_name, int line_nr)
: m_layer(layer), m_err_type(err_type), m_err_desc(err_desc),
m_file_name(file_name), m_funct_name(funct_name), m_line_nr(line_nr)
{
}
Exception::String Exception::getErrMsg() const
string Exception::getErrMsg() const
{
ostringstream os;
os << m_layer << ": "
......@@ -23,7 +23,7 @@ Exception::String Exception::getErrMsg() const
return os.str();
}
std::ostream& lima::operator <<(std::ostream& os, Layer layer)
ostream& lima::operator <<(ostream& os, Layer layer)
{
string name = "Unknown";
switch (layer) {
......@@ -34,7 +34,7 @@ std::ostream& lima::operator <<(std::ostream& os, Layer layer)
return os << name;
}
std::ostream& lima::operator <<(std::ostream& os, ErrorType err_type)
ostream& lima::operator <<(ostream& os, ErrorType err_type)
{
string name = "Unknown";
switch (err_type) {
......@@ -45,7 +45,7 @@ std::ostream& lima::operator <<(std::ostream& os, ErrorType err_type)
return os << name;
}
std::ostream& lima::operator <<(std::ostream& os, const Exception& e)
ostream& lima::operator <<(ostream& os, const Exception& e)
{
return os << e.getErrMsg();
}
......
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