Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

driver.cc File Reference

#include "rs274ngc.hh"
#include "rs274ngc_return.hh"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Include dependency graph for driver.cc:

Include dependency graph

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)


Function Documentation

void report_error int    error_code,
int    print_stack
 

print stack if ON, otherwise not

Parameters:
error_code  ARGUMENTS
print_stack  the code number of the error message

Definition at line 52 of file driver.cc.

References ISNT, ON, rs274ngc_error_text(), rs274ngc_line_text(), rs274ngc_stack_name(), and RS274NGC_TEXT_SIZE.

Referenced by interpret_from_file(), interpret_from_keyboard(), and main().

int interpret_from_keyboard int    block_delete,
int    print_stack
 

option which is ON or OFF

Parameters:
block_delete  ARGUMENTS
print_stack  switch which is ON or OFF

Definition at line 103 of file driver.cc.

References AND, ISNT, ON, report_error(), RS274NGC_ENDFILE, rs274ngc_execute(), RS274NGC_EXECUTE_FINISH, RS274NGC_EXIT, RS274NGC_OK, rs274ngc_read(), and RS274NGC_TEXT_SIZE.

Referenced by interpret_from_file(), and main().

int interpret_from_file int    do_next,
int    block_delete,
int    print_stack
 

option which is ON or OFF

Parameters:
do_next  ARGUMENTS
block_delete  what to do if error
print_stack  switch which is ON or OFF

Definition at line 166 of file driver.cc.

References AND, interpret_from_keyboard(), ISNT, NCE_FILE_ENDED_WITH_NO_PERCENT_SIGN, ON, report_error(), RS274NGC_ENDFILE, rs274ngc_execute(), RS274NGC_EXECUTE_FINISH, RS274NGC_EXIT, RS274NGC_OK, rs274ngc_read(), and RS274NGC_TEXT_SIZE.

Referenced by main().

int read_tool_file char *    file_name
 

name of tool file

Parameters:
file_name  ARGUMENTS

Definition at line 268 of file driver.cc.

References ISNT.

Referenced by main().

int designate_parameter_file char *    file_name
 

designate_parameter_file

Returned Value: int If any of the following errors occur, this returns 1. Otherwise, it returns 0. 1. The file named by the user cannot be opened.

Side Effects: The name of a parameter file given by the user is put in the file_name string.

Called By: main

Definition at line 347 of file driver.cc.

References PARAMETER_FILE_NAME_LENGTH.

Referenced by main().

int adjust_error_handling int    args,
int *    print_stack,
int *    do_next
 

adjust_error_handling

Returned Value: int (0)

Side Effects: The values of print_stack and do_next are set.

Called By: main

This function allows the user to set one or two aspects of error handling.

By default the driver does not print the function stack in case of error. This function always allows the user to turn stack printing on if it is off or to turn stack printing off if it is on.

When interpreting from the keyboard, the driver always goes ahead if there is an error.

When interpreting from a file, the default behavior is to stop in case of an error. If the user is interpreting from a file (indicated by args being 2 or 3), this lets the user change what it does on an error.

If the user has not asked for output to a file (indicated by args being 2), the user can choose any of three behaviors in case of an error (1) continue, (2) stop, (3) go into MDI mode. This function allows the user to cycle among the three.

If the user has asked for output to a file (indicated by args being 3), the user can choose any of two behaviors in case of an error (1) continue, (2) stop. This function allows the user to toggle between the two.

Definition at line 398 of file driver.cc.

References AND, ISNT, OFF, ON, and SET_TO.

Referenced by main().

int main int    argc,
char **    argv
 

main

The executable exits with either 0 (under all conditions not listed below) or 1 (under the following conditions): 1. A fatal error occurs while interpreting from a file. 2. Read_tool_file fails. 3. An error occurs in rs274ngc_init.

Here are three ways in which the rs274abc executable may be called. Any other sort of call to the executable will cause an error message to be printed and the interpreter will not run. Other executables may be called similarly.

1. If the rs274abc stand-alone executable is called with no arguments, input is taken from the keyboard, and an error in the input does not cause the rs274abc executable to exit.

EXAMPLE:

1A. To interpret from the keyboard, enter:

rs274abc

2. If the executable is called with one argument, the argument is taken to be the name of an NC file and the file is interpreted as described in the documentation of interpret_from_file.

EXAMPLES:

2A. To interpret the file "cds.abc" and read the results on the screen, enter:

rs274abc cds.abc

2B. To interpret the file "cds.abc" and print the results in the file "cds.prim", enter:

rs274abc cds.abc > cds.prim

Whichever way the executable is called, this gives the user several choices before interpretation starts

1 = start interpreting 2 = choose parameter file 3 = read tool file ... 4 = turn block delete switch ON 5 = adjust error handling...

Interpretation starts when option 1 is chosen. Until that happens, the user is repeatedly given the five choices listed above. Item 4 toggles between "turn block delete switch ON" and "turn block delete switch OFF". See documentation of adjust_error_handling regarding what option 5 does.

User instructions are printed to stderr (with fprintf) so that output can be redirected to a file. When output is redirected and user instructions are printed to stdout (with printf), the instructions get redirected and the user does not see them.

Definition at line 519 of file driver.cc.

References adjust_error_handling(), designate_parameter_file(), interpret_from_file(), interpret_from_keyboard(), ISNT, OFF, ON, read_tool_file(), report_error(), rs274ngc_active_g_codes(), RS274NGC_ACTIVE_G_CODES, rs274ngc_active_m_codes(), RS274NGC_ACTIVE_M_CODES, rs274ngc_active_settings(), RS274NGC_ACTIVE_SETTINGS, rs274ngc_close(), rs274ngc_exit(), rs274ngc_file_name(), rs274ngc_init(), rs274ngc_line_length(), RS274NGC_OK, rs274ngc_open(), rs274ngc_sequence_number(), and SET_TO.


Generated on Mon Feb 11 21:31:16 2002 for rs274ngc by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001