2 using System.Collections.Generic;
4 using System.Threading;
5 using System.ComponentModel;
6 using Seci.Definitions;
22 private int _updateRate = 500;
24 private Boolean _daeUpdating =
false;
25 private Boolean _timedOut =
false;
30 public delegate
void ValuesUpdatedEventHandler(Boolean timeout);
45 _updateRate = updateRate;
50 if (_blockUpdater == null)
53 _blockUpdater =
new BackgroundWorker();
54 _blockUpdater.DoWork +=
new DoWorkEventHandler(blockUpdater_DoWork);
55 _blockUpdater.RunWorkerCompleted +=
new RunWorkerCompletedEventHandler(blockUpdater_RunWorkerCompleted);
58 if (_daeUpdater == null)
61 _daeUpdater =
new BackgroundWorker();
62 _daeUpdater.DoWork +=
new DoWorkEventHandler(_daeUpdater_DoWork);
63 _daeUpdater.RunWorkerCompleted +=
new RunWorkerCompletedEventHandler(_daeUpdater_RunWorkerCompleted);
70 _statusBlock.BlockName = Status.StatusBlockName;
71 _statusBlock.LoggingRate = 5;
72 _statusBlock.LogChangesOnly =
true;
73 _statusBlock.Tolerance = 0;
74 _statusBlock.LogValueToFile =
true;
75 _statusBlock.BlockEnabled =
true;
83 if (_updateCallBack == null && _updateTimer == null)
85 _updateCallBack =
new TimerCallback(updateTimer_Tick);
86 _updateTimer =
new Timer(_updateCallBack, null, 0, _updateRate);
95 if (_updateTimer != null)
97 _updateTimer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
106 if (_updateTimer != null)
108 _updateTimer.Change(0, _updateRate);
122 if (!_blockUpdater.IsBusy)
124 _blockUpdater.RunWorkerAsync();
126 if (!_daeUpdater.IsBusy)
128 _daeUpdater.RunWorkerAsync();
147 Standard.DaeMonitor.GetRunControlSettings();
151 Managers.BlockMgr.UpdateBlockValues();
161 DateTime start = DateTime.UtcNow;
165 System.Threading.Thread.Sleep(100);
167 if (DateTime.UtcNow - start >=
new TimeSpan(0, 0, 1))
176 catch (Exception err)
178 Helpers.ErrorLogger.LabViewError(
"blockUpdater_DoWork", err.Message);
191 if (OnValuesUpdated != null)
193 OnValuesUpdated(_timedOut);
208 Standard.Dae.updateRunInformation();
209 _daeUpdating =
false;
211 catch (Exception err)
213 Helpers.ErrorLogger.SeciError(
"daeUpdater_DoWork", err);
216 logStatusBlock(
false);
224 if (_statusBlock != null)
226 String tempStatus = Seci.Standard.Dae.RunStatus;
228 if (String.IsNullOrEmpty(tempStatus))
230 tempStatus =
"Unknown";
233 if (force || tempStatus.ToLower() != _statusBlock.CurrentValue.ToLower())
235 _statusBlock.CurrentValue = tempStatus;
237 _statusBlock.ForceLogForChangesOnly(DateTime.Now, Status.ShortInstrument, Standard.Dae.RunNumber);
241 catch (Exception err)
243 Helpers.ErrorLogger.LabViewError(
"daeUpdater_DoWork problem writing status file", err.Message);
255 _daeUpdating =
false;
267 logStatusBlock(
true);
269 for (
int i = 0; i < Managers.BlockMgr.Blocks.Count; ++i)
271 Managers.BlockMgr.Blocks[i].ForceLogForChangesOnly(time, Status.ShortInstrument, runNumber);
276 #region IDisposable Members
289 GC.SuppressFinalize(
this);
300 protected virtual void Dispose(
bool disposing)
305 if (_blockUpdater != null) _blockUpdater.Dispose();
306 if (_updateTimer != null) _updateTimer.Dispose();
309 _blockUpdater = null;
This class is used for storing the information for any blocks that are created and provides methods f...
Class for holding the standard run-time settings for SECI. A large percentage of the information held...
static Boolean UseDaeMonitorVI