~epics-core/epics-base/3.14

7854 by Janet B. Anderson
Updated license comments.
1
/*************************************************************************\
11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
2
* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne
7854 by Janet B. Anderson
Updated license comments.
3
*     National Laboratory.
4
* Copyright (c) 2002 The Regents of the University of California, as
5
*     Operator of Los Alamos National Laboratory.
11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
6
* EPICS BASE is distributed subject to a Software License Agreement found
7854 by Janet B. Anderson
Updated license comments.
7
* in file LICENSE that is included with this distribution. 
8
\*************************************************************************/
11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
9
10
/* $Id$ */
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
11
/*
12
 *      Original Author: Bob Dalesio
13
 *      Date:            7-14-89 
14
 */
15

4221 by Marty Kraimer
changes for 3.14
16
#include <stddef.h>
17
#include <stdlib.h>
18
#include <stdarg.h>
19
#include <stdio.h>
20
#include <string.h>
21
#include <math.h>
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
22
3309 by Marty Kraimer
Fix include statements
23
#include "dbDefs.h"
24
#include "epicsPrint.h"
4221 by Marty Kraimer
changes for 3.14
25
#include "alarm.h"
26
#include "dbStaticLib.h"
27
#include "dbAccess.h"
28
#include "dbEvent.h"
29
#include "dbFldTypes.h"
30
#include "errMdef.h"
31
#include "special.h"
32
#include "recSup.h"
4826 by Marty Kraimer
include recGbl.h
33
#include "recGbl.h"
8769 by Marty Kraimer
more changes for epicsShare
34
#define GEN_SIZE_OFFSET
4221 by Marty Kraimer
changes for 3.14
35
#include "compressRecord.h"
8769 by Marty Kraimer
more changes for epicsShare
36
#undef  GEN_SIZE_OFFSET
8796 by Marty Kraimer
changes for epicsExport
37
#include "epicsExport.h"
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
38
39
/* Create RSET - Record Support Entry Table*/
40
#define report NULL
41
#define initialize NULL
11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
42
static long init_record(compressRecord *, int);
43
static long process(compressRecord *);
44
static long special(DBADDR *, int);
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
45
#define get_value NULL
11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
46
static long cvt_dbaddr(DBADDR *);
47
static long get_array_info(DBADDR *, long *, long *);
48
static long put_array_info(DBADDR *, long);
49
static long get_units(DBADDR *, char *);
50
static long get_precision(DBADDR *, long *);
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
51
#define get_enum_str NULL
52
#define get_enum_strs NULL
53
#define put_enum_str NULL
11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
54
static long get_graphic_double(DBADDR *, struct dbr_grDouble *);
55
static long get_control_double(DBADDR *, struct dbr_ctrlDouble *);
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
56
#define get_alarm_double NULL
57
8796 by Marty Kraimer
changes for epicsExport
58
rset compressRSET={
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
59
	RSETNUMBER,
60
	report,
61
	initialize,
62
	init_record,
63
	process,
64
	special,
65
	get_value,
66
	cvt_dbaddr,
67
	get_array_info,
68
	put_array_info,
69
	get_units,
70
	get_precision,
71
	get_enum_str,
72
	get_enum_strs,
73
	put_enum_str,
74
	get_graphic_double,
75
	get_control_double,
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
76
	get_alarm_double
77
};
8796 by Marty Kraimer
changes for epicsExport
78
epicsExportAddress(rset,compressRSET);
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
79

11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
80
static void reset(compressRecord *prec)
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
81
{
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
82
    prec->nuse = 0;
12045.1.1 by Ralph Lange
Fixed crash when ALG (algorithm) was changed to Average at runtime. (Fixes #552803)
83
    prec->off = 0;
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
84
    prec->inx = 0;
85
    prec->cvb = 0.0;
86
    prec->res = 0;
12045.1.1 by Ralph Lange
Fixed crash when ALG (algorithm) was changed to Average at runtime. (Fixes #552803)
87
    /* allocate memory for the summing buffer for conversions requiring it */
88
    if (prec->alg == compressALG_Average && prec->sptr == 0){
89
        prec->sptr = (double *)calloc(prec->nsam,sizeof(double));
90
    }
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
91
}
92
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
93
static void monitor(compressRecord *prec)
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
94
{
95
	unsigned short	monitor_mask;
96
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
97
        monitor_mask = recGblResetAlarms(prec);
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
98
	monitor_mask |= (DBE_LOG|DBE_VALUE);
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
99
	if(monitor_mask) db_post_events(prec,prec->bptr,monitor_mask);
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
100
	return;
101
}
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
102
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
103
static void put_value(compressRecord *prec,double *psource, epicsInt32 n)
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
104
{
105
/* treat bptr as pointer to a circular buffer*/
106
	double *pdest;
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
107
	epicsInt32 offset=prec->off;
108
	epicsInt32 nuse=prec->nuse;
109
	epicsInt32 nsam=prec->nsam;
11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
110
	epicsInt32 i;
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
111
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
112
	pdest = prec->bptr + offset;
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
113
	for(i=0; i<n; i++, psource++) {
114
		*pdest=*psource;
115
		offset++;
116
		if(offset>=nsam) {
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
117
			pdest=prec->bptr;
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
118
			offset=0;
119
		} else pdest++;
120
	}
121
	nuse = nuse+n;
122
	if(nuse>nsam) nuse=nsam;
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
123
	prec->off = offset;
124
	prec->nuse = nuse;
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
125
	return;
126
}
127

3974 by William Lupton
added 'N to 1 Median' algorithm (only for array inputs)
128
/* qsort comparison function (for median calculation) */
129
static int compare(const void *arg1, const void *arg2)
130
{
131
    double a = *(double *)arg1;
132
    double b = *(double *)arg2;
133
134
    if      ( a <  b ) return -1;
135
    else if ( a == b ) return  0;
136
    else               return  1;
137
}
138
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
139
static int compress_array(compressRecord *prec,
11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
140
	double *psource,epicsInt32 no_elements)
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
141
{
11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
142
	epicsInt32	i,j;
143
	epicsInt32	nnew;
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
144
	epicsInt32	nsam=prec->nsam;
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
145
	double		value;
11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
146
	epicsInt32	n;
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
147
148
	/* skip out of limit data */
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
149
	if (prec->ilil < prec->ihil){
150
	    while (((*psource < prec->ilil) || (*psource > prec->ihil))
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
151
		 && (no_elements > 0)){
152
		    no_elements--;
153
		    psource++;
154
	    }
155
	}
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
156
	if(prec->n <= 0) prec->n = 1;
157
	n = prec->n;
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
158
	if(no_elements<n) return(1); /*dont do anything*/
159
160
	/* determine number of samples to take */
161
	if (no_elements < (nsam * n)) nnew = (no_elements / n);
162
	else nnew = nsam;
163
164
	/* compress according to specified algorithm */
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
165
	switch (prec->alg){
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
166
	case (compressALG_N_to_1_Low_Value):
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
167
	    /* compress N to 1 keeping the lowest value */
168
	    for (i = 0; i < nnew; i++){
169
		value = *psource++;
170
		for (j = 1; j < n; j++, psource++){
171
		    if (value > *psource) value = *psource;
172
		}
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
173
		put_value(prec,&value,1);
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
174
	    }
175
	    break;
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
176
	case (compressALG_N_to_1_High_Value):
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
177
	    /* compress N to 1 keeping the highest value */
178
	    for (i = 0; i < nnew; i++){
179
		value = *psource++;
180
		for (j = 1; j < n; j++, psource++){
181
		    if (value < *psource) value = *psource;
182
		}
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
183
		put_value(prec,&value,1);
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
184
	    }
185
	    break;
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
186
	case (compressALG_N_to_1_Average):
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
187
	    /* compress N to 1 keeping the average value */
188
	    for (i = 0; i < nnew; i++){
189
		value = 0;
190
		for (j = 0; j < n; j++, psource++)
191
			value += *psource;
192
		value /= n;
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
193
		put_value(prec,&value,1);
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
194
	    }
195
	    break;
3974 by William Lupton
added 'N to 1 Median' algorithm (only for array inputs)
196
        case (compressALG_N_to_1_Median):
197
            /* compress N to 1 keeping the median value */
198
	    /* note: sorts source array (OK; it's a work pointer) */
199
            for (i = 0; i < nnew; i++, psource+=nnew){
200
	        qsort(psource,n,sizeof(double),compare);
201
		value=psource[n/2];
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
202
                put_value(prec,&value,1);
3974 by William Lupton
added 'N to 1 Median' algorithm (only for array inputs)
203
            }
204
            break;
205
        }
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
206
	return(0);
207
}
208

11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
209
static int array_average(compressRecord *prec,
11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
210
	double *psource,epicsInt32 no_elements)
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
211
{
11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
212
	epicsInt32	i;
213
	epicsInt32	nnow;
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
214
	epicsInt32	nsam=prec->nsam;
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
215
	double	*psum;
216
	double	multiplier;
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
217
	epicsInt32	inx=prec->inx;
11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
218
	epicsInt32	nuse,n;
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
219
220
	nuse = nsam;
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
221
	if(nuse>no_elements) nuse = no_elements;
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
222
	nnow=nuse;
223
	if(nnow>no_elements) nnow=no_elements;
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
224
	psum = (double *)prec->sptr;
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
225
226
	/* add in the new waveform */
227
	if (inx == 0){
228
		for (i = 0; i < nnow; i++)
229
		    *psum++ = *psource++;
230
		for(i=nnow; i<nuse; i++) *psum++ = 0;
231
	}else{
232
		for (i = 0; i < nnow; i++)
233
		    *psum++ += *psource++;
234
	}
235
236
	/* do we need to calculate the result */
237
	inx++;
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
238
	if(prec->n<=0)prec->n=1;
239
	n = prec->n;
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
240
	if (inx<n) {
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
241
		prec->inx = inx;
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
242
		return(1);
243
	}
244
	if(n>1) {
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
245
		psum = (double *)prec->sptr;
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
246
		multiplier = 1.0/((double)n);
247
		for (i = 0; i < nuse; i++, psum++)
248
	    		*psum = *psum * multiplier;
249
	}
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
250
	put_value(prec,prec->sptr,nuse);
251
	prec->inx = 0;
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
252
	return(0);
253
}
254

11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
255
static int compress_scalar(struct compressRecord *prec,double *psource)
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
256
{
257
	double	value = *psource;
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
258
	double	*pdest=&prec->cvb;
259
	epicsInt32	inx = prec->inx;
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
260
261
	/* compress according to specified algorithm */
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
262
	switch (prec->alg){
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
263
	case (compressALG_N_to_1_Low_Value):
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
264
	    if ((value < *pdest) || (inx == 0))
265
		*pdest = value;
266
	    break;
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
267
	case (compressALG_N_to_1_High_Value):
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
268
	    if ((value > *pdest) || (inx == 0))
269
		*pdest = value;
270
	    break;
3974 by William Lupton
added 'N to 1 Median' algorithm (only for array inputs)
271
	/* for scalars, Median not implemented => use average */
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
272
	case (compressALG_N_to_1_Average):
3974 by William Lupton
added 'N to 1 Median' algorithm (only for array inputs)
273
	case (compressALG_N_to_1_Median):
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
274
	    if (inx == 0)
275
		*pdest = value;
276
	    else {
277
		*pdest += value;
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
278
		if(inx+1>=(prec->n)) *pdest = *pdest/(inx+1);
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
279
	    }
280
	    break;
281
	}
282
	inx++;
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
283
	if(inx>=prec->n) {
284
		put_value(prec,pdest,1);
285
		prec->inx = 0;
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
286
		return(0);
287
	} else {
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
288
		prec->inx = inx;
1997 by Marty Kraimer
Changes for replacing default.dctsdr: Renamed all record support modules
289
		return(1);
290
	}
291
}
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
292

293
/*Beginning of record support routines*/
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
294
static long init_record(compressRecord *prec, int pass)
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
295
{
296
    if (pass==0){
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
297
	if(prec->nsam<1) prec->nsam = 1;
298
	prec->bptr = (double *)calloc(prec->nsam,sizeof(double));
299
        reset(prec);
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
300
    }
301
    return(0);
302
}
303
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
304
static long process(compressRecord *prec)
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
305
{
306
    long	status=0;
307
    long	nelements = 0;
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
308
    int		alg = prec->alg;
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
309
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
310
    prec->pact = TRUE;
311
    if(!dbIsLinkConnected(&prec->inp)
312
    || dbGetNelements(&prec->inp,&nelements)
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
313
    || nelements<=0) {
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
314
	recGblSetSevr(prec,LINK_ALARM,INVALID_ALARM);
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
315
    } else {
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
316
	if(!prec->wptr || nelements!=prec->inpn) {
317
            if(prec->wptr) {
318
                free(prec->wptr);
319
                reset(prec);
9874 by Marty Kraimer
handle array allocation properly when link connects
320
            }
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
321
	    prec->wptr = (double *)dbCalloc(nelements,sizeof(double));
322
	    prec->inpn = nelements;
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
323
	}
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
324
	status = dbGetLink(&prec->inp,DBF_DOUBLE,prec->wptr,0,&nelements);
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
325
	if(status || nelements<=0) {
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
326
            recGblSetSevr(prec,LINK_ALARM,INVALID_ALARM);
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
327
	    status = 0;
328
	} else {
329
	    if(alg==compressALG_Average) {
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
330
		status = array_average(prec,prec->wptr,nelements);
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
331
	    } else if(alg==compressALG_Circular_Buffer) {
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
332
		(void)put_value(prec,prec->wptr,nelements);
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
333
		status = 0;
334
	    } else if(nelements>1) {
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
335
		status = compress_array(prec,prec->wptr,nelements);
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
336
	    }else if(nelements==1){
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
337
		status = compress_scalar(prec,prec->wptr);
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
338
	    }else status=1;
339
	}
340
    }
341
    /* check event list */
342
    if(status!=1) {
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
343
		prec->udf=FALSE;
344
		recGblGetTimeStamp(prec);
345
		monitor(prec);
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
346
		/* process the forward scan link record */
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
347
		recGblFwdLink(prec);
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
348
    }
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
349
    prec->pact=FALSE;
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
350
    return(0);
351
}
352

11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
353
static long special(DBADDR *paddr, int after)
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
354
{
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
355
    compressRecord   *prec = (compressRecord *)(paddr->precord);
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
356
    int                 special_type = paddr->special;
357
358
    if(!after) return(0);
359
    switch(special_type) {
360
    case(SPC_RESET):
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
361
	reset(prec);
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
362
        return(0);
363
    default:
364
        recGblDbaddrError(S_db_badChoice,paddr,"compress: special");
365
        return(S_db_badChoice);
366
    }
367
}
368
11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
369
static long cvt_dbaddr(DBADDR *paddr)
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
370
{
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
371
    compressRecord *prec=(compressRecord *)paddr->precord;
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
372
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
373
    paddr->pfield = (void *)(prec->bptr);
374
    paddr->no_elements = prec->nsam;
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
375
    paddr->field_type = DBF_DOUBLE;
376
    paddr->field_size = sizeof(double);
377
    paddr->dbr_field_type = DBF_DOUBLE;
378
    return(0);
379
}
380
11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
381
static long get_array_info(DBADDR *paddr,long *no_elements, long *offset)
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
382
{
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
383
    compressRecord *prec=(compressRecord *)paddr->precord;
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
384
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
385
    *no_elements =  prec->nuse;
386
    if(prec->nuse==prec->nsam) *offset = prec->off;
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
387
    else *offset = 0;
388
    return(0);
389
}
390
11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
391
static long put_array_info(DBADDR *paddr, long nNew)
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
392
{
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
393
    compressRecord *prec=(compressRecord *)paddr->precord;
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
394
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
395
    prec->off = (prec->off + nNew) % (prec->nsam);
396
    prec->nuse = (prec->nuse + nNew);
397
    if(prec->nuse > prec->nsam) prec->nuse = prec->nsam;
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
398
    return(0);
399
}
400

11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
401
static long get_units(DBADDR *paddr,char *units)
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
402
{
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
403
    compressRecord *prec=(compressRecord *)paddr->precord;
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
404
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
405
    strncpy(units,prec->egu,DB_UNITS_SIZE);
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
406
    return(0);
407
}
408
11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
409
static long get_precision(DBADDR *paddr, long *precision)
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
410
{
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
411
    compressRecord	*prec=(compressRecord *)paddr->precord;
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
412
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
413
    *precision = prec->prec;
414
    if(paddr->pfield == (void *)prec->bptr) return(0);
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
415
    recGblGetPrec(paddr,precision);
416
    return(0);
417
}
418
11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
419
static long get_graphic_double(DBADDR *paddr,struct dbr_grDouble *pgd)
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
420
{
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
421
    compressRecord *prec=(compressRecord *)paddr->precord;
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
422
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
423
    if(paddr->pfield==(void *)prec->bptr
424
    || paddr->pfield==(void *)&prec->ihil
425
    || paddr->pfield==(void *)&prec->ilil){
426
        pgd->upper_disp_limit = prec->hopr;
427
        pgd->lower_disp_limit = prec->lopr;
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
428
    } else recGblGetGraphicDouble(paddr,pgd);
429
    return(0);
430
}
431
11223 by Andrew Johnson
Fixes for IOCs on 64-bit platforms.
432
static long get_control_double(DBADDR *paddr, struct dbr_ctrlDouble *pcd)
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
433
{
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
434
    compressRecord *prec=(compressRecord *)paddr->precord;
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
435
11643 by Ralph Lange
Rename pxxx -> prec in all xxxRecord.c
436
    if(paddr->pfield==(void *)prec->bptr
437
    || paddr->pfield==(void *)&prec->ihil
438
    || paddr->pfield==(void *)&prec->ilil){
439
        pcd->upper_ctrl_limit = prec->hopr;
440
        pcd->lower_ctrl_limit = prec->lopr;
2639 by Marty Kraimer
Changes for udf and other problems discovered while looking at udf
441
    } else recGblGetControlDouble(paddr,pcd);
442
    return(0);
443
}