Пример #1
0
        public static async Task SendMacroCommandAsync(this ISerial serial, Machine machine, string commandString)
        {
            string[] separators = { @"\n" };
            string[] cmds       = commandString.Split(separators, StringSplitOptions.RemoveEmptyEntries);
            foreach (string s in cmds)
            {
                string[] infos = s.Split(':');
                int      axis;

                if (infos.Length > 1 && string.Compare(infos[0], @";probe", true) == 0 && -1 != (axis = GCodeHelper.AxisNameToIndex(infos[1])))
                {
                    if (false == await serial.SendProbeCommandAsync(machine, axis))
                    {
                        break;
                    }
                }
                else if (infos.Length == 1 && string.Compare(infos[0], @";beep", true) == 0)
                {
                    SystemSounds.Beep.Play();
                }
                else
                {
                    if (s.TrimEnd().EndsWith("?"))
                    {
                        var result = await serial.SendCommandAsync(s.TrimEnd().TrimEnd('?'), GCodeSerial.DefaultTimeout);

                        if (result?.LastOrDefault()?.ReplyType.HasFlag(EReplyType.ReplyError) == false)
                        {
                            return;
                        }
                    }
                    else
                    {
                        await serial.SendCommandAsync(s, GCodeSerial.DefaultTimeout);
                    }
                }
            }
        }
Пример #2
0
 public static async Task <bool> SendProbeCommandAsync(this ISerial serial, Machine machine, int axisIndex)
 {
     return(await serial.SendProbeCommandAsync(machine.GetAxisName(axisIndex), machine.GetProbeSize(axisIndex), machine.ProbeDist, machine.ProbeDistUp, machine.ProbeFeed));
 }