Exemplo n.º 1
0
        /// <summary>
        /// Private Function which is deriving the current X in the cnc-controller
        /// </summary>
        /// <returns></returns>
        public async Task <float> GetCurrentX()
        {
            float r = 0;
            await Task.Run(() =>
            {
                CNCMessage message = Protokoll.GetCurrentXMessage();
                Interface.SendMessage(message);

                CNCMessage output = Interface.WaitReceiveMessageContaining(100, "WPos", 1000);
                var tmp           = Regex.Match(output.Message, @"(WPos:([-0-9]+.[0-9]+),([-0-9]+.[0-9]+),([-0-9]+.[0-9]))").Groups[2].Value;
                try
                {
                    r = Convert.ToSingle(tmp, CultureInfo.InvariantCulture);
                }
                catch (FormatException ex)
                {
                    r = 0;
                }
            });

            return(r);
        }