public List <EventData> CreateSamples(long millis, bool waitScan) { if (ActivityMode != ActivityMode.Ready) { return((Cones == null) ? new List <EventData>() : Cones.Select(c => c.ToEventData(millis)).ToList()); } else { // get a data point for this time var data = _ActivityData?.FirstOrDefault(); if (data != null) { data.Timestamp = millis; } // need to generate a new path if ((State != ActivityState.Waiting) && (data == null) && (millis > _MaxMillis)) { GeneratePath(millis, waitScan); data = _ActivityData?.FirstOrDefault(d => (d.Timestamp >= millis - 100) && (d.Timestamp <= millis)); } // return data var outList = new List <EventData>(); foreach (var tag in _Tags) { if ((data != null) && (_SelectedTag != null) && (tag == _SelectedTag)) { // the in-use tag moves tag.X = data.X; tag.Y = data.Y; tag.Z = data.Z; tag.V = data.V; tag.R = data.R; outList.Add(new EventData { Timestamp = data.Timestamp, TagId = tag.TagId, X = data.X, Y = data.Y, V = data.V, R = data.R }); } } // remove data point from list if ((_ActivityData != null) && (data != null)) { _ActivityData.Remove(data); } return(outList); } }
private void createConesRec(Dictionary <int, Cone> ComponentConeDic, Gate Component) { if (ComponentConeDic.ContainsKey(Component.Id)) { return; } Cone cone = null; if (Component.Output.OutputComponents == null || Component.Output.OutputComponents.Count == 0) { return; } foreach (Gate g in Component.Output.OutputComponents) { createConesRec(ComponentConeDic, g); if (ComponentConeDic.ContainsKey(g.Id)) { if (cone == null) { cone = ComponentConeDic[g.Id]; } else if (cone.Id != ComponentConeDic[g.Id].Id) { cone = new Cone(Component.Id); cone.Output = Component.Output; Cones.Add(cone);// cone.Order = Component.Order; break; } } } if (cone != null) { ComponentConeDic.Add(Component.Id, cone); cone.cone.AddComponent(Component); } }
public void createCones() { if (Cones == null || Cones.Count > 0) { return; } Dictionary <int, Cone> ComponentConeDic = new Dictionary <int, Cone>(); //int Component_id-> Model cone foreach (Wire wire in Output) { Cone cone = new Cone(wire.InputComponent.Id); cone.Output = wire; cone.Order = wire.InputComponent.Order; cone.cone.AddComponent(wire.InputComponent); //if wire.InputComponent==null? ComponentConeDic.Add(wire.InputComponent.Id, cone); Cones.Add(cone); } foreach (Wire wire in Input) { if (wire.OutputComponents == null || wire.OutputComponents.Count == 0) { continue; } foreach (Gate Component in wire.OutputComponents) { createConesRec(ComponentConeDic, Component); if (!ComponentConeDic.ContainsKey(Component.Id)) { Cone newcone = new Cone(Component.Id); newcone.Output = Component.Output; Cones.Add(newcone);// ComponentConeDic.Add(Component.Id, newcone); newcone.cone.AddComponent(Component); newcone.Order = Component.Order; if (Component is MultipleInputComponent) { ComponentConeDic[Component.Id].cone.Input.AddRange(((MultipleInputComponent)Component).Input); } else if (Component is OneInputComponent) { ComponentConeDic[Component.Id].cone.Input.Add(((OneInputComponent)Component).Input1); } } else { ComponentConeDic[Component.Id].cone.Input.Add(wire); } } } //cones input foreach (Cone cone in Cones) { if (cone.Output.OutputComponents != null && cone.Output.OutputComponents.Count != 0)//cone with inside output { foreach (Gate g in cone.Output.OutputComponents) { if (ComponentConeDic.ContainsKey(g.Id)) { ComponentConeDic[g.Id].cone.Input.Add(cone.Output); } } } } Cones.Sort(Gate.CompareComponents); foreach (Cone cone in Cones) { cone.SetInputOutputComponents(); } }