Esempio n. 1
0
    IEnumerator RunCalibrationStressTest()
    {
        while (true)
        {
            yield return(Scheduler.StartCoroutine(pc.CalibrateTop(pc.originalPrinter)));

            topSeeksCompleted++;
            centersCompleted++;
            yield return(Scheduler.StartCoroutine(pc.CalibrateBottom(pc.originalPrinter)));

            bottomSeeksCompleted++;
            centersCompleted++;
        }
    }
Esempio n. 2
0
    /// <summary>
    /// Scans an object.
    /// </summary>
    /// <returns>The object.</returns>
    public IEnumerator ScanObject()
    {
        Contract.Assert(!enabled, "Scanner already running.");

        enabled          = true;
        m_workingPrinter = pc.originalPrinter.Clone();

        m_readyToScan = false;
        Dispatcher <string, PanelController.Handler, PanelController.Handler> .Broadcast(
            PanelController.kEventConfirm, kClearPlatformString,
            delegate {
            m_readyToScan = true;
        },
            delegate {
            StopCameras();
            enabled = false;
            Scheduler.StopCoroutines(this);
        });

        yield return(new WaitUntil(() => m_readyToScan));

        Dispatcher <Panel> .Broadcast(PanelController.kEventOpenPanel, Panel.Message);

        Dispatcher <string> .Broadcast(PanelController.kEventShowMessage, "Calibrating...");

        //Prepare Printer
        pc.InitializeMotors(m_workingPrinter);
        // Turn on lights to best detect calibration pattern
        pc.TurnFetOnOff(GanglionPowered.pScannerBackLight, true);
        pc.TurnFetOnOff(GanglionPowered.pScannerMidLight, true);
        m_workingPrinter.extruders = new PrinterExtruder[0];

        // Go to the bottom for scanning
        yield return(Scheduler.StartCoroutine(pc.CalibrateBottom(m_workingPrinter)));

        // Calibrate the cameras if needed.
        int timeout = 5;

        if (calibratedCameras.Count != 2)
        {
            while (calibratedCameras.Count < 2 && timeout-- > 0)
            {
                Text.Log("Attempting to calibrate cameras...");
                yield return(Scheduler.StartCoroutine(CalibrateCameras()));
            }

            if (timeout == 0)
            {
                Text.Error("Failed to detect cameras; aborting.");
                Dispatcher <Panel> .Broadcast(PanelController.kEventClosePanel, Panel.Progress);

                enabled = false;
                yield break;
            }
        }
        else
        {
            foreach (ScanningCamera c in calibratedCameras)
            {
                c.Ready();
            }
        }

        yield return(Scheduler.StartCoroutine(SilhouetteScan()));

        Dispatcher <Panel> .Broadcast(PanelController.kEventClosePanel, Panel.Progress);

        enabled = false;
    }