New Feature: load/save lima configuration

parent e03c705f
......@@ -82,3 +82,6 @@
[submodule "camera/andor3"]
path = camera/andor3
url = git://github.com/esrf-bliss/Lima-camera-andor3.git
[submodule "third-party/libconfig"]
path = third-party/libconfig
url = git://github.com/esrf-bliss/libconfig.git
......@@ -56,7 +56,7 @@ create-links = \
# LIMA - CORE
############################
CORE_LDFLAGS := -L../third-party/Processlib/build
CORE_LDFLAGS := -L../third-party/Processlib/build -Wl,-rpath=$(shell pwd)/../third-party/Processlib/build
CORE_LDLIBS := -lprocesslib -lrt
ifneq ($(COMPILE_CBF_SAVING),0)
......@@ -73,6 +73,10 @@ ifneq ($(COMPILE_EDFGZ_SAVING),0)
CORE_LDLIBS += -lz
endif
ifneq ($(COMPILE_CONFIG),0)
CORE_LDLIBS += -L../third-party/libconfig/lib/.libs -Wl,-rpath=$(shell pwd)/../third-party/libconfig/lib/.libs -lconfig++
endif
ifneq ($(COMPILE_CORE),0)
core-name := core
......
......@@ -3,14 +3,19 @@ Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibSimulator", "LibSimulator.vcproj", "{3E1490E7-66C0-4E77-9746-0632466FF270}"
ProjectSection(ProjectDependencies) = postProject
{F6556656-D091-43AF-B46F-355F4ABA5DB6} = {F6556656-D091-43AF-B46F-355F4ABA5DB6}
{A4B703A6-C50F-442F-8952-54FB8EA51FF3} = {A4B703A6-C50F-442F-8952-54FB8EA51FF3}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibLimaCore", "..\LimaCore\LimaCore.vcproj", "{A4B703A6-C50F-442F-8952-54FB8EA51FF3}"
ProjectSection(ProjectDependencies) = postProject
{F6556656-D091-43AF-B46F-355F4ABA5DB6} = {F6556656-D091-43AF-B46F-355F4ABA5DB6}
{1A234565-926D-49B2-83E4-D56E0C38C9F2} = {1A234565-926D-49B2-83E4-D56E0C38C9F2}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libprocesslib", "..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\libprocesslib.vcproj", "{F6556656-D091-43AF-B46F-355F4ABA5DB6}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libconfig", "..\..\..\..\third-party\libconfig\lib\libconfig.vcproj", "{1A234565-926D-49B2-83E4-D56E0C38C9F2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
......@@ -29,6 +34,10 @@ Global
{F6556656-D091-43AF-B46F-355F4ABA5DB6}.Debug|Win32.Build.0 = Debug|Win32
{F6556656-D091-43AF-B46F-355F4ABA5DB6}.Release|Win32.ActiveCfg = Release|Win32
{F6556656-D091-43AF-B46F-355F4ABA5DB6}.Release|Win32.Build.0 = Release|Win32
{1A234565-926D-49B2-83E4-D56E0C38C9F2}.Debug|Win32.ActiveCfg = Debug|Win32
{1A234565-926D-49B2-83E4-D56E0C38C9F2}.Debug|Win32.Build.0 = Debug|Win32
{1A234565-926D-49B2-83E4-D56E0C38C9F2}.Release|Win32.ActiveCfg = Release|Win32
{1A234565-926D-49B2-83E4-D56E0C38C9F2}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -178,6 +178,14 @@
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\..\..\camera\simulator\src\SimulatorCamera.cpp"
>
</File>
<File
RelativePath="..\..\..\..\camera\simulator\src\SimulatorDetInfoCtrlObj.cpp"
>
</File>
<File
RelativePath="..\..\..\..\camera\simulator\src\SimulatorFrameBuilder.cpp"
>
......@@ -187,7 +195,7 @@
>
</File>
<File
RelativePath="..\..\..\..\camera\simulator\src\SimulatorCamera.cpp"
RelativePath="..\..\..\..\camera\simulator\src\SimulatorSyncCtrlObj.cpp"
>
</File>
</Filter>
......@@ -197,15 +205,15 @@
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\..\..\camera\simulator\include\SimulatorFrameBuilder.h"
RelativePath="..\..\..\..\camera\simulator\include\SimulatorCamera.h"
>
</File>
<File
RelativePath="..\..\..\..\camera\simulator\include\SimulatorInterface.h"
RelativePath="..\..\..\..\camera\simulator\include\SimulatorFrameBuilder.h"
>
</File>
<File
RelativePath="..\..\..\..\camera\simulator\include\SimulatorCamera.h"
RelativePath="..\..\..\..\camera\simulator\include\SimulatorInterface.h"
>
</File>
</Filter>
......
......@@ -4,10 +4,13 @@ Microsoft Visual Studio Solution File, Format Version 10.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibLimaCore", "LimaCore.vcproj", "{A4B703A6-C50F-442F-8952-54FB8EA51FF3}"
ProjectSection(ProjectDependencies) = postProject
{F6556656-D091-43AF-B46F-355F4ABA5DB6} = {F6556656-D091-43AF-B46F-355F4ABA5DB6}
{A0C36CE7-D908-4573-8B69-249EEEB7D2BE} = {A0C36CE7-D908-4573-8B69-249EEEB7D2BE}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libprocesslib", "..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\libprocesslib.vcproj", "{F6556656-D091-43AF-B46F-355F4ABA5DB6}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libconfig++", "..\..\..\..\third-party\libconfig\lib\libconfig++.vcproj", "{A0C36CE7-D908-4573-8B69-249EEEB7D2BE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
......@@ -22,6 +25,10 @@ Global
{F6556656-D091-43AF-B46F-355F4ABA5DB6}.Debug|Win32.Build.0 = Debug|Win32
{F6556656-D091-43AF-B46F-355F4ABA5DB6}.Release|Win32.ActiveCfg = Release|Win32
{F6556656-D091-43AF-B46F-355F4ABA5DB6}.Release|Win32.Build.0 = Release|Win32
{A0C36CE7-D908-4573-8B69-249EEEB7D2BE}.Debug|Win32.ActiveCfg = Debug|Win32
{A0C36CE7-D908-4573-8B69-249EEEB7D2BE}.Debug|Win32.Build.0 = Debug|Win32
{A0C36CE7-D908-4573-8B69-249EEEB7D2BE}.Release|Win32.ActiveCfg = Release|Win32
{A0C36CE7-D908-4573-8B69-249EEEB7D2BE}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -42,8 +42,8 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\control\src;&quot;..\..\..\..\third-party\Processlib\tasks\include&quot;;&quot;..\..\..\..\third-party\Processlib\core\include\WindowSpecific&quot;;&quot;..\..\..\..\third-party\Processlib\core\include&quot;;..\..\..\..\control\software_operation\include;..\..\..\..\control\include;..\..\..\..\hardware\include;..\..\..\..\common\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIMACORE_EXPORTS;_WIN32_WINNT=0x0502"
AdditionalIncludeDirectories="..\..\..\..\control\src;&quot;..\..\..\..\third-party\Processlib\tasks\include&quot;;&quot;..\..\..\..\third-party\Processlib\core\include\WindowSpecific&quot;;&quot;..\..\..\..\third-party\Processlib\core\include&quot;;..\..\..\..\control\software_operation\include;..\..\..\..\control\include;..\..\..\..\hardware\include;..\..\..\..\common\include;&quot;..\..\..\..\third-party\libconfig\lib&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIMACORE_EXPORTS;_WIN32_WINNT=0x0502;WITH_CONFIG"
MinimalRebuild="true"
BasicRuntimeChecks="0"
RuntimeLibrary="2"
......@@ -65,7 +65,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(InputDir)..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\Debug\libprocesslib.lib"
AdditionalDependencies="$(InputDir)..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\Debug\libprocesslib.lib $(InputDir)..\..\..\..\third-party\libconfig\lib\libconfig++.Debug\libconfig++_d.lib"
OutputFile="$(InputDir)$(IntDir)\$(ProjectName).dll"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\Debug&quot;"
......@@ -123,8 +123,8 @@
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\..\..\..\control\src;&quot;..\..\..\..\third-party\Processlib\tasks\include&quot;;&quot;..\..\..\..\third-party\Processlib\core\include\WindowSpecific&quot;;&quot;..\..\..\..\third-party\Processlib\core\include&quot;;..\..\..\..\control\software_operation\include;..\..\..\..\control\include;..\..\..\..\hardware\include;..\..\..\..\common\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIMACORE_EXPORTS;_WIN32_WINNT=0x0502"
AdditionalIncludeDirectories="..\..\..\..\control\src;&quot;..\..\..\..\third-party\Processlib\tasks\include&quot;;&quot;..\..\..\..\third-party\Processlib\core\include\WindowSpecific&quot;;&quot;..\..\..\..\third-party\Processlib\core\include&quot;;..\..\..\..\control\software_operation\include;..\..\..\..\control\include;..\..\..\..\hardware\include;..\..\..\..\common\include;&quot;..\..\..\..\third-party\libconfig\lib&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIMACORE_EXPORTS;_WIN32_WINNT=0x0502;WITH_CONFIG"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
......@@ -145,10 +145,10 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(InputDir)..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\Release\libprocesslib.lib"
AdditionalDependencies="$(InputDir)..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\Release\libprocesslib.lib $(InputDir)..\..\..\..\third-party\libconfig\lib\libconfig++.Release\libconfig++.lib"
OutputFile="$(InputDir)$(IntDir)\$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\Release&quot;"
AdditionalLibraryDirectories="&quot;..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\Release&quot;;&quot;..\..\..\..\third-party\libconfig\lib\libconfig++.Release&quot;"
GenerateDebugInformation="true"
GenerateMapFile="true"
MapExports="true"
......@@ -192,6 +192,10 @@
RelativePath="..\..\..\..\common\src\AcqState.cpp"
>
</File>
<File
RelativePath="..\..\..\..\common\src\ConfigUtils.cpp"
>
</File>
<File
RelativePath="..\..\..\..\common\src\Constants.cpp"
>
......@@ -208,6 +212,10 @@
RelativePath="..\..\..\..\control\src\CtBuffer.cpp"
>
</File>
<File
RelativePath="..\..\..\..\control\src\CtConfig.cpp"
>
</File>
<File
RelativePath="..\..\..\..\control\src\CtControl.cpp"
>
......@@ -397,6 +405,10 @@
RelativePath="..\..\..\..\control\include\CtBuffer.h"
>
</File>
<File
RelativePath="..\..\..\..\control\include\CtConfig.h"
>
</File>
<File
RelativePath="..\..\..\..\control\include\CtControl.h"
>
......@@ -453,6 +465,10 @@
RelativePath="..\..\..\..\hardware\include\HwCap.h"
>
</File>
<File
RelativePath="..\..\..\..\hardware\include\HwConfigCtrlObj.h"
>
</File>
<File
RelativePath="..\..\..\..\hardware\include\HwDetInfoCtrlObj.h"
>
......
......@@ -20,28 +20,27 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>.
############################################################################
std-objs = ../../../common/src/Common.o ../../../hardware/src/Hw.o
simu-objs = ../src/Simu.o
test-objs = test.o
test-ext-objs = $(simu-objs)
testsimulator-objs = testsimulator.o
testsimulator-ext-objs = $(simu-objs) $(std-objs)
testsimulator-ext-objs = $(simu-objs)
testsimuhwinterface-objs = testsimuhwinterface.o
testsimuhwinterface-ext-objs = $(simu-objs) $(std-objs)
testsimuhwinterface-ext-objs = $(simu-objs)
SRCS = $(test-objs:.o=.cpp) $(testsimulator-objs:.o=.cpp) \
$(testsimuhwinterface-objs:.o=.cpp)
INC = -I../include -I../../../common/include -I../../../hardware/include -I../../../third-party/Processlib/core/include
CXXFLAGS += $(INC) -Wall -pthread -g
LDFLAGS = -L../../../third-party/Processlib/build -lprocesslib -pthread -lrt
LDFLAGS = -L../../../third-party/Processlib/build -lprocesslib -L../../../build -llimacore -pthread -lrt
all: test testsimulator testsimuhwinterface
test: $(test-objs) $(test-ext-objs) $(std-objs)
test: $(test-objs) $(test-ext-objs)
$(CXX) -o $@ $+ $(LDFLAGS)
testsimulator: $(testsimulator-objs) $(testsimulator-ext-objs)
......
//###########################################################################
// 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/>.
//###########################################################################
#ifndef CONFIGUTILS_H
#define CONFIGUTILS_H
#include "Debug.h"
#include "LimaCompatibility.h"
namespace libconfig
{
class Setting;
}
namespace lima
{
class LIMACORE_API Setting
{
DEB_CLASS_NAMESPC(DebModCommon,"Setting","Common");
public:
Setting(libconfig::Setting* setting = NULL) : m_setting(setting) {}
// --- lookup
bool get(const char* alias,bool& value) const;
bool get(const char* alias,int& value) const;
bool get(const char* alias,long& value) const;
bool get(const char* alias,long long& value) const;
bool get(const char* alias,double& value) const;
bool get(const char* alias,const char*& value) const;
bool get(const char* alias,std::string &value) const;
// --- modifiers
void set(const char* alias,bool value);
void set(const char* alias,int value);
void set(const char* alias,long value);
void set(const char* alias,long long value);
void set(const char* alias,double value);
void set(const char* alias,const char* value);
void set(const char* alias,const std::string &value);
// --- child
Setting addChild(const char* alias);
bool getChild(const char* alias,Setting& child) const;
const libconfig::Setting* get_raw_setting() const {return m_setting;}
private:
libconfig::Setting* m_setting;
};
}
#endif
......@@ -44,13 +44,15 @@ enum ImageType {
};
LIMACORE_API std::ostream& operator <<(std::ostream& os, ImageType image_type);
LIMACORE_API const char* convert_2_string(ImageType image_type);
LIMACORE_API void convert_from_string(const std::string&,ImageType&);
enum AcqMode {
Single, Concatenation, Accumulation,
};
LIMACORE_API std::ostream& operator <<(std::ostream& os, AcqMode acq_mode);
LIMACORE_API const char* convert_2_string(AcqMode mode);
LIMACORE_API void convert_from_string(const std::string&,AcqMode&);
enum TrigMode {
IntTrig,IntTrigMult,
ExtTrigSingle, ExtTrigMult,
......@@ -58,7 +60,8 @@ enum TrigMode {
};
LIMACORE_API std::ostream& operator <<(std::ostream& os, TrigMode trig_mode);
LIMACORE_API const char* convert_2_string(TrigMode trigMode);
LIMACORE_API void convert_from_string(const std::string&,TrigMode&);
enum BufferMode {
Linear, Circular,
};
......@@ -72,7 +75,8 @@ enum ShutterMode {
typedef std::vector<ShutterMode> ShutterModeList;
LIMACORE_API std::ostream& operator <<(std::ostream& os, ShutterMode shutter_mode);
LIMACORE_API const char* convert_2_string(ShutterMode);
LIMACORE_API void convert_from_string(const std::string&,ShutterMode&);
enum AcqStatus {
AcqReady, AcqRunning, AcqFault, AcqConfig
};
......@@ -104,7 +108,8 @@ enum VideoMode {Y8,Y16,Y32,Y64,
I420,YUV411,YUV422,YUV444};
LIMACORE_API std::ostream& operator <<(std::ostream& os,VideoMode videoMode);
LIMACORE_API const char* convert_2_string(VideoMode);
LIMACORE_API void convert_from_string(const std::string&,VideoMode&);
enum RotationMode {
Rotation_0,
Rotation_90,
......@@ -113,6 +118,8 @@ enum RotationMode {
};
LIMACORE_API std::ostream& operator <<(std::ostream& os,RotationMode rotationMode);
LIMACORE_API const char* convert_2_string(RotationMode rotationMode);
LIMACORE_API void convert_from_string(const std::string&,RotationMode&);
} // namespace lima
#endif // CONSTANTS_H
//###########################################################################
// 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/>.
//###########################################################################
#include <libconfig.h++>
#include "Exceptions.h"
#include "ConfigUtils.h"
using namespace lima;
bool Setting::get(const char* alias,bool& value) const
{
return m_setting->lookupValue(alias,value);
}
bool Setting::get(const char* alias,int& value) const
{
return m_setting->lookupValue(alias,value);
}
bool Setting::get(const char* alias,long& value) const
{
long long tmpValue;
bool rFlag = m_setting->lookupValue(alias,tmpValue);
if(rFlag) value = long(tmpValue);
return rFlag;
}
bool Setting::get(const char* alias,long long& value) const
{
return m_setting->lookupValue(alias,value);
}
bool Setting::get(const char* alias,double& value) const
{
return m_setting->lookupValue(alias,value);
}
bool Setting::get(const char* alias,const char*& value) const
{
return m_setting->lookupValue(alias,value);
}
bool Setting::get(const char* alias,std::string& value) const
{
return m_setting->lookupValue(alias,value);
}
// --- modifiers
#define SET_VALUE(Type) \
if(m_setting->exists(alias)) \
m_setting->operator[](alias) = value; \
else \
{ \
libconfig::Setting& nSetting = m_setting->add(alias,Type); \
nSetting = value; \
}
void Setting::set(const char* alias,bool value)
{
SET_VALUE(libconfig::Setting::TypeBoolean);
}
void Setting::set(const char* alias,int value)
{
SET_VALUE(libconfig::Setting::TypeInt);
}
void Setting::set(const char* alias,long value)
{
SET_VALUE(libconfig::Setting::TypeInt64);
}
void Setting::set(const char* alias,long long value)
{
SET_VALUE(libconfig::Setting::TypeInt64);
}
void Setting::set(const char* alias,double value)
{
SET_VALUE(libconfig::Setting::TypeFloat);
}
void Setting::set(const char* alias,const char* value)
{
SET_VALUE(libconfig::Setting::TypeString);
}
void Setting::set(const char* alias,
const std::string &value)
{
SET_VALUE(libconfig::Setting::TypeString);
}
// --- child management
Setting Setting::addChild(const char *alias)
{
DEB_MEMBER_FUNCT();
try
{
libconfig::Setting &alias_setting = m_setting->add(alias,libconfig::Setting::TypeGroup);
return Setting(&alias_setting);
}
catch(libconfig::SettingNameException& exp)
{
THROW_COM_ERROR(Error) << exp.what();
}
catch(libconfig::SettingTypeException& exp)
{
THROW_COM_ERROR(Error) << exp.what();
}
}
bool Setting::getChild(const char* alias,Setting& child) const
{
bool returnFlag = m_setting->exists(alias);
if(returnFlag)
{
libconfig::Setting &alias_setting = m_setting->operator[](alias);
returnFlag = alias_setting.isGroup();
if(returnFlag)
child.m_setting = &alias_setting;
}
return returnFlag;
}
......@@ -19,6 +19,10 @@
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#include <algorithm>
#include "Debug.h"
#include "Exceptions.h"
#include "Constants.h"
using namespace lima;
......@@ -34,7 +38,7 @@ ostream& lima::operator <<(ostream& os, AlignDir align_dir)
return os << name;
}
ostream& lima::operator <<(ostream& os, ImageType image_type)
const char* lima::convert_2_string(ImageType image_type)
{
const char *name = "Unknown";
switch (image_type) {
......@@ -51,21 +55,74 @@ ostream& lima::operator <<(ostream& os, ImageType image_type)
case Bpp32: name = "Bpp32"; break;
case Bpp32S: name = "Bpp32S"; break;
}
return os << name;
return name;
}
void lima::convert_from_string(const std::string& val,
ImageType& image_type)
{
std::string buffer = val;
std::transform(buffer.begin(),buffer.end(),
buffer.begin(),::tolower);
if(buffer == "bpp8") image_type = Bpp8;
else if(buffer == "bpp8s") image_type = Bpp8S;
else if(buffer == "bpp10") image_type = Bpp10;
else if(buffer == "bpp10s") image_type = Bpp10S;
else if(buffer == "bpp12") image_type = Bpp12;
else if(buffer == "bpp12s") image_type = Bpp12S;
else if(buffer == "bpp14") image_type = Bpp14;
else if(buffer == "bpp14s") image_type = Bpp14S;
else if(buffer == "bpp16") image_type = Bpp16;
else if(buffer == "bpp16s") image_type = Bpp16S;
else if(buffer == "bpp32") image_type = Bpp32;
else if(buffer == "bpp32s") image_type = Bpp32S;
else
{
std::ostringstream msg;
msg << "ImageType can't be:" << DEB_VAR1(val);
throw LIMA_EXC(Common,InvalidValue,msg.str());
}
}
ostream& lima::operator <<(ostream& os, AcqMode acq_mode)
ostream& lima::operator <<(ostream& os, ImageType image_type)
{
const char *name = "Unknown";
return os << convert_2_string(image_type);
}
const char* lima::convert_2_string(AcqMode acq_mode)
{
const char *name = "Unknown";
switch (acq_mode) {
case Single: name = "Single"; break;
case Accumulation: name = "Accumulation"; break;
case Concatenation: name = "Concatenation"; break;
}
return os << name;
return name;
}
void lima::convert_from_string(const std::string& val,
AcqMode& mode)
{
std::string buffer = val;
std::transform(buffer.begin(),buffer.end(),
buffer.begin(),::tolower);
if(buffer == "single") mode = Single;
else if(buffer == "accumulation") mode = Accumulation;
else if(buffer == "concatenation") mode = Concatenation;
else
{
std::ostringstream msg;
msg << "AcqMode can't be:" << DEB_VAR1(val);
throw LIMA_EXC(Common,InvalidValue,msg.str());
}
}
ostream& lima::operator <<(ostream& os, AcqMode acq_mode)
{
return os << convert_2_string(acq_mode);
}
ostream& lima::operator <<(ostream& os, TrigMode trig_mode)
const char* lima::convert_2_string(TrigMode trig_mode)
{
const char *name = "Unknown";
switch (trig_mode) {
......@@ -77,7 +134,33 @@ ostream& lima::operator <<(ostream& os, TrigMode trig_mode)
case ExtStartStop: name = "ExtStartStop"; break;
case ExtTrigReadout: name = "ExtTrigReadout";break;
}
return os << name;
return name;
}
void lima::convert_from_string(const std::string& val,
TrigMode& trig_mode)
{
std::string buffer = val;
std::transform(buffer.begin(),buffer.end(),
buffer.begin(),::tolower);
if(buffer == "inttrig") trig_mode = IntTrig;
else if(buffer == "inttrigmult") trig_mode = IntTrigMult;
else if(buffer == "exttrigsingle") trig_mode = ExtTrigSingle;
else if(buffer == "exttrigmult") trig_mode = ExtTrigMult;
else if(buffer == "extgate") trig_mode = ExtGate;
else if(buffer == "extstartstop") trig_mode = ExtStartStop;
else if(buffer == "exttrigreadout") trig_mode = ExtTrigReadout;
else
{
std::ostringstream msg;
msg << "TrigMode can't be:" << DEB_VAR1(val);
throw LIMA_EXC(Common,InvalidValue,msg.str());