Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions include/gcode/gcode_meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ static GcodeMeta AeroBasicMeta = {GcodeSyntax::kAeroBasic,
rev / s, // angular velocity
".gcode"};

static GcodeMeta ORNLMeta = {GcodeSyntax::kCincinnati,
static GcodeMeta ORNLMeta = {GcodeSyntax::kORNL,
QString("("), // starting_delim
QString(")"), // ending_delim
in,
Expand All @@ -237,7 +237,7 @@ static GcodeMeta ORNLMeta = {GcodeSyntax::kCincinnati,
in / s / s,
rev / minute,
".gcode"};
static GcodeMeta ORNLMetricMeta = {GcodeSyntax::kCincinnati,
static GcodeMeta ORNLMetricMeta = {GcodeSyntax::kORNLMetric,
QString("("), // starting_delim
QString(")"), // ending_delim
mm,
Expand Down Expand Up @@ -340,6 +340,7 @@ static QHash<int, GcodeMeta> createMapping() {
result.insert((int)GcodeSyntax::kORNL, ORNLMeta);
result.insert((int)GcodeSyntax::kTormach, TormachMeta);
result.insert((int)GcodeSyntax::kAdamantine, AdamantineMeta);
result.insert((int)GcodeSyntax::kORNLMetric, ORNLMetricMeta);
return result;
}

Expand Down
33 changes: 33 additions & 0 deletions include/threading/gcode_amcm_saver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#pragma once

#include "QThread"
#include "gcode/gcode_meta.h"

namespace ORNL {
/*!
* \class GCodeAMCMSaver
* \brief Threaded class that provides additional gcode processing.
*/
class GCodeAMCMSaver : public QThread {
Q_OBJECT
public:
//! \brief Constructor
//! \param tempLocation: location of gcode file
//! \param path: path to output
//! \param filename: filename to output
//! \param text: current gcode
//! \param meta: meta used to generate gcode
GCodeAMCMSaver(QString tempLocation, QString path, QString filename, QString text, GcodeMeta meta);

//! \brief Function that is run when start is called on this thread.
void run() override;

private:
//! \brief Temporary file location, output path, output filename, and text to output
QString m_temp_location, m_path, m_filename, m_text;

//! \brief Meta info determined from file
GcodeMeta m_selected_meta;

}; // class GCodeAMCMSaver
} // namespace ORNL
2 changes: 2 additions & 0 deletions include/utilities/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ class Constants {
static QString kMach4;
static QString kAeroBasic;
static QString kAdamantine;
static QString kORNLMetric;
};
};

Expand Down Expand Up @@ -938,6 +939,7 @@ class Constants {
static const QString kMarlinOutput;
static const QString kMarlinTravels;
static const QString kSimulationOutput;
static const QString kAMCMOutput;
};

class RotationOrigin {
Expand Down
5 changes: 4 additions & 1 deletion include/utilities/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ enum class GcodeSyntax : uint8_t {
kSandia,
k5AxisMarlin,
kMeltio,
kAdamantine
kAdamantine,
kORNLMetric
};

inline QString toString(GcodeSyntax syntax) {
Expand Down Expand Up @@ -228,6 +229,8 @@ inline QString toString(GcodeSyntax syntax) {
return PRS::SyntaxString::kAeroBasic;
case GcodeSyntax::kAdamantine:
return PRS::SyntaxString::kAdamantine;
case GcodeSyntax::kORNLMetric:
return PRS::SyntaxString::kORNLMetric;
default:
return PRS::SyntaxString::kCommon;
}
Expand Down
Binary file modified mss.ods
Binary file not shown.
22 changes: 18 additions & 4 deletions resources/configs/master.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type":"enumeration",
"tooltip":"Declares the syntax of the G-code (mm or in, comments () or ; etc",
"depends":"",
"options":"Beam, Cincinnati, Common, Dmg Dmu, GKN, Gudel, Haas Inch, Haas Metric, Haas Metric No Comments, Hurco,Ingersoll,Marlin,Marlin Pellet,Mazak,MVP,RomiFanuc,RPBF,Siemens,SkyBaam,Thermwood,Wolf,RepRap,Mach4,AeroBasic,Meld,ORNL,Okuma,Tormach,AML3D,KraussMaffei,Sandia,5AxisMarlin,Meltio,Adamantine",
"options":"Beam, Cincinnati, Common, Dmg Dmu, GKN, Gudel, Haas Inch, Haas Metric, Haas Metric No Comments, Hurco,Ingersoll,Marlin,Marlin Pellet,Mazak,MVP,RomiFanuc,RPBF,Siemens,SkyBaam,Thermwood,Wolf,RepRap,Mach4,AeroBasic,Meld,ORNL,Okuma,Tormach,AML3D,KraussMaffei,Sandia,5AxisMarlin,Meltio,Adamantine,ORNL Metric",
"default":0,
"minor":"Machine Setup",
"major":"Printer",
Expand Down Expand Up @@ -73,7 +73,7 @@
"display":"Axis A",
"type":"angle",
"tooltip":"Sets the printing angle for the A axis",
"depends":{"OR": [{"syntax": 4}, {"syntax": 31}]},
"depends":{"OR": [{"syntax": 4}, {"OR": [{"syntax": 31}, {"OR": [{"syntax": 34},{"syntax": 25}]}]}]},
"options":"",
"default":0,
"minor":"Machine Setup",
Expand All @@ -87,7 +87,7 @@
"display":"Axis B",
"type":"angle",
"tooltip":"Sets the printing angle for the B axis",
"depends":{"OR": [{"syntax": 4}, {"syntax": 31}]},
"depends":{"OR": [{"syntax": 4}, {"OR": [{"syntax": 31}, {"OR": [{"syntax": 34},{"syntax": 25}]}]}]},
"options":"",
"default":0,
"minor":"Machine Setup",
Expand All @@ -101,7 +101,7 @@
"display":"Axis C",
"type":"angle",
"tooltip":"Sets the printing angle for the C axis",
"depends":{"OR": [{"syntax": 4}, {"syntax": 31}]},
"depends":{"OR": [{"syntax": 4}, {"OR": [{"syntax": 31}, {"OR": [{"syntax": 34},{"syntax": 25}]}]}]},
"options":"",
"default":0,
"minor":"Machine Setup",
Expand Down Expand Up @@ -7383,6 +7383,20 @@
"dependency_group":"",
"local":false
},
"amcm_file_output": {
"display":"Enable AMCM SRC File Output",
"type":"boolean",
"tooltip":"If enabled, a src file for AMCM will be saved when exporting the g-code file.",
"depends":{"OR": [{"syntax": 25}, {"syntax": 34}]},
"options":"",
"default":false,
"minor":"File Output",
"major":"Experimental",
"namespace":"Experimental::FileOutput",
"symbol":"kEnableAMCMSRCFileOutput",
"dependency_group":"",
"local":false
},
"rotation_origin_offset_x": {
"display":"Rotational Origin X Offset",
"type":"location",
Expand Down
9 changes: 6 additions & 3 deletions src/gcode/writers/writer_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ QString WriterBase::writeSettingsHeader(GcodeSyntax syntax) {
//

if (syntax != GcodeSyntax::kCincinnati && syntax != GcodeSyntax::kHaasInch && syntax != GcodeSyntax::kMeld &&
syntax != GcodeSyntax::kORNL && syntax != GcodeSyntax::kSiemens && syntax != GcodeSyntax::kSkyBaam) {
syntax != GcodeSyntax::kORNL && syntax != GcodeSyntax::kSiemens && syntax != GcodeSyntax::kORNLMetric &&
syntax != GcodeSyntax::kSkyBaam) {
text += commentLine(
QString("Nozzle Diameter: %0mm").arg(m_sb->setting<Distance>(PS::Layer::kNozzleDiameter).to(mm)));
}
Expand All @@ -113,7 +114,8 @@ QString WriterBase::writeSettingsHeader(GcodeSyntax syntax) {
QString("Filament Diameter: %0mm").arg(m_sb->setting<Distance>(MS::Filament::kDiameter).to(mm)));
}
if (syntax != GcodeSyntax::kCincinnati && syntax != GcodeSyntax::kHaasInch && syntax != GcodeSyntax::kMeld &&
syntax != GcodeSyntax::kORNL && syntax != GcodeSyntax::kSiemens && syntax != GcodeSyntax::kSkyBaam) {
syntax != GcodeSyntax::kORNL && syntax != GcodeSyntax::kSiemens && syntax != GcodeSyntax::kORNLMetric &&
syntax != GcodeSyntax::kSkyBaam) {
text += commentLine(
QString("Printer Base Offset: %0mm").arg(m_sb->setting<Distance>(PRS::Dimensions::kZOffset).to(mm)));
}
Expand All @@ -126,7 +128,8 @@ QString WriterBase::writeSettingsHeader(GcodeSyntax syntax) {
QString("Minimum Table Value: %0in").arg(m_sb->setting<Distance>(PRS::Dimensions::kWMin).to(in)));
}
if (syntax != GcodeSyntax::kCincinnati && syntax != GcodeSyntax::kHaasInch && syntax != GcodeSyntax::kMeld &&
syntax != GcodeSyntax::kORNL && syntax != GcodeSyntax::kSiemens && syntax != GcodeSyntax::kSkyBaam) {
syntax != GcodeSyntax::kORNL && syntax != GcodeSyntax::kSiemens && syntax != GcodeSyntax::kORNLMetric &&
syntax != GcodeSyntax::kSkyBaam) {
text += commentLine(QString("Layer Height: %0mm").arg(m_sb->setting<Distance>(PS::Layer::kLayerHeight).to(mm)));
text += commentLine(
QString("Default Extrusion Width: %0mm").arg(m_sb->setting<Distance>(PS::Layer::kBeadWidth).to(mm)));
Expand Down
6 changes: 5 additions & 1 deletion src/threading/abs_slicing_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void AbstractSlicingThread::setGcodeOutput(QString output) {
m_base = QSharedPointer<OkumaWriter>(new OkumaWriter(GcodeMetaList::HaasMetricMeta, GSM->getGlobal()));
break;
case GcodeSyntax::kORNL:
m_base = QSharedPointer<ORNLWriter>(new ORNLWriter(GcodeMetaList::ORNLMetricMeta, GSM->getGlobal()));
m_base = QSharedPointer<ORNLWriter>(new ORNLWriter(GcodeMetaList::ORNLMeta, GSM->getGlobal()));
break;
case GcodeSyntax::kRomiFanuc:
m_base =
Expand Down Expand Up @@ -167,6 +167,10 @@ void AbstractSlicingThread::setGcodeOutput(QString output) {
m_base =
QSharedPointer<AdamantineWriter>(new AdamantineWriter(GcodeMetaList::AdamantineMeta, GSM->getGlobal()));
break;
case GcodeSyntax::kORNLMetric:
m_base =
QSharedPointer<ORNLWriter>(new ORNLWriter(GcodeMetaList::ORNLMetricMeta, GSM->getGlobal()));
break;
default:
m_base =
QSharedPointer<CincinnatiWriter>(new CincinnatiWriter(GcodeMetaList::CincinnatiMeta, GSM->getGlobal()));
Expand Down
177 changes: 177 additions & 0 deletions src/threading/gcode_amcm_saver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
#include "threading/gcode_amcm_saver.h"

#include "QDir"
#include "QFile"
#include "QRegularExpression"
#include "QStringBuilder"
#include "QStringList"
#include "QTextStream"
#include "managers/settings/settings_manager.h"
#include <qmath.h>

namespace ORNL {
GCodeAMCMSaver::GCodeAMCMSaver(QString tempLocation, QString path, QString filename, QString text, GcodeMeta meta)
: m_temp_location(tempLocation), m_path(path), m_filename(filename), m_text(text), m_selected_meta(meta) {
// NOP
}

void GCodeAMCMSaver::run() {
// First, get necessary parameters from settings to rotate all pathing
QChar comma(','), newline('\n'), space(' '), x('X'), y('Y'), z('Z'), f('F'), s('S'), zero('0');
qint16 layerNum = 0;
QStringList lines = m_text.split(newline);
QString G0("G0"), G1("G1"), M3("M3 "), M5("M5"), commaSpace(", ");
QString xval("0"), yval("0"), zval("0"), velocity, feedrate;
QString aval = QString::number(qRadiansToDegrees(GSM->getGlobal()->setting<Angle>(PRS::MachineSetup::kAxisA)()));
QString bval = QString::number(qRadiansToDegrees(GSM->getGlobal()->setting<Angle>(PRS::MachineSetup::kAxisB)()));
QString cval = QString::number(qRadiansToDegrees(GSM->getGlobal()->setting<Angle>(PRS::MachineSetup::kAxisC)()));
QString maxVelocity = QString::number(
GSM->getGlobal()->setting<Velocity>(PRS::MachineSpeed::kMaxXYSpeed).to(m_selected_meta.m_velocity_unit), 'f',
4);
zval = QString::number(
GSM->getGlobal()->setting<Distance>(PRS::Dimensions::kZMax).to(m_selected_meta.m_distance_unit), 'f', 4);
feedrate = QString::number(0);

QFile tempFile(m_temp_location % "temp");
if (tempFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
QTextStream out(&tempFile);
out << m_text;
tempFile.close();

QFile::rename(tempFile.fileName(), m_filename);
}

QFileInfo fi(m_filename);
QString filePath = fi.absolutePath() + QDir::separator() + fi.baseName() + "_output.src";

QFile file(filePath);
file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
QTextStream out(&file);

// File Header
out << "&ACCESS RVP" % newline;
out << "&REL 1" % newline;
out << "&PARAM TEMPLATE = C:\\KRC\\Roboter\\Template\\vorgabe" % newline;
out << "&PARAM EDITMASK = *" % newline;
out << "DEF Hexagon ( )" % newline % newline;

out << "; GLOBAL INTERRUPT DECL 3 WHEN $STOPMESS==TRUE DO IR_STOPM ( )" % newline;
out << "; INTERRUPT ON 3" % newline % newline;

out << ";FOLD Initialise and set default speed" % newline;
out << "BAS (#INITMOV,0)" % newline;
out << "BAS (#VEL_PTP,100)" % newline;
out << "BAS (#ACC_PTP,20)" % newline;
out << "$VEL.CP=0.2" % newline;
out << "BAS (#TOOL,0)" % newline;
out << "BAS (#BASE,0)" % newline;
out << ";ENDFOLD" % newline % newline;

out << ";;FOLD STARTPOS" % newline;
out << ";$BWDSTART = FALSE" % newline;
out << ";PDAT_ACT = PDEFAULT" % newline;
out << ";BAS(#PTP_DAT)" % newline;
out << ";FDAT_ACT = {TOOL_NO 0,BASE_NO 0,IPO_FRAME #BASE}" % newline;
out << ";BAS(#FRAMES)" % newline;
out << ";;ENDFOLD" % newline % newline;

out << "$ADVANCE = 5" % newline;

out << ";FOLD ---- Quickly skip BCO ----" % newline;
out << "; PTP $AXIS_ACT" % newline;
out << ";ENDFOLD" % newline % newline;

out << ";FOLD ---- GO HOME ----" % newline;
out << "; PTP {A1 0.000, A2 -90.000, A3 90.000, A4 0.000, A5 0.000, A6 0.000, E1 0, E2 0, E3 0, E4 0, E5 0, E6 0}" % newline;
out << ";ENDFOLD" % newline % newline;

out << "; Program generated by ORNL Slicer for KUKA KR 300 R2500 ultra" % newline;
out << "; Using nominal kinematics." % newline;
out << "$APO.CPTP = 1.000" % newline;
out << "$APO.CDIS = 1.000" % newline;
out << "$VEL.CP = 0.06000" % newline;
out << "; ---- Setting reference (Base) ----" % newline;
out << "; BASE_DATA[14] = {FRAME: X 1022.920,Y -1522.720,Z -588.000,A 135.000,B 0.000,C 0.000}" % newline;
out << "; $BASE = {FRAME: X 1022.920,Y -1522.720,Z -588.000,A 135.000,B 0.000,C 0.000}" % newline;
out << "$BASE = BASE_DATA[14]" % newline;
out << "; --------------------------" % newline;
out << "; ---- Setting tool (TCP) ----" % newline;
out << "; TOOL_DATA[5] = {FRAME: X 843.812,Y 0.000,Z 301.216,A 0.000,B 0.000,C -90.000}" % newline;
out << "; $TOOL = {FRAME: X 843.812,Y 0.000,Z 301.216,A 0.000,B 0.000,C -90.000}" % newline;
out << "$TOOL = TOOL_DATA[5]" % newline;
out << "; --------------------------" % newline;
out << "; Show Tool 5" % newline;
out << "PTP {A1 60.68200,A2 -65.00000,A3 124.01700,A4 18.60870,A5 -57.89280,A6 -10.14630,E1 0.00000} C_PTP" % newline;


QString line;

for (int i = 0; i < lines.size(); i++)
{
line = lines[i];
if (line.startsWith(G0)) {
velocity = QString::number(
GSM->getGlobal()->setting<Velocity>(PS::Travel::kSpeed).to(m_selected_meta.m_velocity_unit), 'f',
4);
QString temp = line.mid(0, line.indexOf(m_selected_meta.m_comment_starting_delimiter));
QVector<QString> params = temp.split(space);

if (params[0] == G0) {
for (int i = 1, end = params.size(); i < end; ++i) {
if (params[i].startsWith(x))
xval = params[i].mid(1);
else if (params[i].startsWith(y))
yval = params[i].mid(1);
else if (params[i].startsWith(z))
zval = params[i].mid(1);
}
}

if (velocity != feedrate) {
out << "$VEL.CP = " % velocity % newline;
feedrate = velocity;
}

out << "LIN {X " % xval % ", Y " % yval % ", Z " % zval % ", A " % aval % ", B " % bval % ", C " %
cval % ", E1 0.000} C_DIS" % newline;
}
else if (line.startsWith(G1)) {
QString temp = line.mid(0, line.indexOf(m_selected_meta.m_comment_starting_delimiter));
QVector<QString> params = temp.split(space);

if (params[0] == G1) {
for (int i = 1, end = params.size(); i < end; ++i) {
if (params[i].startsWith(x))
xval = params[i].mid(1);
else if (params[i].startsWith(y))
yval = params[i].mid(1);
else if (params[i].startsWith(z))
zval = params[i].mid(1);
else if (params[i].startsWith(f))
velocity = params[i].mid(1);
}
}
if (velocity != feedrate) {
out << "$VEL.CP = " % velocity % newline;
feedrate = velocity;
}

out << "LIN {X " % xval % ", Y " % yval % ", Z " % zval % ", A " % aval % ", B " % bval % ", C " %
cval % ", E1 0.000} C_DIS" % newline;
if (line.contains("S0")){
out << "; Stop Extrusion" % newline;
}
}
else if (line.startsWith(M3)) {
out << "; Start Extrusion" % newline;
}
else if (line.startsWith(M5)) {
out << "; Stop Extrusion" % newline;
}
}

out << newline % "END";
file.close();
}

} // namespace ORNL
6 changes: 5 additions & 1 deletion src/threading/gcode_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,14 @@ void GCodeLoader::setParser(QStringList& originalLines, QStringList& lines) {
m_parser.reset(new CommonParser(GcodeMetaList::HaasMetricMeta, m_adjust_file, originalLines, lines));
m_selected_meta = GcodeMetaList::ORNLMeta;
}
else if (m_lines[m_current_line].contains(toString(GcodeSyntax::kORNL).toUpper())) {
else if (m_lines[m_current_line].contains(toString(GcodeSyntax::kORNLMetric).toUpper())) {
m_parser.reset(new CommonParser(GcodeMetaList::ORNLMetricMeta, m_adjust_file, originalLines, lines));
m_selected_meta = GcodeMetaList::ORNLMetricMeta;
}
else if (m_lines[m_current_line].contains(toString(GcodeSyntax::kORNL).toUpper())) {
m_parser.reset(new CommonParser(GcodeMetaList::ORNLMeta, m_adjust_file, originalLines, lines));
m_selected_meta = GcodeMetaList::ORNLMeta;
}
else if (m_lines[m_current_line].contains(toString(GcodeSyntax::kRomiFanuc).toUpper())) {
m_parser.reset(new CommonParser(GcodeMetaList::RomiFanucMeta, m_adjust_file, originalLines, lines));
m_selected_meta = GcodeMetaList::RomiFanucMeta;
Expand Down
Loading