Example #1
0
    void Start()
    {
        // Layout
        float offsetXFactor = 1.0f / 6.0f;       // The amount of empty screen space in each vertical margin
        float offsetYFactor = 1.0f / 6.0f;       // The amount of empty screen space in the top horizontal margin
        int   gapSize       = 10;
        int   defaultHeight = 50;

        layout = new Layout((int)(Screen.width * offsetXFactor),                                                               // Horizontal offset
                            (int)(Screen.height * offsetYFactor),                                                              // Vertical offset
                            gapSize,                                                                                           // Gap between elements
                            (int)(Screen.width * (1 - 2 * offsetXFactor) / 3),                                                 // Element width
                            (int)(Screen.height < Screen.height * offsetYFactor + maxNoElementsY * (defaultHeight + gapSize) ? // Element height
                                  ((Screen.height - Screen.height * offsetYFactor - maxNoElementsY * gapSize) / maxNoElementsY) :
                                  defaultHeight)
                            );

        progressBar = new ProgressBar(layout.ElementRect(0, 7));
        demoPage    = new DemographicPage(layout);

        // Initialize personalityQuestions
        string[] left  = personalityQuestions.GetLefthandQuestions();
        string[] right = personalityQuestions.GetRighthandQuestions();

        personalityPages = new PersonalityPage[(int)Math.Ceiling((float)(left.Length) / questionsPerPage)];

        for (int i = 0; i < personalityPages.Length; i++)
        {
            personalityPages[i] = new PersonalityPage(left, right,
                                                      i * questionsPerPage,                                      // Startindex
                                                      Math.Min((i + 1) * questionsPerPage - 1, left.Length - 1), // Endindex
                                                      layout);
        }

        // Initialize instructions page
        instructionsPage = new InstructionsPage(layout);

        //PrimeOutputFile(); // Insert suitable header in the output file
        //personalityPageIndex = 5; // Go to last page
    }
Example #2
0
 public override void PageIsBecomingInactive()
 {
     if (haveDrawn)
     {
         PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, 2, InstructionsPage.ManualControlsFeedRate().z);
     }
     base.PageIsBecomingInactive();
 }
Example #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();
                }
            }
        }
Example #4
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);
        }
Example #5
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);
        }
Example #6
0
 void zPlusControl_Click(object sender, EventArgs mouseEvent)
 {
     PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, moveAmount, InstructionsPage.ManualControlsFeedRate().z);
     PrinterConnectionAndCommunication.Instance.ReadPosition();
 }
Example #7
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();
 }
Example #8
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));
                }
            }
        }
        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);
        }