50 gerbv_aperture_list_t* aperture_list;
51 gerbv_aperture_list_t* D_code_list;
61 GERB_FATAL_ERROR(
"malloc error_list failed in %s()", __FUNCTION__);
65 aperture_list = gerbv_stats_new_aperture_list();
66 if (aperture_list == NULL)
67 GERB_FATAL_ERROR(
"malloc aperture_list failed in %s()", __FUNCTION__);
68 stats->aperture_list = (gerbv_aperture_list_t*)aperture_list;
71 D_code_list = gerbv_stats_new_aperture_list();
72 if (D_code_list == NULL)
73 GERB_FATAL_ERROR(
"malloc D_code_list failed in %s()", __FUNCTION__);
74 stats->D_code_list = (gerbv_aperture_list_t*)D_code_list;
84 tempError = nextError->next;
85 g_free(nextError->error_text);
87 nextError = tempError;
92 gerbv_destroy_aperture_list(gerbv_aperture_list_t* apertureList) {
93 gerbv_aperture_list_t *nextAperture = apertureList, *tempAperture;
95 while (nextAperture) {
96 tempAperture = nextAperture->next;
98 nextAperture = tempAperture;
107 gerbv_destroy_error_list(stats->error_list);
108 gerbv_destroy_aperture_list(stats->aperture_list);
109 gerbv_destroy_aperture_list(stats->D_code_list);
123 dprintf(
"---> Entering gerbv_stats_add_layer ... \n");
126 gerbv_aperture_list_t* aperture;
127 gerbv_aperture_list_t* D_code;
129 accum_stats->layer_count++;
130 accum_stats->G0 += input_stats->G0;
131 accum_stats->G1 += input_stats->G1;
132 accum_stats->G2 += input_stats->G2;
133 accum_stats->G3 += input_stats->G3;
134 accum_stats->G4 += input_stats->G4;
135 accum_stats->G10 += input_stats->G10;
136 accum_stats->G11 += input_stats->G11;
137 accum_stats->G12 += input_stats->G12;
138 accum_stats->G36 += input_stats->G36;
139 accum_stats->G37 += input_stats->G37;
140 accum_stats->G54 += input_stats->G54;
141 accum_stats->G55 += input_stats->G55;
142 accum_stats->G70 += input_stats->G70;
143 accum_stats->G71 += input_stats->G71;
144 accum_stats->G74 += input_stats->G74;
145 accum_stats->G75 += input_stats->G75;
146 accum_stats->G90 += input_stats->G90;
147 accum_stats->G91 += input_stats->G91;
148 accum_stats->G_unknown += input_stats->G_unknown;
150 accum_stats->D1 += input_stats->D1;
151 accum_stats->D2 += input_stats->D2;
152 accum_stats->D3 += input_stats->D3;
154 for (D_code = input_stats->D_code_list; D_code != NULL; D_code = D_code->next) {
155 if (D_code->number != -1) {
157 " .... In gerbv_stats_add_layer, D code section, adding number = %d to accum_stats D list ...\n",
160 gerbv_stats_add_to_D_list(accum_stats->D_code_list, D_code->number);
162 " .... In gerbv_stats_add_layer, D code section, calling increment_D_count with count %d ...\n",
165 gerbv_stats_increment_D_list_count(
166 accum_stats->D_code_list, D_code->number, D_code->count, accum_stats->error_list
170 accum_stats->D_unknown += input_stats->D_unknown;
171 accum_stats->D_error += input_stats->D_error;
173 accum_stats->M0 += input_stats->M0;
174 accum_stats->M1 += input_stats->M1;
175 accum_stats->M2 += input_stats->M2;
176 accum_stats->M_unknown += input_stats->M_unknown;
178 accum_stats->X += input_stats->X;
179 accum_stats->Y += input_stats->Y;
180 accum_stats->I += input_stats->I;
181 accum_stats->J += input_stats->J;
183 accum_stats->star += input_stats->star;
184 accum_stats->unknown += input_stats->unknown;
187 for (error = input_stats->error_list; error != NULL; error = error->next) {
188 if (error->error_text != NULL) {
189 gerbv_stats_add_error(accum_stats->error_list, this_layer, error->error_text, error->type);
194 for (aperture = input_stats->aperture_list; aperture != NULL; aperture = aperture->next) {
195 if (aperture->number != -1) {
196 gerbv_stats_add_aperture(
197 accum_stats->aperture_list, this_layer, aperture->number, aperture->type, aperture->parameter
202 dprintf(
"<---- .... Leaving gerbv_stats_add_layer. \n");
209 gerbv_stats_new_error_list() {
229 va_start(args, text);
230 str = g_strdup_vprintf(text, args);
232 gerbv_stats_add_error(list, layer, str, type);
244 char* ec = (
char*)&i;
249 case '\0': ec[1] =
'0';
break;
250 case '\a': ec[1] =
'a';
break;
251 case '\b': ec[1] =
'b';
break;
252 case '\f': ec[1] =
'f';
break;
253 case '\n': ec[1] =
'n';
break;
254 case '\r': ec[1] =
'r';
break;
255 case '\t': ec[1] =
't';
break;
256 case '\v': ec[1] =
'v';
break;
257 case '\\': ec[1] =
'\\';
break;
258 case '"': ec[1] =
'"';
break;
282 if (error_list_in->error_text == NULL) {
283 error_list_in->layer = layer;
284 error_list_in->error_text = g_strdup_printf(
"%s", error_text);
285 error_list_in->type = type;
286 error_list_in->next = NULL;
291 for (error = error_list_in; error != NULL; error = error->next) {
292 if ((strcmp(error->error_text, error_text) == 0) && (error->layer == layer)) {
301 GERB_FATAL_ERROR(
"malloc error_list failed in %s()", __FUNCTION__);
305 error_list_new->layer = layer;
306 error_list_new->error_text = g_strdup_printf(
"%s", error_text);
307 error_list_new->type = type;
308 error_list_new->next = NULL;
309 error_last->next = error_list_new;
315 gerbv_aperture_list_t*
316 gerbv_stats_new_aperture_list() {
317 gerbv_aperture_list_t* aperture_list;
320 dprintf(
"Mallocing new gerb aperture list\n");
322 if (NULL == (aperture_list = g_new(gerbv_aperture_list_t, 1))) {
323 dprintf(
"malloc new gerb aperture list failed in %s()\n", __FUNCTION__);
327 dprintf(
" Placing values in certain structs.\n");
328 aperture_list->number = -1;
329 aperture_list->count = 0;
330 aperture_list->type = 0;
331 for (i = 0; i < 5; i++) {
332 aperture_list->parameter[i] = 0.0;
334 aperture_list->next = NULL;
335 return aperture_list;
340 gerbv_stats_add_aperture(
341 gerbv_aperture_list_t* aperture_list_in,
int layer,
int number,
gerbv_aperture_type_t type,
double parameter[5]
344 gerbv_aperture_list_t* aperture_list_new;
345 gerbv_aperture_list_t* aperture_last = NULL;
346 gerbv_aperture_list_t* aperture;
349 dprintf(
" ---> Entering gerbv_stats_add_aperture ....\n");
352 if (aperture_list_in->number == -1) {
353 dprintf(
" .... Adding first aperture to aperture list ... \n");
354 dprintf(
" .... Aperture type = %d ... \n", type);
355 aperture_list_in->number = number;
356 aperture_list_in->type = type;
357 aperture_list_in->layer = layer;
358 for (i = 0; i < 5; i++) {
359 aperture_list_in->parameter[i] = parameter[i];
361 aperture_list_in->next = NULL;
362 dprintf(
" <--- .... Leaving gerbv_stats_add_aperture.\n");
367 for (aperture = aperture_list_in; aperture != NULL; aperture = aperture->next) {
368 if ((aperture->number == number) && (aperture->layer == layer)) {
369 dprintf(
" .... This aperture is already in the list ... \n");
370 dprintf(
" <--- .... Leaving gerbv_stats_add_aperture.\n");
373 aperture_last = aperture;
376 dprintf(
" .... Adding another aperture to list ... \n");
377 dprintf(
" .... Aperture type = %d ... \n", type);
380 if (NULL == (aperture_list_new = g_new(gerbv_aperture_list_t, 1))) {
381 GERB_FATAL_ERROR(
"malloc aperture_list failed in %s()", __FUNCTION__);
385 aperture_list_new->layer = layer;
386 aperture_list_new->number = number;
387 aperture_list_new->type = type;
388 aperture_list_new->next = NULL;
389 for (i = 0; i < 5; i++) {
390 aperture_list_new->parameter[i] = parameter[i];
392 aperture_last->next = aperture_list_new;
394 dprintf(
" <--- .... Leaving gerbv_stats_add_aperture.\n");
401 gerbv_stats_add_to_D_list(gerbv_aperture_list_t* D_list_in,
int number) {
403 gerbv_aperture_list_t* D_list;
404 gerbv_aperture_list_t* D_list_last = NULL;
405 gerbv_aperture_list_t* D_list_new;
407 dprintf(
" ----> Entering add_to_D_list, numbr = %d\n", number);
410 if (D_list_in->number == -1) {
411 dprintf(
" .... Adding first D code to D code list ... \n");
412 dprintf(
" .... Aperture number = %d ... \n", number);
413 D_list_in->number = number;
414 D_list_in->count = 0;
415 D_list_in->next = NULL;
416 dprintf(
" <--- .... Leaving add_to_D_list.\n");
421 for (D_list = D_list_in; D_list != NULL; D_list = D_list->next) {
422 if (D_list->number == number) {
423 dprintf(
" .... Found in D list .... \n");
424 dprintf(
" <--- .... Leaving add_to_D_list.\n");
427 D_list_last = D_list;
431 dprintf(
" .... Adding another D code to D code list ... \n");
434 if (NULL == (D_list_new = g_new(gerbv_aperture_list_t, 1))) {
435 GERB_FATAL_ERROR(
"malloc D_list failed in %s()", __FUNCTION__);
439 D_list_new->number = number;
440 D_list_new->count = 0;
441 D_list_new->next = NULL;
442 D_list_last->next = D_list_new;
444 dprintf(
" <--- .... Leaving add_to_D_list.\n");
451 gerbv_stats_increment_D_list_count(gerbv_aperture_list_t* D_list_in,
int number,
int count,
gerbv_error_list_t* error) {
453 gerbv_aperture_list_t* D_list;
455 dprintf(
" Entering inc_D_list_count, code = D%d, input count to add = %d\n", number, count);
458 for (D_list = D_list_in; D_list != NULL; D_list = D_list->next) {
459 if (D_list->number == number) {
460 dprintf(
" old count = %d\n", D_list->count);
461 D_list->count += count;
462 dprintf(
" updated count = %d\n", D_list->count);
468 dprintf(
" .... Didn't find this D code in defined list .... \n");
469 dprintf(
" <--- .... Leaving inc_D_list_count.\n");
471 gerbv_stats_printf(error,
GERBV_MESSAGE_ERROR, -1, _(
"Undefined aperture number called out in D code"));
int gerbv_escape_char_return_int(char c)
Escape special ASCII char (' ', '\0').
gerbv_stats_t * gerbv_stats_new(void)
Allocates a new gerbv_stats structure.
void gerbv_stats_add_layer(gerbv_stats_t *accum_stats, gerbv_stats_t *input_stats, int this_layer)
void gerbv_stats_destroy(gerbv_stats_t *stats)
Header info for the statistics generating functions for RS274X files.
The main header file for the libgerbv library.