예제 #1
0
        /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        * StartDetectorDataAcq is invoked upon establishment of the
        * APCS instance's connection. At that time, there is no
        * guarantee that the Detectors instance has already established
        * all of its underlying NCB command connections. APCS initiates
        * its connection when the above public method, Connect, is
        * invoked, which establishes the APCS connection. Connect may be
        * invoked also from DetectorsApp/MainWindow.xaml.cs.
        *!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
        public bool StartDetectorDataAcq(string reason = null)
        {
            _detectorsAccess.SourcesSynchronized = false;

            // If all of the detector servers are connected, stop the
            // detector timing pulses, then, reset the line identities
            // of the detector servers, then, start the detectors' data
            // connections and, finally, restart the the timing pulses.
            if (!Detectors.CommandIsReady)
            {
                _logger.LogError("All NCB(s) not yet ready");
                return(false);
            }
            if (/*fail?*/ !Apcs.DetectorsTimingEnable(false))
            {
                _logger.LogError("Apcs.DetectorsTimingEnable(false) failed");
                return(false);
            }
            try { Detectors.ResetLineCount(); }
            catch (Exception ex)
            {
                _logger.LogError(ex);
                return(false);
            }
            if (/*fail?*/ !Apcs.DetectorsTimingEnable(true))
            {
                _logger.LogError("Apcs.DetectorsTimingEnable(true) failed");
                return(false);
            }

            _detectorsAccess.SourcesSynchronized = true;

            // All NCBs are connected and APCS timing has been started: the NCBs' LineID counters
            // have been synchronized.
            return(true);
        }