GCC Code Coverage Report
Directory: emc/rs274ngc/ Exec Total Coverage
File: emc/rs274ngc/rs274ngc_interp.hh Lines: 3 3 100.0 %
Date: 2016-10-27 Branches: 0 0 0.0 %

Line Exec Source
1
//    Copyright 2009-2011, various authors
2
//
3
//    This program is free software; you can redistribute it and/or modify
4
//    it under the terms of the GNU General Public License as published by
5
//    the Free Software Foundation; either version 2 of the License, or
6
//    (at your option) any later version.
7
//
8
//    This program is distributed in the hope that it will be useful,
9
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
10
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
//    GNU General Public License for more details.
12
//
13
//    You should have received a copy of the GNU General Public License
14
//    along with this program; if not, write to the Free Software
15
//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17
#ifndef RS274NGC_INTERP_H
18
#define RS274NGC_INTERP_H
19
#include "rs274ngc.hh"
20
#include "interp_internal.hh"
21
22
class Interp : public InterpBase {
23
24
public:
25
 Interp();
26
 ~Interp();
27
28
/* Interface functions to call to tell the interpreter what to do.
29
   Return values indicate status of execution.
30
   These functions may change the state of the interpreter. */
31
32
// close the currently open NC code file
33
 int close();
34
35
// execute a line of NC code
36
 int execute(const char *command);
37
 int execute();
38
39
 int execute(const char *command, int line_no); //used for MDI calls to specify the pseudo MDI line number
40
41
// stop running
42
 int exit();
43
44
// get ready to run
45
 int init();
46
47
// load a tool table
48
 int load_tool_table();
49
50
// open a file of NC code
51
 int open(const char *filename);
52
53
// read the mdi or the next line of the open NC code file
54
 int read(const char *mdi);
55
 int read();
56
57
// reset yourself
58
 int reset();
59
60
// restore interpreter variables from a file
61
 int restore_parameters(const char *filename);
62
63
// save interpreter variables to file
64
 int save_parameters(const char *filename,
65
                                    const double parameters[]);
66
67
// synchronize your internal model with the external world
68
 int synch();
69
70
/* Interface functions to call to get information from the interpreter.
71
   If a function has a return value, the return value contains the information.
72
   If a function returns nothing, information is copied into one of the
73
   arguments to the function. These functions do not change the state of
74
   the interpreter. */
75
76
// copy active G codes into array [0]..[15]
77
 void active_g_codes(int *codes);
78
79
// copy active M codes into array [0]..[9]
80
 void active_m_codes(int *codes);
81
82
// copy active F, S settings into array [0]..[2]
83
 void active_settings(double *settings);
84
85
// copy the text of the error message whose number is error_code into the
86
// error_text array, but stop at max_size if the text is longer.
87
 char *error_text(int error_code, char *error_text,
88
                                size_t max_size);
89
90
 void setError(const char *fmt, ...) __attribute__((format(printf,2,3)));
91
92
// copy the name of the currently open file into the file_name array,
93
// but stop at max_size if the name is longer
94
 char *file_name(char *file_name, size_t max_size);
95
96
// return the length of the most recently read line
97
 size_t line_length();
98
99
// copy the text of the most recently read line into the line_text array,
100
// but stop at max_size if the text is longer
101
 char *line_text(char *line_text, size_t max_size);
102
103
// return the current sequence number (how many lines read)
104
 int sequence_number();
105
106
// copy the function name from the stack_index'th position of the
107
// function call stack at the time of the most recent error into
108
// the function name string, but stop at max_size if the name is longer
109
 char *stack_name(int stack_index, char *function_name,
110
                                size_t max_size);
111
112
// Get the parameter file name from the ini file.
113
 int ini_load(const char *filename);
114
115
18
 int line() { return sequence_number(); }
116
 int call_level();
117
118
9
 char *command(char *buf, size_t len) { line_text(buf, len); return buf; }
119
120
2116
 char *file(char *buf, size_t len) { file_name(buf, len); return buf; }
121
122
 int init_tool_parameters();
123
 int default_tool_parameters();
124
 int set_tool_parameters();
125
 int on_abort(int reason, const char *message);
126
127
 // program_end_cleanup() resets Interp settings, and enqueues (on the
128
 // interp_list) Canon calls to reset Canon state after a program ends
129
 // (either by executing M2 or M30, or by Abort.
130
 void program_end_cleanup(setup_pointer settings);
131
132
    void set_loglevel(int level);
133
134
    // for now, public - for boost.python access
135
 int find_named_param(const char *nameBuf, int *status, double *value);
136
 int store_named_param(setup_pointer settings,const char *nameBuf, double value, int override_readonly = 0);
137
 int add_named_param(const char *nameBuf, int attr = 0);
138
 int fetch_ini_param( const char *nameBuf, int *status, double *value);
139
 int fetch_hal_param( const char *nameBuf, int *status, double *value);
140
141
    // common combination of add_named_param and store_named_param
142
    // int assign_named_param(const char *nameBuf, int attr = 0, double value = 0.0);
143
    remap_pointer remapping(const char *code);
144
    remap_pointer remapping(const char letter, int number = -1);
145
 int find_tool_pocket(setup_pointer settings, int toolno, int *pocket);
146
147
    // private:
148
    //protected:  // for boost wrapper access
149
150
/* Function prototypes for all  functions */
151
152
 int arc_data_comp_ijk(int move,
153
         int plane,
154
         int side,
155
         double tool_radius,
156
         double current_x,
157
         double current_y,
158
         double end_x,
159
         double end_y,
160
         int ij_absolute,
161
         double i_number,
162
         double j_number,
163
         int p_number,
164
         double *center_x,
165
         double *center_y,
166
         int *turn,
167
         double radius_tolerance,
168
         double spiral_abs_tolerance,
169
         double spiral_rel_tolerance);
170
171
 int arc_data_comp_r(int move,
172
         int plane,
173
         int side,
174
         double tool_radius,
175
         double current_x,
176
         double current_y,
177
         double end_x,
178
         double end_y,
179
         double big_radius,
180
         int p_number,
181
         double *center_x,
182
         double *center_y,
183
         int *turn,
184
         double radius_tolerance);
185
186
 int arc_data_ijk(int move,
187
         int plane,
188
         double current_x,
189
         double current_y,
190
         double end_x,
191
         double end_y,
192
         int ij_absolute,
193
         double i_number,
194
         double j_number,
195
         int p_number,
196
         double *center_x,
197
         double *center_y,
198
         int *turn,
199
         double radius_tolerance,
200
         double spiral_abs_tolerance,
201
         double spiral_rel_tolerance);
202
203
 int arc_data_r(int move,
204
         int plane,
205
         double current_x,
206
         double current_y,
207
         double end_x,
208
         double end_y,
209
         double radius,
210
         int p_number,
211
         double *center_x,
212
         double *center_y,
213
         int *turn,
214
         double radius_tolerance);
215
 int check_g_codes(block_pointer block, setup_pointer settings);
216
 int check_items(block_pointer block, setup_pointer settings);
217
 int check_m_codes(block_pointer block);
218
 int check_other_codes(block_pointer block);
219
 int close_and_downcase(char *line);
220
 int convert_nurbs(int move, block_pointer block, setup_pointer settings);
221
 int convert_spline(int move, block_pointer block, setup_pointer settings);
222
 int comp_get_current(setup_pointer settings, double *x, double *y, double *z);
223
 int comp_set_current(setup_pointer settings, double x, double y, double z);
224
 int comp_get_programmed(setup_pointer settings, double *x, double *y, double *z);
225
 int comp_set_programmed(setup_pointer settings, double x, double y, double z);
226
 int convert_arc(int move, block_pointer block, setup_pointer settings);
227
 int convert_arc2(int move, block_pointer block,
228
                  setup_pointer settings,
229
                  double *current1, double *current2, double *current3,
230
                  double end1, double end2, double end3,
231
                  double AA_end, double BB_end, double CC_end,
232
                  double u_end, double v_end, double w_end,
233
                  double offset1, double offset2);
234
235
 int convert_arc_comp1(int move, block_pointer block,
236
                       setup_pointer settings,
237
                       double end_x, double end_y, double end_z,
238
                       double offset_x, double offset_y,
239
                       double AA_end, double BB_end, double CC_end,
240
                       double u_end, double v_end, double w_end);
241
242
 int convert_arc_comp2(int move, block_pointer block,
243
                       setup_pointer settings,
244
                       double end_x, double end_y, double end_z,
245
                       double offset_x, double offset_y,
246
                       double AA_end, double BB_end, double CC_end,
247
                       double u_end, double v_end, double w_end);
248
 char arc_axis1(int plane);
249
 char arc_axis2(int plane);
250
 int convert_axis_offsets(int g_code, block_pointer block,
251
                                setup_pointer settings);
252
 int convert_param_comment(char *comment, char *expanded, int len);
253
    int convert_comment(char *comment, bool enqueue = true);
254
 int convert_control_mode(int g_code, double tolerance, double naivecam_tolerance, setup_pointer settings);
255
 int convert_adaptive_mode(int g_code, setup_pointer settings);
256
257
 int convert_coordinate_system(int g_code, setup_pointer settings);
258
 int convert_cutter_compensation(int g_code, block_pointer block,
259
                                       setup_pointer settings);
260
 int convert_cutter_compensation_off(setup_pointer settings);
261
 int convert_cutter_compensation_on(int side, block_pointer block,
262
                                          setup_pointer settings);
263
 int convert_cycle(int motion, block_pointer block,
264
                         setup_pointer settings);
265
 int convert_cycle_g81(block_pointer block, CANON_PLANE plane, double x, double y,
266
                             double clear_z, double bottom_z);
267
 int convert_cycle_g82(block_pointer block, CANON_PLANE plane, double x, double y,
268
                             double clear_z, double bottom_z, double dwell);
269
 int convert_cycle_g73(block_pointer block, CANON_PLANE plane, double x, double y,
270
                             double r, double clear_z, double bottom_z,
271
                             double delta);
272
 int convert_cycle_g83(block_pointer block, CANON_PLANE plane, double x, double y,
273
                             double r, double clear_z, double bottom_z,
274
                             double delta);
275
 int convert_cycle_g84(block_pointer block, CANON_PLANE plane, double x, double y,
276
                             double clear_z, double bottom_z,
277
                             CANON_DIRECTION direction,
278
                             CANON_SPEED_FEED_MODE mode);
279
 int convert_cycle_g85(block_pointer block, CANON_PLANE plane, double x, double y,
280
                             double r, double clear_z, double bottom_z);
281
 int convert_cycle_g86(block_pointer block, CANON_PLANE plane, double x, double y,
282
                             double clear_z, double bottom_z, double dwell,
283
                             CANON_DIRECTION direction);
284
 int convert_cycle_g87(block_pointer block, CANON_PLANE plane, double x, double offset_x,
285
                             double y, double offset_y, double r,
286
                             double clear_z, double middle_z, double bottom_z,
287
                             CANON_DIRECTION direction);
288
 int convert_cycle_g88(block_pointer block, CANON_PLANE plane, double x, double y,
289
                             double bottom_z, double dwell,
290
                             CANON_DIRECTION direction);
291
 int convert_cycle_g89(block_pointer block, CANON_PLANE plane, double x, double y,
292
                             double clear_z, double bottom_z, double dwell);
293
 int convert_cycle_xy(int motion, block_pointer block,
294
                            setup_pointer settings);
295
 int convert_cycle_yz(int motion, block_pointer block,
296
                            setup_pointer settings);
297
 int convert_cycle_zx(int motion, block_pointer block,
298
                            setup_pointer settings);
299
 int convert_cycle_uv(int motion, block_pointer block,
300
                            setup_pointer settings);
301
 int convert_cycle_vw(int motion, block_pointer block,
302
                            setup_pointer settings);
303
 int convert_cycle_wu(int motion, block_pointer block,
304
                            setup_pointer settings);
305
 int convert_distance_mode(int g_code, setup_pointer settings);
306
 int convert_ijk_distance_mode(int g_code, setup_pointer settings);
307
 int convert_lathe_diameter_mode(int g_code, block_pointer block, setup_pointer settings);
308
 int convert_dwell(setup_pointer settings, double time);
309
 int convert_feed_mode(int g_code, setup_pointer settings);
310
 int convert_feed_rate(block_pointer block, setup_pointer settings);
311
    int convert_g(block_pointer block, setup_pointer settings);
312
 int convert_home(int move, block_pointer block,
313
                        setup_pointer settings);
314
 int convert_savehome(int move, block_pointer block,
315
                        setup_pointer settings);
316
 int convert_length_units(int g_code, setup_pointer settings);
317
    int convert_m(block_pointer block, setup_pointer settings);
318
 int convert_modal_0(int code, block_pointer block,
319
                           setup_pointer settings);
320
 int convert_motion(int motion, block_pointer block,
321
                          setup_pointer settings);
322
 int convert_probe(block_pointer block, int g_code, setup_pointer settings);
323
 int convert_retract_mode(int g_code, setup_pointer settings);
324
 int convert_setup(block_pointer block, setup_pointer settings);
325
 int convert_setup_tool(block_pointer block, setup_pointer settings);
326
 int convert_set_plane(int g_code, setup_pointer settings);
327
 int convert_speed(block_pointer block, setup_pointer settings);
328
     int convert_spindle_mode(block_pointer block, setup_pointer settings);
329
 int convert_stop(block_pointer block, setup_pointer settings);
330
 int convert_straight(int move, block_pointer block,
331
                            setup_pointer settings);
332
 int convert_straight_comp1(int move, block_pointer block,
333
                            setup_pointer settings,
334
                            double px, double py, double end_z,
335
                            double AA_end, double BB_end, double CC_end,
336
                            double u_end, double v_end, double w_end);
337
 int convert_straight_comp2(int move, block_pointer block,
338
                            setup_pointer settings,
339
                            double px, double py, double end_z,
340
                            double AA_end, double BB_end, double CC_end,
341
                            double u_end, double v_end, double w_end);
342
 int convert_threading_cycle(block_pointer block, setup_pointer settings,
343
                             double end_x, double end_y, double end_z);
344
 int convert_tool_change(setup_pointer settings);
345
 int convert_tool_length_offset(int g_code, block_pointer block,
346
                                      setup_pointer settings);
347
 int convert_tool_select(block_pointer block, setup_pointer settings);
348
 int cycle_feed(block_pointer block, CANON_PLANE plane, double end1,
349
                double end2, double end3);
350
 int cycle_traverse(block_pointer block, CANON_PLANE plane, double end1, double end2,
351
                          double end3);
352
 int enhance_block(block_pointer block, setup_pointer settings);
353
 int _execute(const char *command = 0);
354
 int execute_binary(double *left, int operation, double *right);
355
 int execute_binary1(double *left, int operation, double *right);
356
 int execute_binary2(double *left, int operation, double *right);
357
    int execute_block(block_pointer block, setup_pointer settings);
358
 int execute_unary(double *double_ptr, int operation);
359
 double find_arc_length(double x1, double y1, double z1,
360
                              double center_x, double center_y, int turn,
361
                              double x2, double y2, double z2);
362
 int find_current_in_system(setup_pointer s, int system, double *x, double *y, double *z,
363
                            double *a, double *b, double *c,
364
                            double *u, double *v, double *w);
365
 int find_current_in_system_without_tlo(setup_pointer s, int system, double *x, double *y, double *z,
366
                            double *a, double *b, double *c,
367
                            double *u, double *v, double *w);
368
 int find_ends(block_pointer block, setup_pointer settings,
369
               double *px, double *py, double *pz,
370
               double *AA_p, double *BB_p, double *CC_p,
371
               double *u_p, double *v_p, double *w_p);
372
 int find_relative(double x1, double y1, double z1,
373
                   double AA_1, double BB_1, double CC_1,
374
                   double u_1, double v_1, double w_1,
375
                   double *x2, double *y2, double *z2,
376
                   double *AA_2, double *BB_2, double *CC_2,
377
                   double *u_2, double *v_2, double *w_2,
378
                   setup_pointer settings);
379
 double find_straight_length(double x2, double y2, double z2,
380
                             double AA_2, double BB_2, double CC_2,
381
                             double u_w, double v_2, double w_2,
382
                             double x1, double y1, double z1,
383
                             double AA_1, double BB_1, double CC_1,
384
                             double u_1, double v_1, double w_1);
385
 double find_turn(double x1, double y1, double center_x,
386
                        double center_y, int turn, double x2, double y2);
387
 int init_block(block_pointer block);
388
 int inverse_time_rate_arc(double x1, double y1, double z1,
389
                                 double cx, double cy, int turn, double x2,
390
                                 double y2, double z2, block_pointer block,
391
                                 setup_pointer settings);
392
 int inverse_time_rate_straight(double end_x, double end_y, double end_z,
393
                                double AA_end, double BB_end, double CC_end,
394
                                double u_end, double v_end, double w_end,
395
                                block_pointer block,
396
                                setup_pointer settings);
397
 int move_endpoint_and_flush(setup_pointer, double, double);
398
 int parse_line(char *line, block_pointer block,
399
                      setup_pointer settings);
400
 int precedence(int an_operator);
401
 int _read(const char *command);
402
 int read_a(char *line, int *counter, block_pointer block,
403
                  double *parameters);
404
 int read_atan(char *line, int *counter, double *double_ptr,
405
                     double *parameters);
406
 int read_atsign(char *line, int *counter, block_pointer block,
407
                  double *parameters);
408
 int read_b(char *line, int *counter, block_pointer block,
409
                  double *parameters);
410
 int read_c(char *line, int *counter, block_pointer block,
411
                  double *parameters);
412
 int read_carat(char *line, int *counter, block_pointer block,
413
                  double *parameters);
414
 int read_comment(char *line, int *counter, block_pointer block,
415
                        double *parameters);
416
 int read_semicolon(char *line, int *counter, block_pointer block,
417
                        double *parameters);
418
 int read_d(char *line, int *counter, block_pointer block,
419
                  double *parameters);
420
 int read_e(char *line, int *counter, block_pointer block,
421
                  double *parameters);
422
 int read_f(char *line, int *counter, block_pointer block,
423
                  double *parameters);
424
 int read_g(char *line, int *counter, block_pointer block,
425
                  double *parameters);
426
 int read_h(char *line, int *counter, block_pointer block,
427
                  double *parameters);
428
 int read_i(char *line, int *counter, block_pointer block,
429
                  double *parameters);
430
 int read_integer_unsigned(char *line, int *counter, int *integer_ptr);
431
 int read_integer_value(char *line, int *counter, int *integer_ptr,
432
                              double *parameters);
433
 int read_items(block_pointer block, char *line, double *parameters);
434
 int read_j(char *line, int *counter, block_pointer block,
435
                  double *parameters);
436
 int read_k(char *line, int *counter, block_pointer block,
437
                  double *parameters);
438
 int read_l(char *line, int *counter, block_pointer block,
439
                  double *parameters);
440
 int read_n_number(char *line, int *counter, block_pointer block);
441
 int read_m(char *line, int *counter, block_pointer block,
442
                  double *parameters);
443
 int read_o(char *line, int *counter, block_pointer block,
444
                  double *parameters);
445
446
447
 int read_one_item(char *line, int *counter, block_pointer block,
448
                   double *parameters);
449
 int read_operation(char *line, int *counter, int *operation);
450
 int read_operation_unary(char *line, int *counter, int *operation);
451
 int read_p(char *line, int *counter, block_pointer block,
452
                  double *parameters);
453
454
455
456
 int lookup_named_param(const char *nameBuf, double index, double *value);
457
    int init_readonly_param(const char *nameBuf, double value, int attr);
458
    int free_named_parameters(context_pointer frame);
459
 int save_settings(setup_pointer settings);
460
 int restore_settings(setup_pointer settings, int from_level);
461
 int gen_settings(double *current, double *saved, std::string &cmd);
462
 int gen_g_codes(int *current, int *saved, std::string &cmd);
463
 int gen_m_codes(int *current, int *saved, std::string &cmd);
464
 int read_name(char *line, int *counter, char *nameBuf);
465
 int read_named_parameter(char *line, int *counter, double *double_ptr,
466
                          double *parameters, bool check_exists);
467
 int read_parameter(char *line, int *counter, double *double_ptr,
468
                          double *parameters, bool check_exists);
469
 int read_parameter_setting(char *line, int *counter,
470
                                  block_pointer block, double *parameters);
471
 int read_bracketed_parameter(char *line, int *counter, double *double_ptr,
472
                          double *parameters, bool check_exists);
473
 int read_named_parameter_setting(char *line, int *counter,
474
                                  char **param, double *parameters);
475
 int read_q(char *line, int *counter, block_pointer block,
476
                  double *parameters);
477
 int read_r(char *line, int *counter, block_pointer block,
478
                  double *parameters);
479
 int read_real_expression(char *line, int *counter,
480
                                double *hold2, double *parameters);
481
 int read_real_number(char *line, int *counter, double *double_ptr);
482
 int read_real_value(char *line, int *counter, double *double_ptr,
483
                           double *parameters);
484
 int read_s(char *line, int *counter, block_pointer block,
485
                  double *parameters);
486
 int read_t(char *line, int *counter, block_pointer block,
487
                  double *parameters);
488
 int read_text(const char *command, FILE * inport, char *raw_line,
489
                     char *line, int *length);
490
 int read_unary(char *line, int *counter, double *double_ptr,
491
                      double *parameters);
492
 int read_u(char *line, int *counter, block_pointer block,
493
                  double *parameters);
494
 int read_v(char *line, int *counter, block_pointer block,
495
                  double *parameters);
496
 int read_w(char *line, int *counter, block_pointer block,
497
                  double *parameters);
498
 int read_x(char *line, int *counter, block_pointer block,
499
                  double *parameters);
500
 int read_y(char *line, int *counter, block_pointer block,
501
                  double *parameters);
502
 int read_z(char *line, int *counter, block_pointer block,
503
                  double *parameters);
504
 int refresh_actual_position(setup_pointer settings);
505
 void rotate(double *x, double *y, double t);
506
 int set_probe_data(setup_pointer settings);
507
 int write_g_codes(block_pointer block, setup_pointer settings);
508
 int write_m_codes(block_pointer block, setup_pointer settings);
509
 int write_settings(setup_pointer settings);
510
 int unwrap_rotary(double *, double, double, double, char);
511
 bool isreadonly(int index);
512
513
  // O_word stuff
514
515
 int findFile( // ARGUMENTS
516
		     char *direct,  // the directory to start looking in
517
		     char *target,  // the name of the file to find
518
		     char *foundFileDirect); // where to store the result
519
520
 int control_save_offset(    /* ARGUMENTS                   */
521
			 // int line,                  /* (o-word) line number        */
522
  block_pointer block,       /* pointer to a block of RS274/NGC instructions */
523
  setup_pointer settings);   /* pointer to machine settings */
524
525
 int control_find_oword(     /* ARGUMENTS                   */
526
  block_pointer block,       /* block pointer to get (o-word) name        */
527
  setup_pointer settings,    /* pointer to machine settings */
528
  offset_pointer *ppo);
529
//  int *o_index);             /* the index of o-word (returned) */
530
531
 int control_back_to(        /* ARGUMENTS                   */
532
  block_pointer block, // pointer to block
533
  setup_pointer settings);   /* pointer to machine settings */
534
535
 // establish a new subroutine context
536
 int enter_context(setup_pointer settings, block_pointer block);
537
 // leave current subroutine context
538
 int leave_context(setup_pointer settings, bool restore = true);
539
540
    //int call_fsm(setup_pointer settings, int event);
541
    //int execute_pycall(setup_pointer settings, const char *name, int call_phase);
542
 int execute_call(setup_pointer settings, context_pointer current_frame, int call_type);
543
 int execute_return(setup_pointer settings,  context_pointer current_frame, int call_type);
544
    //int execute_remap(setup_pointer settings, int call_phase);   // remap call state machine
545
    int handler_returned( setup_pointer settings,
546
			  context_pointer active_frame, const char *name, bool osub);
547
int read_inputs(setup_pointer settings);
548
549
 int convert_control_functions( /* ARGUMENTS           */
550
  block_pointer block,       /* pointer to a block of RS274/NGC instructions */
551
  setup_pointer settings);   /* pointer to machine settings */
552
553
554
 // parse a REMAP= descriptor from the ini file
555
 int parse_remap(const char *inistring, int lineno);
556
557
 // step through parsed block and collect remapped items in
558
 // block.remappings set
559
    int find_remappings(block_pointer block, setup_pointer settings);
560
561
 // establish a new remapping context
562
 int enter_remap(void);
563
 // leave current remapping context
564
 int leave_remap(void);
565
566
 // callback when remapping handler done
567
 int remap_finished( int status);
568
569
 int report_error(setup_pointer settings,int status,const char *text);
570
571
 //  add named params/param dict if argspec given
572
 // present optional words to the subroutine's local variables and Py dict
573
    int add_parameters(setup_pointer settings, block_pointer cblock,
574
		       char *posarglist);
575
576
 int init_named_parameters();
577
    int init_python_predef_parameter(const char *name);
578
579
    bool has_user_mcode(setup_pointer settings,block_pointer block);
580
581
#define M_BUILTIN(m) (_ems[m] != -1)
582
#define G_BUILTIN(g) (_gees[g] != -1)
583
584
    // range for user-remapped M-codes
585
    // and M6,M61
586
    // this is overdue for a bitset
587
#define M_REMAPPABLE(m)					\
588
    (((m > 199) && (m < 1000)) ||			\
589
     ((m > 0) && (m < 100) &&				\
590
      !M_BUILTIN(m)) ||					\
591
     (m == 6) ||					\
592
     (m == 61) ||					\
593
     (m == 0) ||					\
594
     (m == 1) ||					\
595
     (m == 60))
596
597
598
599
    // range for user-remapped G-codes
600
#define G_REMAPPABLE(g)	 \
601
    ((g > 0) && \
602
     (g < 1000) && \
603
     !G_BUILTIN(g))
604
605
#define IS_USER_GCODE(x) (G_REMAPPABLE(x) && _setup.g_remapped[x])
606
607
#define IS_USER_MCODE(bp,sp,mgroup) \
608
    ((M_REMAPPABLE((bp)->m_modes[mgroup])) && \
609
    (((bp)->m_modes[mgroup]) > -1) &&		\
610
     ((sp)->m_remapped[(bp)->m_modes[mgroup]]))
611
612
    bool remap_in_progress(const char *code);
613
    int convert_remapped_code(block_pointer block,
614
			       setup_pointer settings,
615
			      int phase,
616
			      char letter,
617
			      int number = -1);
618
619
    bool is_pycallable(setup_pointer settings, const char *module, const char *funcname);
620
621
#define OWORD_MODULE "oword"
622
#define REMAP_MODULE "remap"
623
#define NAMEDPARAMS_MODULE "namedparams"
624
    // describes intented use, and hence parameter and return value
625
    // interpretation
626
    enum py_calltype { PY_OWORDCALL,
627
		       PY_FINISH_OWORDCALL,
628
		       PY_PROLOG,
629
		       PY_FINISH_PROLOG,
630
		       PY_BODY,
631
		       PY_FINISH_BODY,
632
		       PY_EPILOG,
633
		       PY_FINISH_EPILOG,
634
		       PY_INTERNAL,
635
		       PY_EXECUTE,
636
		       PY_PLUGIN_CALL
637
    };
638
    int pycall(setup_pointer settings,
639
	       context_pointer frame,
640
	       const char *module,
641
	       const char *funcname,
642
	       int calltype);
643
    int py_execute(const char *cmd, bool as_file = false); // for (py, ....) comments
644
    int py_reload();
645
    FILE *find_ngc_file(setup_pointer settings,const char *basename, char *foundhere = NULL);
646
647
    const char *getSavedError();
648
    // set error message text without going through printf format interpretation
649
    int setSavedError(const char *msg);
650
651
    int unwind_call(int status, const char *file, int line, const char *function);
652
653
654
 int convert_straight_indexer(int anum, int jnum, block* blk, setup* settings);
655
 int issue_straight_index(int anum, int jnum, double end, int lineno, setup* settings);
656
657
 void doLog(unsigned int flags, const char *file, int line,
658
	    const char *fmt, ...) __attribute__((format(printf,5,6)));
659
660
 const char *interp_status(int status);
661
662
    //technically this violates encapsulation rules but is needed for
663
    // the Python introspection module
664
665
 FILE *log_file;
666
667
/* Internal arrays */
668
 static const int _gees[];
669
 static const int _ems[];
670
 static const int _required_parameters[];
671
 static const int _readonly_parameters[];
672
 static const int _n_readonly_parameters;
673
 read_function_pointer _readers[256];
674
 static const read_function_pointer default_readers[256];
675
676
 setup _setup;
677
678
 enum {
679
     AXIS_MASK_X =   1, AXIS_MASK_Y =   2, AXIS_MASK_Z =   4,
680
     AXIS_MASK_A =   8, AXIS_MASK_B =  16, AXIS_MASK_C =  32,
681
     AXIS_MASK_U =  64, AXIS_MASK_V = 128, AXIS_MASK_W = 256,
682
 };
683
};
684
685
#endif