public Measurement(MeasurementTuple newMT, AssaySelector.MeasurementOption at, LMLoggers.LognLM logger) { mt = newMT; this.logger = logger; mid = new MeasId(at); InitMisc(); }
public TalkToLMMMM(LMLoggers.LognLM logger) { cmdprocessor = new LMMMLingo(); // same for cfg copy commlog = logger; cmdprocessor.CommLog = logger; }
public virtual void Init(LMLoggers.LognLM datalogger, LMLoggers.LognLM alogger) { //cfg = config; this.logger = datalogger; this.analogger = alogger; state.logger = datalogger; }
bool PrepList(List <AssaySelector.MeasurementOption> filters, Detector det) { if (Goal == EndGoal.Report) { if (LMOnly) // LMOnly { mlist.RemoveAll(EmptyCSVFile); // cull those without LM CSV results } else { mlist.RemoveAll(EmptyINCC5File); // cull those with traditional INCC5 results } } ctrllog = N.App.Loggers.Logger(LMLoggers.AppSection.Control); if (mlist.Count == 0) { string msg = string.Format("No {0}measurements for {1} found.", TypeTextFragment(filters), det == null ? "any" : det.Id.DetectorId); MessageBox.Show(msg, "WARNING"); return(false); } LoadList(filters); if (Goal == EndGoal.Report || Goal == EndGoal.Reanalysis || Goal == EndGoal.Transfer) // it is for a named detector so elide the detector column { listView1.Columns[1].Width = 0; } if (!AllMeas) { listView1.Columns[0].Width = 0; } if (filters.Contains(AssaySelector.MeasurementOption.rates)) // show item id { listView1.Columns[2].Width = 0; } if (filters.Contains(AssaySelector.MeasurementOption.normalization)) { listView1.Columns[2].Width = 0; listView1.Columns[3].Width = 0; } if (filters.Contains(AssaySelector.MeasurementOption.background)) // NEXT: add configuration active or passive column { listView1.Columns[2].Width = 0; listView1.Columns[3].Width = 0; } foreach (AssaySelector.MeasurementOption mo in filters) { if (!AssaySelector.ForMass(mo) && !mo.IsWildCard()) { listView1.Columns[7].Width = 0; // material column } } if (Goal == EndGoal.Reanalysis) { listView1.Columns[0].Text = "Id"; listView1.Columns[0].Width = 43; } return(true); }
public IDDMeasurementList(string filter = "") { InitializeComponent(); this.Text = filter == ""?"All Measurements":filter + " Measurements"; Detector det = Integ.GetCurrentAcquireDetector(); mlist = NC.App.DB.MeasurementsFor(det, filter); mlist.RemoveAll(EmptyFile); ctrllog = NC.App.Loggers.Logger(LMLoggers.AppSection.Control); foreach (Measurement m in mlist) { string ItemWithNumber = string.IsNullOrEmpty(m.MeasurementId.Item.item) ? "Empty" : m.AcquireState.ItemId.item; if (Path.GetFileName(m.MeasurementId.FileName).Contains("_")) { //Lameness alert to display subsequent reanalysis number...... hn 9.21.2015 ItemWithNumber += "(" + Path.GetFileName(m.MeasurementId.FileName).Substring(Path.GetFileName(m.MeasurementId.FileName).IndexOf('_') + 1, 2) + ")"; } ListViewItem lvi = new ListViewItem(new string[] { ItemWithNumber, String.IsNullOrEmpty(m.AcquireState.stratum_id.Name) ? "Empty" : m.AcquireState.stratum_id.Name, m.MeasDate.DateTime.ToString("MM.dd.yy"), m.MeasDate.DateTime.ToString("HH:mm:ss") }); listView1.Items.Add(lvi); } if (mlist.Count == 0) { string msg = string.Format("There were no measurements for {0} of type {1} found.", det.Id.DetectorId, filter == "Rates"?"Rates Only": filter); MessageBox.Show(msg, "WARNING"); } }
public Measurement(AssaySelector.MeasurementOption at) { mt = new MeasurementTuple(); this.logger = null; mid = new MeasId(at); InitMisc(); }
void SpecialPrepThreadOp(object sender, DoWorkEventArgs ea) { Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; try { List <NCCTransfer.INCCKnew.TransferSummary> x = null; bool ok = PrepTransferProcessing(ref x, NC.App.Opstate.CancelStopAbort.LinkedCancelStopAbortToken); if (ok && x.Count > 0) { ea.Result = x; // save the constructed list if the operation was not canceled or not a measurement xfer, o.w. Result is a bool } else { ea.Result = ok; } NC.App.Opstate.SOH = OperatingState.Stopped; } catch (Exception e) { NC.App.Opstate.SOH = OperatingState.Trouble; LMLoggers.LognLM applog = NC.App.Logger(LMLoggers.AppSection.App); applog.TraceException(e, true); applog.EmitFatalErrorMsg(); } finally { NC.App.Opstate.ResetTokens(); } }
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(); }
public override void Init(LMLoggers.LognLM datalog, LMLoggers.LognLM alog) { if (RDT == null) { RDT = new SRCycleDataTransform(); // only using the synch point for now RDT.Init(datalog == null ? datalog : NC.App.Loggers.Logger(LMLoggers.AppSection.Data), alog == null ? alog : NC.App.Loggers.Logger(LMLoggers.AppSection.Analysis)); } }
public INeutronDataFile file; // output only public override void Init(LMLoggers.LognLM datalog, LMLoggers.LognLM alog) { if (RDT == null) { RDT = new LMRawDataTransform(); RDT.Init(datalog == null ? NC.App.Loggers.Logger(LMLoggers.AppSection.Data) : datalog, alog == null ? NC.App.Loggers.Logger(LMLoggers.AppSection.Analysis) : alog); } }
public void Close() { NC.App.Opstate.SOH = NCC.OperatingState.Stopped; NC.App.Config.RetainChanges(); LMLoggers.LognLM applog = NC.App.Logger(LMLoggers.AppSection.App); applog.TraceInformation("==== Exiting " + DateTimeOffset.Now.ToString("MMM dd yyy HH:mm:ss.ff K") + " " + NC.App.Name + " . . ."); NC.App.Loggers.Flush(); //DisconnectUILogger = true; }
internal INeutronDataFile PrepFile(string prefix, int idx, LMLoggers.LognLM collog) { if (!NC.App.AppContext.LiveFileWrite) { return(null); } file.GenName(prefix, idx); // dev note: good to provide external config approach to specify output file pattern file.CreateForWriting(); return(file); }
/*============================================================================ * * function name: SRControl() et al. from takedata.cpp * * purpose: acquire a set of shift register data (measurement). * * return value: SUCCESS/FAIL/MEAS_ABORTED/SR_FAIL/CHECKSUM_FAIL/ACC_SNGL_FAIL * * special notes: * * revision history: * * date author revision * ---- ------ -------- * 12/09/93 Bill Harker created * 03/29/11 Frank Black reimplemented in C# *============================================================================*/ public SRControl(int identifyingNumber, LMLoggers.LognLM log, Measurement meas, Detector det) { this.log = log; this.identifyingNumber = identifyingNumber; LastSRStatus = sr_h.SR_SUCCESS; LastMeasStatus = SR.SUCCESS; SaveOnTerminate = true; this.meas = meas; this.detector = det; }
/// <summary> /// Initializes the instrument. /// </summary> /// <param name="dataLog">The data log.</param> /// <param name="analysisLog">The analysis log.</param> public override void Init(LMLoggers.LognLM dataLog, LMLoggers.LognLM analysisLog) { if (RDT == null) { RDT = new Analysis.Ptr32RawDataTransform(); RDT.Init( (dataLog != null) ? dataLog : NC.App.Logger(LMLoggers.AppSection.Data), (analysisLog != null) ? analysisLog : NC.App.Logger(LMLoggers.AppSection.Analysis)); } }
public AnalysisDefs.RateResult GetResult(LMLoggers.LognLM log) { AnalysisDefs.RateResult result; RateAccumulator aBlock; UInt32 i, j, blockOffset, index; result = new AnalysisDefs.RateResult(RawAnalysisProperties.ChannelCount); try { result.gateWidthInTics = this.gateWidth; result.numCompletedGates = this.presentDataZeroGateIndexOffset + this.presentData.numCompletedGates; result.neutronsPerGate = new UInt32[result.numCompletedGates]; result.neutronsPerGatePerChannel = new UInt32[result.numCompletedGates][]; aBlock = this.gateStack; blockOffset = 0; //copy data from all but the last block while (aBlock.next != null) { for (i = 0; i < RawAnalysisProperties.rateGatesPerAccumulator; i++) { index = i + blockOffset; result.neutronsPerGate[index] = aBlock.neutronsPerGate[i]; result.neutronsPerGatePerChannel[index] = new UInt32[RawAnalysisProperties.ChannelCount]; for (j = 0; j < RawAnalysisProperties.ChannelCount; j++) { result.neutronsPerGatePerChannel[index][j] = aBlock.neutronsPerGatePerChannel[i][j]; } } blockOffset += RawAnalysisProperties.rateGatesPerAccumulator; aBlock = aBlock.next; } //copy data from the last block for (i = 0; i < aBlock.numCompletedGates; i++) { index = i + blockOffset; result.neutronsPerGate[index] = aBlock.neutronsPerGate[i]; result.neutronsPerGatePerChannel[index] = new UInt32[RawAnalysisProperties.ChannelCount]; for (j = 0; j < RawAnalysisProperties.ChannelCount; j++) { result.neutronsPerGatePerChannel[index][j] = aBlock.neutronsPerGatePerChannel[i][j]; } } } catch (System.OutOfMemoryException oom) { GC.Collect(); if (log != null) { log.TraceException(oom); } } return(result); }
public Cycle(LMLoggers.LognLM logger = null) { // Raw counts aka totals singles = new VTuple(); dsid = new DataSourceIdentifier(); qcstatus = new QCStatusMap(); countresults = new CountingResults(); daqStatus = CycleDAQStatus.None; this.logger = logger; hitsPerChn = new double[NC.ChannelCount]; }
void UpdateGUIWithNewdata() { if (lawg == null) { lawg = NC.App.Logger(LMLoggers.AppSection.App); } if (lawg.ShouldTrace(LogLevels.Verbose)) { lawg.TS.TraceEvent((System.Diagnostics.TraceEventType)LogLevels.Verbose, 0, "$$$"); } }
bool PrepList() { ctrllog = N.App.Loggers.Logger(LMLoggers.AppSection.Control); if ((IsIso && ilist.Count == 0) || (!IsIso && cilist.Count == 0)) { string msg = string.Format("No isotopics found."); MessageBox.Show(msg, "WARNING"); return(false); } LoadList(); return(true); }
public void SetupEventHandlers() { LMLoggers.LognLM applog = NC.App.Loggers.Logger(LMLoggers.AppSection.App); /// set up the 7 magic event handlers /// here I have a base handler that does the same thing for every event (writes a string to the log) SetEventHandler(ActionEvents.EventType.PreAction, (object o) => { string s = FileCtrl.LoggableFileProcessingStatus(ActionEvents.EventType.PreAction, applog, LogLevels.Verbose, o); }); SetEventHandler(ActionEvents.EventType.ActionPrep, (object o) => { string s = FileCtrl.LoggableFileProcessingStatus(ActionEvents.EventType.ActionPrep, applog, LogLevels.Verbose, o); }); SetEventHandler(ActionEvents.EventType.ActionStart, (object o) => { string s = FileCtrl.LoggableFileProcessingStatus(ActionEvents.EventType.ActionStart, applog, LogLevels.Verbose, o); }); SetEventHandler(ActionEvents.EventType.ActionInProgress, (object o) => { string s = FileCtrl.LoggableFileProcessingStatus(ActionEvents.EventType.ActionInProgress, applog, LogLevels.Verbose, o); }); SetEventHandler(ActionEvents.EventType.ActionStop, (object o) => { string s = FileCtrl.LoggableFileProcessingStatus(ActionEvents.EventType.ActionStop, applog, LogLevels.Warning, o); }); SetEventHandler(ActionEvents.EventType.ActionCancel, (object o) => { string s = FileCtrl.LoggableFileProcessingStatus(ActionEvents.EventType.ActionCancel, applog, LogLevels.Warning, o); }); SetEventHandler(ActionEvents.EventType.ActionFinished, (object o) => { FileCtrl f = (FileCtrl)o; if (o == null) { String s = "Finished: SOH " + NC.App.Opstate.SOH + " but no processing occurred"; applog.TraceEvent(LogLevels.Verbose, FileCtrl.logid[ActionEvents.EventType.ActionFinished], s); } else { FileCtrl.LoggableFileProcessingStatus(ActionEvents.EventType.ActionFinished, applog, LogLevels.Verbose, o); } NC.App.Opstate.SOH = NCC.OperatingState.Stopped; // in case we got here after a Cancel NC.App.Loggers.Flush(); }); NC.App.Opstate.SOH = NCC.OperatingState.Stopped; }
static void GCCollect() { LMLoggers.LognLM log = NC.App.Loggers.Logger(LMLoggers.AppSection.Control); long mem = GC.GetTotalMemory(false); log.TraceEvent(LogLevels.Verbose, 4255, "Total GC Memory is {0:N0}Kb", mem / 1024L); log.TraceEvent(LogLevels.Verbose, 4248, "GC now"); GC.Collect(); GC.WaitForPendingFinalizers(); log.TraceEvent(LogLevels.Verbose, 4284, "GC complete"); mem = GC.GetTotalMemory(true); log.TraceEvent(LogLevels.Verbose, 4255, "Total GC Memory now {0:N0}Kb", mem / 1024L); }
void ThreadOp(object sender, DoWorkEventArgs ea) { try { base.StartAction(); Run(); } catch (Exception e) { NC.App.Opstate.SOH = NCC.OperatingState.Trouble; LMLoggers.LognLM applog = NC.App.Logger(LMLoggers.AppSection.App); applog.TraceException(e, true); applog.EmitFatalErrorMsg(); } base.Cleanup(); }
/// <summary> /// Extract root path from INCC5 incc.ini file, and use that path to construct 3 new paths for use by the iRAP software. /// Assumes iRAP runtime directory structure (data and output directories). /// </summary> /// <param name="ctrllog">log handle for error output</param> /// <returns>paths, non-null empty array if no INCC5 in file is used, or /// an array of 3 paths, 0: common input path, 1: data path, 2: log file path</returns> static public string[] ProcessINCC5IniFile(LMLoggers.LognLM ctrllog) { string [] paths = new string[] { string.Empty }; if (!NC.App.AppContext.UseINCC5Ini) { return(paths); } string filename = System.IO.Path.Combine(NC.App.AppContext.INCC5IniLoc, "incc.ini"); if (!System.IO.File.Exists(filename)) { if (ctrllog != null) { ctrllog.TraceEvent(LogLevels.Warning, 112, "INCC5 ini file does not exist or cannot be opened: " + filename); } return(paths); } string inputpath = string.Empty; using (System.IO.StreamReader sr = new System.IO.StreamReader(filename)) { string line; // Read lines from the file until the end of the file is reached or the relevant tag is found while ((line = sr.ReadLine()) != null) { string tline = line.TrimStart(); if (tline.StartsWith(@"//") || tline.StartsWith(@"#")) { continue; } if (tline.TrimStart().StartsWith("RT_COMMON_DATABASE_PATH")) // lolz { string[] otkens = line.Split(); inputpath = otkens.Length > 1 ? otkens[1] : string.Empty; break; } } } if (!string.IsNullOrEmpty(inputpath)) { System.IO.DirectoryInfo parentpath = System.IO.Directory.GetParent(inputpath.TrimEnd(new char[] { '\\', '/' })); paths = new string[] { inputpath, // as specified in the ini file entry System.IO.Path.Combine(System.IO.Path.GetFullPath("./"), @"Data"), // todo: hard-coded path from examples in iRAP, but could be wrong System.IO.Path.Combine(parentpath.FullName, @"output") }; // log file goes into the final sweep output path } return(paths); }
public DAQControl(bool usingGui) { gui = usingGui; gControl = this; applog = NC.App.Loggers.Logger(LMLoggers.AppSection.App); collog = NC.App.Loggers.Logger(LMLoggers.AppSection.Collect); ctrllog = NC.App.Loggers.Logger(LMLoggers.AppSection.Control); datalog = NC.App.Loggers.Logger(LMLoggers.AppSection.Data); // The state was set on cmd line prior to exec here, and it still is, so must upcast to an Assay instance NC.App.Opstate = new AssayState(NC.App.Opstate); LMMMComm = LMMMComm ?? new TalkToLMMMM(collog); // a singleton, modern syntax just for fun CurState.SOH = NCC.OperatingState.Starting; }
void ThreadOp(object sender, DoWorkEventArgs ea) { Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; try { base.StartAction(); Run(); EndCommentCheck(); } catch (Exception e) { NC.App.Opstate.SOH = OperatingState.Trouble; LMLoggers.LognLM applog = NC.App.Logger(LMLoggers.AppSection.App); applog.TraceException(e, true); applog.EmitFatalErrorMsg(); } Cleanup(); }
void ThreadOp(object sender, DoWorkEventArgs ea) { Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; try { base.StartAction(); Run(); EndCommentCheck(); // devnote: (difficult code refactoring) move report generation here to include the optional ending comment in the generated text files } catch (Exception e) { NC.App.Opstate.SOH = OperatingState.Trouble; LMLoggers.LognLM applog = NC.App.Logger(LMLoggers.AppSection.App); applog.TraceException(e, true); applog.EmitFatalErrorMsg(); } Cleanup(); }
public new void Run() { try { switch (NC.App.Opstate.Action) // these are the actions available from the GUI only { case NCCAction.Discover: FireEvent(EventType.PreAction, this); ConnectWithRetries(false, 3); ApplyInstrumentSettings(); FireEvent(EventType.ActionFinished, this); break; case NCCAction.HVCalibration: FireEvent(EventType.PreAction, this); ConnectWithRetries(false, 3); ApplyInstrumentSettings(); HVCoreOp(); DisconnectInstruments(); FireEvent(EventType.ActionFinished, this); break; case NCCAction.Assay: FireEvent(EventType.PreAction, this); ConnectWithRetries(false, 3); ApplyInstrumentSettings(); AssayCoreOp(); DisconnectInstruments(); FireEvent(EventType.ActionFinished, this); break; } NC.App.Loggers.Flush(); NC.App.Opstate.SOH = OperatingState.Stopped; } catch (Exception e) { NC.App.Opstate.SOH = OperatingState.Trouble; LMLoggers.LognLM applog = NC.App.Logger(LMLoggers.AppSection.App); applog.TraceException(e, true); applog.EmitFatalErrorMsg(); FireEvent(EventType.ActionFinished, this); } }
public Cycle(Cycle copyFrom) { // Raw counts aka totals singles = new VTuple(copyFrom.singles); dsid = new DataSourceIdentifier(copyFrom.dsid); qcstatus = new QCStatusMap(); foreach (KeyValuePair <Multiplicity, QCStatus> kvp in copyFrom.qcstatus) { qcstatus.Add(kvp.Key, kvp.Value); } countresults = new CountingResults(); foreach (KeyValuePair <SpecificCountingAnalyzerParams, object> cr in copyFrom.countresults) { countresults.Add(cr.Key, cr.Value); } daqStatus = CycleDAQStatus.None; ts = copyFrom.TS; this.logger = null; hitsPerChn = new double[NC.ChannelCount]; }
public IDDReviewAssayMeas(string filter = "Verification") { InitializeComponent(); this.Text = "Verification Measurements"; Detector det = Integ.GetCurrentAcquireDetector(); mlist = NC.App.DB.MeasurementsFor(det, filter); mlist.RemoveAll(EmptyFile); ctrllog = NC.App.Loggers.Logger(LMLoggers.AppSection.Control); foreach (Measurement m in mlist) { ListViewItem lvi = new ListViewItem(new string[] { String.IsNullOrEmpty(m.MeasurementId.Item.item) ? "Empty" : m.MeasurementId.Item.item, String.IsNullOrEmpty(m.AcquireState.stratum_id.Name) ? "Empty" : m.AcquireState.stratum_id.Name, m.MeasOption.ToString(), m.MeasDate.DateTime.ToString("MM.dd.yy"), m.MeasDate.DateTime.ToString("HH:mm:ss") }); listView1.Items.Add(lvi); } if (mlist.Count == 0) { MessageBox.Show("There are no Verification Measurements found in the database.", "WARNING"); this.DialogResult = DialogResult.Abort; } }
public static string LoggableDAQProcessingStatus(EventType EH, LMLoggers.LognLM log, LogLevels lvl, object o) { string s = String.Empty; if (o != null) { string ss = string.Empty; if (o is DAQControl) { DAQControl d = (DAQControl)o; ss = d.InstrStatusString(Instruments.Active.FirstActive(), true); } else if (o is Measurement) { Measurement m = (Measurement)o; ss = DAQControl.MeasStatusString(m); } s += ss; } log.TraceEvent(lvl, DAQControl.logid[EH], s); return(s); // just in case it could be of further use }
public DAQControl(MLMEmulation.IEmulatorDiversion emu, bool usingGui) { gui = usingGui; gControl = this; applog = NC.App.Loggers.Logger(LMLoggers.AppSection.App); collog = NC.App.Loggers.Logger(LMLoggers.AppSection.Collect); ctrllog = NC.App.Loggers.Logger(LMLoggers.AppSection.Control); netlog = NC.App.Loggers.Logger(LMLoggers.AppSection.Net); datalog = NC.App.Loggers.Logger(LMLoggers.AppSection.Data); // JFL was set on cmd line prior to exec here, and it still is, upcast to an Assay instance NC.App.Opstate = new AssayState(NC.App.Opstate); LMMMComm = LMMMComm ?? new TalkToLMMMM(NC.App.Loggers.Logger(LMLoggers.AppSection.LMComm)); // a singleton emu.SetLogger(NC.App.Loggers.Logger(LMLoggers.AppSection.LMComm)); LMMMComm.EmulatorInstance = emu; CurState.SOH = NCC.OperatingState.Starting; }