You may insert code into ARC_FEED/STRAIT_FEED of the attached program.
command line to compile it (put your paths to emc source):
g++ -I../x/emc2-trunk/include/ -L../x/emc2-trunk/lib/
-R../x/emc2-trunk/lib/ -lrs274 -lemcini test.cc -o t
Mark wrote:
What I want is a way to get lines and arcs from a gcode file.
Question: if changes are made to the main interp, do they propagate to the
Axis version or must the Axis version be edited by hand?
Mark
On Tue, Mar 3, 2009 at 11:55 AM, Jeff Epler <[email protected]> wrote:
The so-called "stand-alone" interpreter is available as the program
"rs274".
I'm not 100% sure this is in the precompiled package (I think it is),
but I know you get it when you build emc2 yourself.
However, axis uses a different method (embed rs274 as a shared library)
to generate the preview plot.
Jeff
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco,
CA
-OSBC tackles the biggest issue in open source: Open Sourcing the
Enterprise
-Strategies to boost innovation and cut costs with open source
participation
-Receive a $600 discount off the registration fee with the source code:
SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers
------------------------------------------------------------------------
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
------------------------------------------------------------------------
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers
#include <stdio.h>
#include <rs274ngc.hh>
#include "interp_return.hh"
#include <config.h>
char _parameter_file_name[LINELEN];
double _pos_x, _pos_y, _pos_z, _pos_a, _pos_b, _pos_c, _pos_u, _pos_v, _pos_w;
double tool_xoffset, tool_zoffset, tool_woffset;
void ARC_FEED(int line_number,
double first_end, double second_end, double first_axis,
double second_axis, int rotation, double axis_end_point,
double a_position, double b_position, double c_position,
double u_position, double v_position, double w_position)
{
fprintf(stderr, "arc feed: %d, (%g, %g) (%g, %g) %d %g /%g %g %g %g %g %g/\n", line_number, first_end, second_end, first_axis, second_axis, rotation, axis_end_point, a_position, b_position, c_position, u_position, v_position, w_position);
}
void STRAIGHT_FEED(int line_number,
double x, double y, double z,
double a, double b, double c,
double u, double v, double w)
{
fprintf(stderr, "straight feed: %d, %g %g %g - %g %g %g - %g %g %g\n", line_number, x, y, z, a, b, c, u, v, w);
}
void STRAIGHT_TRAVERSE(int line_number,
double x, double y, double z,
double a, double b, double c,
double u, double v, double w)
{
fprintf(stderr, "straight traverse: %d, %g %g %g - %g %g %g - %g %g %g\n", line_number, x, y, z, a, b, c, u, v, w);
}
void SET_ORIGIN_OFFSETS(double x, double y, double z,
double a, double b, double c,
double u, double v, double w)
{
}
void USE_LENGTH_UNITS(CANON_UNITS u) {
}
void SET_LENGTH_UNITS(CANON_UNITS u) {
}
void SELECT_PLANE(CANON_PLANE pl) {}
void SET_TRAVERSE_RATE(double rate) {}
void SET_FEED_MODE(int mode) {}
void CHANGE_TOOL(int tool) {}
void CHANGE_TOOL_NUMBER(int tool) {}
void SET_FEED_RATE(double rate) {}
void DWELL(double time) {
}
void MESSAGE(char *comment) {
}
void LOG(char *s) {}
void LOGOPEN(char *f) {}
void LOGCLOSE() {}
void SYSTEM(char *comment) {
}
void COMMENT(char *comment) {
}
void SET_TOOL_TABLE_ENTRY(int id, double zoffset, double xoffset, double diameter,
double frontangle, double backangle, int orientation) {
}
void SET_TOOL_TABLE_ENTRY(int id, double zoffset, double diameter) {
}
void USE_TOOL_LENGTH_OFFSET(double xoffset, double zoffset, double woffset) {
tool_zoffset = zoffset; tool_xoffset = xoffset; tool_woffset = woffset;
}
void SET_FEED_REFERENCE(double reference) { }
void SET_CUTTER_RADIUS_COMPENSATION(double radius) {}
void START_CUTTER_RADIUS_COMPENSATION(int direction) {}
void STOP_CUTTER_RADIUS_COMPENSATION(int direction) {}
void START_SPEED_FEED_SYNCH() {}
void START_SPEED_FEED_SYNCH(double sync, bool vel) {}
void STOP_SPEED_FEED_SYNCH() {}
void START_SPINDLE_COUNTERCLOCKWISE() {}
void START_SPINDLE_CLOCKWISE() {}
void SET_SPINDLE_MODE(double) {}
void STOP_SPINDLE_TURNING() {}
void SET_SPINDLE_SPEED(double rpm) {}
void ORIENT_SPINDLE(double d, int i) {}
void PROGRAM_STOP() {}
void PROGRAM_END() {}
void FINISH() {}
void PALLET_SHUTTLE() {}
void SELECT_TOOL(int tool) {}
void OPTIONAL_PROGRAM_STOP() {}
extern bool GET_BLOCK_DELETE(void) {
int bd = 0;
return bd;
}
void DISABLE_FEED_OVERRIDE() {}
void DISABLE_FEED_HOLD() {}
void ENABLE_FEED_HOLD() {}
void DISABLE_SPEED_OVERRIDE() {}
void ENABLE_FEED_OVERRIDE() {}
void ENABLE_SPEED_OVERRIDE() {}
void MIST_OFF() {}
void FLOOD_OFF() {}
void MIST_ON() {}
void FLOOD_ON() {}
void CLEAR_AUX_OUTPUT_BIT(int bit) {}
void SET_AUX_OUTPUT_BIT(int bit) {}
void SET_AUX_OUTPUT_VALUE(int index, double value) {}
void CLEAR_MOTION_OUTPUT_BIT(int bit) {}
void SET_MOTION_OUTPUT_BIT(int bit) {}
void SET_MOTION_OUTPUT_VALUE(int index, double value) {}
void TURN_PROBE_ON() {}
void TURN_PROBE_OFF() {}
void STRAIGHT_PROBE(int line_number,
double x, double y, double z,
double a, double b, double c,
double u, double v, double w, unsigned char probe_type) {
_pos_x=x; _pos_y=y; _pos_z=z;
_pos_a=a; _pos_b=b; _pos_c=c;
_pos_u=u; _pos_v=v; _pos_w=w;
}
void RIGID_TAP(int line_number,
double x, double y, double z) {
}
double GET_EXTERNAL_MOTION_CONTROL_TOLERANCE() { return 0.1; }
double GET_EXTERNAL_PROBE_POSITION_X() { return _pos_x; }
double GET_EXTERNAL_PROBE_POSITION_Y() { return _pos_y; }
double GET_EXTERNAL_PROBE_POSITION_Z() { return _pos_z; }
double GET_EXTERNAL_PROBE_POSITION_A() { return _pos_a; }
double GET_EXTERNAL_PROBE_POSITION_B() { return _pos_b; }
double GET_EXTERNAL_PROBE_POSITION_C() { return _pos_c; }
double GET_EXTERNAL_PROBE_POSITION_U() { return _pos_u; }
double GET_EXTERNAL_PROBE_POSITION_V() { return _pos_v; }
double GET_EXTERNAL_PROBE_POSITION_W() { return _pos_w; }
double GET_EXTERNAL_PROBE_VALUE() { return 0.0; }
int GET_EXTERNAL_PROBE_TRIPPED_VALUE() { return 0; }
double GET_EXTERNAL_POSITION_X() { return _pos_x; }
double GET_EXTERNAL_POSITION_Y() { return _pos_y; }
double GET_EXTERNAL_POSITION_Z() { return _pos_z; }
double GET_EXTERNAL_POSITION_A() { return _pos_a; }
double GET_EXTERNAL_POSITION_B() { return _pos_b; }
double GET_EXTERNAL_POSITION_C() { return _pos_c; }
double GET_EXTERNAL_POSITION_U() { return _pos_u; }
double GET_EXTERNAL_POSITION_V() { return _pos_v; }
double GET_EXTERNAL_POSITION_W() { return _pos_w; }
void INIT_CANON() {}
void GET_EXTERNAL_PARAMETER_FILE_NAME(char *name, int max_size) {}
int GET_EXTERNAL_LENGTH_UNIT_TYPE() { return CANON_UNITS_MM; }
CANON_TOOL_TABLE GET_EXTERNAL_TOOL_TABLE(int tool) {
CANON_TOOL_TABLE t = {0,0,0,0,0,0,0};
return t;
}
int GET_EXTERNAL_TLO_IS_ALONG_W(void) {
int is_along_w = 0;
return is_along_w;
}
int GET_EXTERNAL_DIGITAL_INPUT(int index, int def) { return def; }
double GET_EXTERNAL_ANALOG_INPUT(int index, double def) { return def; }
int WAIT(int index, int input_type, int wait_type, int timeout) { return 0;}
void user_defined_function(int num, double arg1, double arg2) {}
void SET_FEED_REFERENCE(int ref) {}
int GET_EXTERNAL_QUEUE_EMPTY() { return true; }
CANON_DIRECTION GET_EXTERNAL_SPINDLE() { return 0; }
int GET_EXTERNAL_TOOL_SLOT() { return 0; }
int GET_EXTERNAL_SELECTED_TOOL_SLOT() { return 0; }
double GET_EXTERNAL_FEED_RATE() { return 1; }
double GET_EXTERNAL_TRAVERSE_RATE() { return 0; }
int GET_EXTERNAL_FLOOD() { return 0; }
int GET_EXTERNAL_MIST() { return 0; }
CANON_PLANE GET_EXTERNAL_PLANE() { return 1; }
double GET_EXTERNAL_SPEED() { return 0; }
int GET_EXTERNAL_TOOL_MAX() { return CANON_TOOL_MAX; }
void DISABLE_ADAPTIVE_FEED() {}
void ENABLE_ADAPTIVE_FEED() {}
int GET_EXTERNAL_FEED_OVERRIDE_ENABLE() {return 1;}
int GET_EXTERNAL_SPINDLE_OVERRIDE_ENABLE() {return 1;}
int GET_EXTERNAL_ADAPTIVE_FEED_ENABLE() {return 0;}
int GET_EXTERNAL_FEED_HOLD_ENABLE() {return 1;}
int GET_EXTERNAL_AXIS_MASK() {
int mask = 0xf;
return mask;
}
double GET_EXTERNAL_TOOL_LENGTH_XOFFSET() {
return tool_xoffset;
}
double GET_EXTERNAL_TOOL_LENGTH_ZOFFSET() {
return tool_zoffset;
}
double GET_EXTERNAL_ANGLE_UNITS() {
double dresult = 1.0;
return dresult;
}
double GET_EXTERNAL_LENGTH_UNITS() {
double dresult = 1;
return dresult;
}
bool check_abort() {
return 0;
}
USER_DEFINED_FUNCTION_TYPE USER_DEFINED_FUNCTION[USER_DEFINED_FUNCTION_NUM];
CANON_MOTION_MODE motion_mode;
void SET_MOTION_CONTROL_MODE(CANON_MOTION_MODE mode, double tolerance) { motion_mode = mode; }
void SET_MOTION_CONTROL_MODE(double tolerance) { }
void SET_MOTION_CONTROL_MODE(CANON_MOTION_MODE mode) { motion_mode = mode; }
CANON_MOTION_MODE GET_EXTERNAL_MOTION_CONTROL_MODE() { return motion_mode; }
int main()
{
int res = INTERP_OK;
int active_g_codes[ACTIVE_G_CODES];
int active_m_codes[ACTIVE_M_CODES];
double active_settings[ACTIVE_SETTINGS];
Interp interp;
interp.init();
interp.open("a.ngc");
interp.read("G80 G17 G40 G21 G90 G94 G54 G49 G99 G64 G0 G97 G91.1 G8 M5 M9 M48 M53 M0 F0 S0");
while ((res = interp.read()) == INTERP_OK || res == INTERP_EXECUTE_FINISH) {
res = interp.execute();
if (res != INTERP_OK) break;
}
interp.active_g_codes(active_g_codes);
interp.active_m_codes(active_m_codes);
interp.active_settings(active_settings);
return 0;
}------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers