2014-02-18 17:52:50 -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-18 17:52:50 -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-18 17:52:50 -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-18 17:52:50 -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-18 17:52:50 -08:00
|
|
|
|
either expressed or implied, of the FreeBSD Project.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2016-02-12 09:30:24 -08:00
|
|
|
|
using MatterHackers.Agg;
|
2014-06-11 14:52:58 -07:00
|
|
|
|
using MatterHackers.MatterControl.PrinterCommunication;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
using System;
|
2016-02-12 09:30:24 -08:00
|
|
|
|
using System.IO;
|
2014-02-18 17:52:50 -08:00
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl.EeProm
|
|
|
|
|
|
{
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public class EePromRepetierParameter : EventArgs
|
|
|
|
|
|
{
|
2016-01-14 13:07:00 -08:00
|
|
|
|
public string description = "";
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public int type;
|
|
|
|
|
|
public int position;
|
2016-02-12 09:30:24 -08:00
|
|
|
|
public string value { get; private set; } = "";
|
2015-04-08 15:20:10 -07:00
|
|
|
|
private bool changed = false;
|
|
|
|
|
|
|
|
|
|
|
|
public EePromRepetierParameter(string line)
|
|
|
|
|
|
{
|
|
|
|
|
|
update(line);
|
|
|
|
|
|
}
|
2014-02-18 17:52:50 -08:00
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public void update(string line)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (line.Length > 4)
|
|
|
|
|
|
{
|
|
|
|
|
|
string[] lines = line.Substring(4).Split(' ');
|
|
|
|
|
|
if (lines.Length > 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
int.TryParse(lines[0], out type);
|
|
|
|
|
|
int.TryParse(lines[1], out position);
|
2016-02-12 09:30:24 -08:00
|
|
|
|
value = lines[2];
|
2016-01-14 13:07:00 -08:00
|
|
|
|
int startPos = 7 + lines[0].Length + lines[1].Length + lines[2].Length;
|
|
|
|
|
|
if (line.Length > startPos)
|
|
|
|
|
|
{
|
|
|
|
|
|
description = line.Substring(startPos);
|
|
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
changed = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2014-02-18 17:52:50 -08:00
|
|
|
|
|
2017-09-03 11:48:08 -07:00
|
|
|
|
public void Save(PrinterConnection printerConnection)
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
|
|
|
|
|
if (!changed)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2014-02-18 17:52:50 -08:00
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
string cmd = "M206 T" + type + " P" + position + " ";
|
2016-02-12 09:30:24 -08:00
|
|
|
|
if (type == 3) cmd += "X" + value;
|
|
|
|
|
|
else cmd += "S" + value;
|
2018-01-04 17:30:48 -08:00
|
|
|
|
printerConnection.QueueLine(cmd);
|
2015-04-08 15:20:10 -07:00
|
|
|
|
changed = false;
|
|
|
|
|
|
}
|
2014-02-18 17:52:50 -08:00
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public string Description
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return description; }
|
|
|
|
|
|
set { description = value; }
|
|
|
|
|
|
}
|
2014-02-18 17:52:50 -08:00
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public string Value
|
|
|
|
|
|
{
|
2016-02-12 09:30:24 -08:00
|
|
|
|
get { return value; }
|
2015-04-08 15:20:10 -07:00
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
value = value.Replace(',', '.').Trim();
|
2016-02-12 09:30:24 -08:00
|
|
|
|
if (this.value.Equals(value)) return;
|
|
|
|
|
|
this.value = value;
|
|
|
|
|
|
MarkChanged();
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-02-12 09:30:24 -08:00
|
|
|
|
|
|
|
|
|
|
internal void MarkChanged()
|
|
|
|
|
|
{
|
|
|
|
|
|
changed = true;
|
|
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|