コード例 #1
0
        public int StartSRActionAndWait(DataSourceIdentifier dsid, SROp op, int setpt = -1, int runtime = -1)
        {
            SRControlThread srct;
            int             res = SR.SUCCESS;

            if (threads.ContainsKey(dsid))
            {
                srct = threads[dsid];
                if (srct == null || !srct.IsBusy)
                {
                    return(res);
                }

                try
                {
                    if (setpt >= 0)
                    {
                        srct.SRCtrl.HVSet(setpt, runtime);
                    }

                    srct.op = op;
                    // tell caller to wait, then kick the thread into action
                    srct.callwait.Reset();

                    // tell the thread to go ahead
                    srct.opgate.Set();

                    // caller will now wait for completion
                    srct.callwait.Wait(srct.cts.Token);

                    // fire the operation completed event here, consciously placed out of the executing SR service thread context
                    srct.SROpCompletedEvent(srct.status);
                }
                catch (OperationCanceledException)
                {
                }
                finally
                {
                    res = srct.SRCtrl.LastMeasStatus;
                }
            }
            return(res);
        }
コード例 #2
0
        public void SetAction(DataSourceIdentifier dsid, SROp op)
        {
            SRControlThread srct;

            if (threads.ContainsKey(dsid))
            {
                srct = threads[dsid];
                if (!srct.IsBusy)
                {
                    return;
                }

                srct.op = op;

                // tell caller to wait, then kick the waiting thread into action
                srct.callwait.Reset();

                srct.opgate.Set();
            }
        }
コード例 #3
0
 public SROpCompletedEventArgs(SROp op, int statusNow, object userState)
 {
     Op        = op;
     OpStatus  = statusNow;
     UserState = userState;
 }
コード例 #4
0
 public void Shutdown()
 {
     op = SROp.Shutdown;
     CancelMe();
 }
コード例 #5
0
ファイル: SRDAQHandler.cs プロジェクト: tempbottle/INCC6
        public int StartSRActionAndWait(DataSourceIdentifier dsid, SROp op, int setpt = -1, int runtime = -1)
        {
            SRControlThread srct;
            int res = SR.SUCCESS;
            if (threads.ContainsKey(dsid))
            {
                srct = threads[dsid];
                if (srct == null || !srct.IsBusy)
                    return res;

                try
                {
                    if (setpt >= 0)
                        srct.SRCtrl.HVSet(setpt, runtime);

                    srct.op = op;
                    // tell caller to wait, then kick the thread into action
                    srct.callwait.Reset();

                    // tell the thread to go ahead
                    srct.opgate.Set();

                    // caller will now wait for completion
                    srct.callwait.Wait(srct.cts.Token);

                    // fire the operation completed event here, consciously placed out of the executing SR service thread context
                    srct.SROpCompletedEvent(srct.status);
                }
                catch (OperationCanceledException)
                {
                }
                finally
                {
                    res = srct.SRCtrl.LastMeasStatus;
                }
            }
            return res;
        }
コード例 #6
0
        // a general idea of what to do next in an SR processing sequence
        public static SROp NextOp(SROp thisOp, int curStatus)
        {
            SROp next = SROp.Nothing;

            switch (thisOp)
            {
            case SROp.Shutdown:
                next = SROp.Nothing;
                break;

            case SROp.Nothing:
                next = SROp.InitializeContext;
                break;

            case SROp.InitializeContext:
                next = SROp.InitializeSR;
                break;

            case SROp.InitializeSR:
                if (curStatus != sr_h.SR_SUCCESS)      // status here is an sr.h machine code only
                {
                    next = SROp.CloseSR;
                }
                else
                {
                    next = SROp.StartSRDAQ;
                }
                break;

            case SROp.StartSRDAQ:
                if (curStatus != SR.MEAS_CONTINUE)      // MEAS_ABORT or MEAS_TERMINATE
                {
                    next = SROp.StartSRDAQ;
                }
                else
                {
                    next = SROp.CloseSR;
                }
                break;

            case SROp.WaitForResults:
                if ((curStatus == SR.ZERO_COUNT_TIME) || (curStatus == SR.SR_TRY_AGAIN))      // dev note: empty cycles are eliminated by this step
                {
                    next = SROp.StartSRDAQ;
                }
                else if (curStatus != SR.SUCCESS)      // MEAS_ABORT or MEAS_TERMINATE
                {
                    next = SROp.CloseSR;
                }
                else
                {
                    next = SROp.CloseSR;
                }
                break;

            case SROp.CloseSR:
                next = SROp.Shutdown;
                break;
            }
            return(next);
        }
コード例 #7
0
ファイル: SRDAQHandler.cs プロジェクト: tempbottle/INCC6
        public void SetAction(DataSourceIdentifier dsid, SROp op)
        {
            SRControlThread srct;
            if (threads.ContainsKey(dsid))
            {
                srct = threads[dsid];
                if (!srct.IsBusy)
                    return;

                srct.op = op;

                // tell caller to wait, then kick the waiting thread into action
                srct.callwait.Reset();

                srct.opgate.Set();
            }
        }
コード例 #8
0
ファイル: SRDAQHandler.cs プロジェクト: tempbottle/INCC6
 public void Shutdown()
 {
     op = SROp.Shutdown;
     CancelMe();
 }
コード例 #9
0
ファイル: SRDAQHandler.cs プロジェクト: tempbottle/INCC6
 public SROpCompletedEventArgs(SROp op, int statusNow, object userState)
 {
     Op = op;
     OpStatus = statusNow;
     UserState = userState;
 }
コード例 #10
0
ファイル: SRDAQHandler.cs プロジェクト: tempbottle/INCC6
        // a general idea of what to do next in an SR processing sequence
        public static SROp NextOp(SROp thisOp, int curStatus)
        {

            SROp next = SROp.Nothing;
            switch (thisOp)
            {
                case SROp.Shutdown:
                    next = SROp.Nothing;
                    break;
                case SROp.Nothing:
                    next = SROp.InitializeContext;
                    break;
                case SROp.InitializeContext:
                    next = SROp.InitializeSR;
                    break;
                case SROp.InitializeSR:
                    if (curStatus != sr_h.SR_SUCCESS)  // status here is an sr.h machine code only
                        next = SROp.CloseSR;
                    else
                        next = SROp.StartSRDAQ;
                    break;
                case SROp.StartSRDAQ:
                    if (curStatus != SR.MEAS_CONTINUE)  // MEAS_ABORT or MEAS_TERMINATE
                        next = SROp.StartSRDAQ;
                    else
                        next = SROp.CloseSR;
                    break;
                case SROp.WaitForResults:
                    if ((curStatus == SR.ZERO_COUNT_TIME) || (curStatus == SR.SR_TRY_AGAIN))  // dev note: empty cycles are eliminated by this step
                    {
                        next = SROp.StartSRDAQ;
                    }
                    else if (curStatus != SR.SUCCESS)  // MEAS_ABORT or MEAS_TERMINATE
                    {
                        next = SROp.CloseSR;
                    }
                    else
                    {
                        next = SROp.CloseSR;
                    }
                    break;
                case SROp.CloseSR:
                    next = SROp.Shutdown;
                    break;
            }
            return next;

        }
コード例 #11
0
ファイル: SRDAQHandler.cs プロジェクト: hnordquist/INCC6
 public SRControlThread(int count, LMLoggers.LognLM log, Measurement meas, Detector det)
 {
     op = SROp.Nothing;
     SRCtrl = new SRControl(count, log, meas, det);
     opgate = new ManualResetEventSlim(false);
     callwait = new ManualResetEventSlim(false);
     cts = new CancellationTokenSource();
 }