private void update_point_master(OutstationWrapper ow, IndexedValue<DataPoint> point, DateTime update_time) { DateTime timestamp; if (point.value.time == TimeStamp.epoch) timestamp = update_time; else timestamp = point.value.time; /* Check if the point currently exists in the points table */ Point point_model = ow.Model.Points.SingleOrDefault(x => x.PointIndex == point.index && x.Type == point.value.GetBasicType()); /* Create a new point */ if (point_model == null) { point_model = new Point(); point_model.OutstationID = ow.Model.Id; point_model.PointIndex = (int)point.index; point_model.Status = POINT_STATUS.DETECTED; point_model.Type = point.value.GetBasicType(); TulipContext.Points.Add(point_model); } else { // ?? p.Status == POINT_STATUS.UPDATED; } // if a series of measurements come through, only keep the most recent if (timestamp > point_model.LastMeasurement) { if (point_model.Type == BasicType.ANALOG_STATUS) point_model.ValueAnalog = point.value.ToSingle(); else point_model.ValueDigital = Convert.ToInt32(point.value.ToBoolean()); point_model.LastMeasurement = timestamp; point_model.Quality = point.value.quality; point_model.LastUpdate = update_time; } }
public void SetUp() { _testTarget = new IndexedValue("Foo"); }
public void Callback_OutstationMeasurementReceived(OutstationWrapper ow, IMeasurementUpdate update) { // TODO make async DateTime update_time = DateTime.UtcNow; // TODO: FIX if (update.AnalogUpdates.Count > 0) { foreach (IndexedValue<Analog> ana in update.AnalogUpdates) { // TODO: better way to do this? IndexedValue<DataPoint> dp = new IndexedValue<DataPoint>(ana.value, ana.index); update_point_master(ow, dp, update_time); update_point_history(ow, dp, update_time); } } if (update.BinaryUpdates.Count > 0) { foreach (IndexedValue<Binary> bin in update.BinaryUpdates) { IndexedValue<DataPoint> dp = new IndexedValue<DataPoint>(bin.value, bin.index); update_point_master(ow, dp, update_time); update_point_history(ow, dp, update_time); } } if (OnOutstationMeasurementReceived != null) OnOutstationMeasurementReceived(); TulipContext.SaveChanges(); }
private void update_point_history(OutstationWrapper ow, IndexedValue<DataPoint> point, DateTime update_time) { History H = new History(); // get the master point BasicType b = point.value.GetBasicType(); Point P = TulipContext.Points.SingleOrDefault(X => X.PointIndex == point.index && X.Type == b); if (P != null) { DateTime timestamp; if (point.value.time == TimeStamp.epoch) timestamp = update_time; else timestamp = point.value.time; H.Timestamp = timestamp; H.Quality = point.value.quality; if (P.Type == BasicType.ANALOG_STATUS) H.ValueAnalog = point.value.ToSingle(); else H.ValueDigital = Convert.ToInt32(point.value.ToBoolean()); P.Histories.Add(H); } }
internal All(IndexedValue <TObj, TAttribute> indexedValue) { this.IndexedValue = indexedValue; }
public static void Deactivate(IndexedValue indexedValue) { Console.WriteLine("Fin de l'action de : " + indexedValue.ToString()); }
public static void Activate(IndexedValue indexedValue) { Console.WriteLine("Nouvel effet actif : " + indexedValue.ToString()); }
public IndexedValueView(IndexedValue indexedValue, WorldState wo, bool mutable, params DisplayTag[] tags) : this(indexedValue, 100, 100, wo, mutable, tags) { }
public int CompareTo(IndexedValue <T> other) { return(Value.CompareTo(other.Value)); }