Esempio n. 1
0
        public void GetHomingMessage_IsEqual()
        {
            GRBLProtokoll protokoll  = new GRBLProtokoll();
            CNCMessage    cNCMessage = protokoll.GetHomingMessage();

            Assert.Equal("$H", cNCMessage.Message);
        }
Esempio n. 2
0
        public override CNCMessage GetSpindelSetRPMMessage(double RPM, string Direction)
        {
            CNCMessage spindelmessage = new CNCMessage();
            string     dir            = Direction.Trim().ToLower();

            if (RPM < 0)
            {
                return(spindelmessage);
            }
            if (dir != "clockwise" && dir != "counterclockwise")
            {
                return(spindelmessage);
            }


            if (dir == "clockwise")
            {
                spindelmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.RTC_SetSpindleSpeedClockWise));
                spindelmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.GRBL_WriteValue, "S", RPM.ToString()));
            }
            else if (dir == "counterclockwise")
            {
                spindelmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.RTC_SetSpindleSpeedCounterClockWise));
                spindelmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.GRBL_WriteValue, "S", RPM.ToString()));
            }

            return(spindelmessage);
        }
Esempio n. 3
0
        public override CNCMessage GetKillAlarmMessage()
        {
            CNCMessage rmessage = new CNCMessage();

            rmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.GRBL_KillAlarmLock));

            return(rmessage);
        }
Esempio n. 4
0
        /// <summary>
        /// Gets a GRBL Message for Feed.
        /// This is the message who will returned
        /// [GC:G0 G54 G17 G21 G90 G94 M5 M9 T0 F0 S0]
        /// </summary>
        /// <returns>CNCMessage</returns>
        public override CNCMessage GetCurrentFeedMessage()
        {
            CNCMessage rmessage = new CNCMessage();

            rmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.GRBL_ViewGCODEParserState));

            return(rmessage);
        }
Esempio n. 5
0
        /// <summary>
        /// Gets a GRBL Message for setting the feed of the CNC Controller
        /// </summary>
        /// <returns></returns>
        public override CNCMessage GetSetFeedMessage(double Feed)
        {
            CNCMessage rmessage = new CNCMessage();

            rmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.GRBL_WriteSetting, "F", Feed.ToString()));

            return(rmessage);
        }
Esempio n. 6
0
        /// <summary>
        /// Gets a GRBL Message for Z
        /// </summary>
        /// <returns>CNCMessage</returns>
        public override CNCMessage GetCurrentZMessage()
        {
            CNCMessage rmessage = new CNCMessage();

            rmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.RTC_StatusReportQuery));

            return(rmessage);
        }
Esempio n. 7
0
        public void GetSetZeroMessage_IsEqual()
        {
            GRBLProtokoll protokoll = new GRBLProtokoll();

            CNCMessage output = protokoll.GetSetZeroMessage();

            Assert.Equal("G10 P1 L20 X0 Y0 Z0", output.Message);
        }
Esempio n. 8
0
        public override CNCMessage GetSoftResetMessage()
        {
            CNCMessage rmessage = new CNCMessage();

            rmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.RTC_SoftReset));

            return(rmessage);
        }
Esempio n. 9
0
        public void GetKillAlarmMessage_IsEqual()
        {
            GRBLProtokoll protokoll = new GRBLProtokoll();

            CNCMessage cNCMessage = protokoll.GetKillAlarmMessage();

            Assert.Equal("$X", cNCMessage.Message.Trim());
        }
Esempio n. 10
0
        public override CNCMessage GetHomingMessage()
        {
            CNCMessage homingmessage = new CNCMessage();

            homingmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.GRBL_RunHomincCycle));


            return(homingmessage);
        }
Esempio n. 11
0
        /// <summary>
        /// Gets a GRBL Message for moving the tool by ... Millimeters in X direction
        /// </summary>
        /// <returns></returns>
        public override CNCMessage GetMoveByXMessage(double XMillimieter, double Feed)
        {
            CNCMessage rmessage = new CNCMessage();

            rmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.GRBL_WriteValue, "X", XMillimieter.ToString()));
            rmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.GRBL_WriteValue, "F", Feed.ToString()));

            return(rmessage);
        }
Esempio n. 12
0
        public override CNCMessage GetJogByZMessage(double ZMillimieter, double Feed)
        {
            CNCMessage rmessage = new CNCMessage();

            rmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.GRBL_RunJoggingMogion));
            rmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.GRBL_WriteValue, "Z", ZMillimieter.ToString()));
            rmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.GRBL_WriteValue, "F", Feed.ToString()));

            return(rmessage);
        }
Esempio n. 13
0
        public void GetRelativeJogByXYZMessage_IsEqual()
        {
            // Arrange
            GRBLProtokoll protokoll = new GRBLProtokoll();

            // Act
            CNCMessage output = protokoll.GetRelativeJogByXYZMessage(12, 12, 12, 100);

            // Assert
            Assert.Equal("$J=G21 G91 X12 Y12 Z12 F100", output.Message.Trim());
        }
Esempio n. 14
0
        public void GetCurrentXYZMessage_IsEqual()
        {
            // Arrange
            GRBLProtokoll protokoll = new GRBLProtokoll();

            // Act
            CNCMessage output = protokoll.GetCurrentXYZMessage();

            // Assert
            Assert.Equal("?", output.Message);
        }
Esempio n. 15
0
        public void GetMoveByZMessage_IsEqual()
        {
            // Arrange
            GRBLProtokoll protokoll = new GRBLProtokoll();

            // Act
            CNCMessage output = protokoll.GetMoveByZMessage(12, 100);

            // Assert
            Assert.Equal("Z12 F100", output.Message.Trim());
        }
Esempio n. 16
0
        public override CNCMessage GetRelativeJogByZMessage(double ZMillimeter, double Feed)
        {
            CNCMessage rmessage = new CNCMessage();

            rmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.GRBL_RunJoggingMogion));
            rmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.G_SetUnitToMillimeter_G21));
            rmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.G_RelativeMotion_G91));
            rmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.GRBL_WriteValue, "Z", ZMillimeter.ToString()));
            rmessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.GRBL_WriteValue, "F", Feed.ToString()));

            return(rmessage);
        }
Esempio n. 17
0
        public void GetSpindelSetRPMMessage_IsEqual()
        {
            GRBLProtokoll gRBLProtokoll = new GRBLProtokoll();

            CNCMessage cNCMessage = gRBLProtokoll.GetSpindelSetRPMMessage(1000, "clockwise");


            CNCMessage nNCMessagecounter = gRBLProtokoll.GetSpindelSetRPMMessage(1000, "counterclockwise");

            Assert.Equal("M3 S1000", cNCMessage.Message.Trim());
            Assert.Equal("M4 S1000", nNCMessagecounter.Message.Trim());
        }
Esempio n. 18
0
        public void SendMessage_GotAnythingBack()
        {
            // Assamble
            GRBLProtokoll pr = new GRBLProtokoll();
            CNCMessage    m  = pr.GetCurrentFeedMessage();

            // Act
            GRBLInterface.SendMessage(m);


            // Assert
            // No Exception is proof enough
        }
Esempio n. 19
0
        public override CNCMessage GetSetZeroMessage()
        {
            CNCMessage zeromessage = new CNCMessage();

            zeromessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.G_SetOffset_G10));
            zeromessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.P_Tool1));
            zeromessage.AppendCommand(CommandDict.GetCommand(GRBLCommand.L20));
            zeromessage.AppendCommand("X0 ");
            zeromessage.AppendCommand("Y0 ");
            zeromessage.AppendCommand("Z0");


            return(zeromessage);
        }
Esempio n. 20
0
        public async Task SendCustomMessage()
        {
            CNCMessage message = new CNCMessage()
            {
                Message = "$X"
            };
            CNCMessage message1 = new CNCMessage()
            {
                Message = "FALSCH"
            };

            var tmp = await device.SendCustomMessage(message);

            Assert.Contains("ok", tmp.Message);

            tmp = await device.SendCustomMessage(message1);

            Assert.Contains("error", tmp.Message);
        }
Esempio n. 21
0
        public void SendMessage_ReceiveMessage()
        {
            // Assamble
            GRBLProtokoll pr    = new GRBLProtokoll();
            CNCMessage    m     = pr.GetCurrentFeedMessage();
            CNCMessage    start = new CNCMessage()
            {
                Message = "Grbl 1.1g ['$' for help]"
            };
            var an = GRBLInterface.WaitReceiveMessage(100, start, 2000);

            // Act
            GRBLInterface.SendMessage(m);
            //CNCMessage answer = GRBLInterface.ReceiveMessage(10);
            CNCMessage tmp = new CNCMessage()
            {
                Message = "F"
            };
            CNCMessage answer = GRBLInterface.WaitReceiveMessage(100, tmp, 3000);


            // Assert
            Assert.Contains("F", answer.Message);
        }