Pco.h 4.27 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/**************************************************************************
###########################################################################
 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/>.
###########################################################################
**************************************************************************/
24 25 26 27 28 29 30 31 32 33 34
#ifndef PCO_H
#define PCO_H

#define _LINUX

#ifdef __x86_64
	#define _x64
#else
	#define _x86
#endif

35

36
#include "processlib/Compatibility.h"
37 38 39 40
#include "PCO_Structures.h"
#include "PCO_ConvStructures.h"
#include "Pco_ConvDlgExport.h"
#include "sc2_SDKStructures.h"
Roberto Arturo Homs-Regojo's avatar
Roberto Arturo Homs-Regojo committed
41
#include "sc2_common.h"
42 43
#include "SC2_CamExport.h"
#include "sc2_defs.h"
44 45 46 47 48
#include "SC2_SDKAddendum.h"
#include "PCO_errt.h"


#include <math.h>
49

unknown's avatar
unknown committed
50 51 52

#define DWORD_MAX ULONG_MAX 

53
#define ERR_SIZE	256
54
#define ERRMSG_SIZE	(256+128)
Roberto Arturo Homs-Regojo's avatar
Roberto Arturo Homs-Regojo committed
55 56 57
#define MODEL_TYPE_SIZE	64
#define MODEL_SUBTYPE_SIZE	64
#define INTERFACE_TYPE_SIZE	64
58
#define CAMERA_NAME_SIZE	128
59
#define MSG_SIZE	512
Roberto Arturo Homs Regojo's avatar
Roberto Arturo Homs Regojo committed
60
#define BUFF_XLAT_SIZE 128
61
#define MSG1K	(1024 * 1)
62
#define MSG2K	(1024 * 2)
63 64
#define MSG4K	(1024 * 4)
#define MSG8K	(1024 * 8)
65

66
#define ID_TIMESTAMP "$Id: [" __DATE__ " " __TIME__ "] [" __TIMESTAMP__ "] [" __FILE__ "] $"
67 68 69

typedef DWORD tPvUint32;
typedef int tPvErr;
70

Roberto Arturo Homs Regojo's avatar
Roberto Arturo Homs Regojo committed
71 72 73 74 75 76
#define THROW_LIMA_HW_EXC(e, x)  { \
	printf("========*** LIMA_HW_EXC %s\n", x ); \
			throw LIMA_HW_EXC(e, x); \
} 


77

78
#if 0
Roberto Arturo Homs Regojo's avatar
Roberto Arturo Homs Regojo committed
79 80 81
#define PCO_TRACE(x)  \
{ \
		if(error){ \
82 83 84 85
			char msg[ERRMSG_SIZE+1]; \
			sprintf_s(msg, "=== %s PcoError[x%08x][%s]", x, m_pcoData->pcoError,  m_pcoData->pcoErrorMsg); \
			DEB_TRACE() << msg; \
			throw LIMA_HW_EXC(Error, msg); \
Roberto Arturo Homs Regojo's avatar
Roberto Arturo Homs Regojo committed
86 87 88 89 90 91 92 93 94 95 96 97
		} \
		DEB_TRACE() << "*** " <<  x << " OK" ; \
}
#define _PCO_TRACE(x, s)  \
{ \
		if(error){ \
			DEB_TRACE() << "*** " <<  x << " PCO ERROR " << s; \
			throw LIMA_HW_EXC(Error, x); \
		} \
		DEB_TRACE() << "*** " <<  x << " OK" ; \
}

98 99 100 101 102
#endif

#define PCO_THROW_OR_TRACE(__err__, __msg__)  \
{ \
		if(__err__){ \
103
			char ___buff___[ERRMSG_SIZE+1]; \
Roberto Arturo Homs-Regojo's avatar
Roberto Arturo Homs-Regojo committed
104 105
			sprintf_s(___buff___, ERRMSG_SIZE, "LIMA_HW_EXC ===> %s PcoError[x%08x][%s]", __msg__, m_pcoData->pcoError,  m_pcoData->pcoErrorMsg); \
			DEB_ALWAYS() << ___buff___; \
106
			throw LIMA_HW_EXC(Error, ___buff___); \
107 108 109 110
		} \
		DEB_TRACE() << "*** " <<  __msg__ << " OK" ; \
}

111 112 113 114 115 116 117 118 119
#define PCO_PRINT_ERR(__err__, __msg__)  \
{ \
		if(__err__){ \
			char ___buff___[ERRMSG_SIZE+1]; \
			sprintf_s(___buff___,  ERRMSG_SIZE, "=== %s PcoError[x%08x][%s]", __msg__, m_pcoData->pcoError,  m_pcoData->pcoErrorMsg); \
			printf("%s [%s][%d]\n", ___buff___, __FILE__, __LINE__); \
			DEB_TRACE() << ___buff___; \
		} \
}
120

121
#define DEF_FNID 	static char *fnId =__FUNCTION__;
Roberto Arturo Homs Regojo's avatar
Roberto Arturo Homs Regojo committed
122

123 124
#define PRINTLINES { for(int i = 0; i<50;i++) printf("=====  %s [%d]/[%d]\n", __FILE__, __LINE__,i); }

125
#define PCO_FN0(er,mg, fn) {mg = #fn; er = PcoCheckError(__LINE__, __FILE__, fn ( ), #fn ); }
126 127 128 129 130 131
#define PCO_FN1(er,mg, fn, x1) {mg = #fn; er = PcoCheckError(__LINE__, __FILE__, fn ( (x1) ), #fn ); }
#define PCO_FN2(er,mg, fn, x1, x2) {mg = #fn; er = PcoCheckError(__LINE__, __FILE__, fn ( (x1),(x2) ), #fn ) ; }
#define PCO_FN3(er,mg, fn, x1, x2, x3) {mg = #fn; er = PcoCheckError(__LINE__, __FILE__, fn ( (x1),(x2),(x3) ), #fn ) ; }
#define PCO_FN4(er,mg, fn, x1, x2, x3, x4) {mg = #fn; er = PcoCheckError(__LINE__, __FILE__, fn ( (x1),(x2),(x3),(x4) ), #fn ) ; }
#define PCO_FN5(er,mg, fn, x1, x2, x3, x4, x5) {mg = #fn; er = PcoCheckError(__LINE__, __FILE__, fn ( (x1),(x2),(x3),(x4),(x5) ), #fn ) ; }

Roberto Arturo Homs-Regojo's avatar
Roberto Arturo Homs-Regojo committed
132 133 134
char * _sprintComment(char *comment, char *comment1 ="" , char *comment2 ="" );
int _get_imageNr_from_imageTimestamp(void *buf,int shift);
int _get_time_from_imageTimestamp(void *buf,int shift,SYSTEMTIME *st);
135
#endif