~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/tools/fgrabber/dasm_grab.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2         dasm_grab.c
  3 
  4         dasm grabbing support functions
  5 
  6         ajl - 20/5/94; version 1.0
  7           15.1.96; version 2.0
  8 */
  9 
 10 #include <stdio.h>
 11 #include <tina/sys.h>
 12 #include <tina/sysfuncs.h>
 13 #include <tina/math.h>
 14 #include <tina/mathfuncs.h>
 15 #include <tina/grabdefs.h>
 16 #include <tina/grabsrv.h>
 17 #include <tina/grabpro.h>
 18 
 19 
 20 
 21 void             dasm_check_info(Grabber *info)
 22 {
 23         
 24         unsigned int    memory;
 25         float                   allowed;
 26         
 27 /*
 28         Width
 29 */
 30         if (info->width > MAX_WIDTH)
 31         {
 32                 info->width = MAX_WIDTH;
 33                 format("Grab tool: width too large, set to %d\n", MAX_WIDTH);
 34         }
 35 
 36         else
 37         if (info->width < MIN_WIDTH)
 38         {
 39                 info->width = MIN_WIDTH;
 40                 format("Grab tool: width too small, set to %d\n", MIN_WIDTH);
 41         }
 42            
 43 /*
 44         Length
 45 */
 46         if (info->length > MAX_LENGTH)
 47         {
 48                 info->length = MAX_LENGTH;
 49                 format("Grab tool: length too large, set to %d\n", MAX_LENGTH);
 50         }
 51 
 52         else
 53         if (info->length < MIN_LENGTH)
 54         {
 55                 info->length = MIN_LENGTH;
 56                 format("Grab tool: length too small, set to %d\n", MIN_LENGTH);
 57         }          
 58 /*
 59         Spacing
 60 */
 61 
 62         if (!((info->spacing == 1) || (info->spacing == 2) || (info->spacing == 4)))
 63         {
 64                 info->spacing = 1;
 65                 format("Grab tool: invalid spacing, set to 1\n");
 66         }
 67 
 68 /*
 69         Check width-spacing-length
 70 */
 71         if ((info->spacing)*(info->width) > MAX_WIDTH)
 72         {
 73                 info->spacing = 1;
 74                 format("Grab tool: width exceeded via spacing, set to 1\n");
 75         }
 76 
 77         if ((info->spacing)*(info->length) > MAX_LENGTH)
 78         {
 79                 info->spacing = 1;
 80                 format("Grab tool: length exceeded via spacing, set to 1\n");
 81         }
 82 /*
 83         Number
 84 */
 85         if (info->number <= 0)
 86         {
 87                 format("Grab tool: illegal image number, set to 1\n");
 88                 info->number = 1;
 89         }
 90 
 91         else
 92         if ((info->st_pair == STEREO_GRAB) && info->number > 1)
 93         {
 94                 format("Grab tool: Stereo pair number = 1\n");
 95                 info->number = 1;
 96         }
 97         
 98 /*
 99         Number of images
100 */              
101         memory = (info->width)*(info->length)*(info->spacing)*(info->number);
102         
103         if (memory > DASM_MEMORY)
104         {
105                 allowed = (DASM_MEMORY/((info->width)*(info->length)*(info->spacing)));
106                 allowed = floor(allowed);
107                 info->number = allowed;
108                 format("Grab tool: too many images for memory, set to %d\n", info->number);
109         }
110 
111 }
112 
113 
114 
115 
116 int          dasm_create_message(Grabber *info)
117 {
118 
119         char    message[512];
120 
121         if (info->count == 0)
122            sprintf(message, "0,0,0,0,0\n");
123 
124         else
125         sprintf(message, "%d,%d,%d,%d,%d\n",info->width,
126                                                                                 info->length,
127                                                                                 info->spacing,
128                                                                                 info->number,
129                                                                                 info->st_pair);
130         strcpy(info->mssg, message);
131 
132         return(0);
133 }
134         
135 
136 
137 void            dasm_grab(Grabber *data)
138 {
139 
140         Imrect *im = NULL, *iml = NULL, *imr = NULL;
141         int     sock;
142         char    buf[512];
143 
144 
145         dasm_check_info(data);
146         dasm_create_message(data);
147 
148         if ((sock = sock_connect(data)) < 0)
149                  return;
150 /*
151         Send message
152 */
153         if(rm_write(sock, data->mssg, MAX_PACKET) <  0)
154         {
155                 format("Grab tool: write message error\n");
156         }
157 /*
158         Retrieve data
159 */
160 
161         if ((data->st_pair == STEREO_GRAB) && (data->count != 0))
162         {
163                 iml = im_alloc(data->length, data->width, NULL, uchar_v);
164                 imr = im_alloc(data->length, data->width, NULL, uchar_v);
165                 retrieve_st_pair(sock, iml, imr, data);
166                 im_free(iml);
167                 im_free(imr);
168         }
169 
170         if ((data->st_pair == MONO_GRAB) && (data->count != 0))
171         {
172                 im = im_alloc(data->length, data->width, NULL, uchar_v);
173                 retrieve_mono(sock, im, data);
174                 im_free(im);
175         }
176 
177         data->count = 1;
178 
179 }
180 
181 
182 void            dasm_config(Grabber *params)
183 {
184         params->count = 0;
185         strcpy(params->service, DASM_SERVICE);
186         strcpy(params->host, DASM_HOST);
187 
188         dasm_grab(params);
189 }
190 
191 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.