public static PartInfo Process(PartCountEvent partCountEvent, GeneratedEvent gEvent, long _lastSequence) { if (partCountEvent.ValueType == ValueType.CAPTURE_ITEM) { return ProcessCaptureItemMethod(partCountEvent, gEvent, _lastSequence); } else if (partCountEvent.ValueType == ValueType.STATIC_INCREMENT) { return ProcessStaticIncrementMethod(partCountEvent, gEvent, _lastSequence); } return null; }
private static GeneratedEvent ProcessEvent(Event e, Instance instance) { // Process Event using InstanceData Return eventReturn = e.Process(instance); if (e.PreviousValue == null) { e.PreviousValue = e.Default.Copy(); } if (e.CurrentValue != null) { e.PreviousValue = e.CurrentValue.Copy(); e.PreviousValue.Id = e.CurrentValue.Id; } if (eventReturn != e.CurrentValue) { e.CurrentValue = eventReturn.Copy(); e.CurrentValue.ChangedTimeStamp = instance.Timestamp; e.CurrentValue.ChangedSequence = instance.Sequence; } e.CurrentValue.TimeStamp = instance.Timestamp; e.CurrentValue.Sequence = instance.Sequence; // Set Duration if (e.CurrentValue.TimeStamp > DateTime.MinValue && e.PreviousValue.TimeStamp > DateTime.MinValue) { eventReturn.Duration = (e.CurrentValue.TimeStamp - e.PreviousValue.TimeStamp).TotalSeconds; } else { eventReturn.Duration = 0; } // Create new GeneratedEvent object var result = new GeneratedEvent(); result.EventName = e.Name; result.PreviousValue = new ValueData(e.PreviousValue); result.CurrentValue = new ValueData(e.CurrentValue); result.CaptureItems.AddRange(e.CurrentValue.CaptureItems); return(result); }
public void GetSentData(EventData data) { if (data != null && data.Id != null && configuration != null) { var gec = Configuration.Get(configuration); if (gec != null) { if (data.Id == "INSTANCES") { var instances = (List <Instance>)data.Data02; var events = GeneratedEvent.Process(configuration, instances); // Send List of GeneratedEventItems to other Plugins SendGeneratedEvents(events); } } } }
private static PartInfo ProcessCaptureItemMethod(PartCountEvent partCountEvent, GeneratedEvent gEvent, long _lastSequence) { if (!string.IsNullOrEmpty(partCountEvent.CaptureItemLink)) { var captureItem = gEvent.CaptureItems.Find(x => x.Name == partCountEvent.CaptureItemLink); if (captureItem != null && captureItem.Sequence > _lastSequence) { int count = 0; int.TryParse(captureItem.Value, out count); if (count > 0) { DateTime timestamp = gEvent.CurrentValue.Timestamp; // Create new PartInfo object var info = new PartInfo(); info.Id = Guid.NewGuid().ToString(); info.Timestamp = timestamp; info.Sequence = captureItem.Sequence; // Calculate Increment Value based on CalculationType if (partCountEvent.CalculationType == CalculationType.INCREMENTAL) { info.Count = count; } else if (partCountEvent.CalculationType == CalculationType.TOTAL) { int previousCount = 0; int.TryParse(captureItem.PreviousValue, out previousCount); // If Part Count is less than or equal to stored value then assume // it has been reset and needs to be incremented the entire new amount if (count <= previousCount) info.Count = count; else info.Count = count - previousCount; } return info; } } } return null; }
private static PartInfo ProcessStaticIncrementMethod(PartCountEvent partCountEvent, GeneratedEvent gEvent, long _lastSequence) { long sequence = gEvent.CurrentValue.ChangedSequence; // Create new PartInfo object var info = new PartInfo(); info.Id = Guid.NewGuid().ToString(); info.Timestamp = gEvent.CurrentValue.Timestamp; info.Sequence = sequence; info.Count = partCountEvent.StaticIncrementValue; return info; }
private static GeneratedEvent ProcessEvent(Event e, Instance instance) { // Process Event using InstanceData Return eventReturn = e.Process(instance); if (e.PreviousValue == null) e.PreviousValue = e.Default.Copy(); if (e.CurrentValue != null) { e.PreviousValue = e.CurrentValue.Copy(); e.PreviousValue.Id = e.CurrentValue.Id; } if (eventReturn != e.CurrentValue) { e.CurrentValue = eventReturn.Copy(); e.CurrentValue.ChangedTimeStamp = instance.Timestamp; e.CurrentValue.ChangedSequence = instance.Sequence; } e.CurrentValue.TimeStamp = instance.Timestamp; e.CurrentValue.Sequence = instance.Sequence; // Set Duration if (e.CurrentValue.TimeStamp > DateTime.MinValue && e.PreviousValue.TimeStamp > DateTime.MinValue) { eventReturn.Duration = (e.CurrentValue.TimeStamp - e.PreviousValue.TimeStamp).TotalSeconds; } else { eventReturn.Duration = 0; } // Create new GeneratedEvent object var result = new GeneratedEvent(); result.EventName = e.Name; result.PreviousValue = new ValueData(e.PreviousValue); result.CurrentValue = new ValueData(e.CurrentValue); result.CaptureItems.AddRange(e.CurrentValue.CaptureItems); return result; }