2014-02-22 14:52:53 -08:00
|
|
|
|
/*
|
|
|
|
|
|
Copyright (c) 2014, Lars Brubaker
|
|
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
2015-04-08 15:20:10 -07:00
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
2014-02-22 14:52:53 -08:00
|
|
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
2015-04-08 15:20:10 -07:00
|
|
|
|
list of conditions and the following disclaimer.
|
2014-02-22 14:52:53 -08:00
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
2015-04-08 15:20:10 -07:00
|
|
|
|
and/or other materials provided with the distribution.
|
2014-02-22 14:52:53 -08:00
|
|
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
|
|
|
The views and conclusions contained in the software and documentation are those
|
2015-04-08 15:20:10 -07:00
|
|
|
|
of the authors and should not be interpreted as representing official policies,
|
2014-02-22 14:52:53 -08:00
|
|
|
|
either expressed or implied, of the FreeBSD Project.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
using System;
|
2016-02-12 10:26:40 -08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Reflection;
|
2017-08-20 15:52:43 -07:00
|
|
|
|
using MatterHackers.Agg;
|
|
|
|
|
|
using MatterHackers.Agg.UI;
|
|
|
|
|
|
using MatterHackers.MatterControl.PrinterCommunication;
|
2014-02-22 14:52:53 -08:00
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl.EeProm
|
|
|
|
|
|
{
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public class EePromMarlinSettings : EventArgs
|
|
|
|
|
|
{
|
|
|
|
|
|
public event EventHandler eventAdded = null;
|
|
|
|
|
|
|
|
|
|
|
|
public string sx = "0";
|
|
|
|
|
|
public string sy = "0";
|
|
|
|
|
|
public string sz = "0";
|
|
|
|
|
|
public string se = "0";
|
|
|
|
|
|
public string fx = "0";
|
|
|
|
|
|
public string fy = "0";
|
|
|
|
|
|
public string fz = "0";
|
|
|
|
|
|
public string fe = "0";
|
|
|
|
|
|
public string ax = "0";
|
|
|
|
|
|
public string ay = "0";
|
|
|
|
|
|
public string az = "0";
|
|
|
|
|
|
public string ae = "0";
|
2018-06-11 18:10:16 -07:00
|
|
|
|
public string acc_printing_moves_legacy = "0";
|
|
|
|
|
|
public string acc_printing_moves = "0";
|
|
|
|
|
|
public string acc_retraction = "0";
|
|
|
|
|
|
public string acc_travel_moves = "0";
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public string avs = "0";
|
|
|
|
|
|
public string avt = "0";
|
|
|
|
|
|
public string avb = "0";
|
|
|
|
|
|
public string avx = "0";
|
|
|
|
|
|
public string avz = "0";
|
2021-08-23 11:44:13 -07:00
|
|
|
|
public string avj = "0";
|
2018-06-11 18:10:16 -07:00
|
|
|
|
public string ave = "0";
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public string ppid = "0";
|
|
|
|
|
|
public string ipid = "0";
|
|
|
|
|
|
public string dpid = "0";
|
2018-06-11 18:10:16 -07:00
|
|
|
|
public string bed_ppid = "0";
|
|
|
|
|
|
public string bed_ipid = "0";
|
|
|
|
|
|
public string bed_dpid = "0";
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public string hox = "0";
|
|
|
|
|
|
public string hoy = "0";
|
|
|
|
|
|
public string hoz = "0";
|
|
|
|
|
|
public bool hasPID = false;
|
2018-06-11 18:10:16 -07:00
|
|
|
|
public bool bed_HasPID = false;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
|
|
|
|
|
private bool changed = false;
|
2017-09-01 21:23:08 -07:00
|
|
|
|
private PrinterConnection printerConnection;
|
|
|
|
|
|
|
|
|
|
|
|
public EePromMarlinSettings(PrinterConnection printerConnection)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.printerConnection = printerConnection;
|
|
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
|
|
|
|
|
public bool update(string line)
|
|
|
|
|
|
{
|
2021-08-23 11:44:13 -07:00
|
|
|
|
bool foundAnySetting = false;
|
|
|
|
|
|
string[] splitOnSpace = line.Split(' ');
|
2015-04-08 15:20:10 -07:00
|
|
|
|
string mode = "";
|
2015-09-01 16:03:25 -07:00
|
|
|
|
bool foundFirstM92E = false;
|
2021-08-23 11:44:13 -07:00
|
|
|
|
foreach (string token in splitOnSpace)
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2016-09-28 17:16:21 -07:00
|
|
|
|
if(string.IsNullOrWhiteSpace(token))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2021-08-23 11:44:13 -07:00
|
|
|
|
if ((token == "M92") || (mode == "M92"))
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2021-08-23 11:44:13 -07:00
|
|
|
|
foundAnySetting = true;
|
2016-02-12 10:26:40 -08:00
|
|
|
|
if (mode != "M92")
|
2015-09-01 16:03:25 -07:00
|
|
|
|
{
|
|
|
|
|
|
foundFirstM92E = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
mode = "M92";
|
|
|
|
|
|
if (token[0] == 'X')
|
|
|
|
|
|
{
|
|
|
|
|
|
sx = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'Y')
|
|
|
|
|
|
{
|
|
|
|
|
|
sy = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'Z')
|
|
|
|
|
|
{
|
|
|
|
|
|
sz = token.Substring(1);
|
|
|
|
|
|
}
|
2015-09-01 16:03:25 -07:00
|
|
|
|
if (token[0] == 'E' && !foundFirstM92E)
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2015-09-01 16:03:25 -07:00
|
|
|
|
foundFirstM92E = true;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
se = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-09-28 17:16:21 -07:00
|
|
|
|
if (((token == "M203") || (mode == "M203")))
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2021-08-23 11:44:13 -07:00
|
|
|
|
foundAnySetting = true;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
mode = "M203";
|
|
|
|
|
|
if (token[0] == 'X')
|
|
|
|
|
|
{
|
|
|
|
|
|
fx = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'Y')
|
|
|
|
|
|
{
|
|
|
|
|
|
fy = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'Z')
|
|
|
|
|
|
{
|
|
|
|
|
|
fz = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'E')
|
|
|
|
|
|
{
|
|
|
|
|
|
fe = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-09-28 17:16:21 -07:00
|
|
|
|
if (((token == "M201") || (mode == "M201")))
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2021-08-23 11:44:13 -07:00
|
|
|
|
foundAnySetting = true;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
mode = "M201";
|
|
|
|
|
|
if (token[0] == 'X')
|
|
|
|
|
|
{
|
|
|
|
|
|
ax = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'Y')
|
|
|
|
|
|
{
|
|
|
|
|
|
ay = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'Z')
|
|
|
|
|
|
{
|
|
|
|
|
|
az = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'E')
|
|
|
|
|
|
{
|
|
|
|
|
|
ae = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-09-28 17:16:21 -07:00
|
|
|
|
if (((token == "M204") || (mode == "M204")))
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2021-08-23 11:44:13 -07:00
|
|
|
|
foundAnySetting = true;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
mode = "M204";
|
2018-06-11 18:10:16 -07:00
|
|
|
|
if (token[0] == 'S') // legacy printing
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2018-06-11 18:10:16 -07:00
|
|
|
|
acc_printing_moves_legacy = token.Substring(1);
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
2018-06-11 18:10:16 -07:00
|
|
|
|
if (token[0] == 'P') // printing
|
|
|
|
|
|
{
|
|
|
|
|
|
acc_printing_moves = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'T') // travel
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2018-06-11 18:10:16 -07:00
|
|
|
|
acc_travel_moves = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'R') // retraction
|
|
|
|
|
|
{
|
|
|
|
|
|
acc_retraction = token.Substring(1);
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-09-28 17:16:21 -07:00
|
|
|
|
if (((token == "M205") || (mode == "M205")))
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2021-08-23 11:44:13 -07:00
|
|
|
|
foundAnySetting = true;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
mode = "M205";
|
|
|
|
|
|
if (token[0] == 'S')
|
|
|
|
|
|
{
|
|
|
|
|
|
avs = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'T')
|
|
|
|
|
|
{
|
|
|
|
|
|
avt = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'B')
|
|
|
|
|
|
{
|
|
|
|
|
|
avb = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'X')
|
|
|
|
|
|
{
|
|
|
|
|
|
avx = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'Z')
|
|
|
|
|
|
{
|
|
|
|
|
|
avz = token.Substring(1);
|
|
|
|
|
|
}
|
2021-08-23 11:44:13 -07:00
|
|
|
|
if (token[0] == 'J')
|
|
|
|
|
|
{
|
|
|
|
|
|
avj = token.Substring(1);
|
|
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
2016-09-28 17:16:21 -07:00
|
|
|
|
if (((token == "M301") || (mode == "M301")))
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2021-08-23 11:44:13 -07:00
|
|
|
|
foundAnySetting = true;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
mode = "M301";
|
|
|
|
|
|
hasPID = true;
|
|
|
|
|
|
if (token[0] == 'P')
|
|
|
|
|
|
{
|
|
|
|
|
|
ppid = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'I')
|
|
|
|
|
|
{
|
|
|
|
|
|
ipid = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'D')
|
|
|
|
|
|
{
|
|
|
|
|
|
dpid = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-06-11 18:10:16 -07:00
|
|
|
|
if (((token == "M304") || (mode == "M304")))
|
|
|
|
|
|
{
|
2021-08-23 11:44:13 -07:00
|
|
|
|
foundAnySetting = true;
|
2018-06-11 18:10:16 -07:00
|
|
|
|
mode = "M304";
|
|
|
|
|
|
bed_HasPID = true;
|
|
|
|
|
|
if (token[0] == 'P')
|
|
|
|
|
|
{
|
|
|
|
|
|
bed_ppid = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'I')
|
|
|
|
|
|
{
|
|
|
|
|
|
bed_ipid = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'D')
|
|
|
|
|
|
{
|
|
|
|
|
|
bed_dpid = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-09-28 17:16:21 -07:00
|
|
|
|
if (((token == "M206") || (mode == "M206")))
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2021-08-23 11:44:13 -07:00
|
|
|
|
foundAnySetting = true;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
mode = "M206";
|
|
|
|
|
|
hasPID = true;
|
|
|
|
|
|
if (token[0] == 'X')
|
|
|
|
|
|
{
|
|
|
|
|
|
hox = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'Y')
|
|
|
|
|
|
{
|
|
|
|
|
|
hoy = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (token[0] == 'Z')
|
|
|
|
|
|
{
|
|
|
|
|
|
hoz = token.Substring(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
changed = false;
|
|
|
|
|
|
|
2021-08-23 11:44:13 -07:00
|
|
|
|
return foundAnySetting;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Save()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!changed) return; // nothing changed
|
|
|
|
|
|
string cmdsteps = "M92 X" + sx + " Y" + sy + " Z" + sz + " E" + se;
|
|
|
|
|
|
string cmdfeed = "M203 X" + fx + " Y" + fy + " Z" + fz + " E" + fe;
|
|
|
|
|
|
string cmdmacc = "M201 X" + ax + " Y" + ay + " Z" + az + " E" + ae;
|
2018-06-11 18:10:16 -07:00
|
|
|
|
|
|
|
|
|
|
string cmdacc = "M204";
|
|
|
|
|
|
if (acc_printing_moves_legacy != "0") cmdacc += $" S{acc_printing_moves_legacy}";
|
|
|
|
|
|
if (acc_printing_moves != "0") cmdacc += $" P{acc_printing_moves}";
|
|
|
|
|
|
if (acc_travel_moves != "0") cmdacc += $" T{acc_travel_moves}";
|
|
|
|
|
|
if (acc_retraction != "0") cmdacc += $" R{acc_retraction}";
|
|
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
string cmdav = "M205 S" + avs + " T" + avt + " B" + avb + " X" + avx + " Z" + avz;
|
2021-08-23 11:44:13 -07:00
|
|
|
|
if (avj != "0")
|
|
|
|
|
|
{
|
|
|
|
|
|
cmdav += " J" + avj;
|
|
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
string cmdho = "M206 X" + hox + " Y" + hoy + " Z" + hoz;
|
|
|
|
|
|
string cmdpid = "M301 P" + ppid + " I" + ipid + " D" + dpid;
|
2021-08-23 11:44:13 -07:00
|
|
|
|
// string cmdbed_pid = "M304 P" + bed_ppid + " I" + bed_ipid + " D" + bed_dpid;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
2018-01-04 17:30:48 -08:00
|
|
|
|
printerConnection.QueueLine(cmdsteps);
|
|
|
|
|
|
printerConnection.QueueLine(cmdfeed);
|
|
|
|
|
|
printerConnection.QueueLine(cmdmacc);
|
|
|
|
|
|
printerConnection.QueueLine(cmdacc);
|
|
|
|
|
|
printerConnection.QueueLine(cmdav);
|
|
|
|
|
|
printerConnection.QueueLine(cmdho);
|
2015-04-08 15:20:10 -07:00
|
|
|
|
if (hasPID)
|
|
|
|
|
|
{
|
2018-01-04 17:30:48 -08:00
|
|
|
|
printerConnection.QueueLine(cmdpid);
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
changed = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string SX
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return sx; }
|
|
|
|
|
|
set { if (sx.Equals(value)) return; sx = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string SY
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return sy; }
|
|
|
|
|
|
set { if (sy.Equals(value)) return; sy = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string SZ
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return sz; }
|
|
|
|
|
|
set { if (sz.Equals(value)) return; sz = value; changed = true; }
|
|
|
|
|
|
}
|
2015-09-01 16:03:25 -07:00
|
|
|
|
//This is it
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public string SE
|
|
|
|
|
|
{
|
2015-09-01 16:03:25 -07:00
|
|
|
|
|
|
|
|
|
|
//String l
|
2015-04-08 15:20:10 -07:00
|
|
|
|
get { return se; }
|
2016-09-28 13:46:26 -07:00
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (se.Equals(value))
|
2016-02-12 10:26:40 -08:00
|
|
|
|
return;
|
|
|
|
|
|
se = value;
|
|
|
|
|
|
changed = true;
|
2015-09-01 16:03:25 -07:00
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string FX
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return fx; }
|
|
|
|
|
|
set { if (fx.Equals(value)) return; fx = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string FY
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return fy; }
|
|
|
|
|
|
set { if (fy.Equals(value)) return; fy = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string FZ
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return fz; }
|
|
|
|
|
|
set { if (fz.Equals(value)) return; fz = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string FE
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return fe; }
|
|
|
|
|
|
set { if (fe.Equals(value)) return; fe = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string AX
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return ax; }
|
|
|
|
|
|
set { if (ax.Equals(value)) return; ax = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-02-12 10:26:40 -08:00
|
|
|
|
internal void Import(string fileName)
|
|
|
|
|
|
{
|
|
|
|
|
|
// read all the lines
|
|
|
|
|
|
string[] allLines = File.ReadAllLines(fileName);
|
|
|
|
|
|
// find all the descriptions we can
|
|
|
|
|
|
foreach (string line in allLines)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (line.Contains("|"))
|
|
|
|
|
|
{
|
|
|
|
|
|
string[] descriptionValue = line.Split('|');
|
|
|
|
|
|
if (descriptionValue.Length == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetSetting(descriptionValue[0], descriptionValue[1]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
changed = true;
|
2016-09-28 13:46:26 -07:00
|
|
|
|
}
|
2016-02-12 10:26:40 -08:00
|
|
|
|
|
|
|
|
|
|
void SetSetting(string keyToSet, string valueToSetTo)
|
|
|
|
|
|
{
|
|
|
|
|
|
valueToSetTo = valueToSetTo.Replace("\"", "").Trim();
|
|
|
|
|
|
|
|
|
|
|
|
FieldInfo[] fields;
|
|
|
|
|
|
fields = this.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
|
|
|
|
|
|
foreach (FieldInfo field in fields)
|
|
|
|
|
|
{
|
2021-08-23 11:44:13 -07:00
|
|
|
|
var possibleNames = new List<string>
|
|
|
|
|
|
{
|
|
|
|
|
|
field.Name
|
|
|
|
|
|
};
|
2016-02-12 10:26:40 -08:00
|
|
|
|
|
|
|
|
|
|
if (possibleNames.Contains(keyToSet))
|
|
|
|
|
|
{
|
|
|
|
|
|
string name = field.Name;
|
|
|
|
|
|
object value = field.GetValue(this);
|
|
|
|
|
|
switch (field.FieldType.Name)
|
|
|
|
|
|
{
|
|
|
|
|
|
case "Int32":
|
|
|
|
|
|
field.SetValue(this, (int)double.Parse(valueToSetTo));
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case "Double":
|
|
|
|
|
|
field.SetValue(this, double.Parse(valueToSetTo));
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case "Boolean":
|
|
|
|
|
|
field.SetValue(this, bool.Parse(valueToSetTo));
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case "String":
|
|
|
|
|
|
field.SetValue(this, valueToSetTo.Replace("\\n", "\n"));
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
throw new NotImplementedException("unknown type");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public string AY
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return ay; }
|
|
|
|
|
|
set { if (ay.Equals(value)) return; ay = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string AZ
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return az; }
|
|
|
|
|
|
set { if (az.Equals(value)) return; az = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string AE
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return ae; }
|
|
|
|
|
|
set { if (ae.Equals(value)) return; ae = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-11 18:10:16 -07:00
|
|
|
|
public string AccPrintingMoves
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if(acc_printing_moves_legacy != "0")
|
|
|
|
|
|
{
|
|
|
|
|
|
return acc_printing_moves_legacy;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return acc_printing_moves;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
// prefer legacy
|
|
|
|
|
|
if (acc_printing_moves_legacy != "0"
|
|
|
|
|
|
&& acc_printing_moves_legacy != value)
|
|
|
|
|
|
{
|
|
|
|
|
|
acc_printing_moves_legacy = value;
|
|
|
|
|
|
changed = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (acc_printing_moves != value)
|
|
|
|
|
|
{
|
|
|
|
|
|
acc_printing_moves = value;
|
|
|
|
|
|
changed = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string AccTravelMoves
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2018-06-11 18:10:16 -07:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return acc_travel_moves;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (acc_travel_moves != value)
|
|
|
|
|
|
{
|
|
|
|
|
|
acc_travel_moves = value;
|
|
|
|
|
|
changed = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-11 18:10:16 -07:00
|
|
|
|
public string AccRetraction
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2018-06-11 18:10:16 -07:00
|
|
|
|
get
|
|
|
|
|
|
{
|
2018-06-15 11:05:33 -07:00
|
|
|
|
return acc_retraction;
|
2018-06-11 18:10:16 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (acc_retraction != value)
|
|
|
|
|
|
{
|
|
|
|
|
|
acc_retraction = value;
|
|
|
|
|
|
changed = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string AVS
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return avs; }
|
|
|
|
|
|
set { if (avs.Equals(value)) return; avs = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-02-12 10:26:40 -08:00
|
|
|
|
internal void Export(string fileName)
|
|
|
|
|
|
{
|
|
|
|
|
|
using (var sw = new StreamWriter(fileName))
|
|
|
|
|
|
{
|
|
|
|
|
|
FieldInfo[] fields;
|
|
|
|
|
|
fields = this.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
|
|
|
|
|
|
foreach (FieldInfo field in fields)
|
|
|
|
|
|
{
|
|
|
|
|
|
string name = field.Name;
|
|
|
|
|
|
object value = field.GetValue(this);
|
|
|
|
|
|
switch (field.FieldType.Name)
|
|
|
|
|
|
{
|
|
|
|
|
|
case "Int32":
|
|
|
|
|
|
case "Double":
|
|
|
|
|
|
case "Boolean":
|
|
|
|
|
|
case "FMatrix3x3":
|
|
|
|
|
|
case "String":
|
|
|
|
|
|
// all these setting just output correctly with ToString() so we don't have to do anything special.
|
|
|
|
|
|
sw.WriteLine("{0}|{1}".FormatWith(name, value));
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public string AVT
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return avt; }
|
|
|
|
|
|
set { if (avt.Equals(value)) return; avt = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string AVB
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return avb; }
|
|
|
|
|
|
set { if (avb.Equals(value)) return; avb = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string AVX
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return avx; }
|
|
|
|
|
|
set { if (avx.Equals(value)) return; avx = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string AVZ
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return avz; }
|
|
|
|
|
|
set { if (avz.Equals(value)) return; avz = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-08-23 11:44:13 -07:00
|
|
|
|
public string AVJ
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return avj; }
|
|
|
|
|
|
set { if (avj.Equals(value)) return; avj = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-11 18:10:16 -07:00
|
|
|
|
public string AVE
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return ave; }
|
|
|
|
|
|
set { if (ave.Equals(value)) return; ave = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public string PPID
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return ppid; }
|
|
|
|
|
|
set { if (ppid.Equals(value)) return; ppid = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string IPID
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return ipid; }
|
|
|
|
|
|
set { if (ipid.Equals(value)) return; ipid = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string DPID
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return dpid; }
|
|
|
|
|
|
set { if (dpid.Equals(value)) return; dpid = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-11 18:10:16 -07:00
|
|
|
|
public string BED_PPID
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return bed_ppid; }
|
|
|
|
|
|
set { if (bed_ppid.Equals(value)) return; bed_ppid = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string BED_IPID
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return bed_ipid; }
|
|
|
|
|
|
set { if (bed_ipid.Equals(value)) return; bed_ipid = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string BED_DPID
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return bed_dpid; }
|
|
|
|
|
|
set { if (bed_dpid.Equals(value)) return; bed_dpid = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public string HOX
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return hox; }
|
|
|
|
|
|
set { if (hox.Equals(value)) return; hox = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string HOY
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return hoy; }
|
|
|
|
|
|
set { if (hoy.Equals(value)) return; hoy = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string HOZ
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return hoz; }
|
|
|
|
|
|
set { if (hoz.Equals(value)) return; hoz = value; changed = true; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SaveToEeProm()
|
|
|
|
|
|
{
|
2018-01-04 17:30:48 -08:00
|
|
|
|
printerConnection.QueueLine("M500");
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// this does not save them to eeprom
|
|
|
|
|
|
public void SetPrinterToFactorySettings()
|
|
|
|
|
|
{
|
|
|
|
|
|
hasPID = false;
|
2018-01-04 17:30:48 -08:00
|
|
|
|
printerConnection.QueueLine("M502");
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-11-09 08:57:30 -08:00
|
|
|
|
public void Add(object sender, string line)
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2018-11-09 08:57:30 -08:00
|
|
|
|
if (line == null)
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-11-09 08:57:30 -08:00
|
|
|
|
if (update(line))
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
|
|
|
|
|
if (eventAdded != null)
|
|
|
|
|
|
{
|
2017-12-23 06:56:05 -08:00
|
|
|
|
UiThread.RunOnIdle(() =>
|
|
|
|
|
|
{
|
2018-11-09 08:57:30 -08:00
|
|
|
|
if (line != null)
|
2017-12-23 06:56:05 -08:00
|
|
|
|
{
|
2018-11-09 08:57:30 -08:00
|
|
|
|
eventAdded(this, new StringEventArgs(line));
|
2017-12-23 06:56:05 -08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
hasPID = false;
|
2018-01-04 17:30:48 -08:00
|
|
|
|
printerConnection.QueueLine("M503");
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|