File Coverage

IIS.xs
Criterion Covered Total %
statement 0 1274 0.0
branch 0 1354 0.0
condition n/a
subroutine n/a
pod n/a
total 0 2628 0.0


line stmt bran cond sub pod time code
1              
2             #line 453 "lib/PDL/PP.pm"
3             /*
4             * THIS FILE WAS GENERATED BY PDL::PP from iis.pd! Do not modify!
5             */
6              
7             #define PDL_FREE_CODE(trans, destroy, comp_free_code, ntpriv_free_code) \
8             if (destroy) { \
9             comp_free_code \
10             } \
11             if ((trans)->dims_redone) { \
12             ntpriv_free_code \
13             }
14              
15             #include "EXTERN.h"
16             #include "perl.h"
17             #include "XSUB.h"
18             #include "pdl.h"
19             #include "pdlcore.h"
20             #define PDL PDL_Graphics_IIS
21             extern Core* PDL; /* Structure hold core C functions */
22             #line 23 "IIS.xs"
23             #include "libiis.h"
24              
25             #line 1846 "lib/PDL/PP.pm"
26             typedef struct pdl_params__iis {
27             #line 28 "IIS.xs"
28             char *perl_title;
29             } pdl_params__iis;
30              
31              
32             #line 1857 "lib/PDL/PP.pm"
33             pdl_error pdl__iis_readdata(pdl_trans *__privtrans) {
34             pdl_error PDL_err = {0, NULL, 0};
35             #line 36 "IIS.xs"
36 0           pdl_params__iis *__params = __privtrans->params; (void)__params;
37 0 0         if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in _iis:" "broadcast.incs NULL");
38             /* broadcastloop declarations */
39             int __brcloopval;
40             register PDL_Indx __tind0,__tind1; /* counters along dim */
41 0           register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
42             /* dims here are how many steps along those dims */
43 0           register PDL_Indx __tinc0_image = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
44 0           register PDL_Indx __tinc0_min = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
45 0           register PDL_Indx __tinc0_max = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,0);
46 0           register PDL_Indx __tinc1_image = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
47 0           register PDL_Indx __tinc1_min = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
48 0           register PDL_Indx __tinc1_max = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,1);
49             #define PDL_BROADCASTLOOP_START__iis_readdata PDL_BROADCASTLOOP_START( \
50             readdata, \
51             __privtrans->broadcast, \
52             __privtrans->vtable, \
53             image_datap += __offsp[0]; \
54             min_datap += __offsp[1]; \
55             max_datap += __offsp[2]; \
56             , \
57             ( ,image_datap += __tinc1_image - __tinc0_image * __tdims0 \
58             ,min_datap += __tinc1_min - __tinc0_min * __tdims0 \
59             ,max_datap += __tinc1_max - __tinc0_max * __tdims0 \
60             ), \
61             ( ,image_datap += __tinc0_image \
62             ,min_datap += __tinc0_min \
63             ,max_datap += __tinc0_max \
64             ) \
65             )
66             #define PDL_BROADCASTLOOP_END__iis_readdata PDL_BROADCASTLOOP_END( \
67             __privtrans->broadcast, \
68             image_datap -= __tinc1_image * __tdims1 + __offsp[0]; \
69             min_datap -= __tinc1_min * __tdims1 + __offsp[1]; \
70             max_datap -= __tinc1_max * __tdims1 + __offsp[2]; \
71             )
72 0           register PDL_Indx __inc_image_m = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_image_m;register PDL_Indx __inc_image_n = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,1)]; (void)__inc_image_n;
73             #ifndef PDL_DECLARE_PARAMS__iis_1
74             #define PDL_DECLARE_PARAMS__iis_1(PDL_TYPE_OP,PDL_PPSYM_OP) \
75             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, image, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
76             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, min, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP) \
77             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, max, (__privtrans->pdls[2]), 1, PDL_PPSYM_OP)
78             #endif
79             #define PDL_IF_BAD(t,f) f
80 0           switch (__privtrans->__datatype) { /* Start generic switch */
81 0           case PDL_SB: {
82 0 0         PDL_DECLARE_PARAMS__iis_1(PDL_SByte,A)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
83             {
84              
85 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
86             unsigned short hdr[8];
87             unsigned char *data;
88             int j,nlines, x,y, offx, offy, nx, ny, nx2, ny2, baseX, baseY, m1, n1;
89             int ntrans;
90             float xx, yx, xy, yy, xo, yo; int w_type; /* WCS */
91             float fmin, fmax;
92             char wcsbuf[SZ_WCSTEXT];
93             char title[33]; /* 32 chars + null terminator */
94             int chan;
95              
96             /* Open pipes etc */
97              
98 0 0         if (frame<1 || frame>4)
    0          
99 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iis:" "$iisframe must be in range 1--4");
100              
101 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
102 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
103 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
104 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
105              
106             /* Convenience variables */
107              
108 0           nx = __privtrans->ind_sizes[0];
109 0           ny = __privtrans->ind_sizes[1];
110 0           fmin = (float) (min_datap)[0];
111 0           fmax = (float) (max_datap)[0];
112              
113 0           chan = iis_chan(frame);
114              
115             /* Work out how many lines to transfer at a go */
116              
117 0           ntrans = BUFFSZ/frameX;
118 0 0         if (ntrans<1)
119 0           ntrans = 1;
120              
121             /* Allocate buffer for data transfers */
122              
123 0           data = (unsigned char*) calloc(ntrans*frameX, sizeof(unsigned char));
124 0 0         if (data==NULL)
125 0           iis_error("iis_display: out of memory for buffer","");
126              
127 0 0         PDL_BROADCASTLOOP_START__iis_readdata
    0          
    0          
    0          
    0          
    0          
    0          
128              
129             /* Send WCS info */
130              
131 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED;
132 0           hdr[THING_COUNT] = -SZ_WCSTEXT;
133 0           hdr[SUB_UNIT] = WCS;
134 0           hdr[CHECK_SUM] = 0;
135 0           hdr[X_REGISTER] = 0;
136 0           hdr[Y_REGISTER] = 0;
137 0           hdr[Z_REGISTER] = chan;
138 0           hdr[T_REGISTER] = fbconfig-1; /* fbconfig number */
139 0           iis_checksum(hdr);
140 0           iis_write((char*)hdr, 8*sizeof(short));
141              
142 0           offx = 0; offy = 0; /* Centre image in frame if small */
143 0 0         if (nx
144 0           offx = (frameX-nx)/2;
145 0 0         if (ny
146 0           offy = (frameY-ny)/2;
147              
148 0           nx2 = nx; ny2 = ny; baseX=0; baseY=0; /* Truncate image if too big */
149 0 0         if (nx>frameX) {
150 0           nx2=frameX; baseX = (nx-frameX)/2;
151             }
152 0 0         if (ny>frameY) {
153 0           ny2=frameY; baseY = (ny-frameY)/2;
154             }
155              
156             /* Note my WCS is zero offset! */
157              
158 0           xx=1; yx=0; xy=0; yy=-1; xo=baseX-offx; yo=baseY+frameY-offy-1; w_type=1;
159              
160 0           strncpy( title, __params->perl_title, 32 );
161 0           title[32] = '\0';
162 0           sprintf (wcsbuf, "%-33s\n%f %f %f %f %f %f %f %f %d",
163             title, /*** was "perlDL rules!", ***/
164             xx, yx, xy, yy, xo, yo, fmin, fmax, w_type);
165 0           iis_write((char*)wcsbuf, SZ_WCSTEXT*sizeof(char));
166              
167             /* Reset the frame buffer */
168              
169 0           hdr[TRANSFER_ID] = fbconfig-1; /* fbconfig number */
170 0           hdr[THING_COUNT] = 0;
171 0           hdr[SUB_UNIT] = FEEDBACK;
172 0           hdr[CHECK_SUM] = 0;
173 0           hdr[X_REGISTER] = 0;
174 0           hdr[Y_REGISTER] = 0;
175 0           hdr[Z_REGISTER] = chan;
176 0           hdr[T_REGISTER] = 0;
177 0           iis_checksum(hdr);
178 0           iis_write((char*)hdr, 8*sizeof(short));
179              
180             { PDL_SByte val,sval;
181              
182 0 0         for (y = 0; y < ny2; y+=ntrans) {
183              
184 0           nlines = ntrans; /* Number of lines to transfer */
185 0 0         if (y+ntrans>ny2)
186 0           nlines = ny2 - y;
187              
188             /* create header */
189 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED | BLOCKXFER;
190 0           hdr[THING_COUNT] = -nlines*frameX;
191 0           hdr[SUB_UNIT] = REFRESH;
192 0           hdr[CHECK_SUM] = 0;
193 0           hdr[X_REGISTER] = ADVXONTC;
194 0           hdr[Y_REGISTER] = ADVYONXOV+frameY-y-nlines-offy;
195 0           hdr[Z_REGISTER] = chan;
196 0           hdr[T_REGISTER] = ALLBITPL;
197 0           iis_checksum(hdr);
198 0           iis_write((char*)hdr, 8*sizeof(short));
199              
200 0 0         for (j=0; j
201 0           n1 = baseY+y+nlines-j-1;
202 0 0         for (x = 0; x < nx2; x++) {
203 0           m1 = x + baseX;
204 0           val = (image_datap)[0+(__inc_image_m*(m1))+(__inc_image_n*(n1))];
205 0           sval = FMIN+(val-fmin)*(FMAX-FMIN)/(fmax-fmin);
206 0 0         if (sval
207 0           sval = FMIN;
208             if (sval>FMAX)
209             sval = FMAX;
210 0           data[j*frameX+x+offx] = (unsigned char) sval;
211             }
212             }
213 0           iis_write((char*)data, nlines*frameX*sizeof(char) );
214             }
215              
216             }
217              
218 0 0         PDL_BROADCASTLOOP_END__iis_readdata
    0          
219              
220 0           free(data);
221 0           iis_close();
222              
223             }
224 0           } break;
225 0           case PDL_B: {
226 0 0         PDL_DECLARE_PARAMS__iis_1(PDL_Byte,B)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
227             {
228              
229 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
230             unsigned short hdr[8];
231             unsigned char *data;
232             int j,nlines, x,y, offx, offy, nx, ny, nx2, ny2, baseX, baseY, m1, n1;
233             int ntrans;
234             float xx, yx, xy, yy, xo, yo; int w_type; /* WCS */
235             float fmin, fmax;
236             char wcsbuf[SZ_WCSTEXT];
237             char title[33]; /* 32 chars + null terminator */
238             int chan;
239              
240             /* Open pipes etc */
241              
242 0 0         if (frame<1 || frame>4)
    0          
243 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iis:" "$iisframe must be in range 1--4");
244              
245 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
246 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
247 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
248 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
249              
250             /* Convenience variables */
251              
252 0           nx = __privtrans->ind_sizes[0];
253 0           ny = __privtrans->ind_sizes[1];
254 0           fmin = (float) (min_datap)[0];
255 0           fmax = (float) (max_datap)[0];
256              
257 0           chan = iis_chan(frame);
258              
259             /* Work out how many lines to transfer at a go */
260              
261 0           ntrans = BUFFSZ/frameX;
262 0 0         if (ntrans<1)
263 0           ntrans = 1;
264              
265             /* Allocate buffer for data transfers */
266              
267 0           data = (unsigned char*) calloc(ntrans*frameX, sizeof(unsigned char));
268 0 0         if (data==NULL)
269 0           iis_error("iis_display: out of memory for buffer","");
270              
271 0 0         PDL_BROADCASTLOOP_START__iis_readdata
    0          
    0          
    0          
    0          
    0          
    0          
272              
273             /* Send WCS info */
274              
275 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED;
276 0           hdr[THING_COUNT] = -SZ_WCSTEXT;
277 0           hdr[SUB_UNIT] = WCS;
278 0           hdr[CHECK_SUM] = 0;
279 0           hdr[X_REGISTER] = 0;
280 0           hdr[Y_REGISTER] = 0;
281 0           hdr[Z_REGISTER] = chan;
282 0           hdr[T_REGISTER] = fbconfig-1; /* fbconfig number */
283 0           iis_checksum(hdr);
284 0           iis_write((char*)hdr, 8*sizeof(short));
285              
286 0           offx = 0; offy = 0; /* Centre image in frame if small */
287 0 0         if (nx
288 0           offx = (frameX-nx)/2;
289 0 0         if (ny
290 0           offy = (frameY-ny)/2;
291              
292 0           nx2 = nx; ny2 = ny; baseX=0; baseY=0; /* Truncate image if too big */
293 0 0         if (nx>frameX) {
294 0           nx2=frameX; baseX = (nx-frameX)/2;
295             }
296 0 0         if (ny>frameY) {
297 0           ny2=frameY; baseY = (ny-frameY)/2;
298             }
299              
300             /* Note my WCS is zero offset! */
301              
302 0           xx=1; yx=0; xy=0; yy=-1; xo=baseX-offx; yo=baseY+frameY-offy-1; w_type=1;
303              
304 0           strncpy( title, __params->perl_title, 32 );
305 0           title[32] = '\0';
306 0           sprintf (wcsbuf, "%-33s\n%f %f %f %f %f %f %f %f %d",
307             title, /*** was "perlDL rules!", ***/
308             xx, yx, xy, yy, xo, yo, fmin, fmax, w_type);
309 0           iis_write((char*)wcsbuf, SZ_WCSTEXT*sizeof(char));
310              
311             /* Reset the frame buffer */
312              
313 0           hdr[TRANSFER_ID] = fbconfig-1; /* fbconfig number */
314 0           hdr[THING_COUNT] = 0;
315 0           hdr[SUB_UNIT] = FEEDBACK;
316 0           hdr[CHECK_SUM] = 0;
317 0           hdr[X_REGISTER] = 0;
318 0           hdr[Y_REGISTER] = 0;
319 0           hdr[Z_REGISTER] = chan;
320 0           hdr[T_REGISTER] = 0;
321 0           iis_checksum(hdr);
322 0           iis_write((char*)hdr, 8*sizeof(short));
323              
324             { PDL_Byte val,sval;
325              
326 0 0         for (y = 0; y < ny2; y+=ntrans) {
327              
328 0           nlines = ntrans; /* Number of lines to transfer */
329 0 0         if (y+ntrans>ny2)
330 0           nlines = ny2 - y;
331              
332             /* create header */
333 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED | BLOCKXFER;
334 0           hdr[THING_COUNT] = -nlines*frameX;
335 0           hdr[SUB_UNIT] = REFRESH;
336 0           hdr[CHECK_SUM] = 0;
337 0           hdr[X_REGISTER] = ADVXONTC;
338 0           hdr[Y_REGISTER] = ADVYONXOV+frameY-y-nlines-offy;
339 0           hdr[Z_REGISTER] = chan;
340 0           hdr[T_REGISTER] = ALLBITPL;
341 0           iis_checksum(hdr);
342 0           iis_write((char*)hdr, 8*sizeof(short));
343              
344 0 0         for (j=0; j
345 0           n1 = baseY+y+nlines-j-1;
346 0 0         for (x = 0; x < nx2; x++) {
347 0           m1 = x + baseX;
348 0           val = (image_datap)[0+(__inc_image_m*(m1))+(__inc_image_n*(n1))];
349 0           sval = FMIN+(val-fmin)*(FMAX-FMIN)/(fmax-fmin);
350 0 0         if (sval
351 0           sval = FMIN;
352 0 0         if (sval>FMAX)
353 0           sval = FMAX;
354 0           data[j*frameX+x+offx] = (unsigned char) sval;
355             }
356             }
357 0           iis_write((char*)data, nlines*frameX*sizeof(char) );
358             }
359              
360             }
361              
362 0 0         PDL_BROADCASTLOOP_END__iis_readdata
    0          
363              
364 0           free(data);
365 0           iis_close();
366              
367             }
368 0           } break;
369 0           case PDL_S: {
370 0 0         PDL_DECLARE_PARAMS__iis_1(PDL_Short,S)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
371             {
372              
373 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
374             unsigned short hdr[8];
375             unsigned char *data;
376             int j,nlines, x,y, offx, offy, nx, ny, nx2, ny2, baseX, baseY, m1, n1;
377             int ntrans;
378             float xx, yx, xy, yy, xo, yo; int w_type; /* WCS */
379             float fmin, fmax;
380             char wcsbuf[SZ_WCSTEXT];
381             char title[33]; /* 32 chars + null terminator */
382             int chan;
383              
384             /* Open pipes etc */
385              
386 0 0         if (frame<1 || frame>4)
    0          
387 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iis:" "$iisframe must be in range 1--4");
388              
389 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
390 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
391 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
392 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
393              
394             /* Convenience variables */
395              
396 0           nx = __privtrans->ind_sizes[0];
397 0           ny = __privtrans->ind_sizes[1];
398 0           fmin = (float) (min_datap)[0];
399 0           fmax = (float) (max_datap)[0];
400              
401 0           chan = iis_chan(frame);
402              
403             /* Work out how many lines to transfer at a go */
404              
405 0           ntrans = BUFFSZ/frameX;
406 0 0         if (ntrans<1)
407 0           ntrans = 1;
408              
409             /* Allocate buffer for data transfers */
410              
411 0           data = (unsigned char*) calloc(ntrans*frameX, sizeof(unsigned char));
412 0 0         if (data==NULL)
413 0           iis_error("iis_display: out of memory for buffer","");
414              
415 0 0         PDL_BROADCASTLOOP_START__iis_readdata
    0          
    0          
    0          
    0          
    0          
    0          
416              
417             /* Send WCS info */
418              
419 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED;
420 0           hdr[THING_COUNT] = -SZ_WCSTEXT;
421 0           hdr[SUB_UNIT] = WCS;
422 0           hdr[CHECK_SUM] = 0;
423 0           hdr[X_REGISTER] = 0;
424 0           hdr[Y_REGISTER] = 0;
425 0           hdr[Z_REGISTER] = chan;
426 0           hdr[T_REGISTER] = fbconfig-1; /* fbconfig number */
427 0           iis_checksum(hdr);
428 0           iis_write((char*)hdr, 8*sizeof(short));
429              
430 0           offx = 0; offy = 0; /* Centre image in frame if small */
431 0 0         if (nx
432 0           offx = (frameX-nx)/2;
433 0 0         if (ny
434 0           offy = (frameY-ny)/2;
435              
436 0           nx2 = nx; ny2 = ny; baseX=0; baseY=0; /* Truncate image if too big */
437 0 0         if (nx>frameX) {
438 0           nx2=frameX; baseX = (nx-frameX)/2;
439             }
440 0 0         if (ny>frameY) {
441 0           ny2=frameY; baseY = (ny-frameY)/2;
442             }
443              
444             /* Note my WCS is zero offset! */
445              
446 0           xx=1; yx=0; xy=0; yy=-1; xo=baseX-offx; yo=baseY+frameY-offy-1; w_type=1;
447              
448 0           strncpy( title, __params->perl_title, 32 );
449 0           title[32] = '\0';
450 0           sprintf (wcsbuf, "%-33s\n%f %f %f %f %f %f %f %f %d",
451             title, /*** was "perlDL rules!", ***/
452             xx, yx, xy, yy, xo, yo, fmin, fmax, w_type);
453 0           iis_write((char*)wcsbuf, SZ_WCSTEXT*sizeof(char));
454              
455             /* Reset the frame buffer */
456              
457 0           hdr[TRANSFER_ID] = fbconfig-1; /* fbconfig number */
458 0           hdr[THING_COUNT] = 0;
459 0           hdr[SUB_UNIT] = FEEDBACK;
460 0           hdr[CHECK_SUM] = 0;
461 0           hdr[X_REGISTER] = 0;
462 0           hdr[Y_REGISTER] = 0;
463 0           hdr[Z_REGISTER] = chan;
464 0           hdr[T_REGISTER] = 0;
465 0           iis_checksum(hdr);
466 0           iis_write((char*)hdr, 8*sizeof(short));
467              
468             { PDL_Short val,sval;
469              
470 0 0         for (y = 0; y < ny2; y+=ntrans) {
471              
472 0           nlines = ntrans; /* Number of lines to transfer */
473 0 0         if (y+ntrans>ny2)
474 0           nlines = ny2 - y;
475              
476             /* create header */
477 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED | BLOCKXFER;
478 0           hdr[THING_COUNT] = -nlines*frameX;
479 0           hdr[SUB_UNIT] = REFRESH;
480 0           hdr[CHECK_SUM] = 0;
481 0           hdr[X_REGISTER] = ADVXONTC;
482 0           hdr[Y_REGISTER] = ADVYONXOV+frameY-y-nlines-offy;
483 0           hdr[Z_REGISTER] = chan;
484 0           hdr[T_REGISTER] = ALLBITPL;
485 0           iis_checksum(hdr);
486 0           iis_write((char*)hdr, 8*sizeof(short));
487              
488 0 0         for (j=0; j
489 0           n1 = baseY+y+nlines-j-1;
490 0 0         for (x = 0; x < nx2; x++) {
491 0           m1 = x + baseX;
492 0           val = (image_datap)[0+(__inc_image_m*(m1))+(__inc_image_n*(n1))];
493 0           sval = FMIN+(val-fmin)*(FMAX-FMIN)/(fmax-fmin);
494 0 0         if (sval
495 0           sval = FMIN;
496 0 0         if (sval>FMAX)
497 0           sval = FMAX;
498 0           data[j*frameX+x+offx] = (unsigned char) sval;
499             }
500             }
501 0           iis_write((char*)data, nlines*frameX*sizeof(char) );
502             }
503              
504             }
505              
506 0 0         PDL_BROADCASTLOOP_END__iis_readdata
    0          
507              
508 0           free(data);
509 0           iis_close();
510              
511             }
512 0           } break;
513 0           case PDL_US: {
514 0 0         PDL_DECLARE_PARAMS__iis_1(PDL_Ushort,U)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
515             {
516              
517 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
518             unsigned short hdr[8];
519             unsigned char *data;
520             int j,nlines, x,y, offx, offy, nx, ny, nx2, ny2, baseX, baseY, m1, n1;
521             int ntrans;
522             float xx, yx, xy, yy, xo, yo; int w_type; /* WCS */
523             float fmin, fmax;
524             char wcsbuf[SZ_WCSTEXT];
525             char title[33]; /* 32 chars + null terminator */
526             int chan;
527              
528             /* Open pipes etc */
529              
530 0 0         if (frame<1 || frame>4)
    0          
531 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iis:" "$iisframe must be in range 1--4");
532              
533 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
534 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
535 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
536 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
537              
538             /* Convenience variables */
539              
540 0           nx = __privtrans->ind_sizes[0];
541 0           ny = __privtrans->ind_sizes[1];
542 0           fmin = (float) (min_datap)[0];
543 0           fmax = (float) (max_datap)[0];
544              
545 0           chan = iis_chan(frame);
546              
547             /* Work out how many lines to transfer at a go */
548              
549 0           ntrans = BUFFSZ/frameX;
550 0 0         if (ntrans<1)
551 0           ntrans = 1;
552              
553             /* Allocate buffer for data transfers */
554              
555 0           data = (unsigned char*) calloc(ntrans*frameX, sizeof(unsigned char));
556 0 0         if (data==NULL)
557 0           iis_error("iis_display: out of memory for buffer","");
558              
559 0 0         PDL_BROADCASTLOOP_START__iis_readdata
    0          
    0          
    0          
    0          
    0          
    0          
560              
561             /* Send WCS info */
562              
563 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED;
564 0           hdr[THING_COUNT] = -SZ_WCSTEXT;
565 0           hdr[SUB_UNIT] = WCS;
566 0           hdr[CHECK_SUM] = 0;
567 0           hdr[X_REGISTER] = 0;
568 0           hdr[Y_REGISTER] = 0;
569 0           hdr[Z_REGISTER] = chan;
570 0           hdr[T_REGISTER] = fbconfig-1; /* fbconfig number */
571 0           iis_checksum(hdr);
572 0           iis_write((char*)hdr, 8*sizeof(short));
573              
574 0           offx = 0; offy = 0; /* Centre image in frame if small */
575 0 0         if (nx
576 0           offx = (frameX-nx)/2;
577 0 0         if (ny
578 0           offy = (frameY-ny)/2;
579              
580 0           nx2 = nx; ny2 = ny; baseX=0; baseY=0; /* Truncate image if too big */
581 0 0         if (nx>frameX) {
582 0           nx2=frameX; baseX = (nx-frameX)/2;
583             }
584 0 0         if (ny>frameY) {
585 0           ny2=frameY; baseY = (ny-frameY)/2;
586             }
587              
588             /* Note my WCS is zero offset! */
589              
590 0           xx=1; yx=0; xy=0; yy=-1; xo=baseX-offx; yo=baseY+frameY-offy-1; w_type=1;
591              
592 0           strncpy( title, __params->perl_title, 32 );
593 0           title[32] = '\0';
594 0           sprintf (wcsbuf, "%-33s\n%f %f %f %f %f %f %f %f %d",
595             title, /*** was "perlDL rules!", ***/
596             xx, yx, xy, yy, xo, yo, fmin, fmax, w_type);
597 0           iis_write((char*)wcsbuf, SZ_WCSTEXT*sizeof(char));
598              
599             /* Reset the frame buffer */
600              
601 0           hdr[TRANSFER_ID] = fbconfig-1; /* fbconfig number */
602 0           hdr[THING_COUNT] = 0;
603 0           hdr[SUB_UNIT] = FEEDBACK;
604 0           hdr[CHECK_SUM] = 0;
605 0           hdr[X_REGISTER] = 0;
606 0           hdr[Y_REGISTER] = 0;
607 0           hdr[Z_REGISTER] = chan;
608 0           hdr[T_REGISTER] = 0;
609 0           iis_checksum(hdr);
610 0           iis_write((char*)hdr, 8*sizeof(short));
611              
612             { PDL_Ushort val,sval;
613              
614 0 0         for (y = 0; y < ny2; y+=ntrans) {
615              
616 0           nlines = ntrans; /* Number of lines to transfer */
617 0 0         if (y+ntrans>ny2)
618 0           nlines = ny2 - y;
619              
620             /* create header */
621 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED | BLOCKXFER;
622 0           hdr[THING_COUNT] = -nlines*frameX;
623 0           hdr[SUB_UNIT] = REFRESH;
624 0           hdr[CHECK_SUM] = 0;
625 0           hdr[X_REGISTER] = ADVXONTC;
626 0           hdr[Y_REGISTER] = ADVYONXOV+frameY-y-nlines-offy;
627 0           hdr[Z_REGISTER] = chan;
628 0           hdr[T_REGISTER] = ALLBITPL;
629 0           iis_checksum(hdr);
630 0           iis_write((char*)hdr, 8*sizeof(short));
631              
632 0 0         for (j=0; j
633 0           n1 = baseY+y+nlines-j-1;
634 0 0         for (x = 0; x < nx2; x++) {
635 0           m1 = x + baseX;
636 0           val = (image_datap)[0+(__inc_image_m*(m1))+(__inc_image_n*(n1))];
637 0           sval = FMIN+(val-fmin)*(FMAX-FMIN)/(fmax-fmin);
638 0 0         if (sval
639 0           sval = FMIN;
640 0 0         if (sval>FMAX)
641 0           sval = FMAX;
642 0           data[j*frameX+x+offx] = (unsigned char) sval;
643             }
644             }
645 0           iis_write((char*)data, nlines*frameX*sizeof(char) );
646             }
647              
648             }
649              
650 0 0         PDL_BROADCASTLOOP_END__iis_readdata
    0          
651              
652 0           free(data);
653 0           iis_close();
654              
655             }
656 0           } break;
657 0           case PDL_L: {
658 0 0         PDL_DECLARE_PARAMS__iis_1(PDL_Long,L)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
659             {
660              
661 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
662             unsigned short hdr[8];
663             unsigned char *data;
664             int j,nlines, x,y, offx, offy, nx, ny, nx2, ny2, baseX, baseY, m1, n1;
665             int ntrans;
666             float xx, yx, xy, yy, xo, yo; int w_type; /* WCS */
667             float fmin, fmax;
668             char wcsbuf[SZ_WCSTEXT];
669             char title[33]; /* 32 chars + null terminator */
670             int chan;
671              
672             /* Open pipes etc */
673              
674 0 0         if (frame<1 || frame>4)
    0          
675 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iis:" "$iisframe must be in range 1--4");
676              
677 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
678 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
679 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
680 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
681              
682             /* Convenience variables */
683              
684 0           nx = __privtrans->ind_sizes[0];
685 0           ny = __privtrans->ind_sizes[1];
686 0           fmin = (float) (min_datap)[0];
687 0           fmax = (float) (max_datap)[0];
688              
689 0           chan = iis_chan(frame);
690              
691             /* Work out how many lines to transfer at a go */
692              
693 0           ntrans = BUFFSZ/frameX;
694 0 0         if (ntrans<1)
695 0           ntrans = 1;
696              
697             /* Allocate buffer for data transfers */
698              
699 0           data = (unsigned char*) calloc(ntrans*frameX, sizeof(unsigned char));
700 0 0         if (data==NULL)
701 0           iis_error("iis_display: out of memory for buffer","");
702              
703 0 0         PDL_BROADCASTLOOP_START__iis_readdata
    0          
    0          
    0          
    0          
    0          
    0          
704              
705             /* Send WCS info */
706              
707 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED;
708 0           hdr[THING_COUNT] = -SZ_WCSTEXT;
709 0           hdr[SUB_UNIT] = WCS;
710 0           hdr[CHECK_SUM] = 0;
711 0           hdr[X_REGISTER] = 0;
712 0           hdr[Y_REGISTER] = 0;
713 0           hdr[Z_REGISTER] = chan;
714 0           hdr[T_REGISTER] = fbconfig-1; /* fbconfig number */
715 0           iis_checksum(hdr);
716 0           iis_write((char*)hdr, 8*sizeof(short));
717              
718 0           offx = 0; offy = 0; /* Centre image in frame if small */
719 0 0         if (nx
720 0           offx = (frameX-nx)/2;
721 0 0         if (ny
722 0           offy = (frameY-ny)/2;
723              
724 0           nx2 = nx; ny2 = ny; baseX=0; baseY=0; /* Truncate image if too big */
725 0 0         if (nx>frameX) {
726 0           nx2=frameX; baseX = (nx-frameX)/2;
727             }
728 0 0         if (ny>frameY) {
729 0           ny2=frameY; baseY = (ny-frameY)/2;
730             }
731              
732             /* Note my WCS is zero offset! */
733              
734 0           xx=1; yx=0; xy=0; yy=-1; xo=baseX-offx; yo=baseY+frameY-offy-1; w_type=1;
735              
736 0           strncpy( title, __params->perl_title, 32 );
737 0           title[32] = '\0';
738 0           sprintf (wcsbuf, "%-33s\n%f %f %f %f %f %f %f %f %d",
739             title, /*** was "perlDL rules!", ***/
740             xx, yx, xy, yy, xo, yo, fmin, fmax, w_type);
741 0           iis_write((char*)wcsbuf, SZ_WCSTEXT*sizeof(char));
742              
743             /* Reset the frame buffer */
744              
745 0           hdr[TRANSFER_ID] = fbconfig-1; /* fbconfig number */
746 0           hdr[THING_COUNT] = 0;
747 0           hdr[SUB_UNIT] = FEEDBACK;
748 0           hdr[CHECK_SUM] = 0;
749 0           hdr[X_REGISTER] = 0;
750 0           hdr[Y_REGISTER] = 0;
751 0           hdr[Z_REGISTER] = chan;
752 0           hdr[T_REGISTER] = 0;
753 0           iis_checksum(hdr);
754 0           iis_write((char*)hdr, 8*sizeof(short));
755              
756             { PDL_Long val,sval;
757              
758 0 0         for (y = 0; y < ny2; y+=ntrans) {
759              
760 0           nlines = ntrans; /* Number of lines to transfer */
761 0 0         if (y+ntrans>ny2)
762 0           nlines = ny2 - y;
763              
764             /* create header */
765 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED | BLOCKXFER;
766 0           hdr[THING_COUNT] = -nlines*frameX;
767 0           hdr[SUB_UNIT] = REFRESH;
768 0           hdr[CHECK_SUM] = 0;
769 0           hdr[X_REGISTER] = ADVXONTC;
770 0           hdr[Y_REGISTER] = ADVYONXOV+frameY-y-nlines-offy;
771 0           hdr[Z_REGISTER] = chan;
772 0           hdr[T_REGISTER] = ALLBITPL;
773 0           iis_checksum(hdr);
774 0           iis_write((char*)hdr, 8*sizeof(short));
775              
776 0 0         for (j=0; j
777 0           n1 = baseY+y+nlines-j-1;
778 0 0         for (x = 0; x < nx2; x++) {
779 0           m1 = x + baseX;
780 0           val = (image_datap)[0+(__inc_image_m*(m1))+(__inc_image_n*(n1))];
781 0           sval = FMIN+(val-fmin)*(FMAX-FMIN)/(fmax-fmin);
782 0 0         if (sval
783 0           sval = FMIN;
784 0 0         if (sval>FMAX)
785 0           sval = FMAX;
786 0           data[j*frameX+x+offx] = (unsigned char) sval;
787             }
788             }
789 0           iis_write((char*)data, nlines*frameX*sizeof(char) );
790             }
791              
792             }
793              
794 0 0         PDL_BROADCASTLOOP_END__iis_readdata
    0          
795              
796 0           free(data);
797 0           iis_close();
798              
799             }
800 0           } break;
801 0           case PDL_UL: {
802 0 0         PDL_DECLARE_PARAMS__iis_1(PDL_ULong,K)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
803             {
804              
805 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
806             unsigned short hdr[8];
807             unsigned char *data;
808             int j,nlines, x,y, offx, offy, nx, ny, nx2, ny2, baseX, baseY, m1, n1;
809             int ntrans;
810             float xx, yx, xy, yy, xo, yo; int w_type; /* WCS */
811             float fmin, fmax;
812             char wcsbuf[SZ_WCSTEXT];
813             char title[33]; /* 32 chars + null terminator */
814             int chan;
815              
816             /* Open pipes etc */
817              
818 0 0         if (frame<1 || frame>4)
    0          
819 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iis:" "$iisframe must be in range 1--4");
820              
821 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
822 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
823 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
824 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
825              
826             /* Convenience variables */
827              
828 0           nx = __privtrans->ind_sizes[0];
829 0           ny = __privtrans->ind_sizes[1];
830 0           fmin = (float) (min_datap)[0];
831 0           fmax = (float) (max_datap)[0];
832              
833 0           chan = iis_chan(frame);
834              
835             /* Work out how many lines to transfer at a go */
836              
837 0           ntrans = BUFFSZ/frameX;
838 0 0         if (ntrans<1)
839 0           ntrans = 1;
840              
841             /* Allocate buffer for data transfers */
842              
843 0           data = (unsigned char*) calloc(ntrans*frameX, sizeof(unsigned char));
844 0 0         if (data==NULL)
845 0           iis_error("iis_display: out of memory for buffer","");
846              
847 0 0         PDL_BROADCASTLOOP_START__iis_readdata
    0          
    0          
    0          
    0          
    0          
    0          
848              
849             /* Send WCS info */
850              
851 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED;
852 0           hdr[THING_COUNT] = -SZ_WCSTEXT;
853 0           hdr[SUB_UNIT] = WCS;
854 0           hdr[CHECK_SUM] = 0;
855 0           hdr[X_REGISTER] = 0;
856 0           hdr[Y_REGISTER] = 0;
857 0           hdr[Z_REGISTER] = chan;
858 0           hdr[T_REGISTER] = fbconfig-1; /* fbconfig number */
859 0           iis_checksum(hdr);
860 0           iis_write((char*)hdr, 8*sizeof(short));
861              
862 0           offx = 0; offy = 0; /* Centre image in frame if small */
863 0 0         if (nx
864 0           offx = (frameX-nx)/2;
865 0 0         if (ny
866 0           offy = (frameY-ny)/2;
867              
868 0           nx2 = nx; ny2 = ny; baseX=0; baseY=0; /* Truncate image if too big */
869 0 0         if (nx>frameX) {
870 0           nx2=frameX; baseX = (nx-frameX)/2;
871             }
872 0 0         if (ny>frameY) {
873 0           ny2=frameY; baseY = (ny-frameY)/2;
874             }
875              
876             /* Note my WCS is zero offset! */
877              
878 0           xx=1; yx=0; xy=0; yy=-1; xo=baseX-offx; yo=baseY+frameY-offy-1; w_type=1;
879              
880 0           strncpy( title, __params->perl_title, 32 );
881 0           title[32] = '\0';
882 0           sprintf (wcsbuf, "%-33s\n%f %f %f %f %f %f %f %f %d",
883             title, /*** was "perlDL rules!", ***/
884             xx, yx, xy, yy, xo, yo, fmin, fmax, w_type);
885 0           iis_write((char*)wcsbuf, SZ_WCSTEXT*sizeof(char));
886              
887             /* Reset the frame buffer */
888              
889 0           hdr[TRANSFER_ID] = fbconfig-1; /* fbconfig number */
890 0           hdr[THING_COUNT] = 0;
891 0           hdr[SUB_UNIT] = FEEDBACK;
892 0           hdr[CHECK_SUM] = 0;
893 0           hdr[X_REGISTER] = 0;
894 0           hdr[Y_REGISTER] = 0;
895 0           hdr[Z_REGISTER] = chan;
896 0           hdr[T_REGISTER] = 0;
897 0           iis_checksum(hdr);
898 0           iis_write((char*)hdr, 8*sizeof(short));
899              
900             { PDL_ULong val,sval;
901              
902 0 0         for (y = 0; y < ny2; y+=ntrans) {
903              
904 0           nlines = ntrans; /* Number of lines to transfer */
905 0 0         if (y+ntrans>ny2)
906 0           nlines = ny2 - y;
907              
908             /* create header */
909 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED | BLOCKXFER;
910 0           hdr[THING_COUNT] = -nlines*frameX;
911 0           hdr[SUB_UNIT] = REFRESH;
912 0           hdr[CHECK_SUM] = 0;
913 0           hdr[X_REGISTER] = ADVXONTC;
914 0           hdr[Y_REGISTER] = ADVYONXOV+frameY-y-nlines-offy;
915 0           hdr[Z_REGISTER] = chan;
916 0           hdr[T_REGISTER] = ALLBITPL;
917 0           iis_checksum(hdr);
918 0           iis_write((char*)hdr, 8*sizeof(short));
919              
920 0 0         for (j=0; j
921 0           n1 = baseY+y+nlines-j-1;
922 0 0         for (x = 0; x < nx2; x++) {
923 0           m1 = x + baseX;
924 0           val = (image_datap)[0+(__inc_image_m*(m1))+(__inc_image_n*(n1))];
925 0           sval = FMIN+(val-fmin)*(FMAX-FMIN)/(fmax-fmin);
926 0 0         if (sval
927 0           sval = FMIN;
928 0 0         if (sval>FMAX)
929 0           sval = FMAX;
930 0           data[j*frameX+x+offx] = (unsigned char) sval;
931             }
932             }
933 0           iis_write((char*)data, nlines*frameX*sizeof(char) );
934             }
935              
936             }
937              
938 0 0         PDL_BROADCASTLOOP_END__iis_readdata
    0          
939              
940 0           free(data);
941 0           iis_close();
942              
943             }
944 0           } break;
945 0           case PDL_IND: {
946 0 0         PDL_DECLARE_PARAMS__iis_1(PDL_Indx,N)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
947             {
948              
949 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
950             unsigned short hdr[8];
951             unsigned char *data;
952             int j,nlines, x,y, offx, offy, nx, ny, nx2, ny2, baseX, baseY, m1, n1;
953             int ntrans;
954             float xx, yx, xy, yy, xo, yo; int w_type; /* WCS */
955             float fmin, fmax;
956             char wcsbuf[SZ_WCSTEXT];
957             char title[33]; /* 32 chars + null terminator */
958             int chan;
959              
960             /* Open pipes etc */
961              
962 0 0         if (frame<1 || frame>4)
    0          
963 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iis:" "$iisframe must be in range 1--4");
964              
965 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
966 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
967 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
968 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
969              
970             /* Convenience variables */
971              
972 0           nx = __privtrans->ind_sizes[0];
973 0           ny = __privtrans->ind_sizes[1];
974 0           fmin = (float) (min_datap)[0];
975 0           fmax = (float) (max_datap)[0];
976              
977 0           chan = iis_chan(frame);
978              
979             /* Work out how many lines to transfer at a go */
980              
981 0           ntrans = BUFFSZ/frameX;
982 0 0         if (ntrans<1)
983 0           ntrans = 1;
984              
985             /* Allocate buffer for data transfers */
986              
987 0           data = (unsigned char*) calloc(ntrans*frameX, sizeof(unsigned char));
988 0 0         if (data==NULL)
989 0           iis_error("iis_display: out of memory for buffer","");
990              
991 0 0         PDL_BROADCASTLOOP_START__iis_readdata
    0          
    0          
    0          
    0          
    0          
    0          
992              
993             /* Send WCS info */
994              
995 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED;
996 0           hdr[THING_COUNT] = -SZ_WCSTEXT;
997 0           hdr[SUB_UNIT] = WCS;
998 0           hdr[CHECK_SUM] = 0;
999 0           hdr[X_REGISTER] = 0;
1000 0           hdr[Y_REGISTER] = 0;
1001 0           hdr[Z_REGISTER] = chan;
1002 0           hdr[T_REGISTER] = fbconfig-1; /* fbconfig number */
1003 0           iis_checksum(hdr);
1004 0           iis_write((char*)hdr, 8*sizeof(short));
1005              
1006 0           offx = 0; offy = 0; /* Centre image in frame if small */
1007 0 0         if (nx
1008 0           offx = (frameX-nx)/2;
1009 0 0         if (ny
1010 0           offy = (frameY-ny)/2;
1011              
1012 0           nx2 = nx; ny2 = ny; baseX=0; baseY=0; /* Truncate image if too big */
1013 0 0         if (nx>frameX) {
1014 0           nx2=frameX; baseX = (nx-frameX)/2;
1015             }
1016 0 0         if (ny>frameY) {
1017 0           ny2=frameY; baseY = (ny-frameY)/2;
1018             }
1019              
1020             /* Note my WCS is zero offset! */
1021              
1022 0           xx=1; yx=0; xy=0; yy=-1; xo=baseX-offx; yo=baseY+frameY-offy-1; w_type=1;
1023              
1024 0           strncpy( title, __params->perl_title, 32 );
1025 0           title[32] = '\0';
1026 0           sprintf (wcsbuf, "%-33s\n%f %f %f %f %f %f %f %f %d",
1027             title, /*** was "perlDL rules!", ***/
1028             xx, yx, xy, yy, xo, yo, fmin, fmax, w_type);
1029 0           iis_write((char*)wcsbuf, SZ_WCSTEXT*sizeof(char));
1030              
1031             /* Reset the frame buffer */
1032              
1033 0           hdr[TRANSFER_ID] = fbconfig-1; /* fbconfig number */
1034 0           hdr[THING_COUNT] = 0;
1035 0           hdr[SUB_UNIT] = FEEDBACK;
1036 0           hdr[CHECK_SUM] = 0;
1037 0           hdr[X_REGISTER] = 0;
1038 0           hdr[Y_REGISTER] = 0;
1039 0           hdr[Z_REGISTER] = chan;
1040 0           hdr[T_REGISTER] = 0;
1041 0           iis_checksum(hdr);
1042 0           iis_write((char*)hdr, 8*sizeof(short));
1043              
1044             { PDL_Indx val,sval;
1045              
1046 0 0         for (y = 0; y < ny2; y+=ntrans) {
1047              
1048 0           nlines = ntrans; /* Number of lines to transfer */
1049 0 0         if (y+ntrans>ny2)
1050 0           nlines = ny2 - y;
1051              
1052             /* create header */
1053 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED | BLOCKXFER;
1054 0           hdr[THING_COUNT] = -nlines*frameX;
1055 0           hdr[SUB_UNIT] = REFRESH;
1056 0           hdr[CHECK_SUM] = 0;
1057 0           hdr[X_REGISTER] = ADVXONTC;
1058 0           hdr[Y_REGISTER] = ADVYONXOV+frameY-y-nlines-offy;
1059 0           hdr[Z_REGISTER] = chan;
1060 0           hdr[T_REGISTER] = ALLBITPL;
1061 0           iis_checksum(hdr);
1062 0           iis_write((char*)hdr, 8*sizeof(short));
1063              
1064 0 0         for (j=0; j
1065 0           n1 = baseY+y+nlines-j-1;
1066 0 0         for (x = 0; x < nx2; x++) {
1067 0           m1 = x + baseX;
1068 0           val = (image_datap)[0+(__inc_image_m*(m1))+(__inc_image_n*(n1))];
1069 0           sval = FMIN+(val-fmin)*(FMAX-FMIN)/(fmax-fmin);
1070 0 0         if (sval
1071 0           sval = FMIN;
1072 0 0         if (sval>FMAX)
1073 0           sval = FMAX;
1074 0           data[j*frameX+x+offx] = (unsigned char) sval;
1075             }
1076             }
1077 0           iis_write((char*)data, nlines*frameX*sizeof(char) );
1078             }
1079              
1080             }
1081              
1082 0 0         PDL_BROADCASTLOOP_END__iis_readdata
    0          
1083              
1084 0           free(data);
1085 0           iis_close();
1086              
1087             }
1088 0           } break;
1089 0           case PDL_ULL: {
1090 0 0         PDL_DECLARE_PARAMS__iis_1(PDL_ULongLong,P)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
1091             {
1092              
1093 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
1094             unsigned short hdr[8];
1095             unsigned char *data;
1096             int j,nlines, x,y, offx, offy, nx, ny, nx2, ny2, baseX, baseY, m1, n1;
1097             int ntrans;
1098             float xx, yx, xy, yy, xo, yo; int w_type; /* WCS */
1099             float fmin, fmax;
1100             char wcsbuf[SZ_WCSTEXT];
1101             char title[33]; /* 32 chars + null terminator */
1102             int chan;
1103              
1104             /* Open pipes etc */
1105              
1106 0 0         if (frame<1 || frame>4)
    0          
1107 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iis:" "$iisframe must be in range 1--4");
1108              
1109 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
1110 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
1111 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
1112 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
1113              
1114             /* Convenience variables */
1115              
1116 0           nx = __privtrans->ind_sizes[0];
1117 0           ny = __privtrans->ind_sizes[1];
1118 0           fmin = (float) (min_datap)[0];
1119 0           fmax = (float) (max_datap)[0];
1120              
1121 0           chan = iis_chan(frame);
1122              
1123             /* Work out how many lines to transfer at a go */
1124              
1125 0           ntrans = BUFFSZ/frameX;
1126 0 0         if (ntrans<1)
1127 0           ntrans = 1;
1128              
1129             /* Allocate buffer for data transfers */
1130              
1131 0           data = (unsigned char*) calloc(ntrans*frameX, sizeof(unsigned char));
1132 0 0         if (data==NULL)
1133 0           iis_error("iis_display: out of memory for buffer","");
1134              
1135 0 0         PDL_BROADCASTLOOP_START__iis_readdata
    0          
    0          
    0          
    0          
    0          
    0          
1136              
1137             /* Send WCS info */
1138              
1139 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED;
1140 0           hdr[THING_COUNT] = -SZ_WCSTEXT;
1141 0           hdr[SUB_UNIT] = WCS;
1142 0           hdr[CHECK_SUM] = 0;
1143 0           hdr[X_REGISTER] = 0;
1144 0           hdr[Y_REGISTER] = 0;
1145 0           hdr[Z_REGISTER] = chan;
1146 0           hdr[T_REGISTER] = fbconfig-1; /* fbconfig number */
1147 0           iis_checksum(hdr);
1148 0           iis_write((char*)hdr, 8*sizeof(short));
1149              
1150 0           offx = 0; offy = 0; /* Centre image in frame if small */
1151 0 0         if (nx
1152 0           offx = (frameX-nx)/2;
1153 0 0         if (ny
1154 0           offy = (frameY-ny)/2;
1155              
1156 0           nx2 = nx; ny2 = ny; baseX=0; baseY=0; /* Truncate image if too big */
1157 0 0         if (nx>frameX) {
1158 0           nx2=frameX; baseX = (nx-frameX)/2;
1159             }
1160 0 0         if (ny>frameY) {
1161 0           ny2=frameY; baseY = (ny-frameY)/2;
1162             }
1163              
1164             /* Note my WCS is zero offset! */
1165              
1166 0           xx=1; yx=0; xy=0; yy=-1; xo=baseX-offx; yo=baseY+frameY-offy-1; w_type=1;
1167              
1168 0           strncpy( title, __params->perl_title, 32 );
1169 0           title[32] = '\0';
1170 0           sprintf (wcsbuf, "%-33s\n%f %f %f %f %f %f %f %f %d",
1171             title, /*** was "perlDL rules!", ***/
1172             xx, yx, xy, yy, xo, yo, fmin, fmax, w_type);
1173 0           iis_write((char*)wcsbuf, SZ_WCSTEXT*sizeof(char));
1174              
1175             /* Reset the frame buffer */
1176              
1177 0           hdr[TRANSFER_ID] = fbconfig-1; /* fbconfig number */
1178 0           hdr[THING_COUNT] = 0;
1179 0           hdr[SUB_UNIT] = FEEDBACK;
1180 0           hdr[CHECK_SUM] = 0;
1181 0           hdr[X_REGISTER] = 0;
1182 0           hdr[Y_REGISTER] = 0;
1183 0           hdr[Z_REGISTER] = chan;
1184 0           hdr[T_REGISTER] = 0;
1185 0           iis_checksum(hdr);
1186 0           iis_write((char*)hdr, 8*sizeof(short));
1187              
1188             { PDL_ULongLong val,sval;
1189              
1190 0 0         for (y = 0; y < ny2; y+=ntrans) {
1191              
1192 0           nlines = ntrans; /* Number of lines to transfer */
1193 0 0         if (y+ntrans>ny2)
1194 0           nlines = ny2 - y;
1195              
1196             /* create header */
1197 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED | BLOCKXFER;
1198 0           hdr[THING_COUNT] = -nlines*frameX;
1199 0           hdr[SUB_UNIT] = REFRESH;
1200 0           hdr[CHECK_SUM] = 0;
1201 0           hdr[X_REGISTER] = ADVXONTC;
1202 0           hdr[Y_REGISTER] = ADVYONXOV+frameY-y-nlines-offy;
1203 0           hdr[Z_REGISTER] = chan;
1204 0           hdr[T_REGISTER] = ALLBITPL;
1205 0           iis_checksum(hdr);
1206 0           iis_write((char*)hdr, 8*sizeof(short));
1207              
1208 0 0         for (j=0; j
1209 0           n1 = baseY+y+nlines-j-1;
1210 0 0         for (x = 0; x < nx2; x++) {
1211 0           m1 = x + baseX;
1212 0           val = (image_datap)[0+(__inc_image_m*(m1))+(__inc_image_n*(n1))];
1213 0           sval = FMIN+(val-fmin)*(FMAX-FMIN)/(fmax-fmin);
1214 0 0         if (sval
1215 0           sval = FMIN;
1216 0 0         if (sval>FMAX)
1217 0           sval = FMAX;
1218 0           data[j*frameX+x+offx] = (unsigned char) sval;
1219             }
1220             }
1221 0           iis_write((char*)data, nlines*frameX*sizeof(char) );
1222             }
1223              
1224             }
1225              
1226 0 0         PDL_BROADCASTLOOP_END__iis_readdata
    0          
1227              
1228 0           free(data);
1229 0           iis_close();
1230              
1231             }
1232 0           } break;
1233 0           case PDL_LL: {
1234 0 0         PDL_DECLARE_PARAMS__iis_1(PDL_LongLong,Q)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
1235             {
1236              
1237 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
1238             unsigned short hdr[8];
1239             unsigned char *data;
1240             int j,nlines, x,y, offx, offy, nx, ny, nx2, ny2, baseX, baseY, m1, n1;
1241             int ntrans;
1242             float xx, yx, xy, yy, xo, yo; int w_type; /* WCS */
1243             float fmin, fmax;
1244             char wcsbuf[SZ_WCSTEXT];
1245             char title[33]; /* 32 chars + null terminator */
1246             int chan;
1247              
1248             /* Open pipes etc */
1249              
1250 0 0         if (frame<1 || frame>4)
    0          
1251 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iis:" "$iisframe must be in range 1--4");
1252              
1253 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
1254 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
1255 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
1256 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
1257              
1258             /* Convenience variables */
1259              
1260 0           nx = __privtrans->ind_sizes[0];
1261 0           ny = __privtrans->ind_sizes[1];
1262 0           fmin = (float) (min_datap)[0];
1263 0           fmax = (float) (max_datap)[0];
1264              
1265 0           chan = iis_chan(frame);
1266              
1267             /* Work out how many lines to transfer at a go */
1268              
1269 0           ntrans = BUFFSZ/frameX;
1270 0 0         if (ntrans<1)
1271 0           ntrans = 1;
1272              
1273             /* Allocate buffer for data transfers */
1274              
1275 0           data = (unsigned char*) calloc(ntrans*frameX, sizeof(unsigned char));
1276 0 0         if (data==NULL)
1277 0           iis_error("iis_display: out of memory for buffer","");
1278              
1279 0 0         PDL_BROADCASTLOOP_START__iis_readdata
    0          
    0          
    0          
    0          
    0          
    0          
1280              
1281             /* Send WCS info */
1282              
1283 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED;
1284 0           hdr[THING_COUNT] = -SZ_WCSTEXT;
1285 0           hdr[SUB_UNIT] = WCS;
1286 0           hdr[CHECK_SUM] = 0;
1287 0           hdr[X_REGISTER] = 0;
1288 0           hdr[Y_REGISTER] = 0;
1289 0           hdr[Z_REGISTER] = chan;
1290 0           hdr[T_REGISTER] = fbconfig-1; /* fbconfig number */
1291 0           iis_checksum(hdr);
1292 0           iis_write((char*)hdr, 8*sizeof(short));
1293              
1294 0           offx = 0; offy = 0; /* Centre image in frame if small */
1295 0 0         if (nx
1296 0           offx = (frameX-nx)/2;
1297 0 0         if (ny
1298 0           offy = (frameY-ny)/2;
1299              
1300 0           nx2 = nx; ny2 = ny; baseX=0; baseY=0; /* Truncate image if too big */
1301 0 0         if (nx>frameX) {
1302 0           nx2=frameX; baseX = (nx-frameX)/2;
1303             }
1304 0 0         if (ny>frameY) {
1305 0           ny2=frameY; baseY = (ny-frameY)/2;
1306             }
1307              
1308             /* Note my WCS is zero offset! */
1309              
1310 0           xx=1; yx=0; xy=0; yy=-1; xo=baseX-offx; yo=baseY+frameY-offy-1; w_type=1;
1311              
1312 0           strncpy( title, __params->perl_title, 32 );
1313 0           title[32] = '\0';
1314 0           sprintf (wcsbuf, "%-33s\n%f %f %f %f %f %f %f %f %d",
1315             title, /*** was "perlDL rules!", ***/
1316             xx, yx, xy, yy, xo, yo, fmin, fmax, w_type);
1317 0           iis_write((char*)wcsbuf, SZ_WCSTEXT*sizeof(char));
1318              
1319             /* Reset the frame buffer */
1320              
1321 0           hdr[TRANSFER_ID] = fbconfig-1; /* fbconfig number */
1322 0           hdr[THING_COUNT] = 0;
1323 0           hdr[SUB_UNIT] = FEEDBACK;
1324 0           hdr[CHECK_SUM] = 0;
1325 0           hdr[X_REGISTER] = 0;
1326 0           hdr[Y_REGISTER] = 0;
1327 0           hdr[Z_REGISTER] = chan;
1328 0           hdr[T_REGISTER] = 0;
1329 0           iis_checksum(hdr);
1330 0           iis_write((char*)hdr, 8*sizeof(short));
1331              
1332             { PDL_LongLong val,sval;
1333              
1334 0 0         for (y = 0; y < ny2; y+=ntrans) {
1335              
1336 0           nlines = ntrans; /* Number of lines to transfer */
1337 0 0         if (y+ntrans>ny2)
1338 0           nlines = ny2 - y;
1339              
1340             /* create header */
1341 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED | BLOCKXFER;
1342 0           hdr[THING_COUNT] = -nlines*frameX;
1343 0           hdr[SUB_UNIT] = REFRESH;
1344 0           hdr[CHECK_SUM] = 0;
1345 0           hdr[X_REGISTER] = ADVXONTC;
1346 0           hdr[Y_REGISTER] = ADVYONXOV+frameY-y-nlines-offy;
1347 0           hdr[Z_REGISTER] = chan;
1348 0           hdr[T_REGISTER] = ALLBITPL;
1349 0           iis_checksum(hdr);
1350 0           iis_write((char*)hdr, 8*sizeof(short));
1351              
1352 0 0         for (j=0; j
1353 0           n1 = baseY+y+nlines-j-1;
1354 0 0         for (x = 0; x < nx2; x++) {
1355 0           m1 = x + baseX;
1356 0           val = (image_datap)[0+(__inc_image_m*(m1))+(__inc_image_n*(n1))];
1357 0           sval = FMIN+(val-fmin)*(FMAX-FMIN)/(fmax-fmin);
1358 0 0         if (sval
1359 0           sval = FMIN;
1360 0 0         if (sval>FMAX)
1361 0           sval = FMAX;
1362 0           data[j*frameX+x+offx] = (unsigned char) sval;
1363             }
1364             }
1365 0           iis_write((char*)data, nlines*frameX*sizeof(char) );
1366             }
1367              
1368             }
1369              
1370 0 0         PDL_BROADCASTLOOP_END__iis_readdata
    0          
1371              
1372 0           free(data);
1373 0           iis_close();
1374              
1375             }
1376 0           } break;
1377 0           case PDL_F: {
1378 0 0         PDL_DECLARE_PARAMS__iis_1(PDL_Float,F)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
1379             {
1380              
1381 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
1382             unsigned short hdr[8];
1383             unsigned char *data;
1384             int j,nlines, x,y, offx, offy, nx, ny, nx2, ny2, baseX, baseY, m1, n1;
1385             int ntrans;
1386             float xx, yx, xy, yy, xo, yo; int w_type; /* WCS */
1387             float fmin, fmax;
1388             char wcsbuf[SZ_WCSTEXT];
1389             char title[33]; /* 32 chars + null terminator */
1390             int chan;
1391              
1392             /* Open pipes etc */
1393              
1394 0 0         if (frame<1 || frame>4)
    0          
1395 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iis:" "$iisframe must be in range 1--4");
1396              
1397 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
1398 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
1399 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
1400 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
1401              
1402             /* Convenience variables */
1403              
1404 0           nx = __privtrans->ind_sizes[0];
1405 0           ny = __privtrans->ind_sizes[1];
1406 0           fmin = (float) (min_datap)[0];
1407 0           fmax = (float) (max_datap)[0];
1408              
1409 0           chan = iis_chan(frame);
1410              
1411             /* Work out how many lines to transfer at a go */
1412              
1413 0           ntrans = BUFFSZ/frameX;
1414 0 0         if (ntrans<1)
1415 0           ntrans = 1;
1416              
1417             /* Allocate buffer for data transfers */
1418              
1419 0           data = (unsigned char*) calloc(ntrans*frameX, sizeof(unsigned char));
1420 0 0         if (data==NULL)
1421 0           iis_error("iis_display: out of memory for buffer","");
1422              
1423 0 0         PDL_BROADCASTLOOP_START__iis_readdata
    0          
    0          
    0          
    0          
    0          
    0          
1424              
1425             /* Send WCS info */
1426              
1427 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED;
1428 0           hdr[THING_COUNT] = -SZ_WCSTEXT;
1429 0           hdr[SUB_UNIT] = WCS;
1430 0           hdr[CHECK_SUM] = 0;
1431 0           hdr[X_REGISTER] = 0;
1432 0           hdr[Y_REGISTER] = 0;
1433 0           hdr[Z_REGISTER] = chan;
1434 0           hdr[T_REGISTER] = fbconfig-1; /* fbconfig number */
1435 0           iis_checksum(hdr);
1436 0           iis_write((char*)hdr, 8*sizeof(short));
1437              
1438 0           offx = 0; offy = 0; /* Centre image in frame if small */
1439 0 0         if (nx
1440 0           offx = (frameX-nx)/2;
1441 0 0         if (ny
1442 0           offy = (frameY-ny)/2;
1443              
1444 0           nx2 = nx; ny2 = ny; baseX=0; baseY=0; /* Truncate image if too big */
1445 0 0         if (nx>frameX) {
1446 0           nx2=frameX; baseX = (nx-frameX)/2;
1447             }
1448 0 0         if (ny>frameY) {
1449 0           ny2=frameY; baseY = (ny-frameY)/2;
1450             }
1451              
1452             /* Note my WCS is zero offset! */
1453              
1454 0           xx=1; yx=0; xy=0; yy=-1; xo=baseX-offx; yo=baseY+frameY-offy-1; w_type=1;
1455              
1456 0           strncpy( title, __params->perl_title, 32 );
1457 0           title[32] = '\0';
1458 0           sprintf (wcsbuf, "%-33s\n%f %f %f %f %f %f %f %f %d",
1459             title, /*** was "perlDL rules!", ***/
1460             xx, yx, xy, yy, xo, yo, fmin, fmax, w_type);
1461 0           iis_write((char*)wcsbuf, SZ_WCSTEXT*sizeof(char));
1462              
1463             /* Reset the frame buffer */
1464              
1465 0           hdr[TRANSFER_ID] = fbconfig-1; /* fbconfig number */
1466 0           hdr[THING_COUNT] = 0;
1467 0           hdr[SUB_UNIT] = FEEDBACK;
1468 0           hdr[CHECK_SUM] = 0;
1469 0           hdr[X_REGISTER] = 0;
1470 0           hdr[Y_REGISTER] = 0;
1471 0           hdr[Z_REGISTER] = chan;
1472 0           hdr[T_REGISTER] = 0;
1473 0           iis_checksum(hdr);
1474 0           iis_write((char*)hdr, 8*sizeof(short));
1475              
1476             { PDL_Float val,sval;
1477              
1478 0 0         for (y = 0; y < ny2; y+=ntrans) {
1479              
1480 0           nlines = ntrans; /* Number of lines to transfer */
1481 0 0         if (y+ntrans>ny2)
1482 0           nlines = ny2 - y;
1483              
1484             /* create header */
1485 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED | BLOCKXFER;
1486 0           hdr[THING_COUNT] = -nlines*frameX;
1487 0           hdr[SUB_UNIT] = REFRESH;
1488 0           hdr[CHECK_SUM] = 0;
1489 0           hdr[X_REGISTER] = ADVXONTC;
1490 0           hdr[Y_REGISTER] = ADVYONXOV+frameY-y-nlines-offy;
1491 0           hdr[Z_REGISTER] = chan;
1492 0           hdr[T_REGISTER] = ALLBITPL;
1493 0           iis_checksum(hdr);
1494 0           iis_write((char*)hdr, 8*sizeof(short));
1495              
1496 0 0         for (j=0; j
1497 0           n1 = baseY+y+nlines-j-1;
1498 0 0         for (x = 0; x < nx2; x++) {
1499 0           m1 = x + baseX;
1500 0           val = (image_datap)[0+(__inc_image_m*(m1))+(__inc_image_n*(n1))];
1501 0           sval = FMIN+(val-fmin)*(FMAX-FMIN)/(fmax-fmin);
1502 0 0         if (sval
1503 0           sval = FMIN;
1504 0 0         if (sval>FMAX)
1505 0           sval = FMAX;
1506 0           data[j*frameX+x+offx] = (unsigned char) sval;
1507             }
1508             }
1509 0           iis_write((char*)data, nlines*frameX*sizeof(char) );
1510             }
1511              
1512             }
1513              
1514 0 0         PDL_BROADCASTLOOP_END__iis_readdata
    0          
1515              
1516 0           free(data);
1517 0           iis_close();
1518              
1519             }
1520 0           } break;
1521 0           case PDL_D: {
1522 0 0         PDL_DECLARE_PARAMS__iis_1(PDL_Double,D)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
1523             {
1524              
1525 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
1526             unsigned short hdr[8];
1527             unsigned char *data;
1528             int j,nlines, x,y, offx, offy, nx, ny, nx2, ny2, baseX, baseY, m1, n1;
1529             int ntrans;
1530             float xx, yx, xy, yy, xo, yo; int w_type; /* WCS */
1531             float fmin, fmax;
1532             char wcsbuf[SZ_WCSTEXT];
1533             char title[33]; /* 32 chars + null terminator */
1534             int chan;
1535              
1536             /* Open pipes etc */
1537              
1538 0 0         if (frame<1 || frame>4)
    0          
1539 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iis:" "$iisframe must be in range 1--4");
1540              
1541 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
1542 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
1543 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
1544 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
1545              
1546             /* Convenience variables */
1547              
1548 0           nx = __privtrans->ind_sizes[0];
1549 0           ny = __privtrans->ind_sizes[1];
1550 0           fmin = (float) (min_datap)[0];
1551 0           fmax = (float) (max_datap)[0];
1552              
1553 0           chan = iis_chan(frame);
1554              
1555             /* Work out how many lines to transfer at a go */
1556              
1557 0           ntrans = BUFFSZ/frameX;
1558 0 0         if (ntrans<1)
1559 0           ntrans = 1;
1560              
1561             /* Allocate buffer for data transfers */
1562              
1563 0           data = (unsigned char*) calloc(ntrans*frameX, sizeof(unsigned char));
1564 0 0         if (data==NULL)
1565 0           iis_error("iis_display: out of memory for buffer","");
1566              
1567 0 0         PDL_BROADCASTLOOP_START__iis_readdata
    0          
    0          
    0          
    0          
    0          
    0          
1568              
1569             /* Send WCS info */
1570              
1571 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED;
1572 0           hdr[THING_COUNT] = -SZ_WCSTEXT;
1573 0           hdr[SUB_UNIT] = WCS;
1574 0           hdr[CHECK_SUM] = 0;
1575 0           hdr[X_REGISTER] = 0;
1576 0           hdr[Y_REGISTER] = 0;
1577 0           hdr[Z_REGISTER] = chan;
1578 0           hdr[T_REGISTER] = fbconfig-1; /* fbconfig number */
1579 0           iis_checksum(hdr);
1580 0           iis_write((char*)hdr, 8*sizeof(short));
1581              
1582 0           offx = 0; offy = 0; /* Centre image in frame if small */
1583 0 0         if (nx
1584 0           offx = (frameX-nx)/2;
1585 0 0         if (ny
1586 0           offy = (frameY-ny)/2;
1587              
1588 0           nx2 = nx; ny2 = ny; baseX=0; baseY=0; /* Truncate image if too big */
1589 0 0         if (nx>frameX) {
1590 0           nx2=frameX; baseX = (nx-frameX)/2;
1591             }
1592 0 0         if (ny>frameY) {
1593 0           ny2=frameY; baseY = (ny-frameY)/2;
1594             }
1595              
1596             /* Note my WCS is zero offset! */
1597              
1598 0           xx=1; yx=0; xy=0; yy=-1; xo=baseX-offx; yo=baseY+frameY-offy-1; w_type=1;
1599              
1600 0           strncpy( title, __params->perl_title, 32 );
1601 0           title[32] = '\0';
1602 0           sprintf (wcsbuf, "%-33s\n%f %f %f %f %f %f %f %f %d",
1603             title, /*** was "perlDL rules!", ***/
1604             xx, yx, xy, yy, xo, yo, fmin, fmax, w_type);
1605 0           iis_write((char*)wcsbuf, SZ_WCSTEXT*sizeof(char));
1606              
1607             /* Reset the frame buffer */
1608              
1609 0           hdr[TRANSFER_ID] = fbconfig-1; /* fbconfig number */
1610 0           hdr[THING_COUNT] = 0;
1611 0           hdr[SUB_UNIT] = FEEDBACK;
1612 0           hdr[CHECK_SUM] = 0;
1613 0           hdr[X_REGISTER] = 0;
1614 0           hdr[Y_REGISTER] = 0;
1615 0           hdr[Z_REGISTER] = chan;
1616 0           hdr[T_REGISTER] = 0;
1617 0           iis_checksum(hdr);
1618 0           iis_write((char*)hdr, 8*sizeof(short));
1619              
1620             { PDL_Double val,sval;
1621              
1622 0 0         for (y = 0; y < ny2; y+=ntrans) {
1623              
1624 0           nlines = ntrans; /* Number of lines to transfer */
1625 0 0         if (y+ntrans>ny2)
1626 0           nlines = ny2 - y;
1627              
1628             /* create header */
1629 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED | BLOCKXFER;
1630 0           hdr[THING_COUNT] = -nlines*frameX;
1631 0           hdr[SUB_UNIT] = REFRESH;
1632 0           hdr[CHECK_SUM] = 0;
1633 0           hdr[X_REGISTER] = ADVXONTC;
1634 0           hdr[Y_REGISTER] = ADVYONXOV+frameY-y-nlines-offy;
1635 0           hdr[Z_REGISTER] = chan;
1636 0           hdr[T_REGISTER] = ALLBITPL;
1637 0           iis_checksum(hdr);
1638 0           iis_write((char*)hdr, 8*sizeof(short));
1639              
1640 0 0         for (j=0; j
1641 0           n1 = baseY+y+nlines-j-1;
1642 0 0         for (x = 0; x < nx2; x++) {
1643 0           m1 = x + baseX;
1644 0           val = (image_datap)[0+(__inc_image_m*(m1))+(__inc_image_n*(n1))];
1645 0           sval = FMIN+(val-fmin)*(FMAX-FMIN)/(fmax-fmin);
1646 0 0         if (sval
1647 0           sval = FMIN;
1648 0 0         if (sval>FMAX)
1649 0           sval = FMAX;
1650 0           data[j*frameX+x+offx] = (unsigned char) sval;
1651             }
1652             }
1653 0           iis_write((char*)data, nlines*frameX*sizeof(char) );
1654             }
1655              
1656             }
1657              
1658 0 0         PDL_BROADCASTLOOP_END__iis_readdata
    0          
1659              
1660 0           free(data);
1661 0           iis_close();
1662              
1663             }
1664 0           } break;
1665 0           case PDL_LD: {
1666 0 0         PDL_DECLARE_PARAMS__iis_1(PDL_LDouble,E)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
1667             {
1668              
1669 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
1670             unsigned short hdr[8];
1671             unsigned char *data;
1672             int j,nlines, x,y, offx, offy, nx, ny, nx2, ny2, baseX, baseY, m1, n1;
1673             int ntrans;
1674             float xx, yx, xy, yy, xo, yo; int w_type; /* WCS */
1675             float fmin, fmax;
1676             char wcsbuf[SZ_WCSTEXT];
1677             char title[33]; /* 32 chars + null terminator */
1678             int chan;
1679              
1680             /* Open pipes etc */
1681              
1682 0 0         if (frame<1 || frame>4)
    0          
1683 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iis:" "$iisframe must be in range 1--4");
1684              
1685 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
1686 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
1687 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
1688 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
1689              
1690             /* Convenience variables */
1691              
1692 0           nx = __privtrans->ind_sizes[0];
1693 0           ny = __privtrans->ind_sizes[1];
1694 0           fmin = (float) (min_datap)[0];
1695 0           fmax = (float) (max_datap)[0];
1696              
1697 0           chan = iis_chan(frame);
1698              
1699             /* Work out how many lines to transfer at a go */
1700              
1701 0           ntrans = BUFFSZ/frameX;
1702 0 0         if (ntrans<1)
1703 0           ntrans = 1;
1704              
1705             /* Allocate buffer for data transfers */
1706              
1707 0           data = (unsigned char*) calloc(ntrans*frameX, sizeof(unsigned char));
1708 0 0         if (data==NULL)
1709 0           iis_error("iis_display: out of memory for buffer","");
1710              
1711 0 0         PDL_BROADCASTLOOP_START__iis_readdata
    0          
    0          
    0          
    0          
    0          
    0          
1712              
1713             /* Send WCS info */
1714              
1715 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED;
1716 0           hdr[THING_COUNT] = -SZ_WCSTEXT;
1717 0           hdr[SUB_UNIT] = WCS;
1718 0           hdr[CHECK_SUM] = 0;
1719 0           hdr[X_REGISTER] = 0;
1720 0           hdr[Y_REGISTER] = 0;
1721 0           hdr[Z_REGISTER] = chan;
1722 0           hdr[T_REGISTER] = fbconfig-1; /* fbconfig number */
1723 0           iis_checksum(hdr);
1724 0           iis_write((char*)hdr, 8*sizeof(short));
1725              
1726 0           offx = 0; offy = 0; /* Centre image in frame if small */
1727 0 0         if (nx
1728 0           offx = (frameX-nx)/2;
1729 0 0         if (ny
1730 0           offy = (frameY-ny)/2;
1731              
1732 0           nx2 = nx; ny2 = ny; baseX=0; baseY=0; /* Truncate image if too big */
1733 0 0         if (nx>frameX) {
1734 0           nx2=frameX; baseX = (nx-frameX)/2;
1735             }
1736 0 0         if (ny>frameY) {
1737 0           ny2=frameY; baseY = (ny-frameY)/2;
1738             }
1739              
1740             /* Note my WCS is zero offset! */
1741              
1742 0           xx=1; yx=0; xy=0; yy=-1; xo=baseX-offx; yo=baseY+frameY-offy-1; w_type=1;
1743              
1744 0           strncpy( title, __params->perl_title, 32 );
1745 0           title[32] = '\0';
1746 0           sprintf (wcsbuf, "%-33s\n%f %f %f %f %f %f %f %f %d",
1747             title, /*** was "perlDL rules!", ***/
1748             xx, yx, xy, yy, xo, yo, fmin, fmax, w_type);
1749 0           iis_write((char*)wcsbuf, SZ_WCSTEXT*sizeof(char));
1750              
1751             /* Reset the frame buffer */
1752              
1753 0           hdr[TRANSFER_ID] = fbconfig-1; /* fbconfig number */
1754 0           hdr[THING_COUNT] = 0;
1755 0           hdr[SUB_UNIT] = FEEDBACK;
1756 0           hdr[CHECK_SUM] = 0;
1757 0           hdr[X_REGISTER] = 0;
1758 0           hdr[Y_REGISTER] = 0;
1759 0           hdr[Z_REGISTER] = chan;
1760 0           hdr[T_REGISTER] = 0;
1761 0           iis_checksum(hdr);
1762 0           iis_write((char*)hdr, 8*sizeof(short));
1763              
1764             { PDL_LDouble val,sval;
1765              
1766 0 0         for (y = 0; y < ny2; y+=ntrans) {
1767              
1768 0           nlines = ntrans; /* Number of lines to transfer */
1769 0 0         if (y+ntrans>ny2)
1770 0           nlines = ny2 - y;
1771              
1772             /* create header */
1773 0           hdr[TRANSFER_ID] = PDL_IIS_IWRITE | PACKED | BLOCKXFER;
1774 0           hdr[THING_COUNT] = -nlines*frameX;
1775 0           hdr[SUB_UNIT] = REFRESH;
1776 0           hdr[CHECK_SUM] = 0;
1777 0           hdr[X_REGISTER] = ADVXONTC;
1778 0           hdr[Y_REGISTER] = ADVYONXOV+frameY-y-nlines-offy;
1779 0           hdr[Z_REGISTER] = chan;
1780 0           hdr[T_REGISTER] = ALLBITPL;
1781 0           iis_checksum(hdr);
1782 0           iis_write((char*)hdr, 8*sizeof(short));
1783              
1784 0 0         for (j=0; j
1785 0           n1 = baseY+y+nlines-j-1;
1786 0 0         for (x = 0; x < nx2; x++) {
1787 0           m1 = x + baseX;
1788 0           val = (image_datap)[0+(__inc_image_m*(m1))+(__inc_image_n*(n1))];
1789 0           sval = FMIN+(val-fmin)*(FMAX-FMIN)/(fmax-fmin);
1790 0 0         if (sval
1791 0           sval = FMIN;
1792 0 0         if (sval>FMAX)
1793 0           sval = FMAX;
1794 0           data[j*frameX+x+offx] = (unsigned char) sval;
1795             }
1796             }
1797 0           iis_write((char*)data, nlines*frameX*sizeof(char) );
1798             }
1799              
1800             }
1801              
1802 0 0         PDL_BROADCASTLOOP_END__iis_readdata
    0          
1803              
1804 0           free(data);
1805 0           iis_close();
1806              
1807             }
1808 0           } break;
1809 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in _iis: unhandled datatype(%d), only handles (ABSULKNPQFDE)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
1810             }
1811             #undef PDL_IF_BAD
1812 0           return PDL_err;
1813             }
1814              
1815              
1816             #line 1857 "lib/PDL/PP.pm"
1817             pdl_error pdl__iis_free(pdl_trans *__privtrans, char destroy) {
1818             pdl_error PDL_err = {0, NULL, 0};
1819             #line 1820 "IIS.xs"
1820 0           pdl_params__iis *__params = __privtrans->params; (void)__params;
1821 0 0         PDL_FREE_CODE(__privtrans, destroy, free(__params->perl_title); /* CType.get_free */
1822 0           , ) return PDL_err;
1823             }
1824              
1825             static pdl_datatypes pdl__iis_vtable_gentypes[] = { PDL_SB, PDL_B, PDL_S, PDL_US, PDL_L, PDL_UL, PDL_IND, PDL_ULL, PDL_LL, PDL_F, PDL_D, PDL_LD, -1 };
1826             static PDL_Indx pdl__iis_vtable_realdims[] = { 2, 0, 0 };
1827             static char *pdl__iis_vtable_parnames[] = { "image","min","max" };
1828             static short pdl__iis_vtable_parflags[] = {
1829             0,
1830             0,
1831             0
1832             };
1833             static pdl_datatypes pdl__iis_vtable_partypes[] = { -1, -1, -1 };
1834             static PDL_Indx pdl__iis_vtable_realdims_starts[] = { 0, 2, 2 };
1835             static PDL_Indx pdl__iis_vtable_realdims_ind_ids[] = { 0, 1 };
1836             static char *pdl__iis_vtable_indnames[] = { "m","n" };
1837             pdl_transvtable pdl__iis_vtable = {
1838             PDL_TRANS_DO_BROADCAST, 0, pdl__iis_vtable_gentypes, 3, 3, NULL /*CORE21*/,
1839             pdl__iis_vtable_realdims, pdl__iis_vtable_parnames,
1840             pdl__iis_vtable_parflags, pdl__iis_vtable_partypes,
1841             pdl__iis_vtable_realdims_starts, pdl__iis_vtable_realdims_ind_ids, 2,
1842             2, pdl__iis_vtable_indnames,
1843             NULL, pdl__iis_readdata, NULL,
1844             pdl__iis_free,
1845             sizeof(pdl_params__iis),"PDL::Graphics::IIS::_iis"
1846             };
1847              
1848              
1849 0           pdl_error pdl_run__iis(pdl *image,pdl *min,pdl *max,char *perl_title) {
1850 0           pdl_error PDL_err = {0, NULL, 0};
1851 0 0         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
1852 0           pdl_trans *__privtrans = PDL->create_trans(&pdl__iis_vtable);
1853 0 0         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
1854 0           pdl_params__iis *__params = __privtrans->params;
1855 0           __privtrans->pdls[0] = image;
1856 0           __privtrans->pdls[1] = min;
1857 0           __privtrans->pdls[2] = max;
1858 0 0         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
1859 0           (__params->perl_title) = malloc(strlen(perl_title)+1); strcpy(__params->perl_title,perl_title); /* CType.get_copy */
1860 0 0         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
1861 0           return PDL_err;
1862             }
1863              
1864             #line 1857 "lib/PDL/PP.pm"
1865             pdl_error pdl__iiscirc_readdata(pdl_trans *__privtrans) {
1866             pdl_error PDL_err = {0, NULL, 0};
1867             #line 1868 "IIS.xs"
1868 0 0         if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in _iiscirc:" "broadcast.incs NULL");
1869             /* broadcastloop declarations */
1870             int __brcloopval;
1871             register PDL_Indx __tind0,__tind1; /* counters along dim */
1872 0           register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
1873             /* dims here are how many steps along those dims */
1874 0           register PDL_Indx __tinc0_x = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
1875 0           register PDL_Indx __tinc0_y = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
1876 0           register PDL_Indx __tinc0_r = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,0);
1877 0           register PDL_Indx __tinc0_colour = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,3,0);
1878 0           register PDL_Indx __tinc1_x = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
1879 0           register PDL_Indx __tinc1_y = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
1880 0           register PDL_Indx __tinc1_r = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,1);
1881 0           register PDL_Indx __tinc1_colour = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,3,1);
1882             #define PDL_BROADCASTLOOP_START__iiscirc_readdata PDL_BROADCASTLOOP_START( \
1883             readdata, \
1884             __privtrans->broadcast, \
1885             __privtrans->vtable, \
1886             x_datap += __offsp[0]; \
1887             y_datap += __offsp[1]; \
1888             r_datap += __offsp[2]; \
1889             colour_datap += __offsp[3]; \
1890             , \
1891             ( ,x_datap += __tinc1_x - __tinc0_x * __tdims0 \
1892             ,y_datap += __tinc1_y - __tinc0_y * __tdims0 \
1893             ,r_datap += __tinc1_r - __tinc0_r * __tdims0 \
1894             ,colour_datap += __tinc1_colour - __tinc0_colour * __tdims0 \
1895             ), \
1896             ( ,x_datap += __tinc0_x \
1897             ,y_datap += __tinc0_y \
1898             ,r_datap += __tinc0_r \
1899             ,colour_datap += __tinc0_colour \
1900             ) \
1901             )
1902             #define PDL_BROADCASTLOOP_END__iiscirc_readdata PDL_BROADCASTLOOP_END( \
1903             __privtrans->broadcast, \
1904             x_datap -= __tinc1_x * __tdims1 + __offsp[0]; \
1905             y_datap -= __tinc1_y * __tdims1 + __offsp[1]; \
1906             r_datap -= __tinc1_r * __tdims1 + __offsp[2]; \
1907             colour_datap -= __tinc1_colour * __tdims1 + __offsp[3]; \
1908             )
1909             #ifndef PDL_DECLARE_PARAMS__iiscirc_1
1910             #define PDL_DECLARE_PARAMS__iiscirc_1(PDL_TYPE_OP,PDL_PPSYM_OP) \
1911             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, x, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
1912             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, y, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP) \
1913             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, r, (__privtrans->pdls[2]), 1, PDL_PPSYM_OP) \
1914             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, colour, (__privtrans->pdls[3]), 1, PDL_PPSYM_OP)
1915             #endif
1916             #define PDL_IF_BAD(t,f) f
1917 0           switch (__privtrans->__datatype) { /* Start generic switch */
1918 0           case PDL_SB: {
1919 0 0         PDL_DECLARE_PARAMS__iiscirc_1(PDL_SByte,A)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
1920             {
1921              
1922 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
1923              
1924             /* Open pipes etc */
1925              
1926 0 0         if (frame<1 || frame>4)
    0          
1927 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iiscirc:" "$iisframe must be in range 1--4");
1928              
1929 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
1930 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
1931 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
1932 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
1933              
1934 0 0         PDL_BROADCASTLOOP_START__iiscirc_readdata
    0          
    0          
    0          
    0          
    0          
    0          
1935 0           iis_drawcirc( (float) (x_datap)[0], (float) (y_datap)[0], (float) (r_datap)[0], (int) (colour_datap)[0], frame);
1936 0 0         PDL_BROADCASTLOOP_END__iiscirc_readdata
    0          
1937              
1938 0           iis_close();
1939              
1940             }
1941 0           } break;
1942 0           case PDL_B: {
1943 0 0         PDL_DECLARE_PARAMS__iiscirc_1(PDL_Byte,B)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
1944             {
1945              
1946 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
1947              
1948             /* Open pipes etc */
1949              
1950 0 0         if (frame<1 || frame>4)
    0          
1951 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iiscirc:" "$iisframe must be in range 1--4");
1952              
1953 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
1954 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
1955 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
1956 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
1957              
1958 0 0         PDL_BROADCASTLOOP_START__iiscirc_readdata
    0          
    0          
    0          
    0          
    0          
    0          
1959 0           iis_drawcirc( (float) (x_datap)[0], (float) (y_datap)[0], (float) (r_datap)[0], (int) (colour_datap)[0], frame);
1960 0 0         PDL_BROADCASTLOOP_END__iiscirc_readdata
    0          
1961              
1962 0           iis_close();
1963              
1964             }
1965 0           } break;
1966 0           case PDL_S: {
1967 0 0         PDL_DECLARE_PARAMS__iiscirc_1(PDL_Short,S)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
1968             {
1969              
1970 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
1971              
1972             /* Open pipes etc */
1973              
1974 0 0         if (frame<1 || frame>4)
    0          
1975 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iiscirc:" "$iisframe must be in range 1--4");
1976              
1977 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
1978 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
1979 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
1980 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
1981              
1982 0 0         PDL_BROADCASTLOOP_START__iiscirc_readdata
    0          
    0          
    0          
    0          
    0          
    0          
1983 0           iis_drawcirc( (float) (x_datap)[0], (float) (y_datap)[0], (float) (r_datap)[0], (int) (colour_datap)[0], frame);
1984 0 0         PDL_BROADCASTLOOP_END__iiscirc_readdata
    0          
1985              
1986 0           iis_close();
1987              
1988             }
1989 0           } break;
1990 0           case PDL_US: {
1991 0 0         PDL_DECLARE_PARAMS__iiscirc_1(PDL_Ushort,U)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
1992             {
1993              
1994 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
1995              
1996             /* Open pipes etc */
1997              
1998 0 0         if (frame<1 || frame>4)
    0          
1999 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iiscirc:" "$iisframe must be in range 1--4");
2000              
2001 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
2002 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
2003 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
2004 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
2005              
2006 0 0         PDL_BROADCASTLOOP_START__iiscirc_readdata
    0          
    0          
    0          
    0          
    0          
    0          
2007 0           iis_drawcirc( (float) (x_datap)[0], (float) (y_datap)[0], (float) (r_datap)[0], (int) (colour_datap)[0], frame);
2008 0 0         PDL_BROADCASTLOOP_END__iiscirc_readdata
    0          
2009              
2010 0           iis_close();
2011              
2012             }
2013 0           } break;
2014 0           case PDL_L: {
2015 0 0         PDL_DECLARE_PARAMS__iiscirc_1(PDL_Long,L)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
2016             {
2017              
2018 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
2019              
2020             /* Open pipes etc */
2021              
2022 0 0         if (frame<1 || frame>4)
    0          
2023 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iiscirc:" "$iisframe must be in range 1--4");
2024              
2025 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
2026 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
2027 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
2028 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
2029              
2030 0 0         PDL_BROADCASTLOOP_START__iiscirc_readdata
    0          
    0          
    0          
    0          
    0          
    0          
2031 0           iis_drawcirc( (float) (x_datap)[0], (float) (y_datap)[0], (float) (r_datap)[0], (int) (colour_datap)[0], frame);
2032 0 0         PDL_BROADCASTLOOP_END__iiscirc_readdata
    0          
2033              
2034 0           iis_close();
2035              
2036             }
2037 0           } break;
2038 0           case PDL_UL: {
2039 0 0         PDL_DECLARE_PARAMS__iiscirc_1(PDL_ULong,K)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
2040             {
2041              
2042 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
2043              
2044             /* Open pipes etc */
2045              
2046 0 0         if (frame<1 || frame>4)
    0          
2047 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iiscirc:" "$iisframe must be in range 1--4");
2048              
2049 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
2050 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
2051 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
2052 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
2053              
2054 0 0         PDL_BROADCASTLOOP_START__iiscirc_readdata
    0          
    0          
    0          
    0          
    0          
    0          
2055 0           iis_drawcirc( (float) (x_datap)[0], (float) (y_datap)[0], (float) (r_datap)[0], (int) (colour_datap)[0], frame);
2056 0 0         PDL_BROADCASTLOOP_END__iiscirc_readdata
    0          
2057              
2058 0           iis_close();
2059              
2060             }
2061 0           } break;
2062 0           case PDL_IND: {
2063 0 0         PDL_DECLARE_PARAMS__iiscirc_1(PDL_Indx,N)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
2064             {
2065              
2066 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
2067              
2068             /* Open pipes etc */
2069              
2070 0 0         if (frame<1 || frame>4)
    0          
2071 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iiscirc:" "$iisframe must be in range 1--4");
2072              
2073 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
2074 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
2075 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
2076 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
2077              
2078 0 0         PDL_BROADCASTLOOP_START__iiscirc_readdata
    0          
    0          
    0          
    0          
    0          
    0          
2079 0           iis_drawcirc( (float) (x_datap)[0], (float) (y_datap)[0], (float) (r_datap)[0], (int) (colour_datap)[0], frame);
2080 0 0         PDL_BROADCASTLOOP_END__iiscirc_readdata
    0          
2081              
2082 0           iis_close();
2083              
2084             }
2085 0           } break;
2086 0           case PDL_ULL: {
2087 0 0         PDL_DECLARE_PARAMS__iiscirc_1(PDL_ULongLong,P)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
2088             {
2089              
2090 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
2091              
2092             /* Open pipes etc */
2093              
2094 0 0         if (frame<1 || frame>4)
    0          
2095 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iiscirc:" "$iisframe must be in range 1--4");
2096              
2097 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
2098 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
2099 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
2100 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
2101              
2102 0 0         PDL_BROADCASTLOOP_START__iiscirc_readdata
    0          
    0          
    0          
    0          
    0          
    0          
2103 0           iis_drawcirc( (float) (x_datap)[0], (float) (y_datap)[0], (float) (r_datap)[0], (int) (colour_datap)[0], frame);
2104 0 0         PDL_BROADCASTLOOP_END__iiscirc_readdata
    0          
2105              
2106 0           iis_close();
2107              
2108             }
2109 0           } break;
2110 0           case PDL_LL: {
2111 0 0         PDL_DECLARE_PARAMS__iiscirc_1(PDL_LongLong,Q)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
2112             {
2113              
2114 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
2115              
2116             /* Open pipes etc */
2117              
2118 0 0         if (frame<1 || frame>4)
    0          
2119 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iiscirc:" "$iisframe must be in range 1--4");
2120              
2121 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
2122 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
2123 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
2124 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
2125              
2126 0 0         PDL_BROADCASTLOOP_START__iiscirc_readdata
    0          
    0          
    0          
    0          
    0          
    0          
2127 0           iis_drawcirc( (float) (x_datap)[0], (float) (y_datap)[0], (float) (r_datap)[0], (int) (colour_datap)[0], frame);
2128 0 0         PDL_BROADCASTLOOP_END__iiscirc_readdata
    0          
2129              
2130 0           iis_close();
2131              
2132             }
2133 0           } break;
2134 0           case PDL_F: {
2135 0 0         PDL_DECLARE_PARAMS__iiscirc_1(PDL_Float,F)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
2136             {
2137              
2138 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
2139              
2140             /* Open pipes etc */
2141              
2142 0 0         if (frame<1 || frame>4)
    0          
2143 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iiscirc:" "$iisframe must be in range 1--4");
2144              
2145 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
2146 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
2147 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
2148 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
2149              
2150 0 0         PDL_BROADCASTLOOP_START__iiscirc_readdata
    0          
    0          
    0          
    0          
    0          
    0          
2151 0           iis_drawcirc( (float) (x_datap)[0], (float) (y_datap)[0], (float) (r_datap)[0], (int) (colour_datap)[0], frame);
2152 0 0         PDL_BROADCASTLOOP_END__iiscirc_readdata
    0          
2153              
2154 0           iis_close();
2155              
2156             }
2157 0           } break;
2158 0           case PDL_D: {
2159 0 0         PDL_DECLARE_PARAMS__iiscirc_1(PDL_Double,D)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
2160             {
2161              
2162 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
2163              
2164             /* Open pipes etc */
2165              
2166 0 0         if (frame<1 || frame>4)
    0          
2167 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iiscirc:" "$iisframe must be in range 1--4");
2168              
2169 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
2170 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
2171 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
2172 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
2173              
2174 0 0         PDL_BROADCASTLOOP_START__iiscirc_readdata
    0          
    0          
    0          
    0          
    0          
    0          
2175 0           iis_drawcirc( (float) (x_datap)[0], (float) (y_datap)[0], (float) (r_datap)[0], (int) (colour_datap)[0], frame);
2176 0 0         PDL_BROADCASTLOOP_END__iiscirc_readdata
    0          
2177              
2178 0           iis_close();
2179              
2180             }
2181 0           } break;
2182 0           case PDL_LD: {
2183 0 0         PDL_DECLARE_PARAMS__iiscirc_1(PDL_LDouble,E)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
2184             {
2185              
2186 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
2187              
2188             /* Open pipes etc */
2189              
2190 0 0         if (frame<1 || frame>4)
    0          
2191 0           return PDL->make_error(PDL_EUSERERROR, "Error in _iiscirc:" "$iisframe must be in range 1--4");
2192              
2193 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
2194 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
2195 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
2196 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
2197              
2198 0 0         PDL_BROADCASTLOOP_START__iiscirc_readdata
    0          
    0          
    0          
    0          
    0          
    0          
2199 0           iis_drawcirc( (float) (x_datap)[0], (float) (y_datap)[0], (float) (r_datap)[0], (int) (colour_datap)[0], frame);
2200 0 0         PDL_BROADCASTLOOP_END__iiscirc_readdata
    0          
2201              
2202 0           iis_close();
2203              
2204             }
2205 0           } break;
2206 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in _iiscirc: unhandled datatype(%d), only handles (ABSULKNPQFDE)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
2207             }
2208             #undef PDL_IF_BAD
2209 0           return PDL_err;
2210             }
2211              
2212             static pdl_datatypes pdl__iiscirc_vtable_gentypes[] = { PDL_SB, PDL_B, PDL_S, PDL_US, PDL_L, PDL_UL, PDL_IND, PDL_ULL, PDL_LL, PDL_F, PDL_D, PDL_LD, -1 };
2213             static PDL_Indx pdl__iiscirc_vtable_realdims[] = { 0, 0, 0, 0 };
2214             static char *pdl__iiscirc_vtable_parnames[] = { "x","y","r","colour" };
2215             static short pdl__iiscirc_vtable_parflags[] = {
2216             0,
2217             0,
2218             0,
2219             0
2220             };
2221             static pdl_datatypes pdl__iiscirc_vtable_partypes[] = { -1, -1, -1, -1 };
2222             static PDL_Indx pdl__iiscirc_vtable_realdims_starts[] = { 0, 0, 0, 0 };
2223             static PDL_Indx pdl__iiscirc_vtable_realdims_ind_ids[] = { 0 };
2224             static char *pdl__iiscirc_vtable_indnames[] = { "" };
2225             pdl_transvtable pdl__iiscirc_vtable = {
2226             PDL_TRANS_DO_BROADCAST, 0, pdl__iiscirc_vtable_gentypes, 4, 4, NULL /*CORE21*/,
2227             pdl__iiscirc_vtable_realdims, pdl__iiscirc_vtable_parnames,
2228             pdl__iiscirc_vtable_parflags, pdl__iiscirc_vtable_partypes,
2229             pdl__iiscirc_vtable_realdims_starts, pdl__iiscirc_vtable_realdims_ind_ids, 0,
2230             0, pdl__iiscirc_vtable_indnames,
2231             NULL, pdl__iiscirc_readdata, NULL,
2232             NULL,
2233             0,"PDL::Graphics::IIS::_iiscirc"
2234             };
2235              
2236              
2237 0           pdl_error pdl_run__iiscirc(pdl *x,pdl *y,pdl *r,pdl *colour) {
2238 0           pdl_error PDL_err = {0, NULL, 0};
2239 0 0         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
2240 0           pdl_trans *__privtrans = PDL->create_trans(&pdl__iiscirc_vtable);
2241 0 0         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
2242 0           __privtrans->pdls[0] = x;
2243 0           __privtrans->pdls[1] = y;
2244 0           __privtrans->pdls[2] = r;
2245 0           __privtrans->pdls[3] = colour;
2246 0 0         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
2247 0 0         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
2248 0           return PDL_err;
2249             }
2250              
2251             #line 449 "lib/PDL/PP.pm"
2252             #include "pdlperl.h"
2253             #line 2254 "IIS.xs"
2254              
2255             Core* PDL = NULL; /* Structure hold core C functions */
2256              
2257             MODULE = PDL::Graphics::IIS PACKAGE = PDL::Graphics::IIS PREFIX=pdl_run_
2258              
2259             PROTOTYPES: DISABLE
2260              
2261              
2262             MODULE = PDL::Graphics::IIS PACKAGE = PDL::Graphics::IIS
2263              
2264              
2265             MODULE = PDL::Graphics::IIS PACKAGE = PDL::Graphics::IIS
2266              
2267             void
2268             _iiscur_int()
2269             PPCODE:
2270             float x,y;
2271             char ch;
2272 0           int frame = (int)SvIV( perl_get_sv("iisframe", FALSE) );
2273              
2274 0           iis_open(SvPV_nolen(perl_get_sv("fifi",FALSE)),SvPV_nolen(perl_get_sv("fifo",FALSE)),
2275 0           (int)SvIV( perl_get_sv("fbconfig", FALSE) ),
2276 0           (int)SvIV( perl_get_sv("fb_x", FALSE) ),
2277 0           (int)SvIV( perl_get_sv("fb_y", FALSE) ) );
2278 0           iis_cur(&x,&y,&ch);
2279 0           iis_close();
2280              
2281 0 0         EXTEND(sp,3);
2282 0           PUSHs(sv_2mortal(newSVnv((float)x)));
2283 0           PUSHs(sv_2mortal(newSVnv((float)y)));
2284 0           PUSHs(sv_2mortal(newSVpv(&ch,1)));
2285              
2286              
2287              
2288             MODULE = PDL::Graphics::IIS PACKAGE = PDL PREFIX=pdl_run_
2289              
2290              
2291             void
2292             pdl_run__iis(image, min, max, perl_title)
2293             pdl *image
2294             pdl *min
2295             pdl *max
2296             char *perl_title
2297             PPCODE:
2298 0           PDL->barf_if_error(pdl_run__iis(image,min,max,perl_title));
2299              
2300             void
2301             pdl_run__iiscirc(x, y, r, colour)
2302             pdl *x
2303             pdl *y
2304             pdl *r
2305             pdl *colour
2306             PPCODE:
2307 0           PDL->barf_if_error(pdl_run__iiscirc(x,y,r,colour));
2308              
2309              
2310             #line 483 "lib/PDL/PP.pm"
2311             BOOT:
2312             /* Get pointer to structure of core shared C routines */
2313             /* make sure PDL::Core is loaded */
2314             #line 2315 "IIS.xs"
2315 0           perl_require_pv ("PDL/Core.pm"); /* make sure PDL::Core is loaded */
2316             #ifndef aTHX_
2317             #define aTHX_
2318             #endif
2319 0 0         if (SvTRUE (ERRSV)) Perl_croak(aTHX_ "%s",SvPV_nolen (ERRSV));
    0          
    0          
2320 0           SV* CoreSV = perl_get_sv("PDL::SHARE",FALSE); /* var with core structure */
2321 0 0         if (!CoreSV)
2322 0           Perl_croak(aTHX_ "We require the PDL::Core module, which was not found");
2323 0 0         if (!(PDL = INT2PTR(Core*,SvIV( CoreSV )))) /* Core* value */
2324 0           Perl_croak(aTHX_ "Got NULL pointer for PDL");
2325 0 0         if (PDL->Version != PDL_CORE_VERSION)
2326 0           Perl_croak(aTHX_ "[PDL->Version: %ld PDL_CORE_VERSION: %ld XS_VERSION: %s] PDL::Graphics::IIS needs to be recompiled against the newly installed PDL", (long int)PDL->Version, (long int)PDL_CORE_VERSION, XS_VERSION);