Exemplo n.º 1
0
        public void GenerateReports(Measurement m)
        {
            if (m.Detector.ListMode) // generate list mode report if it is list mode, hey!
            {
                RawAnalysisReport rep = new RawAnalysisReport(ctrllog);
                rep.GenerateReport(m);
                ResultsReport = rep.replines;
            }
            MethodResultsReport mrep = new MethodResultsReport(ctrllog);

            mrep.ApplyReportSectionSelections(m.AcquireState.review.Selections);
            mrep.GenerateReport(m);
            foreach (List <string> r in mrep.INCCResultsReports)
            {
                INCCResultsReports.Add(r);
            }
            if (NC.App.AppContext.CreateINCC5TestDataFile)
            {
                TestDataFile mdat = new TestDataFile(ctrllog);
                mdat.GenerateReport(m);
                foreach (List <string> r in mdat.INCCTestDataFiles)
                {
                    TestDataFiles.Add(r);
                }
            }

            if (NC.App.AppContext.OpenResults)
            {
                PrepNotepad();
                if (bNotepadHappensToBeThere)
                {
                    foreach (ResultFile fname in m.ResultsFiles)
                    {
                        System.Diagnostics.Process.Start(notepadPath, fname.Path);
                    }
                }
                // optional enablement
                if (ExcelPush.ExcelPresent() && !string.IsNullOrEmpty(m.ResultsFiles.CSVResultsFileName.Path))
                {
#if EXCEL
                    Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
                    Microsoft.Office.Interop.Excel.Workbook    wb    = excel.Workbooks.Open(m.ResultsFiles.CSVResultsFileName.Path);
                    excel.Visible = true;
#endif
                }
            }
        }
Exemplo n.º 2
0
Arquivo: HV.cs Projeto: radtek/INCC6
        // meant to support SR and LM
        public bool HVCalibRun()
        {
            // only for first active instrument.
            Instrument inst = Instruments.Active.FirstActive();

            if (inst == null)
            {
                ctrllog.TraceInformation("No active instruments for HV calibration. . .");
                return(false);
            }
            if (hvx)
            {
                if (xp == null)
                {
                    if (ExcelPush.ExcelPresent(ctrllog))
                    {
                        xp = new HVExcel(ctrllog);
                        xp.ShowWB();
                        xp.AddHeaderRow(typeof(SimpleHVReport.HVVals));
                    }
                }
            }
            instId = inst.id.DetectorId + "-" + inst.id.SRType.ToString();
            bool res = true;

            if (hvCalibPoint <= hvMaxCalibPoint)
            {
                // todo: catch spurious exceptions and return false
                if (DAQControl.CurState.IsQuitRequested) // leave and do not finish calibration
                {
                    ctrllog.TraceInformation("HV calibration cancelled");
                    inst.DAQState             = DAQInstrState.Online;
                    DAQControl.CurState.State = DAQInstrState.Online;
                    ctrllog.Flush();
                    DAQControl.gControl.MajorOperationCompleted(); // causes pending control thread caller to move forward
                    inst.PendingComplete();                        // each instr must complete for the waitall to move forward
                }
                else
                {
                    if (inst.id.SRType.IsListMode())
                    {
                        if (inst.id.SRType == InstrType.PTR32 || inst.id.SRType == InstrType.MCA527)
                        {
                            Thread.Sleep(hvDelayms);                             // wait for HV to settle, nominally 2 seconds
                            inst.StartHVCalibration(hvCalibPoint, TimeSpan.FromSeconds(hvp.HVDuration));
                        }
                        else if (inst.id.SRType == InstrType.LMMM)
                        {
                            int LM = control.FirstActiveIndexOf(inst);
                            DAQControl.LMMMComm.FormatAndSendLMMMCommand(LMMMLingo.Tokens.hvprep, hvCalibPoint, LM);
                            Thread.Sleep(hvDelayms); // wait for HV to settle, nominally 2 seconds
                            DAQControl.LMMMComm.FormatAndSendLMMMCommand(LMMMLingo.Tokens.hvcalib, 0, LM);
                        }
                    }
                    else
                    {
                        // (re)init the SR
                        int status = 0;
                        if (hvCalibPoint == hvMinCalibPoint)  // starting point
                        {
                            status = control.SRWrangler.StartSRActionAndWait(inst.id, SRTakeDataHandler.SROp.InitializeSR, hvCalibPoint, hvp.HVDuration);
                        }
                        else  // reinit the SR to the next step up in the plateaux
                        {
                            status = control.SRWrangler.StartSRActionAndWait(inst.id, SRTakeDataHandler.SROp.ReInitializeSR, hvCalibPoint, hvp.HVDuration);
                        }

                        if (status == INCCSR.SUCCESS || status == INCCSR.MEAS_CONTINUE)
                        {
                            // do the run
                            status = control.SRWrangler.StartSRActionAndWait(inst.id, SRTakeDataHandler.SROp.StartSRDAQ); // NEXT: check if pending here is going to be an issue
                            if (status == INCCSR.MEAS_CONTINUE)                                                           // the SR started
                            {
                                control.SRWrangler.SetAction(inst.id, SRTakeDataHandler.SROp.WaitForResults);             // event handler will pick up results when the internal timer polling in the thread detects results and fires the event
                            }
                        }
                        else
                        {
                            res = false;
                        }
                    }
                    control.FireEvent(ActionEvents.EventType.ActionInProgress, control);

                    hvCalibPoint += hvStep;
                }
            }
            else // we are done
            {
                ctrllog.TraceInformation("HV calibration complete. . .");
                inst.DAQState             = DAQInstrState.Online;
                DAQControl.CurState.State = DAQInstrState.Online;
                ctrllog.Flush();
                DAQControl.gControl.MajorOperationCompleted(); // causes pending control thread caller to move forward
                inst.PendingComplete();                        // each instr must complete for the waitall to move forward
            }
            return(res);
        }