Skip to content
Snippets Groups Projects
Commit ba5b77eb authored by Julien Malik's avatar Julien Malik
Browse files

add little script for testing '"offline" calibration

parent 0a9574ab
No related branches found
No related tags found
No related merge requests found
#=============================================================================
#-- SOLEIL_ROOT - default install directory
#=============================================================================
ifndef SOLEIL_ROOT
SOLEIL_ROOT = /usr/Local/soleil-root
endif
#=============================================================================
# PROJECT_TYPE
#=============================================================================
# - STATIC_LIB : your project is a static library (.a)
# - SHARED_LIB : your project is a shared library (.so)
# - DEVICE : your project is a TANGO device
# - SIMPLE_EXE : your project is a simple executable binary
#-----------------------------------------------------------------------------
PROJECT_TYPE = SIMPLE_EXE
#=============================================================================
# RELEASE_TYPE
#=============================================================================
# - DEBUG : debug symbols - no optimization
# - OPTIMIZED : no debug symbols - optimization level set to O2
#-----------------------------------------------------------------------------
RELEASE_TYPE = OPTIMIZED
#=============================================================================
# TANGO_REQUIRED
#=============================================================================
# - TRUE : your project depends on TANGO
# - FALSE : your project does not depend on TANGO
#-----------------------------------------------------------------------------
# - NOTE : if PROJECT_TYPE is set to DEVICE, TANGO will be auto. added
#-----------------------------------------------------------------------------
TANGO_REQUIRED = TRUE
#=============================================================================
# OUTPUT_DIR - this directory will contain the build result
#=============================================================================
# - STATIC_LIB : defaults to ../lib
# - SHARED_LIB : defaults to ../lib
# - DEVICE : defaults to $(HOME)/DeviceServers
# - SIMPLE_EXE : defaults to ../bin
#-----------------------------------------------------------------------------
OUTPUT_DIR = ../../bin
#=============================================================================
# PROJECT_NAME is the name of the library/device/exe you want to build
#=============================================================================
# - for a DEVICE : PROJECT_NAME will be prefixed by 'ds_'
# - for a STATIC_LIB : PROJECT_NAME will be prefixed by 'lib'
# - for a SHARED_LIB : PROJECT_NAME will be prefixed by 'lib'
# - for a SIMPLE_EXE : PROJECT_NAME will be the name of the executable
#-----------------------------------------------------------------------------
PROJECT_NAME = calib_save_img
#=============================================================================
# INC_DIR_USER - user defined include paths
#=============================================================================
# - for a DEVICE : TANGO dependencies are automatically added
# - any PROJECT_TYPE : "../include" and "." are automatically added
#-----------------------------------------------------------------------------
INC_DIR_USER =
#=============================================================================
# LIB_DIR_USER - user defined library paths
#=============================================================================
# - for a DEVICE : the TANGO libraries directories are automatically added
# - any PROJECT_TYPE : "../lib" is automatically added
#-----------------------------------------------------------------------------
LIB_DIR_USER =
#=============================================================================
# CXXFLAGS_USER - compiler options or user defined macros
#=============================================================================
# - NOTE : put your compile-time macros here using '-Dmy_macro'
#-----------------------------------------------------------------------------
#####> CXXFLAGS_USER = <your macros and/or compiler options>
#=============================================================================
# LDFLAGS_USER - linker options or user defined libraries
#=============================================================================
# - for a DEVICE : the TANGO libraries are automatically added
# - any PROJECT_TYPE : '-ldl -lpthread' are automatically added
#-----------------------------------------------------------------------------
# - NOTE : Be aware that the order matters! For instance, if you link your
# project versus libA, and libA depends itself on libB, you must
# use '-lA -lB', you will get 'undefined reference' errors otherwise
#----------------------------------------------------------------------------
LDFLAGS_USER =
#=============================================================================
# TANGO.OPT - include standard TANGO compilation options
#=============================================================================
include $(SOLEIL_ROOT)/env/tango.opt
#=============================================================================
# SVC_OBJS - is the list of all objects needed in order to build the project
#=============================================================================
# - NOTE : the following example is given for the average TANGO device
#-----------------------------------------------------------------------------
SVC_OBJS = $(OBJ_DIR)/calib_save_img.o
#=============================================================================
# VERBOSE - comment the following line if you want a verbose compilation
#=============================================================================
.SILENT:
#=============================================================================
# COMMON_TARGET.OPT - include standard TANGO compilation options
#=============================================================================
include $(SOLEIL_ROOT)/env/common_target.opt
#
device_server= calib_save_img
#
# LEs PATHS des includes propres à ce DServer
INCUSER =
#
# Le chemin complet de vos Librairies
#
LIBUSER=
# Si vous souhaitez générer une librairie et pas un executable
# decommentez la ligne suivante
#LIBRARY_NAME=
#
# Le chemin ou j'ai d'autres fichiers sources que ceux du DeviceServer à compiler
CPPDIRUSER=
#
# ------------------Fin des modifications pour le end user -------------------------------------
#
make_dir=$(SOLEIL_ROOT)\env
# Les définitions communes à tous les DeviceServeurs
!include $(make_dir)\tango.opt
exe_device_server= ..\..\bin\$(device_server).exe
pdb_name= $(TEMPLIBDIR)\$(device_server).pdb
# --------------------------------------
# Partie spécifique Device Server
# --------------------------------------
LISTEOBJ = $(OBJDIR)\calib_save_img.OBJ
# --------------------------------------
!include $(make_dir)\common_target.opt
#include <algorithm>
#include <tango.h>
void usage()
{
std::cout << "Usage : calib_save_img [attribute] [file]" << std::endl;
}
int main(int argc, char* argv[])
{
if (argc != 3)
{
usage();
return 1;
}
std::string attr_name = argv[1];
std::string filename = argv[2];
//- add extensions
filename = filename + ".private_format";
int w,h;
try
{
Tango::DeviceAttribute d = Tango::AttributeProxy( attr_name ).read();
w = d.dim_x;
h = d.dim_y;
std::vector<unsigned short> v;
unsigned short* v_buf = new unsigned short[w * h];
d >> v;
std::copy( v.begin(), v.end(), v_buf );
std::ofstream file( filename.c_str(), ios::binary );
file.write( reinterpret_cast<char*>(&w), sizeof(long) );
file.write( reinterpret_cast<char*>(&h), sizeof(long) );
file.write( reinterpret_cast<char*>(v_buf), w * h * sizeof(unsigned short) );
}
catch( std::bad_alloc& )
{
std::cerr << "BAD ALLOC" << std::endl;
return 2;
}
catch( Tango::DevFailed& df )
{
std::cerr << "TANGO ERROR" << std::endl;
std::cerr << df.errors[0].desc << std::endl;
return 4;
}
std::cout << "SUCCESS !" << std::endl;
return 0;
}
#=============================================================================
#-- SOLEIL_ROOT - default install directory
#=============================================================================
ifndef SOLEIL_ROOT
SOLEIL_ROOT = /usr/Local/soleil-root
endif
#=============================================================================
# PROJECT_TYPE
#=============================================================================
# - STATIC_LIB : your project is a static library (.a)
# - SHARED_LIB : your project is a shared library (.so)
# - DEVICE : your project is a TANGO device
# - SIMPLE_EXE : your project is a simple executable binary
#-----------------------------------------------------------------------------
PROJECT_TYPE = SIMPLE_EXE
#=============================================================================
# RELEASE_TYPE
#=============================================================================
# - DEBUG : debug symbols - no optimization
# - OPTIMIZED : no debug symbols - optimization level set to O2
#-----------------------------------------------------------------------------
RELEASE_TYPE = OPTIMIZED
#=============================================================================
# TANGO_REQUIRED
#=============================================================================
# - TRUE : your project depends on TANGO
# - FALSE : your project does not depend on TANGO
#-----------------------------------------------------------------------------
# - NOTE : if PROJECT_TYPE is set to DEVICE, TANGO will be auto. added
#-----------------------------------------------------------------------------
TANGO_REQUIRED = TRUE
#=============================================================================
# OUTPUT_DIR - this directory will contain the build result
#=============================================================================
# - STATIC_LIB : defaults to ../lib
# - SHARED_LIB : defaults to ../lib
# - DEVICE : defaults to $(HOME)/DeviceServers
# - SIMPLE_EXE : defaults to ../bin
#-----------------------------------------------------------------------------
OUTPUT_DIR = ../../bin
#=============================================================================
# PROJECT_NAME is the name of the library/device/exe you want to build
#=============================================================================
# - for a DEVICE : PROJECT_NAME will be prefixed by 'ds_'
# - for a STATIC_LIB : PROJECT_NAME will be prefixed by 'lib'
# - for a SHARED_LIB : PROJECT_NAME will be prefixed by 'lib'
# - for a SIMPLE_EXE : PROJECT_NAME will be the name of the executable
#-----------------------------------------------------------------------------
PROJECT_NAME = calib_write_img
#=============================================================================
# INC_DIR_USER - user defined include paths
#=============================================================================
# - for a DEVICE : TANGO dependencies are automatically added
# - any PROJECT_TYPE : "../include" and "." are automatically added
#-----------------------------------------------------------------------------
INC_DIR_USER =
#=============================================================================
# LIB_DIR_USER - user defined library paths
#=============================================================================
# - for a DEVICE : the TANGO libraries directories are automatically added
# - any PROJECT_TYPE : "../lib" is automatically added
#-----------------------------------------------------------------------------
LIB_DIR_USER =
#=============================================================================
# CXXFLAGS_USER - compiler options or user defined macros
#=============================================================================
# - NOTE : put your compile-time macros here using '-Dmy_macro'
#-----------------------------------------------------------------------------
#####> CXXFLAGS_USER = <your macros and/or compiler options>
#=============================================================================
# LDFLAGS_USER - linker options or user defined libraries
#=============================================================================
# - for a DEVICE : the TANGO libraries are automatically added
# - any PROJECT_TYPE : '-ldl -lpthread' are automatically added
#-----------------------------------------------------------------------------
# - NOTE : Be aware that the order matters! For instance, if you link your
# project versus libA, and libA depends itself on libB, you must
# use '-lA -lB', you will get 'undefined reference' errors otherwise
#----------------------------------------------------------------------------
LDFLAGS_USER =
#=============================================================================
# TANGO.OPT - include standard TANGO compilation options
#=============================================================================
include $(SOLEIL_ROOT)/env/tango.opt
#=============================================================================
# SVC_OBJS - is the list of all objects needed in order to build the project
#=============================================================================
# - NOTE : the following example is given for the average TANGO device
#-----------------------------------------------------------------------------
SVC_OBJS = $(OBJ_DIR)/calib_save_img.o
#=============================================================================
# VERBOSE - comment the following line if you want a verbose compilation
#=============================================================================
.SILENT:
#=============================================================================
# COMMON_TARGET.OPT - include standard TANGO compilation options
#=============================================================================
include $(SOLEIL_ROOT)/env/common_target.opt
#
device_server= calib_write_img
#
# LEs PATHS des includes propres à ce DServer
INCUSER =
#
# Le chemin complet de vos Librairies
#
LIBUSER=
# Si vous souhaitez générer une librairie et pas un executable
# decommentez la ligne suivante
#LIBRARY_NAME=
#
# Le chemin ou j'ai d'autres fichiers sources que ceux du DeviceServer à compiler
CPPDIRUSER=
#
# ------------------Fin des modifications pour le end user -------------------------------------
#
make_dir=$(SOLEIL_ROOT)\env
# Les définitions communes à tous les DeviceServeurs
!include $(make_dir)\tango.opt
exe_device_server= ..\..\bin\$(device_server).exe
pdb_name= $(TEMPLIBDIR)\$(device_server).pdb
# --------------------------------------
# Partie spécifique Device Server
# --------------------------------------
LISTEOBJ = $(OBJDIR)\calib_write_img.OBJ
# --------------------------------------
!include $(make_dir)\common_target.opt
#include <algorithm>
#include <tango.h>
void usage()
{
std::cout << "Usage : calib_write_img [attribute] [file]" << std::endl;
}
int main(int argc, char* argv[])
{
if (argc != 3)
{
usage();
return 1;
}
std::string attr_name = argv[1];
std::string filename = argv[2];
std::string cfg_filename = filename;
//- add extensions
filename = filename + ".private_format";
int w,h;
try
{
std::ifstream file( filename.c_str(), ios::binary );
file.read( reinterpret_cast<char*>(&w), sizeof(int) );
file.read( reinterpret_cast<char*>(&h), sizeof(int) );
std::cout << "reading image file " << filename << std::endl;
std::cout << "width = " << w << std::endl;
std::cout << "height = " << h << std::endl;
unsigned short* img_buf = new unsigned short[w * h];
file.read( reinterpret_cast<char*>(img_buf), w * h * sizeof(unsigned short) );
if ( file.fail() )
{
std::cerr << "FAILED READING FILE" << std::endl;
return 2;
}
std::vector<unsigned short> v;
std::copy( img_buf, img_buf + w * h, std::back_inserter(v) );
Tango::AttributeProxy( attr_name ).write( Tango::DeviceAttribute(attr_name, v, w, h) );
delete [] img_buf;
}
catch( std::bad_alloc& )
{
std::cerr << "BAD ALLOC" << std::endl;
return 3;
}
catch( Tango::DevFailed& df )
{
std::cerr << "TANGO ERROR" << std::endl;
std::cerr << df.errors[0].desc << std::endl;
return 4;
}
std::cout << "SUCCESS !" << std::endl;
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment