public static async Task <bool> SendProbeCommandAsync(this ISerial serial, string axisName, decimal probeSize, decimal probeDist, decimal probeDistUp, decimal probeFeed)
        {
            var result = await serial.SendCommandAsync($"g91 g31 {axisName}-{probeDist.ToString(CultureInfo.InvariantCulture)} F{probeFeed.ToString(CultureInfo.InvariantCulture)} g90", GCodeSerial.DefaultProbeTimeout);

            if (result?.LastOrDefault()?.ReplyType.HasFlag(EReplyType.ReplyError) == false)
            {
                serial.QueueCommand($"g92 {axisName}{(-probeSize).ToString(CultureInfo.InvariantCulture)}");
                serial.QueueCommand($"g91 g0 {axisName}{probeDistUp.ToString(CultureInfo.InvariantCulture)} g90");
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        public static async Task <bool> SendProbeCommandAsync(this ISerial serial, Machine machine, int axisIndex)
        {
            string  axisName  = machine.GetAxisName(axisIndex);
            decimal probeSize = machine.GetProbeSize(axisIndex);

            string probDist   = machine.ProbeDist.ToString(CultureInfo.InvariantCulture);
            string probDistUp = machine.ProbeDistUp.ToString(CultureInfo.InvariantCulture);
            string probFeed   = machine.ProbeFeed.ToString(CultureInfo.InvariantCulture);

            var result = await serial.SendCommandAsync("g91 g31 " + axisName + "-" + probDist + " F" + probFeed + " g90", DefaultProbeTimeout);

            if (result?.LastOrDefault()?.ReplyType.HasFlag(EReplyType.ReplyError) == false)
            {
                serial.QueueCommand("g92 " + axisName + (-probeSize).ToString(CultureInfo.InvariantCulture));
                serial.QueueCommand("g91 g0" + axisName + probDistUp + " g90");
                return(true);
            }

            return(false);
        }
Esempio n. 3
0
 public static void PrepareAndQueueCommand(this ISerial serial, Machine machine, string commandString)
 {
     serial.QueueCommand(machine.PrepareCommand(commandString));
 }