/// <summary> /// Disposes members for garbage collection /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { base.Dispose(disposing); if (m_server != null && m_server.Connected) m_server.Close(); m_server = null; if (m_tagKeyMap != null) m_tagKeyMap.Clear(); m_tagKeyMap = null; m_pi = null; m_points = null; m_pipe = null; m_measurements.Clear(); m_measurements = null; if (m_dataThread != null) { m_dataThread.Abort(); m_dataThread = null; } if (m_publishTimer != null) { m_publishTimer.Stop(); m_publishTimer.Elapsed -= m_publishTimer_Tick; m_publishTimer.Dispose(); m_publishTimer = null; } }
public Cookie(EventPipe <TParam, TResult> pipe, Func <TParam, TResult> func) { _pipe = pipe; _func = func; _pipe._funcs = _pipe._funcs.Add(func); }
static LogEvent[] PipeEvents(string input, InvalidDataHandling invalidDataHandling) { var output = new CollectingSink(); using (var source = new LogEventReader(new StringReader(input))) using (var destination = new LoggerConfiguration() .MinimumLevel.Is(LevelAlias.Minimum) .WriteTo.Sink(output) .CreateLogger()) { EventPipe.PipeEvents(source, destination, invalidDataHandling); } return(output.Events); }
/// <summary> /// Gets an observable stream for all messages of the specified type for all game objects /// </summary> /// <param name="behavior">Behavior (not used)</param> /// <typeparam name="T">Type of message to receive</typeparam> public static IObservable <T> ReceiveAll <T>(this MonoBehaviour behavior) where T : struct { return(EventPipe.Receive <T>()); }
/// <summary> /// Gets an observable stream for all messages of the specified type for all game objects /// </summary> /// <param name="behavior">Behavior (not used)</param> /// <typeparam name="T">Type of message to receive</typeparam> public static IObservable <T> ReceiveAll <T>(this Transform trans) where T : struct { return(EventPipe.Receive <T>()); }
/// <summary> /// Gets an observable stream for all messages of the specified type for all game objects /// </summary> /// <param name="behavior">Behavior (not used)</param> /// <typeparam name="T">Type of message to receive</typeparam> public static IObservable <T> ReceiveAll <T>(this GameObject go) where T : struct { return(EventPipe.Receive <T>()); }
/// <summary> /// Send a new message from the current game object /// </summary> /// <param name="trans">Current transformation</param> /// <param name="msg">Message to send</param> /// <typeparam name="T">Type of message to send</typeparam> public static void Send <T>(this MonoBehaviour behavior, T msg) where T : struct { EventPipe.Send(behavior.gameObject, msg); }
/// <summary> /// Send a new message from the current game object /// </summary> /// <param name="trans">Current transformation</param> /// <param name="msg">Message to send</param> /// <typeparam name="T">Type of message to send</typeparam> public static void Send <T>(this Transform trans, T msg) where T : struct { EventPipe.Send(trans.gameObject, msg); }
/// <summary> /// Send a new message from the current game object /// </summary> /// <param name="trans">Current transformation</param> /// <param name="msg">Message to send</param> /// <typeparam name="T">Type of message to send</typeparam> public static void Send <T>(this GameObject go, T msg) where T : struct { EventPipe.Send(go, msg); }
internal WaitForEventTypeEnumerator(EventPipe owner, Type type) { this.EventType = type; this.owner = owner; }
internal WaitForTriggerOrEventTypeEnumerator(EventPipe owner, Func <bool> trigger, Type type) { this.owner = owner; this.Trigger = trigger; this.EventType = type; }
internal WaitForEventInTypeSetEnumerator(EventPipe owner, Type[] types) { this.owner = owner; this.EventTypes = types; }
public EventListener(EventPipe <TParam, TResult> pipe) { _pipe = pipe; }
public EventCaller(EventPipe <TParam, TResult> pipe) { _pipe = pipe; }
protected override int Run() { try { var failed = false; SelfLog.Enable(m => { Console.Error.WriteLine(m); failed = true; }); var levelSwitch = new LoggingLevelSwitch(LevelAlias.Minimum); var configuration = new LoggerConfiguration() .MinimumLevel.ControlledBy(levelSwitch); foreach (var property in _enrichFeature.Properties) { configuration.Enrich.WithProperty(property.Key, property.Value); } if (_filterFeature.Filter != null) { configuration.Filter.ByIncludingOnly(_filterFeature.Filter); } if (_seqOutputFeature.SeqUrl != null) { configuration.WriteTo.Seq( _seqOutputFeature.SeqUrl, apiKey: _seqOutputFeature.SeqApiKey, compact: true, batchPostingLimit: _seqOutputFeature.BatchPostingLimit, eventBodyLimitBytes: _seqOutputFeature.EventBodyLimitBytes, controlLevelSwitch: levelSwitch); } else if (_jsonFormatFeature.UseJsonFormat) { if (_fileOutputFeature.OutputFilename != null) { configuration.AuditTo.File(new CompactJsonFormatter(), _fileOutputFeature.OutputFilename); } else { configuration.WriteTo.Console(new CompactJsonFormatter()); } } else { var template = _templateFormatFeature.OutputTemplate ?? DefaultOutputTemplate; if (_fileOutputFeature.OutputFilename != null) { // This will differ slightly from the console output until `{Message:l}` becomes available configuration.AuditTo.File( new MessageTemplateTextFormatter(template, CultureInfo.InvariantCulture), _fileOutputFeature.OutputFilename); } else { configuration.WriteTo.LiterateConsole(outputTemplate: template); } } using (var logger = configuration.CreateLogger()) using (var inputFile = _fileInputFeature.InputFilename != null ? new StreamReader(File.Open(_fileInputFeature.InputFilename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) : null) using (var reader = new LogEventReader(inputFile ?? Console.In)) { EventPipe.PipeEvents(reader, logger, _invalidDataHandlingFeature.InvalidDataHandling); } return(failed ? 1 : 0); } catch (Exception ex) { Console.Error.WriteLine(ex.Message); return(-1); } }
private void HandleNewMeasurementsRequest(MeasurementKey[] Keys) { OnStatusMessage("Received request for {0} keys...", new object[] { Keys.Count() }); if (!IsConnected) AttemptConnection(); var query = from row in DataSource.Tables["ActiveMeasurements"].AsEnumerable() from key in Keys where row["ID"].ToString().Split(':')[1] == key.ID.ToString() select new { Key = key, AlternateTag = row["ALTERNATETAG"].ToString(), PointTag = row["POINTTAG"].ToString() }; StringBuilder tagFilter = new StringBuilder(); foreach (var row in query) { string tagname = row.PointTag; if (!String.IsNullOrWhiteSpace(row.AlternateTag)) tagname = row.AlternateTag; if (!m_tagKeyMap.ContainsKey(tagname)) { m_tagKeyMap.AddOrUpdate(tagname, row.Key, (k, v) => row.Key); } if (tagFilter.Length > 0) tagFilter.Append(" OR "); tagFilter.Append(string.Format("tag='{0}'", tagname)); } m_points = m_server.GetPoints(tagFilter.ToString()); // event pipes are only applicable if enabled in connection string and this is a real time session, not playback bool useEventPipes = m_useEventPipes && StartTimeConstraint == DateTime.MinValue && StopTimeConstraint == DateTime.MaxValue; if (useEventPipes) { try { if (m_pipe != null) ((_DEventPipeEvents_Event)m_pipe).OnNewValue -= (PISDK._DEventPipeEvents_OnNewValueEventHandler)PipeOnOnNewValue; m_pipe = m_points.Data.EventPipe; ((_DEventPipeEvents_Event)m_pipe).OnNewValue += (PISDK._DEventPipeEvents_OnNewValueEventHandler)PipeOnOnNewValue; } catch (ThreadAbortException) { throw; } catch (Exception e) { useEventPipes = false; // try to run with polling instead of event pipes; OnProcessException(e); } } if (!useEventPipes) { // warn that we are going to use a different configuration here... if (m_useEventPipes) OnStatusMessage("WARNING: PI adapter switching from event pipes to polling due to error or start/stop time constraints."); // set up a new thread to do some long calls to PI and set up threads, timers, etc for polling StopGettingData(); ThreadPool.QueueUserWorkItem(StartGettingData, tagFilter); } m_useEventPipes = useEventPipes; }