public bool HistoryContainsEvent(IDeviceHistory history, IDevice device, IEventType eventType, DateTime since) { var matches = GetMatches(history, device, eventType, since); var result = matches.Any(); return(result); }
/// <summary> /// The event received from embedded. /// </summary> /// <param name="eventType"> /// The event type. /// </param> /// <param name="context"> /// The context. /// </param> private static void EventReceivedFromEmbedded(IEventType eventType, EventActionContext context) { string stringValue = Encoding.UTF8.GetString(eventType.DataContext); Console.WriteLine("---------------EVENT RECEIVED FROM EMBEDDED LIBRARY---------------"); Console.WriteLine(stringValue); }
private NetworkEvent(INetwork network, IEventType type, IEventSource source) { Network = network; Type = type; TimeStamp = DateTime.UtcNow; Source = source; }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { if ((this._parent.EventType__EmitEventAction == null)) { IEventType eventType__EmitEventActionCasted = item.As <IEventType>(); if ((eventType__EmitEventActionCasted != null)) { this._parent.EventType__EmitEventAction = eventType__EmitEventActionCasted; return; } } if ((this._parent.SourceRole__EmitEventAction == null)) { ISourceRole sourceRole__EmitEventActionCasted = item.As <ISourceRole>(); if ((sourceRole__EmitEventActionCasted != null)) { this._parent.SourceRole__EmitEventAction = sourceRole__EmitEventActionCasted; return; } } IVariableUsage inputVariableUsages__CallActionCasted = item.As <IVariableUsage>(); if ((inputVariableUsages__CallActionCasted != null)) { this._parent.InputVariableUsages__CallAction.Add(inputVariableUsages__CallActionCasted); } }
/// <summary> /// The delegate event executed by a event /// </summary> /// <param name="eventType"> /// </param> /// <param name="context"> /// EventActionContext cosa deve essere esuito /// </param> private static void delegateActionEventEmbedded(IEventType eventType, EventActionContext context) { lock (context) { try { //If embedded mode and trigger source == embeddedtrigger then not execute the internal embedded delelegate if (context.BubblingConfiguration.AssemblyClassType != typeof(GrabCaster.Framework.EmbeddedTrigger.EmbeddedTrigger)) { setEventActionEventEmbedded(eventType, context); } } catch (Exception ex) { context.BubblingConfiguration.CorrelationOverride = null; LogEngine.WriteLog( Configuration.EngineName, $"Error in {MethodBase.GetCurrentMethod().Name}", Constant.DefconOne, Constant.TaskCategoriesError, ex, EventLogEntryType.Error); } } }
public WhenDeviceEventHappensTrigger(IDevice device, IEventType deviceType, IDeviceHistory history) { _device = device; _eventType = deviceType; _history = history; _lastCheck = UpdateLastCheck(); }
public bool HistoryContainsEvent(IDeviceHistory history, IDevice device, IEventType eventType, DateTime since) { var matches = GetMatches(history, device, eventType, since); var result = matches.Any(); return result; }
internal Event(Guid eventId, Guid contextId, IEventType eventType, string eventData, DateTime createdDateTime, DateTime effectiveDateTime) { EventId = eventId; ContextId = contextId; EventType = eventType; EventData = eventData; CreatedDateTime = createdDateTime; EffectiveDateTime = effectiveDateTime; }
public void WriteEntry(string source, string message, IEventType eventType) { ITelemetryStrategy telemetryStrategy = _telemetryFactory.Strategy(eventType); telemetryStrategy.TrackEvent(source, new Dictionary <string, string> { { "message", message } }); }
public static bool Matches(this IEventType a, IEventType b) { var aType = a.GetType(); var bType = b.GetType(); var result = aType == bType; return result; }
private DeviceEvent(IDevice device, IEventType type, IEventSource source) { Device = device; Type = type; Source = source; State = device.Copy(); TimeStamp = DateTime.UtcNow; }
public static void EditJsonStream <T>(this IEventStoreConnection connection, IEventType <T> eventType) where T : class { var eventsStream = connection.ReadStreamEventsBackwardAsync(eventType.EditStreamName, 0, 1, true).Result; var lastEventNr = eventsStream.LastEventNumber; var json = Newtonsoft.Json.JsonConvert.SerializeObject(eventType.Data); var myEvent = new EventData(Guid.NewGuid(), eventType.EventType, true, Encoding.UTF8.GetBytes(json), null); connection.AppendToStreamAsync(eventType.EditStreamName, lastEventNr, myEvent).Wait(); }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { IEventType eventTypes__EventGroupCasted = item.As <IEventType>(); if ((eventTypes__EventGroupCasted != null)) { this._parent.EventTypes__EventGroup.Add(eventTypes__EventGroupCasted); } }
public static bool Matches(this IEventType a, IEventType b) { var aType = a.GetType(); var bType = b.GetType(); var result = aType == bType; return(result); }
public void WhenTheEventTypeIsConstructedItIsPopulatedAsExpected() { var expectedVersion = new Version(4, 2, 1, 2); var expectedType = Guid.NewGuid().ToString(); _target = new EventType(expectedType, expectedVersion); Assert.Same(expectedVersion, _target.Version); Assert.Equal(expectedType, _target.Name); }
// The algorithm implemented here splits the list of messages according to the // batch tuning parameters (number of bytes and number of messages) because the // list is randomly ordered it is possible to have non-optimal batches. It would // be a slight optimization to order by increasing size and then cut the batches. private void PrepareMessageAndSubmit(IEventType eventType, ActionContext context) { Trace.WriteLine("[GrabCasterReceiverEndpoint] PrepareMessageAndSubmit called"); int maxBatchSize = this.properties.MaximumBatchSize; int maximumNumberOfMessages = this.properties.MaximumNumberOfMessages; long bytesInBatch = 0; IBaseMessage msg = CreateMessage(eventType, context); if (null == msg) { return; } else { batchMessages.Add(new BatchMessage(msg, context.BubblingObjectBag.MessageId, BatchOperationType.Submit)); // keep a running total for the current batch } bytesInBatch += eventType.DataContext.Length; // zero for the value means infinite bool messagesCountExceeded = ((0 != maximumNumberOfMessages) && (batchMessages.Count >= maximumNumberOfMessages)); bool byteCountExceeded = ((0 != maxBatchSize) && (bytesInBatch > maxBatchSize)); if (messagesCountExceeded || byteCountExceeded) { // check if we have been asked to stop - if so don't start another batch if (this.controlledTermination.TerminateCalled) { return; } // execute the batch this.SubmitMessages(batchMessages); // reset the running totals bytesInBatch = 0; batchMessages.Clear(); } // check if we have been asked to stop - if so don't start another batch if (this.controlledTermination.TerminateCalled) { return; } // end of message list - one final batch to do if (batchMessages.Count > 0) { this.SubmitMessages(batchMessages); } }
/// <summary> /// Removes the given item from the collection /// </summary> /// <returns>True, if the item was removed, otherwise False</returns> /// <param name="item">The item that should be removed</param> public override bool Remove(IModelElement item) { IEventType eventTypeItem = item.As <IEventType>(); if (((eventTypeItem != null) && this._parent.EventTypes__EventGroup.Remove(eventTypeItem))) { return(true); } return(false); }
public IEventEvaluator[] Filter <TView>(IEventType eventType) where TView : class, IView { return(_registeredEvaluators .Where(registeredEvaluator => EvaluateEventView <TView>(registeredEvaluator.ViewType) && EvaluateEventName(eventType, registeredEvaluator.Name) && EvaluateVersionInRange(eventType, registeredEvaluator.MinimumVersion, registeredEvaluator.MaximumVersion)) .Select(t => t.Evaluator) .ToArray()); }
/// <summary> /// Queues the event to be published in the next update /// </summary> /// <param name="e">E.</param> public void Publish(IEventType e) { if (e.FireImmediately) { TriggerEvent(e); } else { eventQueue.Enqueue(e); } }
/// <summary> /// The event received from embedded. /// </summary> /// <param name="eventType"> /// The event type. /// </param> /// <param name="context"> /// The context. /// </param> private void EventReceivedFromEmbedded(IEventType eventType, ActionContext context) { string stringValue = Encoding.UTF8.GetString(eventType.DataContext); System.Diagnostics.Debug.WriteLine("---------------EVENT RECEIVED FROM EMBEDDED LIBRARY---------------"); PrepareMessageAndSubmit(eventType, context); Trace.WriteLine("---------------EVENT RECEIVED FROM EMBEDDED LIBRARY---------------"); Trace.WriteLine(stringValue); CheckErrorThreshold(); }
void Start() { // Init Hands hands_ = new HandPair(); hands_.L = new Hand(); hands_.R = new Hand(); hands_.empty = true; // Init EventType lastEventType_ = IEventType.NoAction; currentEventType_ = IEventType.NoAction; }
protected virtual IEnumerable<IDeviceEvent> GetMatches(IDeviceHistory history, IDevice device, IEventType eventType, DateTime since) { //TODO: save the last inspected node instead of using a timestamp var matches = history.GetMatches( x => x.TimeStamp >= since, x => x.Device.Equals(device), x => x.Type.Matches(eventType) ); return matches; }
// Check Is Wait Event public bool IsWaitEvent(IEventType eT) { if (eT == IEventType.Wait_NavigationOrSelectionOrCancel || eT == IEventType.Wait_CancelOrScale) { return(true); } else { return(false); } }
public ITelemetryStrategy Strategy(IEventType eventType) { foreach (ITelemetryStrategy strategy in _strategies) { if (!strategy.Responsible(eventType)) { continue; } return(strategy); } return(_strategies.Last()); }
private void EventReceived(object sender, IEventType ev) { if (isRecording && !EventHandlers.waitingforplayers) { MessagePack.MessagePackSerializer.Serialize <IEventType>(recordingStream, new DelayData() { DelayTime = timeElapsed }); timeElapsed = 0; } MessagePack.MessagePackSerializer.Serialize <IEventType>(recordingStream, ev); recordingStream.Flush(); }
/// <summary> /// Recycle the specified object /// </summary> /// <param name="obj">Object.</param> public void Recycle(IEventType obj) { Type type = obj.GetType(); if (!poolCollection.ContainsKey(type)) { #if UNITY_EDITOR Debug.LogWarning("[EventBuilder]: " + type + " pool not found"); #endif return; } poolCollection [type].Recycle(obj); }
// Update is called once per frame void FixedUpdate() { m_InteractionView.updateRotation(new Vector3(1, 1, 1), new Vector3(1, 1, 1)); // Updata Frame UpdateAndMergeFrame(); // Check Current Event m_EventModel.CheckCurrentEvent(currentEventType_, lastEventType_, hands_, m_ControllBall_L, m_ControllBall_R); // Do Current Event m_EventModel.DoCurrentEvent(currentEventType_, lastEventType_, hands_, m_ControllBall_L, m_ControllBall_R); // Change Frame lastEventType_ = currentEventType_; }
//public static void AddNewJsonStream(this EventStoreConnectionManager connectionManager, string eventType, object model) //{ // var json = Newtonsoft.Json.JsonConvert.SerializeObject(model); // var myEvent = new EventData(Guid.NewGuid(), eventType, true, Encoding.UTF8.GetBytes(json), null); // connectionManager.Connection.AppendToStreamAsync("arm", -1, myEvent).Wait(); //} public static T AddNewJsonStream <T>(this IEventStoreConnection connection, IEventType <T> eventType) where T : class { if (!StreamExits(connection, eventType.StreamName)) { var json = Newtonsoft.Json.JsonConvert.SerializeObject(eventType.Data); var myEvent = new EventData(Guid.NewGuid(), eventType.EventType, true, Encoding.UTF8.GetBytes(json), null); connection.AppendToStreamAsync(eventType.StreamName, -1, myEvent).Wait(); return(null); //return eventType.Data; } else { //TODO Implement Edit var item = GetLastEvent <T>(connection, eventType.StreamName); return(item); } }
public void CheckCurrentEvent(IEventType CurrentEventType, IEventType LastEventType, HandPair hands, HitBall m_ControllBall_L, HitBall m_ControllBall_R) { switch (CurrentEventType) { case IEventType.NoAction: break; case IEventType.Navigation_RayHit: if (LastEventType == CurrentEventType) { CurrentEventType = m_ControllBall_R.radius < 0.15 ? IEventType.Navigation_RayHit : IEventType.Selection_Single; } break; case IEventType.Selection_Single: if (LastEventType == CurrentEventType) { CurrentEventType = m_ControllBall_R.radius < 0.15 ? IEventType.Navigation_RayHit : IEventType.Selection_Single; } break; case IEventType.Manipulation_Rotation: if (LastEventType == CurrentEventType) { CurrentEventType = m_ControllBall_L.radius < 0.15 ? IEventType.Manipulation_Rotation : IEventType.Manipulation_Stroll; } break; case IEventType.Manipulation_Stroll: if (LastEventType == CurrentEventType) { CurrentEventType = m_ControllBall_L.radius < 0.15 ? IEventType.Manipulation_Rotation : IEventType.Manipulation_Stroll; } break; default: break; } }
/// <summary> /// Processes all the events in the eventQueue /// </summary> public void Update() { while (this.eventQueue.Count > 0) { IEventType evnt = this.eventQueue.Dequeue(); Action <IEventType> subscribers; if (collection.TryGetValue(evnt.GetType(), out subscribers)) { Debug.Log("[EventAggregator]: Processing event: " + evnt); subscribers.Invoke(evnt); } else { Debug.LogError("[EventAggregator]: No subscriber for eventtype: " + evnt.GetType()); } evnt = null; // marking it for GC } }
private IBaseMessage CreateMessage(IEventType eventType, ActionContext contextItem) { Stream fs; fs = new MemoryStream(eventType.DataContext); IBaseMessagePart part = this.messageFactory.CreateMessagePart(); part.Data = fs; IBaseMessage message = this.messageFactory.CreateMessage(); message.AddPart(MESSAGE_BODY, part, true); SystemMessageContext context = new SystemMessageContext(message.Context); context.InboundTransportType = this.transportType; context.InboundTransportLocation = this.properties.Uri; //Write/Promote any adapter specific properties on the message context message.Context.Write(PROP_REMOTEMESSAGEID, PROP_NAMESPACE, contextItem.BubblingObjectBag.MessageId); return(message); }
private void TriggerEvent(IEventType evnt) { Debug.Assert(evnt != null, "[EventAggregator]: event cannot be null"); Action <IEventType> subscribers; if (collection.TryGetValue(evnt.TypeOf, out subscribers)) { // Debug.Log ("[EventAggregator]: Processing event: " + evnt); subscribers.Invoke(evnt); } else { #if UNITY_EDITOR Debug.LogWarning("[EventAggregator]: No subscriber for eventtype: " + evnt.GetType()); #endif } EventBuilder.Instance.Recycle(evnt); evnt = null; // marking it for GC }
/// <summary> /// The delegate event executed by a event /// </summary> /// <param name="eventType"> /// </param> /// <param name="context"> /// EventActionContext cosa deve essere restituito /// </param> private static void delegateActionEventEmbedded(IEventType eventType, ActionContext context) { try { //If embedded mode and trigger source == embeddedtrigger then not execute the internal embedded delelegate //todo optimization qui controllavo se chi ha chiamato levento e un trigger? forse meglio usare un approccio diverso, ho rimosso il check fdel trigger, sembra inutile // if (context.BubblingObjectBag.AssemblyClassType != typeof(GrabCaster.Framework.EmbeddedTrigger.EmbeddedTrigger)) setEventActionEventEmbedded(eventType, context); } catch (Exception ex) { context.BubblingObjectBag.CorrelationOverride = null; LogEngine.WriteLog( ConfigurationBag.EngineName, $"Error in {MethodBase.GetCurrentMethod().Name}", Constant.LogLevelError, Constant.TaskCategoriesError, ex, Constant.LogLevelError); } }
public void SetEventType(IEventType et) { currentEventType_ = et; }
public void RegisterEventType(IEventType eventType) { _types.Add(eventType.Id, eventType); }
public void Log(Item item, IEventType type, string note = "") { Log(item, type.Id, type.Color, type.Label, note); }
public WhenDeviceEventHappenedWithinTimespanTrigger(IDevice device, IEventType deviceType, TimeSpan timeSpan, IDeviceHistory history) : base(device, deviceType, history) { _timeSpan = timeSpan; }