Generating G Code from MDI history log
13 Mar 2013 22:19 - 13 Mar 2013 22:20 #31334
by ArcEye
Replied by ArcEye on topic Re:Generating G Code from MDI history log
Code for plot component for those interested
Warning: Spoiler!
/*
Component for use with the splice utility to produce gcode from
a set of co-ordinates marked with pyVCP button
*/
component plot;
pin in float xposition "Receives current position from Xpos";
pin in float yposition "Receives current position from Ypos";
pin in float zposition "Receives current position from Zpos";
pin in bit trigger = 0 "Triggers writing co-ordinates to file";
pin out float lastx "Outputs last X position plotted";
pin out float lasty "Outputs last Y position plotted";
pin out float lastz "Outputs last Z position plotted";
pin in bit splice = 0 "Triggers splicing together gcode";
pin in bit load = 0 "Triggers loading of generated gcode";
option singleton yes;
option userspace yes;
author "ArcEye";
license "GPL";
;;
#include <stdio.h> /* Standard input/output definitions */
#include <stdlib.h>
#include <stdint.h> /* Standard types */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <errno.h> /* Error number definitions */
#include <signal.h>
int done = 0;
void adios(int sig)
{
done = 1;
}
void user_mainloop(void)
{
char coordfile[] = "/tmp/cords.txt";
FILE *fptr1;
int triggered, spliced, loaded;
signal(SIGINT, adios);
signal(SIGTERM, adios);
// prevent cycling whilst button depressed
triggered = spliced = loaded = 0;
while(!done)
{
usleep(100000);
FOR_ALL_INSTS()
{
if(trigger && !triggered)
{
fptr1 = fopen(coordfile, "a");
fprintf(fptr1, "X%08.03f Y%08.03f Z%08.03f\n", lastx = xposition, lasty = yposition, lastz = zposition );
fclose(fptr1);
triggered = 1;
}
else if(splice && !spliced)
{
system("splice /usr/share/splice/header.ngc /usr/share/splice/footer.ngc /tmp/cords.txt /tmp/operation.ngc /tmp/output.ngc");
spliced = 1;
}
else if(load && !loaded)
{
system("axis-remote /tmp/output.ngc");
loaded = 1;
}
else // ensure button released before zeroing flag to allow pressing it to register again
{
if(!trigger && triggered) triggered = 0;
if(!splice && spliced) spliced = 0;
if(!load && loaded) loaded = 0;
}
}
}
exit(0);
}
Last edit: 13 Mar 2013 22:20 by ArcEye.
The following user(s) said Thank You: susam
Please Log in or Create an account to join the conversation.
18 Mar 2013 20:15 - 18 Mar 2013 20:17 #31544
by susam
Replied by susam on topic Re:Generating G Code from MDI history log
Thanks!..
I am writing a G-code generator in java...(as I'm more comfortable with it). I will try to integrate these elements through that piece of code. I hope it works out....to integrate java into such an environment.
Regards
I am writing a G-code generator in java...(as I'm more comfortable with it). I will try to integrate these elements through that piece of code. I hope it works out....to integrate java into such an environment.
Regards
Last edit: 18 Mar 2013 20:17 by susam.
Please Log in or Create an account to join the conversation.
18 Mar 2013 20:20 #31545
by susam
Replied by susam on topic Re:Generating G Code from MDI history log
the G-code generator in java works.....however I am not sure if its possible to call a java class that creates something like a pop-up window with buttons,numbers etc......like the way u did. I will try though. Please advice if am taking a wrong direction.
Please Log in or Create an account to join the conversation.
18 Mar 2013 23:36 #31550
by ArcEye
You can create the code that is going to be executed at each of the co-ordinates, any way you like. If you output it to /tmp/operation.ngc it will be used by my splice code, or you can write your own
program entirely to do the same thing as splice.
What you won't be able to do is write a hal component in java. The libraries are written in C, with python bindings written in C to allow python to use them.
If you want to execute a java program, you will probably have to do it from a script, the same way that initially splice was executed.
I know little about java, I looked at it for web programming a long time back but never continued with it.
Dialogs with data fields etc will be bread and butter stuff, it just depends how you are intending to activate them.
regards
Replied by ArcEye on topic Re:Generating G Code from MDI history log
I am writing a G-code generator in java...(as I'm more comfortable with it). I will try to integrate these elements through that piece of code. I hope it works out....to integrate java into such an environment.
You can create the code that is going to be executed at each of the co-ordinates, any way you like. If you output it to /tmp/operation.ngc it will be used by my splice code, or you can write your own
program entirely to do the same thing as splice.
What you won't be able to do is write a hal component in java. The libraries are written in C, with python bindings written in C to allow python to use them.
If you want to execute a java program, you will probably have to do it from a script, the same way that initially splice was executed.
however I am not sure if its possible to call a java class that creates something like a pop-up window with buttons,numbers etc
I know little about java, I looked at it for web programming a long time back but never continued with it.
Dialogs with data fields etc will be bread and butter stuff, it just depends how you are intending to activate them.
regards
Please Log in or Create an account to join the conversation.
Time to create page: 0.168 seconds