Ejemplo n.º 1
0
 public void ResetControlVars()
 {
     HVSteps         = new List <HVStatus>();
     xp              = null;
     hvp             = IntegrationHelpers.GetCurrentHVCalibrationParams(NC.App.Opstate.Measurement.Detectors[0]);
     hvCalibPoint    = hvMinCalibPoint = hvp.MinHV; // starting point for stepping
     hvMaxCalibPoint = hvp.MaxHV;
     hvStep          = hvp.Step;
     hvDelayms       = hvp.DelayMS;
     if (hvp.HVDuration <= hvp.DelayMS / 1000) // seconds to milliseconds
     {
         hvp.DelayMS = (hvp.HVDuration / 1000) + 1000;
         hvDelayms   = hvp.DelayMS;
         ctrllog.TraceEvent(LogLevels.Warning, 604, "HV delay modified to {0} seconds because the HV cycle duration ({1} sec) must be less than HV command delay", hvp.DelayMS * 1000, hvp.HVDuration);
     }
     hvx = false; // excel monitor flag
 }
Ejemplo n.º 2
0
 public void ResetControlVars()
 {
     HVSteps = new List<HVStatus>();
     xp = null;
     hvp = IntegrationHelpers.GetCurrentHVCalibrationParams(NC.App.Opstate.Measurement.Detectors[0]);
     hvCalibPoint = hvMinCalibPoint = hvp.MinHV;  // starting point for stepping
     hvMaxCalibPoint = hvp.MaxHV;
     hvStep = hvp.Step;
     hvDelayms = hvp.DelayMS;
     if (hvp.HVDuration <= hvp.DelayMS / 1000) // seconds to milliseconds
     {
         hvp.DelayMS = (hvp.HVDuration/1000) + 1000;
         hvDelayms = hvp.DelayMS;
         ctrllog.TraceEvent(LogLevels.Warning, 604, "HV delay modified to {0} seconds because the HV cycle duration ({1} sec) must be less than HV command delay", hvp.DelayMS * 1000, hvp.HVDuration); 
     }
     hvx = false; // excel monitor flag
 }
Ejemplo n.º 3
0
        // meant to support SR and LM
        public bool HVCalibRun()
        {
            // only for first active instrument.
            Instrument inst = Instruments.Active.FirstActive(); //  control.FirstActiveInstrument(typeof(LMInstrument));

            if (inst == null)
            {
                ctrllog.TraceInformation("No active instruments for HV calibration. . .");
                return(false);
            }
            if (hvx)
            {
                if (xp == null)
                {
                    xp = new HVExcel(ctrllog);
                    xp.ShowWB();
                    xp.AddHeaderRow(typeof(SimpleHVReport.HVVals));
                }
            }
            instId = inst.id.DetectorId + "-" + inst.id.SRType.ToString();
            if (hvCalibPoint <= hvMaxCalibPoint)
            {
                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();
                }
                else
                {
                    if (inst.id.SRType.IsListMode())
                    {
                        if (inst.id.SRType == InstrType.PTR32)
                        {
                            inst.StartHVCalibration(hvCalibPoint, TimeSpan.FromSeconds(hvp.HVDuration));
                        }
                        else
                        {
                            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
                        if (hvCalibPoint == hvMinCalibPoint)
                        {
                            control.SRWrangler.StartSRActionAndWait(inst.id, SRTakeDataHandler.SROp.InitializeSR, hvCalibPoint, hvp.HVDuration);
                        }
                        else
                        {   // reinit the SR to the next step up in the plateaux
                            control.SRWrangler.StartSRActionAndWait(inst.id, SRTakeDataHandler.SROp.ReInitializeSR, hvCalibPoint, hvp.HVDuration);
                        }

                        // do the run
                        int 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
                        }
                    }

                    hvCalibPoint += hvStep;
                }
            }
            else // we are done
            {
                ctrllog.TraceInformation("HV calibration complete. . .");
                inst.DAQState             = DAQInstrState.Online;
                DAQControl.CurState.State = DAQInstrState.Online;
                ctrllog.Flush();
                inst.PendingComplete(); // each instr must complete for the waitall to move forward
            }
            return(true);
        }
Ejemplo n.º 4
0
        // meant to support SR and LM 
        public bool HVCalibRun()
        {
            // only for first active instrument.
            Instrument inst = Instruments.Active.FirstActive(); //  control.FirstActiveInstrument(typeof(LMInstrument));
            if (inst == null)
            {
                ctrllog.TraceInformation("No active instruments for HV calibration. . .");
                return false;
            }
            if (hvx)
            {
                if (xp == null)
                {
                    xp = new HVExcel(ctrllog);
                    xp.ShowWB();
                    xp.AddHeaderRow(typeof(SimpleHVReport.HVVals));
                }
            }
            instId = inst.id.DetectorId + "-" + inst.id.SRType.ToString();
            if (hvCalibPoint <= hvMaxCalibPoint)
            {
                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();
                }
                else
                {
                    if (inst.id.SRType.IsListMode())
                    {
                        if (inst.id.SRType == InstrType.PTR32) {
                            inst.StartHVCalibration(hvCalibPoint, TimeSpan.FromSeconds(hvp.HVDuration));
                        }
                        else {
                            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
                        if (hvCalibPoint == hvMinCalibPoint)
                            control.SRWrangler.StartSRActionAndWait(inst.id, SRTakeDataHandler.SROp.InitializeSR, hvCalibPoint, hvp.HVDuration);
                        else
                        {   // reinit the SR to the next step up in the plateaux
                            control.SRWrangler.StartSRActionAndWait(inst.id, SRTakeDataHandler.SROp.ReInitializeSR, hvCalibPoint, hvp.HVDuration);
                        }                           

                        // do the run
                        int 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
                        }
                    }

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