#include "rs274ngc.hh"
#include "rs274ngc_return.hh"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for new/driver.cc:
Go to the source code of this file.
Functions | |
void | report_error (int error_code, int print_stack) |
int | interpret_from_keyboard (int block_delete, int print_stack) |
int | interpret_from_file (int do_next, int block_delete, int print_stack) |
int | read_tool_file (char *file_name) |
int | designate_parameter_file (char *file_name) |
int | adjust_error_handling (int args, int *print_stack, int *do_next) |
int | main (int argc, char **argv) |
|
Definition at line 398 of file new/driver.cc. Referenced by main().
00402 { 00403 char buffer[80]; 00404 int choice; 00405 00406 for(;;) 00407 { 00408 fprintf(stderr, "enter a number:\n"); 00409 fprintf(stderr, "1 = done with error handling\n"); 00410 fprintf(stderr, "2 = %sprint stack on error\n", 00411 ((*print_stack IS ON) ? "do not " : "")); 00412 if (args IS 3) 00413 { 00414 if (*do_next IS 0) /* 0 means continue */ 00415 fprintf(stderr, 00416 "3 = stop on error (do not continue)\n"); 00417 else /* if do_next IS 2 -- 2 means stopping on error */ 00418 fprintf(stderr, 00419 "3 = continue on error (do not stop)\n"); 00420 } 00421 else if (args IS 2) 00422 { 00423 if (*do_next IS 0) /* 0 means continue */ 00424 fprintf(stderr, 00425 "3 = mdi on error (do not continue or stop)\n"); 00426 else if (*do_next IS 1) /* 1 means MDI */ 00427 fprintf(stderr, 00428 "3 = stop on error (do not mdi or continue)\n"); 00429 else /* if do_next IS 2 -- 2 means stopping on error */ 00430 fprintf(stderr, 00431 "3 = continue on error (do not stop or mdi)\n"); 00432 } 00433 fprintf(stderr, "enter choice => "); 00434 fgets(buffer,80,stdin); 00435 if (sscanf(buffer, "%d", &choice) ISNT 1) 00436 continue; 00437 if (choice IS 1) 00438 break; 00439 else if (choice IS 2) 00440 *print_stack SET_TO ((*print_stack IS OFF) ? ON : OFF); 00441 else if ((choice IS 3) AND (args IS 3)) 00442 *do_next SET_TO ((*do_next IS 0) ? 2 : 0); 00443 else if ((choice IS 3) AND (args IS 2)) 00444 *do_next SET_TO ((*do_next IS 2) ? 0 : (*do_next + 1)); 00445 } 00446 return 0; 00447 } |
|
Definition at line 347 of file new/driver.cc. Referenced by main().
00348 { 00349 FILE * test_port; 00350 00351 fprintf(stderr, "name of parameter file => "); 00352 fgets(file_name,PARAMETER_FILE_NAME_LENGTH,stdin); 00353 test_port SET_TO fopen(file_name, "r"); 00354 if (test_port IS NULL) 00355 { 00356 fprintf(stderr, "Cannot open %s\n", file_name); 00357 return 1; 00358 } 00359 fclose(test_port); 00360 return 0; 00361 } |
|
Definition at line 166 of file new/driver.cc. Referenced by BuildList(), and main().
00170 { 00171 int status; 00172 char line[RS274NGC_TEXT_SIZE]; 00173 00174 for(; ;) 00175 { 00176 status SET_TO rs274ngc_read(NULL); 00177 if ((status IS RS274NGC_EXECUTE_FINISH) AND (block_delete IS ON)) 00178 continue; 00179 else if (status IS RS274NGC_ENDFILE) 00180 break; 00181 if ((status ISNT RS274NGC_OK) AND // should not be EXIT 00182 (status ISNT RS274NGC_EXECUTE_FINISH)) 00183 { 00184 report_error(status, print_stack); 00185 if ((status IS NCE_FILE_ENDED_WITH_NO_PERCENT_SIGN) OR 00186 (do_next IS 2)) /* 2 means stop */ 00187 { 00188 status SET_TO 1; 00189 break; 00190 } 00191 else if (do_next IS 1) /* 1 means MDI */ 00192 { 00193 fprintf(stderr, "starting MDI\n"); 00194 interpret_from_keyboard(block_delete, print_stack); 00195 fprintf(stderr, "continue program? y/n =>"); 00196 fgets(line,RS274NGC_TEXT_SIZE,stdin); 00197 if (line[0] ISNT 'y') 00198 { 00199 status SET_TO 1; 00200 break; 00201 } 00202 else 00203 continue; 00204 } 00205 else /* if do_next IS 0 -- 0 means continue */ 00206 continue; 00207 } 00208 status SET_TO rs274ngc_execute(); 00209 if ((status ISNT RS274NGC_OK) AND 00210 (status ISNT RS274NGC_EXIT) AND 00211 (status ISNT RS274NGC_EXECUTE_FINISH)) 00212 { 00213 report_error(status, print_stack); 00214 status SET_TO 1; 00215 if (do_next IS 1) /* 1 means MDI */ 00216 { 00217 fprintf(stderr, "starting MDI\n"); 00218 interpret_from_keyboard(block_delete, print_stack); 00219 fprintf(stderr, "continue program? y/n =>"); 00220 fgets(line,RS274NGC_TEXT_SIZE,stdin); 00221 if (line[0] ISNT 'y') 00222 break; 00223 } 00224 else if (do_next IS 2) /* 2 means stop */ 00225 break; 00226 } 00227 else if (status IS RS274NGC_EXIT) 00228 break; 00229 } 00230 return ((status IS 1) ? 1 : 0); 00231 } |
|
Definition at line 103 of file new/driver.cc. Referenced by interpret_from_file(), and main().
00106 { 00107 char line[RS274NGC_TEXT_SIZE]; 00108 int status; 00109 00110 for(; ;) 00111 { 00112 printf("READ => "); 00113 fgets(line,RS274NGC_TEXT_SIZE,stdin); 00114 if (strcmp (line, "quit") IS 0) 00115 return 0; 00116 status SET_TO rs274ngc_read(line); 00117 if ((status IS RS274NGC_EXECUTE_FINISH) AND (block_delete IS ON)); 00118 else if (status IS RS274NGC_ENDFILE); 00119 else if ((status ISNT RS274NGC_EXECUTE_FINISH) AND 00120 (status ISNT RS274NGC_OK)) 00121 report_error(status, print_stack); 00122 else 00123 { 00124 status SET_TO rs274ngc_execute(); 00125 if ((status IS RS274NGC_EXIT) OR 00126 (status IS RS274NGC_EXECUTE_FINISH)); 00127 else if (status ISNT RS274NGC_OK) 00128 report_error(status, print_stack); 00129 } 00130 } 00131 } |
|
Definition at line 519 of file new/driver.cc. 00520 { 00521 int status; 00522 int choice; 00523 int do_next; /* 0=continue, 1=mdi, 2=stop */ 00524 int block_delete; 00525 char buffer[80]; 00526 int tool_flag; 00527 int gees[RS274NGC_ACTIVE_G_CODES]; 00528 int ems[RS274NGC_ACTIVE_M_CODES]; 00529 double sets[RS274NGC_ACTIVE_SETTINGS]; 00530 char default_name[] SET_TO "rs274ngc.var"; 00531 int print_stack; 00532 00533 if (argc > 3) 00534 { 00535 fprintf(stderr, "Usage \"%s\"\n", argv[0]); 00536 fprintf(stderr, " or \"%s <input file>\"\n", argv[0]); 00537 fprintf(stderr, " or \"%s <input file> <output file>\"\n", argv[0]); 00538 exit(1); 00539 } 00540 00541 do_next SET_TO 2; /* 2=stop */ 00542 block_delete SET_TO OFF; 00543 print_stack SET_TO OFF; 00544 tool_flag SET_TO 0; 00545 strcpy(_parameter_file_name, default_name); 00546 _outfile SET_TO stdout; /* may be reset below */ 00547 00548 for(; ;) 00549 { 00550 fprintf(stderr, "enter a number:\n"); 00551 fprintf(stderr, "1 = start interpreting\n"); 00552 fprintf(stderr, "2 = choose parameter file ...\n"); 00553 fprintf(stderr, "3 = read tool file ...\n"); 00554 fprintf(stderr, "4 = turn block delete switch %s\n", 00555 ((block_delete IS OFF) ? "ON" : "OFF")); 00556 fprintf(stderr, "5 = adjust error handling...\n"); 00557 fprintf(stderr, "enter choice => "); 00558 fgets(buffer,80,stdin); 00559 if (sscanf(buffer, "%d", &choice) ISNT 1) 00560 continue; 00561 if (choice IS 1) 00562 break; 00563 else if (choice IS 2) 00564 { 00565 if (designate_parameter_file(_parameter_file_name) ISNT 0) 00566 exit(1); 00567 } 00568 else if (choice IS 3) 00569 { 00570 if (read_tool_file("") ISNT 0) 00571 exit(1); 00572 tool_flag SET_TO 1; 00573 } 00574 else if (choice IS 4) 00575 block_delete SET_TO ((block_delete IS OFF) ? ON : OFF); 00576 else if (choice IS 5) 00577 adjust_error_handling(argc, &print_stack, &do_next); 00578 } 00579 fprintf(stderr, "executing\n"); 00580 if (tool_flag IS 0) 00581 { 00582 if (read_tool_file("rs274ngc.tool_default") ISNT 0) 00583 exit(1); 00584 } 00585 00586 if (argc IS 3) 00587 { 00588 _outfile SET_TO fopen(argv[2], "w"); 00589 if (_outfile IS NULL) 00590 { 00591 fprintf(stderr, "could not open output file %s\n", argv[2]); 00592 exit(1); 00593 } 00594 } 00595 00596 if ((status SET_TO rs274ngc_init()) ISNT RS274NGC_OK) 00597 { 00598 report_error(status, print_stack); 00599 exit(1); 00600 } 00601 00602 if (argc IS 1) 00603 status SET_TO interpret_from_keyboard(block_delete, print_stack); 00604 else /* if (argc IS 2 or argc IS 3) */ 00605 { 00606 status SET_TO rs274ngc_open(argv[1]); 00607 if (status ISNT RS274NGC_OK) /* do not need to close since not open */ 00608 { 00609 report_error(status, print_stack); 00610 exit(1); 00611 } 00612 status SET_TO interpret_from_file(do_next, block_delete, print_stack); 00613 rs274ngc_file_name(buffer, 5); /* called to exercise the function */ 00614 rs274ngc_file_name(buffer, 79); /* called to exercise the function */ 00615 rs274ngc_close(); 00616 } 00617 rs274ngc_line_length(); /* called to exercise the function */ 00618 rs274ngc_sequence_number(); /* called to exercise the function */ 00619 rs274ngc_active_g_codes(gees); /* called to exercise the function */ 00620 rs274ngc_active_m_codes(ems); /* called to exercise the function */ 00621 rs274ngc_active_settings(sets); /* called to exercise the function */ 00622 rs274ngc_exit(); /* saves parameters */ 00623 exit(status); 00624 } |
|
Definition at line 268 of file new/driver.cc. Referenced by main().
00270 { 00271 FILE * tool_file_port; 00272 char buffer[1000]; 00273 int slot; 00274 int tool_id; 00275 double offset; 00276 double diameter; 00277 00278 if (file_name[0] IS 0) /* ask for name if given name is empty string */ 00279 { 00280 fprintf(stderr, "name of tool file => "); 00281 fgets(buffer,1000,stdin); 00282 tool_file_port SET_TO fopen(buffer, "r"); 00283 } 00284 else 00285 tool_file_port SET_TO fopen(file_name, "r"); 00286 if (tool_file_port IS NULL) 00287 { 00288 fprintf(stderr, "Cannot open %s\n", 00289 ((file_name[0] IS 0) ? buffer : file_name)); 00290 return 1; 00291 } 00292 for(;;) /* read and discard header, checking for blank line */ 00293 { 00294 if (fgets(buffer, 1000, tool_file_port) IS NULL) 00295 { 00296 fprintf(stderr, "Bad tool file format\n"); 00297 return 1; 00298 } 00299 else if (buffer[0] IS '\n') 00300 break; 00301 } 00302 00303 for (slot SET_TO 0; slot <= _tool_max; slot++) /* initialize */ 00304 { 00305 _tools[slot].id SET_TO -1; 00306 _tools[slot].length SET_TO 0; 00307 _tools[slot].diameter SET_TO 0; 00308 } 00309 for (; (fgets(buffer, 1000, tool_file_port) ISNT NULL); ) 00310 { 00311 if (sscanf(buffer, "%d %d %lf %lf", &slot, 00312 &tool_id, &offset, &diameter) < 4) 00313 { 00314 fprintf(stderr, "Bad input line \"%s\" in tool file\n", buffer); 00315 return 1; 00316 } 00317 if ((slot < 0) OR (slot > _tool_max)) /* zero and max both OK */ 00318 { 00319 fprintf(stderr, "Out of range tool slot number %d\n", slot); 00320 return 1; 00321 } 00322 _tools[slot].id SET_TO tool_id; 00323 _tools[slot].length SET_TO offset; 00324 _tools[slot].diameter SET_TO diameter; 00325 } 00326 fclose(tool_file_port); 00327 return 0; 00328 } |
|
Definition at line 52 of file new/driver.cc. Referenced by interpret_from_file(), interpret_from_keyboard(), and main().
00055 { 00056 char buffer[RS274NGC_TEXT_SIZE]; 00057 int k; 00058 00059 rs274ngc_error_text(error_code, buffer, 5); /* for coverage of code */ 00060 rs274ngc_error_text(error_code, buffer, RS274NGC_TEXT_SIZE); 00061 fprintf(stderr, "%s\n", 00062 ((buffer[0] IS 0) ? "Unknown error, bad error code" : buffer)); 00063 rs274ngc_line_text(buffer, RS274NGC_TEXT_SIZE); 00064 fprintf(stderr, "%s\n", buffer); 00065 if (print_stack IS ON) 00066 { 00067 for (k SET_TO 0; ; k++) 00068 { 00069 rs274ngc_stack_name(k, buffer, RS274NGC_TEXT_SIZE); 00070 if (buffer[0] ISNT 0) 00071 fprintf(stderr, "%s\n", buffer); 00072 else 00073 break; 00074 } 00075 } 00076 } |