Пример #1
0
 public override void PageIsBecomingInactive()
 {
     if (haveDrawn)
     {
         PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, 2, InstructionsPage.ManualControlsFeedRate().z);
     }
     base.PageIsBecomingInactive();
 }
Пример #2
0
        public override void PageIsBecomingActive()
        {
            // first make sure there is no leftover FinishedProbe event
            PrinterConnectionAndCommunication.Instance.ReadLine.UnregisterEvent(FinishedProbe, ref unregisterEvents);

            PrinterConnectionAndCommunication.Instance.MoveAbsolute(PrinterConnectionAndCommunication.Axis.Z, probeStartPosition.z, InstructionsPage.ManualControlsFeedRate().z);
            PrinterConnectionAndCommunication.Instance.MoveAbsolute(probeStartPosition, InstructionsPage.ManualControlsFeedRate().x);
            PrinterConnectionAndCommunication.Instance.SendLineToPrinterNow("G30");
            PrinterConnectionAndCommunication.Instance.ReadLine.RegisterEvent(FinishedProbe, ref unregisterEvents);

            base.PageIsBecomingActive();

            container.nextButton.Enabled = false;

            zPlusControl.Click  += new EventHandler(zControl_Click);
            zMinusControl.Click += new EventHandler(zControl_Click);
        }
Пример #3
0
        void FinishedProbe(object sender, EventArgs e)
        {
            StringEventArgs currentEvent = e as StringEventArgs;

            if (currentEvent != null)
            {
                if (currentEvent.Data.Contains("endstops hit"))
                {
                    PrinterConnectionAndCommunication.Instance.ReadLine.UnregisterEvent(FinishedProbe, ref unregisterEvents);
                    int    zStringPos   = currentEvent.Data.LastIndexOf("Z:");
                    string zProbeHeight = currentEvent.Data.Substring(zStringPos + 2);
                    // store the position that the limit swich fires
                    whereToWriteSamplePosition.position = new Vector3(probeStartPosition.x, probeStartPosition.y, double.Parse(zProbeHeight));

                    // now move to the probe start position
                    PrinterConnectionAndCommunication.Instance.MoveAbsolute(probeStartPosition, InstructionsPage.ManualControlsFeedRate().z);
                    PrinterConnectionAndCommunication.Instance.ReadPosition();
                }
            }
        }
Пример #4
0
        public override void PageIsBecomingActive()
        {
            base.PageIsBecomingActive();

            PrinterConnectionAndCommunication.Instance.MoveAbsolute(PrinterConnectionAndCommunication.Axis.Z, probeStartPosition.z, InstructionsPage.ManualControlsFeedRate().z);
            PrinterConnectionAndCommunication.Instance.MoveAbsolute(probeStartPosition, InstructionsPage.ManualControlsFeedRate().x);
            PrinterConnectionAndCommunication.Instance.ReadPosition();

            container.nextButton.Enabled = false;

            zPlusControl.Click  += new EventHandler(zControl_Click);
            zMinusControl.Click += new EventHandler(zControl_Click);
        }
Пример #5
0
 void zPlusControl_Click(object sender, EventArgs mouseEvent)
 {
     PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, moveAmount, InstructionsPage.ManualControlsFeedRate().z);
     PrinterConnectionAndCommunication.Instance.ReadPosition();
 }
Пример #6
0
 void zMinusControl_Click(object sender, EventArgs mouseEvent)
 {
     if (!allowLessThan0 &&
         PrinterConnectionAndCommunication.Instance.LastReportedPosition.z - moveAmount < 0)
     {
         UiThread.RunOnIdle((state) =>
         {
             StyledMessageBox.ShowMessageBox(null, zIsTooLowMessage, zTooLowTitle, StyledMessageBox.MessageType.OK);
         });
         // don't move the bed lower it will not work when we print.
         return;
     }
     PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, -moveAmount, InstructionsPage.ManualControlsFeedRate().z);
     PrinterConnectionAndCommunication.Instance.ReadPosition();
 }
Пример #7
0
        void FinishedProbe(object sender, EventArgs e)
        {
            StringEventArgs currentEvent = e as StringEventArgs;

            if (currentEvent != null)
            {
                if (currentEvent.Data.Contains("endstops hit"))
                {
                    PrinterConnectionAndCommunication.Instance.ReadLine.UnregisterEvent(FinishedProbe, ref unregisterEvents);
                    int    zStringPos   = currentEvent.Data.LastIndexOf("Z:");
                    string zProbeHeight = currentEvent.Data.Substring(zStringPos + 2);
                    probePosition.position = new Vector3(probeStartPosition.x, probeStartPosition.y, double.Parse(zProbeHeight));
                    PrinterConnectionAndCommunication.Instance.MoveAbsolute(probeStartPosition, InstructionsPage.ManualControlsFeedRate().z);
                    PrinterConnectionAndCommunication.Instance.ReadPosition();

                    container.nextButton.ClickButton(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0));
                }
            }
        }
Пример #8
0
        public static List <string> ProcessCommand(string lineBeingSent)
        {
            int commentIndex = lineBeingSent.IndexOf(';');

            if (commentIndex > 0)             // there is content in front of the ;
            {
                lineBeingSent = lineBeingSent.Substring(0, commentIndex).Trim();
            }
            List <string> lines = new List <string>();

            if (lineBeingSent == "G28")
            {
                lines.Add("G28 X0");
                lines.Add("G1 X1");
                lines.Add("G28 Y0");
                lines.Add("G1 Y1");
                lines.Add("G28 Z0");
                lines.Add("M114");
            }
            else if (lineBeingSent == "G29")
            {
                // first make sure we don't have any leftover reading.
                PrinterConnectionAndCommunication.Instance.ReadLine.UnregisterEvent(FinishedProbe, ref unregisterEvents);

                if (unregisterEvents != null)
                {
                    unregisterEvents(null, null);
                }
                if (PrinterConnectionAndCommunication.Instance.CommunicationState == PrinterConnectionAndCommunication.CommunicationStates.Printing)
                {
                    ActiveSliceSettings.Instance.DoPrintLeveling(false);
                }

                probeIndex = 0;
                PrinterConnectionAndCommunication.Instance.ReadLine.RegisterEvent(FinishedProbe, ref unregisterEvents);

                StringBuilder commands = new StringBuilder();

                double zFeedRate  = InstructionsPage.ManualControlsFeedRate().z;
                double xyFeedRate = InstructionsPage.ManualControlsFeedRate().x;

                // make sure the probe offset is set to 0
                lines.Add("M565 Z0");

                // probe position 0
                probeRead0 = new Vector3(probeFrontLeft, probeStartZHeight);
                // up in z
                lines.Add("G1 F{0}".FormatWith(zFeedRate));
                lines.Add("G1 {0}{1}".FormatWith("Z", probeStartZHeight));
                // move to xy
                lines.Add("G1 F{0}".FormatWith(xyFeedRate));
                lines.Add("G1 X{0}Y{1}Z{2}".FormatWith(probeFrontLeft.x, probeFrontLeft.y, probeStartZHeight));
                // probe
                lines.Add("G30");

                // probe position 1
                probeRead1 = new Vector3(probeFrontRight, probeStartZHeight);
                // up in z
                lines.Add("G1 F{0}".FormatWith(zFeedRate));
                lines.Add("G1 {0}{1}".FormatWith("Z", probeStartZHeight));
                // move to xy
                lines.Add("G1 F{0}".FormatWith(xyFeedRate));
                lines.Add("G1 X{0}Y{1}Z{2}".FormatWith(probeFrontRight.x, probeFrontRight.y, probeStartZHeight));
                // probe
                lines.Add("G30");

                // probe position 2
                probeRead2 = new Vector3(probeBackLeft, probeStartZHeight);
                // up in z
                lines.Add("G1 F{0}".FormatWith(zFeedRate));
                lines.Add("G1 {0}{1}".FormatWith("Z", probeStartZHeight));
                // move to xy
                lines.Add("G1 F{0}".FormatWith(xyFeedRate));
                lines.Add("G1 X{0}Y{1}Z{2}".FormatWith(probeBackLeft.x, probeBackLeft.y, probeStartZHeight));
                // probe
                lines.Add("G30");
                lines.Add("M114");
                lines.Add("G1 Z1 F300");
            }
            else
            {
                lines.Add(lineBeingSent);
            }

            return(lines);
        }