Exemplo n.º 1
0
        public void RemoveTool(int toolnum)
        {
            CncTool tool = GetTool(toolnum);

            if (tool != null)
            {
                tools.Remove(tool);
            }
        }
Exemplo n.º 2
0
        public void AddUpdateTool(CncTool updatetool)
        {
            CncTool tool = GetTool(updatetool.toolNum);

            if (tool == null)
            {
                tool = new CncTool(updatetool.toolNum);
                tools.Add(tool);
                tools.Sort();
            }
            tool.CopyFrom(updatetool);
        }
Exemplo n.º 3
0
        public void CopyFrom(CncTool other)
        {
            toolNum   = other.toolNum;
            pocketNum = other.pocketNum;
            int naxis = other.offsets.Length > offsets.Length ? offsets.Length : other.offsets.Length;

            for (int i = 0; i < naxis; i++)
            {
                offsets[i] = other.offsets[i];
            }
            diameter    = other.diameter;
            description = other.description;
        }
Exemplo n.º 4
0
        void SetTLO(int toolno)
        {
            CncTool tool = Global.toolTable.GetTool(toolno);

            if (tool != null)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("G43.1");
                for (int i = 0; i < tool.offsets.Length; i++)
                {
                    sb.Append(Utils.GetAxisLetter(i));
                    sb.Append(Utils.F3(tool.offsets[i]));
                }
                PostLine(sb.ToString(), true);
            }
            else
            {
                PostLine("G43.1X0Y0Z0A0B0", true); // assume default tool
            }
        }
Exemplo n.º 5
0
        void ProbeToolEnd()
        {
            machineState = MachineState.Idle;
            CncTool tool = Global.toolTable.GetTool(probeToolNum);

            if (tool != null)
            {
                tool.offsets[probeToolAxis] = grblStatus.axisPos[probeToolAxis] - probeToolOffset;
                if (Global.ginterp.currentTool != 0)
                {
                    SetTLO(Global.ginterp.currentTool); // restore current TLO
                }
            }
            PostLine(string.Format("G0 {0}{1}", Utils.GetAxisLetter(probeToolAxis), Utils.F3(-5 * probeDir)), true);
            if (lastG90State)
            {
                PostLine("G90", true);
            }
            SendCurrentGcodeLine();
        }
Exemplo n.º 6
0
        public void ToolTouchOff(int axis, int toolno, float offset)
        {
            string axisLetter = Utils.GetAxisLetter(axis);

            if (axisLetter == null)
            {
                return;
            }
            CncTool tool = Global.toolTable.GetTool(toolno);

            if (tool != null)
            {
                tool.offsets[axis] = grblStatus.axisPos[axis] - offset;
                if (Global.ginterp.currentTool == toolno)
                {
                    SetTLO(toolno);
                    SendCurrentGcodeLine();
                }
            }
        }
Exemplo n.º 7
0
        public List <int> CompareWith(CncTool other)
        {
            List <int> res = new List <int>();

            if (toolNum != other.toolNum)
            {
                res.Add(ToolNumID);
            }
            if (pocketNum != other.pocketNum)
            {
                res.Add(PocketNumID);
            }
            if (offsets.Length != other.offsets.Length)
            {
                res.Add(NumAxesID);
            }
            int numaxes = offsets.Length;

            if (numaxes > other.offsets.Length)
            {
                numaxes = other.offsets.Length;
            }
            for (int i = 0; i < numaxes; i++)
            {
                if (offsets[i] != other.offsets[i])
                {
                    res.Add(OffsetsID + i);
                }
            }
            if (diameter != other.diameter)
            {
                res.Add(DiameterID);
            }
            if (description != other.description)
            {
                res.Add(DescriptionID);
            }
            return(res);
        }
Exemplo n.º 8
0
        public string Load(string filepath)
        {
            try
            {
                StreamReader sr   = new StreamReader(filepath);
                string       line = sr.ReadLine().Trim();
                if (!line.StartsWith("# GrbleCNC Tool Table"))
                {
                    return("Not a GrblCNC Tool Table file");
                }
                tools.Clear();
                while (!sr.EndOfStream)
                {
                    line = sr.ReadLine().Trim();
                    if (line.Length == 0 || line[0] == '#')
                    {
                        continue;
                    }
                    CncTool tool = new CncTool(0);
                    if (tool.TryParse(line).Count == 0)
                    {
                        tool.Parse(line);
                        tools.Add(tool);
                    }
                }
                sr.Close();
                if (tools.Count > 0)
                {
                    tools.Sort();
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            return("OK");
        }