Esempio n. 1
0
        public AutomaticMode(IShotGlassPositionSettingRepository shotGlassPositionSettingRepository,
                             IXAxis xAxis,
                             IYAxis yAxis,
                             ISpiritDispenserControl spiritDispenserControl,
                             IEmergencyStop emergencyStop)
        {
            _currentStatus = new BehaviorSubject <Status>(Status.NotReady);
            _shotGlassPositionSettingRepository = shotGlassPositionSettingRepository;
            _X_Axis = xAxis;
            _Y_Axis = yAxis;
            _spiritDispenserControl = spiritDispenserControl;
            _emergencyStop          = emergencyStop;
            _emergencyStop.EmergencyStopPressedChanged += (estop) => CalculateStatuts();

            var components = new List <IObservable <Status> >();

            components.Add(_X_Axis.GetStatusObservable());
            components.Add(_Y_Axis.GetStatusObservable());
            components.Add(_spiritDispenserControl.GetStatusObservable());


            components.CombineLatest(lastStates => lastStates.All(state => state == Status.Ready))
            .Subscribe(areComponentsReady =>
            {
                _areComponentsReady = areComponentsReady;
                CalculateStatuts();
            });
        }
Esempio n. 2
0
        protected virtual void DrawGrid(CGContext context, IViewPort viewPort, IYAxis yAxis, nfloat axisLineStart, nfloat axisLineEnd, GridStyle gridStyle)
        {
            var Step = gridStyle.Step;

            var visibleSourceRangeStart = yAxis.Min - (yAxis.Min % Step) - Step;

            var visibleSourceRangeEnd = yAxis.Max - (yAxis.Max % Step) + Step;

            var leftAxisX = viewPort.ViewPortRect.Left + gridStyle.Offset.X;

            var rightAxisX = viewPort.ViewPortRect.Right - gridStyle.Offset.X;

            for (double i = visibleSourceRangeStart; i <= visibleSourceRangeEnd; i += Step)
            {
                var y = yAxis.GetContentValue(i);

                var viewPortPositionY = viewPort.DisplayPositionY((nfloat)y) + gridStyle.Offset.Y;

                if (viewPortPositionY >= axisLineStart && viewPortPositionY <= axisLineEnd)
                {
                    DrawHelper.DrawLines(context, new List <CGPoint> {
                        new CGPoint(leftAxisX, viewPortPositionY), new CGPoint(rightAxisX, viewPortPositionY)
                    }, gridStyle);
                }
            }
        }
Esempio n. 3
0
 public DrivesController(IXAxis xAxis, IYAxis yAxis)
 {
     _axis = new Dictionary <string, IAxis>()
     {
         { xAxis.Name, xAxis },
         { yAxis.Name, yAxis }
     };
 }
Esempio n. 4
0
 public GpioComponentsStartup(
     IXAxis xAxis,
     IYAxis yAxis,
     ISpiritDispenserControl spiritDispenserControl,
     IStatusLamp statusLamp,
     IShotGlassPositionSettingsConfiguration shotGlassPositionSettingsConfiguration)
 {
     _xAxis = xAxis;
     _yAxis = yAxis;
     _spiritDispenserControl = spiritDispenserControl;
     _statusLamp             = statusLamp;
     _shotGlassPositionSettingsConfiguration = shotGlassPositionSettingsConfiguration;
 }
Esempio n. 5
0
        private void DrawLabels(CGContext context, IViewPort viewPort, IYAxis yAxis, nfloat positionX, nfloat axisLineStart, nfloat axisLineEnd, TextStyle textStyle, List <Tuple <double, string> > labels)
        {
            foreach (var label in labels)
            {
                var labelY = yAxis.GetContentValue(label.Item1);

                var viewPortPositionY = viewPort.DisplayPositionY((nfloat)labelY);

                if (viewPortPositionY >= axisLineStart && viewPortPositionY <= axisLineEnd)
                {
                    DrawLabel(context, label.Item2, new CGPoint(positionX, viewPortPositionY), textStyle);
                }
            }
        }
Esempio n. 6
0
        public StatusObserver(
            IAutomaticMode automatic,
            IXAxis xAxis,
            IYAxis yAxis,
            ISpiritDispenserControl spiritDispenserControl,
            IStatusLamp statusLamp)
        {
            _statusObservables = new List <IObservable <Status> >();
            _statusObservables.Add(spiritDispenserControl.GetStatusObservable());
            _statusObservables.Add(xAxis.GetStatusObservable());
            _statusObservables.Add(yAxis.GetStatusObservable());
            _statusObservables.Add(automatic.GetStatusObservable());

            _statusLamp = statusLamp;
        }
Esempio n. 7
0
        public virtual void DrawAxis(CGContext context, IViewPort viewPort, IYAxis yAxis)
        {
            var axisLineStart = viewPort.ViewPortInsets.Top;

            var axisLineEnd = viewPort.ViewPortInsets.Top + viewPort.ViewPortSize.Height;

            if (Style.GridStyle.ShouldDraw)
            {
                DrawGrid(context, viewPort, yAxis, axisLineStart, axisLineEnd, Style.GridStyle);
            }

            if (Style.Position.HasFlag(YAxisPosition.Left))
            {
                var leftAxisX = viewPort.ViewPortRect.Left + Style.AxisDrawOffset;

                if (Style.LineStyle.ShouldDraw)
                {
                    DrawAxisLine(context, new CGPoint(leftAxisX, axisLineStart), new CGPoint(leftAxisX, axisLineEnd), Style.LineStyle);
                }

                if (Style.TextStyle.ShouldDraw)
                {
                    DrawLabels(context, viewPort, yAxis, axisLineStart, axisLineEnd, leftAxisX, Style.TextStyle);
                }
            }

            if (Style.Position.HasFlag(YAxisPosition.Right))
            {
                var rightAxisX = viewPort.ViewPortRect.Right + Style.AxisDrawOffset;

                if (Style.LineStyle.ShouldDraw)
                {
                    DrawAxisLine(context, new CGPoint(rightAxisX, axisLineStart), new CGPoint(rightAxisX, axisLineEnd), Style.LineStyle);
                }

                if (Style.TextStyle.ShouldDraw)
                {
                    DrawLabels(context, viewPort, yAxis, axisLineStart, axisLineEnd, rightAxisX, Style.TextStyle);
                }
            }
        }
Esempio n. 8
0
        protected virtual void DrawLabels(CGContext context, IViewPort viewPort, IYAxis yAxis, nfloat axisLineStart, nfloat axisLineEnd, nfloat axisXPosition, TextStyle textStyle)
        {
            var positions = AxisValuesPositionsProvider?.ValuePositions(yAxis, viewPort);

            if (!positions?.Any() ?? false)
            {
                return;
            }

            var labels = new List <Tuple <double, string> >();

            foreach (var item in positions)
            {
                var text = ValueFormatter(item);

                if (!string.IsNullOrEmpty(text))
                {
                    labels.Add(new Tuple <double, string>(item, text));
                }
            }

            DrawLabels(context, viewPort, yAxis, axisXPosition, axisLineStart, axisLineEnd, textStyle, labels);
        }
Esempio n. 9
0
        protected virtual void Draw(CGContext context, IEnumerable <IPointEntry> entries, IEnumerable <IPointEntry> highlightedEntries, IViewPort viewPort, IXAxis xAxis, IYAxis yAxis, PointRenderStyle renderStyle)
        {
            var points = entries
                         ?.Select(t => new
            {
                Point       = GetDrawPosition(t.X, t.Y, viewPort, xAxis, yAxis),
                IsHighlight = highlightedEntries?.Contains(t) ?? false,
                Entry       = t
            })
                         .ToList();

            if (points != null)
            {
                context.SaveState();

                context.ClipToRect(viewPort.ViewPortRect);

                if (renderStyle.LineStyle.ShouldDraw)
                {
                    DrawLine(context, points.Select(t => t.Point).ToList(), renderStyle);
                }

                if (renderStyle.MarkerStyle.ShouldDraw)
                {
                    DrawNotHighlightedMarkers(context, points.Where(t => !t.IsHighlight).Select(t => t.Point).ToList(), renderStyle.MarkerStyle);
                }

                if (renderStyle.HighlightMarkerStyle.ShouldDraw)
                {
                    DrawHighlightedMarkers(context, points.Where(t => t.IsHighlight).Select(t => t.Point).ToList(), renderStyle.HighlightMarkerStyle);
                }

                foreach (var point in points)
                {
                    if (ShouldDraw(point.IsHighlight, renderStyle.TextStyle, renderStyle.HighlightTextStyle))
                    {
                        DrawEntryValue(context, point.Entry, point.Point, point.IsHighlight ? renderStyle.HighlightTextStyle : renderStyle.TextStyle);
                    }
                }

                context.RestoreState();
            }
        }
Esempio n. 10
0
        public void DrawPlot(CGContext context, IPointDataSource dataSource, IEnumerable <IPointEntry> highlightedEntries, IViewPort viewPort, IXAxis xAxis, IYAxis yAxis)
        {
            var visibleSourceRange = VisibleSourceXRange(xAxis, viewPort);

            var visibleSourceRangeStart = Math.Floor(visibleSourceRange.Item1);

            var visibleSourceRangeEnd = Math.Ceiling(visibleSourceRange.Item2);

            if (Style.BezierCurve)
            {//для отображения кривых нужны дополнительные точки для рассчета опорных точек
             //TODO учитывать масштаб
                visibleSourceRangeStart--;
                visibleSourceRangeEnd++;
            }

            var visibleEntries = dataSource.GetEntriesInRange(visibleSourceRangeStart, visibleSourceRangeEnd);

            Draw(context, visibleEntries, highlightedEntries, viewPort, xAxis, yAxis, Style);
        }
Esempio n. 11
0
 protected virtual CGPoint GetDrawPosition(double sourceX, double sourceY, IViewPort viewPort, IXAxis xAxis, IYAxis yAxis)
 => viewPort.DisplayPosition(new CGPoint(xAxis.GetContentValue(sourceX), yAxis.GetContentValue(sourceY)));
Esempio n. 12
0
        public bool Tap(CGPoint tapContentLocation, IChartView chartView, IPointDataSource pointDataSource, IPointHighlightHandler highlightHandler, IXAxis xAxis, IYAxis yAxis)
        {
            double sourcePositionStart = xAxis.GetSourceValue(tapContentLocation.X - TapDistance);

            var sourcePositionEnd = xAxis.GetSourceValue(tapContentLocation.X + TapDistance);

            var entriesInTapRange = pointDataSource
                                    .GetEntriesInRange(sourcePositionStart, sourcePositionEnd)
                                    .Select((IPointEntry entry) => new { Entry = entry, Distance = GetDistance(tapContentLocation, entry, xAxis, yAxis) })
                                    .Where((t) => t.Distance <= TapDistance)
                                    .OrderBy(p => p.Distance);

            var entryNearestToTap = entriesInTapRange.FirstOrDefault();

            if (entryNearestToTap != null)
            {
                highlightHandler.TapOnEntries(Multiselect ? entriesInTapRange.Select(t => t.Entry) : new List <IPointEntry> {
                    entryNearestToTap.Entry
                });
            }
            else
            {
                highlightHandler.TapOnNoEntry();
            }

            return(entryNearestToTap != null);
        }
Esempio n. 13
0
        protected double GetDistance(CGPoint tapLocation, IPointEntry entry, IXAxis xAxis, IYAxis yAxis)
        {
            var entryContentLocationX = xAxis.GetContentValue(entry.X);

            var entryContentLocationY = yAxis.GetContentValue(entry.Y);

            return(Math.Sqrt(Math.Pow(entryContentLocationX - tapLocation.X, 2) + Math.Pow(entryContentLocationY - tapLocation.Y, 2)));
        }
Esempio n. 14
0
 public AxisHubInformer(IXAxis xAxis, IYAxis yAxis, IHubContext <AxisHub, IAxisHub> hubContext)
 {
     _hubContext            = hubContext;
     xAxis.PositionChanged += PositionChangedHandler;
     yAxis.PositionChanged += PositionChangedHandler;
 }
Esempio n. 15
0
 public ZoomRectangle(IXAxis xAxis, IYAxis yAxis)
 {
     Axes.XAxis = xAxis;
     Axes.YAxis = yAxis;
 }
Esempio n. 16
0
 public DefaultGrid(IXAxis xAxis, IYAxis yAxis)
 {
     XAxis = xAxis;
     YAxis = yAxis;
 }