Ejemplo n.º 1
0
        // Numbered parameters accessors

        private double probe_coord(int id)
        {
            id = id % 10 - 1;

            GrblWorkParameters.Get();

            return(id < GrblInfo.NumAxes ? GrblWorkParameters.ProbePosition.Values[id] : 0d);
        }
Ejemplo n.º 2
0
        private double probe_result(int id)
        {
            GrblWorkParameters.Get();

            return(GrblWorkParameters.ProbeSuccesful ? 1d : 0d);
        }
Ejemplo n.º 3
0
        public void Reset()
        {
            // Sync with controller
            if (GrblInfo.IsGrblHAL)
            {
                GrblParserState.Get();
                GrblWorkParameters.Get();
            }
            else
            {
                GrblParserState.Get(true);
            }

            coordinateSystems.Clear();
            foreach (CoordinateSystem c in GrblWorkParameters.CoordinateSystems)
            {
                coordinateSystems.Add(c);
            }

            toolTable.Clear();
            if (GrblInfo.NumTools > 0)
            {
                foreach (Tool t in GrblWorkParameters.Tools)
                {
                    toolTable.Add(t);
                }
            }

            coordinateSystem = coordinateSystems.Where(x => x.Code == GrblParserState.WorkOffset).FirstOrDefault();
            g28 = coordinateSystems.Where(x => x.Code == "G28").FirstOrDefault();
            g30 = coordinateSystems.Where(x => x.Code == "G30").FirstOrDefault();
            g92 = coordinateSystems.Where(x => x.Code == "G92").FirstOrDefault();

            isRelative       = GrblParserState.DistanceMode == DistanceMode.Incremental;
            IsImperial       = !GrblParserState.IsMetric;
            CoolantState     = GrblParserState.CoolantState;
            SpindleState     = GrblParserState.SpindleState;
            LatheMode        = GrblParserState.LatheMode;
            DistanceMode     = GrblParserState.DistanceMode;
            ToolLengthOffset = GrblParserState.ToolLengthOffset;
            FeedRateMode     = GrblParserState.FeedRateMode;
            MotionMode       = GrblParserState.MotionMode;
            IJKMode          = GrblParserState.IJKMode;
            IsScaled         = GrblParserState.IsActive("G51") != null;
            string val = GrblParserState.IsActive("F");

            Feedrate       = val == null ? 0d : double.Parse(val, CultureInfo.InvariantCulture);
            val            = GrblParserState.IsActive("S");
            _rpm           = val == null ? 0d : double.Parse(val, CultureInfo.InvariantCulture);
            _tool          = GrblParserState.Tool == GrblConstants.NO_TOOL ? 0 : int.Parse(GrblParserState.Tool);
            SelectedTool   = null;
            RetractOldZ    = GrblParserState.IsActive("G99") == null;
            SpindleRpmMode = GrblParserState.IsActive("G96") == null;
            G92Active      = GrblParserState.IsActive("G92") != null;

            Line = 0;

            foreach (int i in AxisFlags.All.ToIndices())
            {
                offsets[i]      = coordinateSystem == null ? 0d :  coordinateSystem.Values[i];
                origin[i]       = g92 == null ? 0d : g92.Values[i];
                machinePos[i]   = 0d;
                scaleFactors[i] = 1d;
                toolOffsets[i]  = SelectedTool == null ? 0d : SelectedTool.Values[i];
            }

            switch (GrblParserState.Plane)
            {
            case GCode.Plane.XY:
                Plane = new GCPlane(Commands.G17, 0);
                break;

            case GCode.Plane.XZ:
                Plane = new GCPlane(Commands.G18, 0);
                break;

            case GCode.Plane.YZ:
                Plane = new GCPlane(Commands.G19, 0);
                break;
            }
        }