private void ParseG29(string dataReceived)
        {
            // Get all responces
            var responces = dataReceived.Split('\n');


            // X:0.00 Y:0.00 Z:5.00 E:0.00 Count X: 0 Y:0 Z:16000
            foreach (var row in responces)
            {
                var positionPattern =
                    @"X:[0-9]*\.[0-9]*\s*Y:[0-9]*\.[0-9]*\s*Z:[0-9]*\.[0-9]*\s*E:[0-9]*\.[0-9]*\s*Count\s*X:\s*";
                var positionMatch = Regex.Match(row, positionPattern);
                if (positionMatch.Success)
                {
                    var x = _numberConversion.ConvertStringToDecimal(Regex.Match(row, @"(?<=X:)[0-9]*\.[0-9]*").Value);
                    var y = _numberConversion.ConvertStringToDecimal(Regex.Match(row, @"(?<=Y:)[0-9]*\.[0-9]*").Value);
                    var z = _numberConversion.ConvertStringToDecimal(Regex.Match(row, @"(?<=Z:)[0-9]*\.[0-9]*").Value);

                    ProbeResponceList.Add(new Position {
                        X = x, Y = y, Z = z
                    });
                }
            }


            // Create G29 responce Event
            var eventG29Resonce = new Responce(new List <string>());

            eventG29Resonce.ResponsRowList.AddRange(responces);

            OnG29Responce(eventG29Resonce);
        }
        private void ParseM48()
        {
            // Return if The _dataReceived not contains ok\n
            if (WaitForOkAndNewLineToBeReceived() == false)
            {
                return;
            }

            // Get all responces
            var responces = GetAllResponces();


            // Create M48 responce Event
            var eventM48Resonce = new Responce(new List <string>());

            eventM48Resonce.ResponsRowList.AddRange(responces);

            OnM48ProbeStatus(eventM48Resonce);

            //Delete the responce from the received bytes
            _dataReceived = DeleteResponceUpToAndInclusiveOk(_dataReceived);

            // ReadyForNextCommand
            OnReadyForNextCommand(EventArgs.Empty);
        }
示例#3
0
        private void ParseM48()
        {
            // Return if The _dataReceived not contains ok\n
            if (WaitForOkAndNewLineToBeReceived() == false)
            {
                return;
            }

            // Get all responces
            var responces = GetAllResponces();


            //ok
            //ok
            //ok
            //M48 Z - Probe Repeatability test.   Version 2.00
            //Full support at: http://3dprintboard.com/forum.php
            //Positioning probe for the test.
            //1 of 4   z: 8.705000 mean: 8.705000   sigma: 0.000000
            //2 of 4   z: 8.706875 mean: 8.705938   sigma: 0.000937
            //3 of 4   z: 8.705313 mean: 8.705730   sigma: 0.000820
            //4 of 4   z: 8.707813 mean: 8.706251   sigma: 0.001148
            //Mean: 8.706251
            //Standard Deviation: 0.001148
            //            ok
            //            echo:endstops hit:  Z:8.71
            //            ok

            // The M48 ends with a calculation of all probes test.
            // The row begins with Mean: and then the calculated value
            // (?<=^Mean:\s*)([-,0-9]*\.[0-9]*)

            try
            {
                var meanProbeValue =
                    Regex.Match(_dataReceived, @"(?<=Mean:\s*)([-,0-9]*\.[0-9]*)", RegexOptions.CultureInvariant).Groups[1]
                    .Value;
                ProbeM48MeanValue = meanProbeValue;
            }
            catch (Exception parsException)
            {
                MessageBox.Show($"Error in parser of M48. Error: {parsException.Message}");
            }

            // Create M48 responce Event
            var eventM48Resonce = new Responce(new List <string>());

            eventM48Resonce.ResponsRowList.AddRange(responces);

            OnM48ProbeStatus(eventM48Resonce);

            //Delete the responce from the received bytes
            _dataReceived = DeleteResponceUpToAndInclusiveOk(_dataReceived);

            // ReadyForNextCommand
            OnReadyForNextCommand(EventArgs.Empty);
        }
示例#4
0
        private void ParseG29()
        {
            // Return if The _dataReceived not contains ok\n
            if (WaitForOkAndNewLineToBeReceived() == false)
            {
                return;
            }


            // Get all responces
            var responces = GetAllResponces();


            // X:0.00 Y:0.00 Z:5.00 E:0.00 Count X: 0 Y:0 Z:16000
            foreach (var row in responces)
            {
                var positionPattern =
                    @"X:[0-9]*\.[0-9]*\s*Y:[0-9]*\.[0-9]*\s*Z:[0-9]*\.[0-9]*\s*E:[0-9]*\.[0-9]*\s*Count\s*X:\s*";
                var positionMatch = Regex.Match(row, positionPattern);
                if (positionMatch.Success)
                {
                    var x =
                        (double)Convert.ToDecimal(Regex.Match(row, @"(?<=X:)[0-9]*\.[0-9]*").Value.Replace('.', ','));
                    var y =
                        (double)Convert.ToDecimal(Regex.Match(row, @"(?<=Y:)[0-9]*\.[0-9]*").Value.Replace('.', ','));
                    var z =
                        (double)Convert.ToDecimal(Regex.Match(row, @"(?<=Z:)[0-9]*\.[0-9]*").Value.Replace('.', ','));
                    ProbeResponceList.Add(new Position {
                        X = x, Y = y, Z = z
                    });
                }
            }


            // Create G29 responce Event
            var eventG29Resonce = new Responce(new List <string>());

            eventG29Resonce.ResponsRowList.AddRange(responces);

            OnG29Responce(eventG29Resonce);


            //Delete the responce from the received bytes
            _dataReceived = DeleteResponceUpToAndInclusiveOk(_dataReceived);

            // ReadyForNextCommand
            OnReadyForNextCommand(EventArgs.Empty);
        }
        /// <summary>
        /// Handle event that rise after G29
        /// </summary>
        private void OnG29Responce(Responce responce)
        {
            var handler = G29Responce;

            handler?.Invoke(this, responce);
        }
示例#6
0
        /// <summary>
        /// Handle event that rise after M48
        /// </summary>
        private void OnM48ProbeStatus(Responce probeResponceList)
        {
            var handler = M48ProbeStatus;

            handler?.Invoke(this, probeResponceList);
        }