public static SourceGraphic Construct(DpkDataBuf dpkLogFile, int address, int maxValue) { SourceGraphic srcGraphic = new SourceGraphic(); srcGraphic.Name = string.Format("Адрес {0}", address); srcGraphic.MaxValue = maxValue; int countWords = dpkLogFile.Count; for (int i = 0; i < countWords; i++) { if (dpkLogFile[i].ADR == address) { srcGraphic.Points.Add(new SourcePoint(dpkLogFile[i].Time, dpkLogFile[i].DATA)); } } return(srcGraphic); }
public static SourceGraphic Construct(DpkDataBuf dpkLogFile, int address, int numBit) { SourceGraphic namedGraphic = new SourceGraphic(); namedGraphic.Name = string.Format("Адрес {0} {1}Бит {2} [{3}]", address, '\n', numBit, numBit + 9); namedGraphic.MaxValue = 1; if (numBit >= 26) { return(namedGraphic); } int countWords = dpkLogFile.Count; for (int i = 0; i < countWords; i++) { if (dpkLogFile[i].ADR == address) { namedGraphic.Points.Add(new SourcePoint(dpkLogFile[i].Time, ((dpkLogFile[i].DATA & (1 << numBit)) > 0) ? 1:0)); } } return(namedGraphic); }
/*-------------------------------------------------------------------------------------------------------------*/ /// <summary> /// Построить двумерный график /// </summary> /// <param name="srcGraphic">Исходные данные</param> /// <param name="rect">область отображения на экране</param> /// <param name="timeInPoint">коэффициент</param> /// <param name="leftTime">левая временная граница</param> /// <param name="rightTime">правая временная граница</param> /// <returns>двумерный график</returns> public static GeometryGraphic Construct(SourceGraphic srcGraphic, Rect rect, double timeInPoint, TimeSpan leftTime, TimeSpan rightTime) { GeometryGraphic geometryGraphic = new GeometryGraphic(); if (srcGraphic.Points.Count == 0) { return(geometryGraphic); } double minV = rect.Location.Y + rect.Height; // -30; double maxV = rect.Location.Y; // +10; double valInPx = (minV - maxV) / srcGraphic.MaxValue; int countPoints = srcGraphic.Points.Count; for (int i = 0; i < countPoints; i++) { if ((i < (countPoints - 1)) && (srcGraphic.Points[i].Time.CompareTo(leftTime) <= 0) && (srcGraphic.Points[i + 1].Time.CompareTo(leftTime) >= 0)) { Point curPosPoint = new Point(rect.Location.X + ToolFunctions.GetDxByTime(leftTime, timeInPoint, leftTime), (minV - srcGraphic.Points[i].Value * valInPx)); GeometryPoint curPoint = new GeometryPoint(curPosPoint, srcGraphic.Points[i]); geometryGraphic.Points.Add(curPoint); } else if ((srcGraphic.Points[i].Time.CompareTo(leftTime) > 0) && (srcGraphic.Points[i].Time.CompareTo(rightTime) < 0)) { Point curPosPoint = new Point(rect.Location.X + ToolFunctions.GetDxByTime(srcGraphic.Points[i].Time, timeInPoint, leftTime), (minV - srcGraphic.Points[i].Value * valInPx)); GeometryPoint curPoint = new GeometryPoint(curPosPoint, srcGraphic.Points[i]); geometryGraphic.Points.Add(curPoint); } else if (srcGraphic.Points[i].Time.CompareTo(rightTime) >= 0) { Point curPosPoint = new Point(rect.Location.X + +ToolFunctions.GetDxByTime(rightTime, timeInPoint, leftTime), (minV - srcGraphic.Points[i].Value * valInPx)); GeometryPoint curPoint = new GeometryPoint(curPosPoint, srcGraphic.Points[i]); geometryGraphic.Points.Add(curPoint); return(geometryGraphic); } } return(geometryGraphic); }
/// <summary> /// Returns the current zone state for a zone, specified by Zone Id. /// </summary> /// <param name="zoneId">Zone Id</param> /// <returns>Zone State.</returns> public ZoneState GetZoneState(Address zoneId) { MonitorAndControlClient mcProxy = getMCProxy(); mcProxy.Connect(); ZoneState zoneState = mcProxy.GetZoneState(zoneId); _log.Trace(m => m("Read zone status for zone with id {0}. Zone State = [{1}]", zoneId.ToString(), zoneState.ToString())); mcProxy.Disconnect(); // Tweak: If a source is not configured, it needs to be added programmatically to the list, because it is still possible to select this source on the keypad. // If such an unconfigured source has been selected an error occurs, becuase the source is unkown! // ToDo: Implement this tweak on server side SourceGraphic source = GetSource(zoneState.Source); if (source.isEmpty()) { _sources.Add(new SourceGraphic(zoneState.Source, String.Format("[{0}]", zoneState.Source), "n/a", "n/a")); _log.Trace(m => m("SOURCE added with id {0}.", zoneState.Source)); } return(zoneState); }
public void AddSourceGraphic(SourceGraphic graphic) { graphicVisualizer.CommonData.SourceGraphics.Add(graphic); this.InvalidateVisual(); }
public static GeometryGraphic ConstructWithApproximation(SourceGraphic srcGraphic, Rect rect, double timeInPoint, TimeSpan leftTime, TimeSpan rightTime, double accuracyApproximationPx, out bool isAppearApproximation) { GeometryGraphic geometryGraphic = new GeometryGraphic(); isAppearApproximation = false; if (srcGraphic.Points.Count == 0) { return(geometryGraphic); } double minV = rect.Location.Y + rect.Height; // -30; double maxV = rect.Location.Y; // +10; double valInPx = (minV - maxV) / srcGraphic.MaxValue; int countPoints = srcGraphic.Points.Count; if (srcGraphic.Points.Count < 5) { for (int i = 0; i < countPoints; i++) { geometryGraphic.Points.Add(GetGeometryPointFrom(srcGraphic.Points[i], (minV - srcGraphic.Points[i].Value * valInPx), rect, timeInPoint, leftTime, srcGraphic.Points[i].Time)); } return(geometryGraphic); } GeometryPoint prevPt = new GeometryPoint(); for (int i = 0; i < countPoints; i++) { if ((i < (countPoints - 1)) && (srcGraphic.Points[i].Time.CompareTo(leftTime) <= 0) && (srcGraphic.Points[i + 1].Time.CompareTo(leftTime) >= 0)) { Point curPosPoint = new Point(rect.Location.X + ToolFunctions.GetDxByTime(leftTime, timeInPoint, leftTime), (minV - srcGraphic.Points[i].Value * valInPx)); GeometryPoint curPoint = new GeometryPoint(curPosPoint, srcGraphic.Points[i]); geometryGraphic.Points.Add(curPoint); prevPt = curPoint; } else if ((srcGraphic.Points[i].Time.CompareTo(leftTime) > 0) && (srcGraphic.Points[i].Time.CompareTo(rightTime) < 0)) { Point curPosPoint = new Point(rect.Location.X + ToolFunctions.GetDxByTime(srcGraphic.Points[i].Time, timeInPoint, leftTime), (minV - srcGraphic.Points[i].Value * valInPx)); GeometryPoint curPoint = new GeometryPoint(curPosPoint, srcGraphic.Points[i]); if (i == 1) { geometryGraphic.Points.Add(curPoint); prevPt = curPoint; continue; } if (i == (countPoints - 1 - 1)) { geometryGraphic.Points.Add(curPoint); prevPt = curPoint; continue; } if ((curPoint.X - prevPt.X) < accuracyApproximationPx) { isAppearApproximation = true; continue; } else { geometryGraphic.Points.Add(curPoint); prevPt = curPoint; } } else if (srcGraphic.Points[i].Time.CompareTo(rightTime) >= 0) { Point curPosPoint = new Point(rect.Location.X + +ToolFunctions.GetDxByTime(rightTime, timeInPoint, leftTime), (minV - srcGraphic.Points[i].Value * valInPx)); GeometryPoint curPoint = new GeometryPoint(curPosPoint, srcGraphic.Points[i]); geometryGraphic.Points.Add(curPoint); return(geometryGraphic); } } return(geometryGraphic); }