예제 #1
0
        public DetectorsStatusManager(DetectorsDataAccess dataAccess, EventLoggerAccess logger) :
            base(dataAccess, logger)
        {
            _logger = logger;
            Dictionary<int, string> ConnectionValueMapping = new Dictionary<int, string>();
            ConnectionValueMapping.Add(0, TagValueTypes.Error);
            ConnectionValueMapping.Add(1, TagValueTypes.Clear);

            StatusElement detectorConnect = new StatusElement(_DetectorConnectTag, 0, TagTypes.Status, ConnectionValueMapping);
            //detectorConnect.Value = 
            _Statuses.Add(detectorConnect);


            StatusElement apcsConnect = new StatusElement(_APCSConnectTag, 0, TagTypes.Status, ConnectionValueMapping);
            _Statuses.Add(apcsConnect);

            dataAccess.DetectorConnectionStateUpdate +=
                    new ConnectionStateChangeHandler(OnDetectorsConnectionChange);
            dataAccess.APCSConnectionStateUpdate +=
                    new ConnectionStateChangeHandler(OnApcsConnectionChange);

            Dictionary<int, string> DetectorsValueMapping = new Dictionary<int, string>();
            DetectorsValueMapping.Add(0, TagValueTypes.Clear);
            DetectorsValueMapping.Add(1, TagValueTypes.Warning);
            DetectorsValueMapping.Add(2, TagValueTypes.Error);
            DetectorsValueMapping.Add(3, TagValueTypes.Warning);

            StatusElement detectorStatus = new StatusElement(_DetectorStatusTag, 0, TagTypes.Status, DetectorsValueMapping);
            _Statuses.Add(detectorStatus);
        }
예제 #2
0
 public DetectorRequestManager(DetectorsDataAccess dataAccess, DetectorsStatusManager statusManager, EventLoggerAccess logger)
     : base (dataAccess, statusManager, logger)
 {
     _logger = logger;
     _dataAccess = dataAccess;
     _dataAccess.DisplayControlUpdateRequest += new DashboardControlUpdateHandler(ProcessControlUpdateRequest);
 }
예제 #3
0
        public RealTimeViewer(EventLoggerAccess log, DetectorsDataAccess dataAccess)
        {
            _log = log;
            _dataAccess = dataAccess;
            _dataAccess.DisplayControlUpdateRequest += new Subsystem.DataAccessCore.DashboardControlUpdateHandler(_dataAccess_DisplayControlUpdateRequest);

            int dataPort = int.Parse(ConfigurationManager.AppSettings["RealTimeViewerDataPort"]);
            string address = ConfigurationManager.AppSettings["RealTimeViewerMulticastIPAddress"];
            _realTimeViewerBytesPerPixel = uint.Parse(ConfigurationManager.AppSettings["RealTimeViewerBytesPerPixel"]);
            _realTimeViewerPixelsPerColumn = uint.Parse(ConfigurationManager.AppSettings["RealTimeViewerPixelsPerColumn"]);

            _masterControlAddress = string.Empty;

            if ((dataAccess.Detectors.PixelPerColumn > _realTimeViewerPixelsPerColumn) &&
                (_realTimeViewerPixelsPerColumn != 0))
            {
                float value = (float)dataAccess.Detectors.PixelPerColumn / (float)_realTimeViewerPixelsPerColumn;
                _pixelInterval = (int)(Math.Round(value, 0, MidpointRounding.ToEven));
            }
            else
                _pixelInterval = 1;

            try
            {
                _realTimeViewerHost = new RealTimeViewerHost(address, dataPort);
            }
            catch { }

            _inComingDataColl = new BlockingCollection<DataInfo>(AppConfiguration.DataCollectionMaxSize);
        }
예제 #4
0
        public NormalizeData(EventLoggerAccess log, DetectorsDataAccess dataAccess, Calibration calibration)
        {
            _log = log;
            _dataAccess = dataAccess;
            _calibration = calibration;
            _objectSearch = new ObjectSearch(log, dataAccess, _calibration);
            _rawDataColl = new BlockingCollection<DataInfo>();

            _normalizeThread = Threads.Create(NormalizeAgent, ref _normalizeEnd, "Normalization thread");
            _normalizeThread.Start();
        }
예제 #5
0
        public ObjectSearch(EventLoggerAccess log, DetectorsDataAccess dataAccess, Calibration calibration)
        {
            _log = log;
            _dataAccess = dataAccess;
            _archiveData = new ArchiveData(log, calibration);

            _inComingDataColl = new BlockingCollection<DataInfo>();

            _searchThread = Threads.Create(SearchAgent, ref _searchEnd, "Object Search thread");
            _searchThread.Start();

            _foundObject = false;
        }
예제 #6
0
        public TestNCB(DetectorsDataAccess detectorsDataAccess, BusinessManager businessManager)
        {
            InitializeComponent();

            AccessBusinessManager = businessManager;
            AccessDetectorsData = detectorsDataAccess;

            // disable fake objects
            FakeObjectCHK.IsChecked = false;
            FakeObjectUpdate();

            CurrentLineIdTextBlk.DataContext = AccessDetectorsData.Detectors;
        }
예제 #7
0
 public MainWindow()
 {
     InitializeComponent();
     _eventLoggerAccess = new EventLoggerAccess();
     _eventLoggerAccess.LogMessageUpdate += new LogMessageUpdateHandler(LogMessage);
     _eventLoggerAccess.LogInfo("DetectorsApp Started");
     _dataAccess = new DetectorsDataAccess(_eventLoggerAccess);
     _businessManager = new BusinessManager(_dataAccess, _eventLoggerAccess);
     _dataAccess.Connect();
     CurrentLineIdTextBlk.DataContext = _dataAccess.Detectors;
     TestAPCS.Content = new TestAPCS(_dataAccess);
     TestNCB.Content = new TestNCB(_dataAccess, _businessManager);
     TestAPCS.Visibility = AppConfiguration.ShowDebugDisplays ? Visibility.Visible : Visibility.Collapsed;
     TestNCB.Visibility = TestAPCS.Visibility;
 }
예제 #8
0
        public BusinessManager(DetectorsDataAccess dataAccess, EventLoggerAccess log)
        {
            _dataAccess = dataAccess;
            _log = log;

            _statusManager = new DetectorsStatusManager(dataAccess, log);
            _requestManager = new RequestManager(dataAccess, (StatusManager)_statusManager, log);

            log.LogInfo("Using calibration: " + AppConfiguration.CalibrationMode.ToString());
            if (AppConfiguration.CalibrationMode == AppConfiguration.CalibrationModeEnum.Inline)
                _calibration = new CalibrationInline(log, _dataAccess, _statusManager);
            else if (AppConfiguration.CalibrationMode == AppConfiguration.CalibrationModeEnum.Persistent)
                _calibration = new CalibrationPersistent(log, _dataAccess, _statusManager);
            else if (AppConfiguration.CalibrationMode == AppConfiguration.CalibrationModeEnum.InlineStandstill)
                _calibration = new CalibrationInline(log, _dataAccess, _statusManager);
            _normalize = new NormalizeData(log, dataAccess, _calibration);

            _processThread = Threads.Create(ProcessDataThreadMethod, ref _processEnd, "Business Data thread");
            _processThread.Start();
        }
예제 #9
0
 private void Window_Closed(object sender, EventArgs eventArguments)
 {
     DetectorsApp.TestAPCS.SpeedMsgStop();
     try
     {
         if (/*exists (avoid first try exceptions)?*/ _businessManager != null)
             _businessManager.Dispose();
     }
     catch { }
     finally { _businessManager = null; }
     try
     {
         if (/*exists (avoid first try exceptions)?*/_dataAccess != null)
             _dataAccess.Dispose();
     }
     catch { }
     finally { _dataAccess = null; }
     _eventLoggerAccess.LogWarning(Utilities.ProcessKill(Process.GetCurrentProcess().Id, true));
     _eventLoggerAccess = null;
 }
예제 #10
0
 public TestAPCS(DetectorsDataAccess detectorsAccess)
 {
     InitializeComponent();
     DetectorsAccess = detectorsAccess;
     SignOfLifeSequenceTBK.DataContext = DetectorsAccess.Apcs;
     DetectorsAccess.Apcs.APCSResetEvent += new EventHandler(ResetDetected);
 }
예제 #11
0
 protected virtual void SetupCalibration(EventLoggerAccess log, DetectorsDataAccess dataAccess, DetectorsStatusManager statusManager)
 {
     _dataAccess = dataAccess;
     _logger = log;
     _badDetectorsList = new List<int>();
 }
예제 #12
0
 public CalibrationInline(EventLoggerAccess log, DetectorsDataAccess dataAccess, DetectorsStatusManager statusManager)
 {
     SetupCalibration(log, dataAccess, statusManager);
     _DataCollection = new CalibrationDataCollection();
 }
예제 #13
0
        protected override void SetupCalibration(EventLoggerAccess log, DetectorsDataAccess dataAccess, DetectorsStatusManager statusManager)
        {
            base.SetupCalibration(log, dataAccess, statusManager);

            _statusMgr = statusManager;
            
            _warningMaxNumBadDetectors = Math.Max((int)(AppConfiguration.WarningPercentBadDetectors * dataAccess.Detectors.PixelsPerColumn), 1);
            _errorMaxNumBadDetectors = Math.Max((int)(AppConfiguration.ErrorPercentBadDetectors * dataAccess.Detectors.PixelsPerColumn), 1);
            _contiguousNumBadDetectorsFound = false;

            _allCalibrationDataFound = false;
            _calibrationStorageLocation = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Calibrations");

            _DualDataCollection = new Dictionary<PulseWidth, CalibrationDataCollection>();
            _HighDataCollection = new Dictionary<PulseWidth, CalibrationDataCollection>();
            _LowDataCollection = new Dictionary<PulseWidth, CalibrationDataCollection>();
            //_LowDoseDataCollection = new Dictionary<PulseWidth, CalibrationDataCollection>();

            //foreach (PulseWidth pulseWidth in Enum.GetValues(typeof(PulseWidth)))
            {
                _DualDataCollection.Add(PulseWidth.PulseWidth1, new CalibrationDataCollection());
                _HighDataCollection.Add(PulseWidth.PulseWidth2, new CalibrationDataCollection());
                _LowDataCollection.Add(PulseWidth.PulseWidth3, new CalibrationDataCollection());
                //_LowDoseDataCollection.Add(PulseWidth.PulseWidth3, new CalibrationDataCollection());
            }
            _calibrationLoaded = false;

            _linacEnergyTagUpdated = new AutoResetEvent(false);
            _apcsEnergyValueUpdated = new AutoResetEvent(false);
            _apcsPulseWidthValueUpdated = new AutoResetEvent(false);
            _linacStateTagUpdated = new AutoResetEvent(false);

            //subscribe to tag updates
            _dataAccess.TagUpdate += new PLCTagUpdateHandler(DataAccess_TagUpdate);
            _dataAccess.Apcs.ApcsUpdate += new ApcsUpdateHandler(Apcs_ApcsUpdate);
        }
예제 #14
0
        public CalibrationPersistent(EventLoggerAccess log, DetectorsDataAccess dataAccess, DetectorsStatusManager statusManager)
        {
            SetupCalibration(log, dataAccess, statusManager);

            ///////////////////
            LoadStoredData();
        }