39 #include <tpia_target.h>
40 #include <tpia_misc.h>
43 #if defined __cplusplus
75 int tpia_frame_setFromString( statusMessageReporting *smr,
const char *forItem,
const char *value,
int dimension, tpia_data_frame *frame ) {
80 for( i = 0; i < tpia_maxNumberOfFrames; i++ )
tpia_frame_setColumn( smr, frame, i, tpia_referenceFrame_None );
81 if( dimension > tpia_maxNumberOfFrames ) {
82 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"dimension argument = %d is greater than tpia_maxNumberOfFrames = %d", dimension,
83 tpia_maxNumberOfFrames );
86 for( i = 0, e = value; ( i < dimension ) && ( *e != 0 ); i++ ) {
87 if( strstr( e, lab_Str ) == e ) {
90 else if( strstr( e,
COM_Str ) == e ) {
94 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"bad frame '%s' for %s", value, forItem );
99 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"bad separater for frame '%s' for %s", value, forItem );
106 if( i == dimension ) {
110 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"extra values for frame '%s' for %s", value, forItem );
113 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"missing values for frame '%s' for %s", value, forItem );
124 int i, dimension = 0;
125 unsigned value = frame->frames;
127 for( i = 0; i < tpia_maxNumberOfFrames; i++ ) {
128 if( ( value & 3 ) == 0 )
break;
141 char *str = NULL, *p;
143 if( nlab_Str == 0 ) {
144 nlab_Str = strlen( lab_Str );
147 for( i = 0; i <
n; i++ ) {
149 if( value == tpia_referenceFrame_COM ) {
151 else if( value == tpia_referenceFrame_lab ) {
152 nStr += nlab_Str + 1; }
154 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"bad frame value = %d for column = %d", value, i );
158 if( nStr == 0 ) nStr = 1;
160 if( ( str = (
char*) xData_malloc2( smr, nStr, 1,
"str" ) ) == NULL )
return( NULL );
161 for( i = 0, p = str - 1; i <
n; i++ ) {
164 if( value == tpia_referenceFrame_COM ) {
168 strcpy( p, lab_Str );
184 for( i = 0; i < nColumns; i++ )
if(
tpia_frame_setColumn( smr, frame, i, values[i] ) != 0 )
return( 1 );
195 if( ( column < 0 ) || ( column >= tpia_maxNumberOfFrames ) ) {
196 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"bad column = %d value for setting frame (0 <= column < %d)", column, tpia_maxNumberOfFrames );
199 if( ( value < tpia_referenceFrame_None ) || ( value > tpia_referenceFrame_Max ) ) {
200 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"bad frame value = %d for column = %d", value, column );
203 i = 3 << ( 2 * column );
204 frame->frames = frame->frames & (~i);
205 value = value << ( 2 * column );
206 frame->frames = frame->frames | value;
218 if( ( column < 0 ) || ( column >= tpia_maxNumberOfFrames ) ) {
219 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"bad column = %d value for getting frame (0 <= column < %d)", column, tpia_maxNumberOfFrames );
222 value = frame->frames >> ( 2 * column );
224 return( (
int) ( value & 3 ) );
227 #if defined __cplusplus
int tpia_frame_setColumns(statusMessageReporting *smr, tpia_data_frame *frame, int nColumns, int *values)
int tpia_frame_clear(statusMessageReporting *, tpia_data_frame *frame)
static G4ThreadLocal int nlab_Str
static const char COM_Str[]
int tpia_misc_setMessageError_Element(statusMessageReporting *smr, void *userInterface, xData_element *element, const char *file, int line, int code, const char *fmt,...)
int smr_setMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...)
const char * xData_getAttributesValueInElement(xData_element *element, const char *name)
int tpia_frame_setFromString(statusMessageReporting *smr, const char *forItem, const char *value, int dimension, tpia_data_frame *frame)
int smr_isOk(statusMessageReporting *smr)
int tpia_frame_getColumn(statusMessageReporting *smr, tpia_data_frame *frame, int column)
static G4ThreadLocal int nCOM_Str
int tpia_frame_setColumn(statusMessageReporting *smr, tpia_data_frame *frame, int column, int value)
int tpia_frame_getDimensions(statusMessageReporting *, tpia_data_frame *frame)
int tpia_frame_setFromElement(statusMessageReporting *smr, xData_element *element, int dimension, tpia_data_frame *frame)
static const char lab_Str[]
char * tpia_frame_toString(statusMessageReporting *smr, const char *, tpia_data_frame *frame)