Hi JT
splice simply splices together 4 different files to make one .ngc output file
It inserts the header, and then reads the co-ordinates file.
For each set of co-ordinates, it moves to that position and carries out whatever moves were programmed in the mdi_history fragment
When there are no more co-ordinate pairs, it appends the footer, writes out and exits
I used it for multiple drilling operations at pretty random co-ordinates that would not easily fit into a canned cycle.
I just had to map the co-ordinates by moving to the centre punch marks, optically aligning and saving them.
Then I did the first drilling operation in MDI and saved that
Then run splice and it creates the file to do the same operation at each co-ordinates
It is not a polished routine, just what I needed at the time and a demonstration of something that is possible
The code is below
regards
Code:
#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 <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <qfile.h>
#include <qstring.h>
#include <qtextstream.h>
int main(int argc, char **argv)
{
QString cord_file, mdi_file, ngc_file, header, footer;
// these are just to make debugging easier, not really used
if(argc < 5)
{
puts("Usage: splice header footer co-ordinates mdi-history output-file");
return(1);
}
QFile hdr(header = argv[1]);
QFile ftr(footer = argv[2]);
QFile cfile( cord_file = argv[3] );
QFile mfile( mdi_file = argv[4] );
QFile nfile( ngc_file = argv[5]);
if ( hdr.open( IO_ReadOnly ) && ftr.open( IO_ReadOnly) && cfile.open( IO_ReadOnly ) && mfile.open( IO_ReadOnly ) && nfile.open( IO_WriteOnly ))
{
QTextStream hstream( &hdr);
QTextStream fstream( &ftr);
QTextStream cstream( &cfile );
QTextStream mstream( &mfile );
QTextStream nstream( &nfile );
while(!hstream.atEnd())
nstream << hstream.readLine() << "\n";
while(!cstream.atEnd())
{
nstream << "G00 " << cstream.readLine() << "\n";
while(!mstream.atEnd())
{
nstream << mstream.readLine() << "\n";
}
mstream.device()->at( 0 );
}
while(!fstream.atEnd())
nstream << fstream.readLine() << "\n";
hdr.close();
ftr.close();
cfile.close();
mfile.close();
nfile.close();
}
else
{
puts("Error: Unable open a specified input file");
return(1);
}
return(0);
}