38 #define dprintf if(DEBUG) printf
48 gerbv_aperture_list_t *aperture_list;
49 gerbv_aperture_list_t *D_code_list;
60 error_list = gerbv_stats_new_error_list();
61 if (error_list == NULL)
62 GERB_FATAL_ERROR(_(
"malloc error_list failed"));
66 aperture_list = gerbv_stats_new_aperture_list();
67 if (aperture_list == NULL)
68 GERB_FATAL_ERROR(_(
"malloc aperture_list failed"));
69 stats->aperture_list = (gerbv_aperture_list_t *) aperture_list;
72 D_code_list = gerbv_stats_new_aperture_list();
73 if (D_code_list == NULL)
74 GERB_FATAL_ERROR(_(
"malloc D_code_list failed"));
75 stats->D_code_list = (gerbv_aperture_list_t *) D_code_list;
85 tempError = nextError->next;
86 g_free (nextError->error_text);
88 nextError = tempError;
93 gerbv_destroy_aperture_list (gerbv_aperture_list_t *apertureList) {
94 gerbv_aperture_list_t *nextAperture=apertureList,*tempAperture;
96 while (nextAperture) {
97 tempAperture = nextAperture->next;
98 g_free (nextAperture);
99 nextAperture = tempAperture;
108 gerbv_destroy_error_list (stats->error_list);
109 gerbv_destroy_aperture_list (stats->aperture_list);
110 gerbv_destroy_aperture_list (stats->D_code_list);
127 dprintf(
"---> Entering gerbv_stats_add_layer ... \n");
130 gerbv_aperture_list_t *aperture;
131 gerbv_aperture_list_t *D_code;
133 accum_stats->layer_count++;
134 accum_stats->G0 += input_stats->G0;
135 accum_stats->G1 += input_stats->G1;
136 accum_stats->G2 += input_stats->G2;
137 accum_stats->G3 += input_stats->G3;
138 accum_stats->G4 += input_stats->G4;
139 accum_stats->G10 += input_stats->G10;
140 accum_stats->G11 += input_stats->G11;
141 accum_stats->G12 += input_stats->G12;
142 accum_stats->G36 += input_stats->G36;
143 accum_stats->G37 += input_stats->G37;
144 accum_stats->G54 += input_stats->G54;
145 accum_stats->G55 += input_stats->G55;
146 accum_stats->G70 += input_stats->G70;
147 accum_stats->G71 += input_stats->G71;
148 accum_stats->G74 += input_stats->G74;
149 accum_stats->G75 += input_stats->G75;
150 accum_stats->G90 += input_stats->G90;
151 accum_stats->G91 += input_stats->G91;
152 accum_stats->G_unknown += input_stats->G_unknown;
154 accum_stats->D1 += input_stats->D1;
155 accum_stats->D2 += input_stats->D2;
156 accum_stats->D3 += input_stats->D3;
158 for (D_code = input_stats->D_code_list;
160 D_code = D_code->next) {
161 if (D_code->number != -1) {
162 dprintf(
" .... In gerbv_stats_add_layer, D code section, adding number = %d to accum_stats D list ...\n",
164 gerbv_stats_add_to_D_list(accum_stats->D_code_list,
166 dprintf(
" .... In gerbv_stats_add_layer, D code section, calling increment_D_count with count %d ...\n",
168 gerbv_stats_increment_D_list_count(accum_stats->D_code_list,
171 accum_stats->error_list);
174 accum_stats->D_unknown += input_stats->D_unknown;
175 accum_stats->D_error += input_stats->D_error;
177 accum_stats->M0 += input_stats->M0;
178 accum_stats->M1 += input_stats->M1;
179 accum_stats->M2 += input_stats->M2;
180 accum_stats->M_unknown += input_stats->M_unknown;
182 accum_stats->X += input_stats->X;
183 accum_stats->Y += input_stats->Y;
184 accum_stats->I += input_stats->I;
185 accum_stats->J += input_stats->J;
187 accum_stats->star += input_stats->star;
188 accum_stats->unknown += input_stats->unknown;
191 for (error = input_stats->error_list;
193 error = error->next) {
194 if (error->error_text != NULL) {
195 gerbv_stats_add_error(accum_stats->error_list,
203 for (aperture = input_stats->aperture_list;
205 aperture = aperture->next) {
206 if (aperture->number != -1) {
207 gerbv_stats_add_aperture(accum_stats->aperture_list,
211 aperture->parameter);
215 dprintf(
"<---- .... Leaving gerbv_stats_add_layer. \n");
222 gerbv_stats_new_error_list() {
230 error_list->layer = -1;
231 error_list->error_text = NULL;
232 error_list->next = NULL;
240 int layer,
const char *error_text,
250 GERB_FATAL_ERROR(
"%s",error_text);
253 GERB_COMPILE_ERROR(
"%s",error_text);
256 GERB_COMPILE_WARNING(
"%s",error_text);
263 if (error_list_in->error_text == NULL) {
264 error_list_in->layer = layer;
265 error_list_in->error_text = g_strdup_printf(
"%s", error_text);
266 error_list_in->type = type;
267 error_list_in->next = NULL;
272 for(error = error_list_in; error != NULL; error = error->next) {
273 if ((strcmp(error->error_text, error_text) == 0) &&
274 (error->layer == layer) ) {
283 if (error_list_new == NULL) {
284 GERB_FATAL_ERROR(_(
"malloc error_list failed"));
288 error_list_new->layer = layer;
289 error_list_new->error_text = g_strdup_printf(
"%s", error_text);
290 error_list_new->type = type;
291 error_list_new->next = NULL;
292 error_last->next = error_list_new;
298 gerbv_aperture_list_t *
299 gerbv_stats_new_aperture_list() {
300 gerbv_aperture_list_t *aperture_list;
303 dprintf(
"Mallocing new gerb aperture list\n");
305 if ((aperture_list = (gerbv_aperture_list_t *)g_malloc(
sizeof(gerbv_aperture_list_t)))
307 dprintf(
"malloc new gerb aperture list failed\n");
311 dprintf(
" Placing values in certain structs.\n");
312 aperture_list->number = -1;
313 aperture_list->count = 0;
314 aperture_list->type = 0;
315 for (i = 0; i<5; i++) {
316 aperture_list->parameter[i] = 0.0;
318 aperture_list->next = NULL;
319 return aperture_list;
325 gerbv_stats_add_aperture(gerbv_aperture_list_t *aperture_list_in,
327 double parameter[5]) {
329 gerbv_aperture_list_t *aperture_list_new;
330 gerbv_aperture_list_t *aperture_last = NULL;
331 gerbv_aperture_list_t *aperture;
334 dprintf(
" ---> Entering gerbv_stats_add_aperture ....\n");
337 if (aperture_list_in->number == -1) {
338 dprintf(
" .... Adding first aperture to aperture list ... \n");
339 dprintf(
" .... Aperture type = %d ... \n", type);
340 aperture_list_in->number = number;
341 aperture_list_in->type = type;
342 aperture_list_in->layer = layer;
344 aperture_list_in->parameter[i] = parameter[i];
346 aperture_list_in->next = NULL;
347 dprintf(
" <--- .... Leaving gerbv_stats_add_aperture.\n");
352 for(aperture = aperture_list_in;
354 aperture = aperture->next) {
355 if ((aperture->number == number) &&
356 (aperture->layer == layer) ) {
357 dprintf(
" .... This aperture is already in the list ... \n");
358 dprintf(
" <--- .... Leaving gerbv_stats_add_aperture.\n");
361 aperture_last = aperture;
364 dprintf(
" .... Adding another aperture to list ... \n");
365 dprintf(
" .... Aperture type = %d ... \n", type);
368 aperture_list_new = (gerbv_aperture_list_t *) g_malloc(
sizeof(gerbv_aperture_list_t));
369 if (aperture_list_new == NULL) {
370 GERB_FATAL_ERROR(_(
"malloc aperture_list failed"));
374 aperture_list_new->layer = layer;
375 aperture_list_new->number = number;
376 aperture_list_new->type = type;
377 aperture_list_new->next = NULL;
379 aperture_list_new->parameter[i] = parameter[i];
381 aperture_last->next = aperture_list_new;
383 dprintf(
" <--- .... Leaving gerbv_stats_add_aperture.\n");
390 gerbv_stats_add_to_D_list(gerbv_aperture_list_t *D_list_in,
393 gerbv_aperture_list_t *D_list;
394 gerbv_aperture_list_t *D_list_last=NULL;
395 gerbv_aperture_list_t *D_list_new;
397 dprintf(
" ----> Entering add_to_D_list, numbr = %d\n", number);
400 if (D_list_in->number == -1) {
401 dprintf(
" .... Adding first D code to D code list ... \n");
402 dprintf(
" .... Aperture number = %d ... \n", number);
403 D_list_in->number = number;
404 D_list_in->count = 0;
405 D_list_in->next = NULL;
406 dprintf(
" <--- .... Leaving add_to_D_list.\n");
411 for(D_list = D_list_in;
413 D_list = D_list->next) {
414 if (D_list->number == number) {
415 dprintf(
" .... Found in D list .... \n");
416 dprintf(
" <--- .... Leaving add_to_D_list.\n");
419 D_list_last = D_list;
423 dprintf(
" .... Adding another D code to D code list ... \n");
426 D_list_new = (gerbv_aperture_list_t *) g_malloc(
sizeof(gerbv_aperture_list_t));
427 if (D_list_new == NULL) {
428 GERB_FATAL_ERROR(_(
"malloc D_list failed"));
432 D_list_new->number = number;
433 D_list_new->count = 0;
434 D_list_new->next = NULL;
435 D_list_last->next = D_list_new;
437 dprintf(
" <--- .... Leaving add_to_D_list.\n");
444 gerbv_stats_increment_D_list_count(gerbv_aperture_list_t *D_list_in,
449 gerbv_aperture_list_t *D_list;
451 dprintf(
" Entering inc_D_list_count, code = D%d, input count to add = %d\n", number, count);
454 for(D_list = D_list_in;
456 D_list = D_list->next) {
457 if (D_list->number == number) {
458 dprintf(
" old count = %d\n", D_list->count);
459 D_list->count += count;
460 dprintf(
" updated count = %d\n", D_list->count);
466 dprintf(
" .... Didn't find this D code in defined list .... \n");
467 dprintf(
" <--- .... Leaving inc_D_list_count.\n");
468 gerbv_stats_add_error(error,
470 _(
"Undefined aperture number called out in D code"),