/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> static void SL_ClientConnected(object sender, SocketAsyncEventArgs e) { connections = Interlocked.Increment(ref connections); Socket s = e.UserToken as Socket; System.Net.IPEndPoint ep = (System.Net.IPEndPoint)s.RemoteEndPoint; gControl.netlog.TraceInformation("New Connection : " + s.RemoteEndPoint.ToString()); LMInstrument lmi = new LMInstrument(e, ep.Port); Instruments.All.Add(lmi); // dev note: need a parallel entry in the counting parameters map on the enclosing Measurement for each instrument and it;s SR params class instance // get the status of the instrument DAQControl.ReadInstrStatus(lmi); }
public static string SuccinctDAQProcessingStatus(object o) { string s = String.Empty; if (o != null) { string ss = string.Empty; if (o is DAQControl) { DAQControl d = (DAQControl)o; ss = d.SuccinctInstrStatusString(Instruments.Active.FirstActive()); } else if (o is Measurement) { Measurement m = (Measurement)o; ss = DAQControl.MeasStatusString(m); } s += ss; } return(s); }
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; }
public HVControl(DAQControl control) { this.control = control; ctrllog = NC.App.Loggers.Logger(LMLoggers.AppSection.Control); }
/// <summary> /// Performs an assay operation. /// </summary> /// <param name="measurement">The measurement.</param> /// <param name="cancellationToken">The cancellation token to observe.</param> /// <exception cref="Ptr32Exception">An error occurred communicating with the device.</exception> protected void PerformAssay(Measurement measurement, CancellationToken cancellationToken) { try { m_logger.TraceEvent(LogLevels.Info, 0, "PTR-32[{0}]: Started assay", DeviceName); m_logger.Flush(); if (m_setvoltage) { SetVoltage(m_voltage, MaxSetVoltageTime, CancellationToken.None); } Stopwatch stopwatch = new Stopwatch(); TimeSpan duration = TimeSpan.FromSeconds(measurement.AcquireState.lm.Interval); byte[] buffer = new byte[1024 * 1024]; long total = 0; m_device.Reset(); stopwatch.Start(); m_logger.TraceEvent(LogLevels.Verbose, 11901, "{0} start", DateTime.Now.ToString()); while (stopwatch.Elapsed < duration) { cancellationToken.ThrowIfCancellationRequested(); if (m_device.Available > 0) { int bytesRead = m_device.Read(buffer, 0, buffer.Length); if (bytesRead > 0) { RDT.PassBufferToTheCounters(buffer, 0, bytesRead); total += bytesRead; } } } stopwatch.Stop(); m_logger.TraceEvent(LogLevels.Verbose, 11901, "{0} stop", DateTime.Now.ToString()); lock (m_monitor) { m_cancellationTokenSource.Dispose(); m_cancellationTokenSource = null; } m_logger.TraceEvent(LogLevels.Info, 0, "PTR-32[{0}]: Finished assay; read {1} bytes in {2}s", DeviceName, total, stopwatch.Elapsed.TotalSeconds); m_logger.Flush(); DAQControl.HandleEndOfCycleProcessing(this, new Analysis.StreamStatusBlock(@"PTR32 Done")); } catch (OperationCanceledException) { //Analysis.StreamStatusBlock ssb = new Analysis.StreamStatusBlock(@"Assay Cancelled."); //DAQControl.HandleEndOfCycleProcessing(this, ssb); m_logger.TraceEvent(LogLevels.Info, 0, "PTR-32[{0}]: Stopped assay", DeviceName); m_logger.Flush(); DAQControl.StopActiveAssayImmediately(); throw; } catch (Exception ex) { m_logger.TraceEvent(LogLevels.Error, 0, "PTR-32[{0}]: Error during assay: {1}", DeviceName, ex.Message); m_logger.TraceException(ex, true); m_logger.Flush(); DAQControl.HandleFatalGeneralError(this, ex); throw; } }