コード例 #1
0
ファイル: gridLine.cs プロジェクト: DiLRandI/ArduinoMonitor
        //gridLine constructor
        public gridLine(int value, string dir, MainWindow window)
        {
            // Create a path to draw a geometry with.
            line = new Path();
            line.Stroke = Brushes.WhiteSmoke;
            line.StrokeThickness = 0.5;
            line.SnapsToDevicePixels = true;

            //this.line = new Line();
            this.canvas = window.plot;
            this.view = window.view;
            this.direction = dir;
            this.window = window;

            creategeometry(value);

            if (dir == LineDirection.Horizontal)
            {
                TextLabel(5, value, value.ToString());
            }
            else
            {
                TextLabel(value + 1, 30, value.ToString());
            }


            canvas.Children.Add(line);
        }
コード例 #2
0
        //Constructor
        public SignalCollection(MainWindow uiWindow)
        {
            brushes = new List<SolidColorBrush>();
            brushes.Add(Brushes.MediumVioletRed);
            brushes.Add(Brushes.LightBlue);
            brushes.Add(Brushes.BurlyWood);
            brushes.Add(Brushes.LightPink);
            brushes.Add(Brushes.Yellow);
            brushes.Add(Brushes.LightGreen);
            brushes.Add(Brushes.Gold);
            window = uiWindow;
            dataDispatcher = window.Dispatcher;
            signals = new List<Signal>(0);
            this.view = uiWindow.view; //set initial view params
            //view.XMAX = 2000;
            view.YMIN = 0;
            view.YMAX = 1024;
            view.XMIN = 0;
            view.LINESCALE = 1;
            horizontals = new List<gridLine>(10);
            verticals = new List<gridLine>(10);
            plotlineH = createHLine(0,false);
            plotlineH.hideLabel();
            plotlineV = createVLine(0,false);
            plotlineV.hideLabel();
            preparePlot();

            drawWorkerDelegate w = drawWorker;
            w.BeginInvoke(null, null);

            //addSignal(true);
        }
コード例 #3
0
        public MainWindow()
        {
            view = new ViewParams();
            InitializeComponent();
            scale = new ScaleTransform(1, 1, 0, 0);
            pan = new TranslateTransform(0, plot.Height);
            signals = new SignalCollection(this);
                signals.scaleSignalStrokes(scale);
                signals.updateLabels();
            resetTransform();
            ports = SerialPort.GetPortNames();
            
            Console.WriteLine("ports:");
            foreach(string port in ports){
                comportList.Items.Add(port.ToString());
                Console.WriteLine(port);
            }
            arduinoPort = new SerialPort();
            arduinoPort.Parity = Parity.None;
            arduinoPort.StopBits = StopBits.One;
            arduinoPort.DataBits = 8;
            arduinoPort.BaudRate = 9600;
            arduinoPort.ReadTimeout = 200;
            if (comportList.Items.Count > 0)
            {
                arduinoPort.PortName = comportList.Items[0].ToString();
            }
            else
            {
                Console.WriteLine("No ports available");
                connectButton.IsEnabled = false;
            }


        }
コード例 #4
0
        //Constructor
        public SignalCollection(MainWindow uiWindow)
        {
            brushes = new List <SolidColorBrush>();
            brushes.Add(Brushes.MediumVioletRed);
            brushes.Add(Brushes.LightBlue);
            brushes.Add(Brushes.BurlyWood);
            brushes.Add(Brushes.LightPink);
            brushes.Add(Brushes.Yellow);
            brushes.Add(Brushes.LightGreen);
            brushes.Add(Brushes.Gold);
            window         = uiWindow;
            dataDispatcher = window.Dispatcher;
            signals        = new List <Signal>(0);
            this.view      = uiWindow.view; //set initial view params
            //view.XMAX = 2000;
            view.YMIN      = 0;
            view.YMAX      = 1024;
            view.XMIN      = 0;
            view.LINESCALE = 1;
            horizontals    = new List <gridLine>(10);
            verticals      = new List <gridLine>(10);
            plotlineH      = createHLine(0, false);
            plotlineH.hideLabel();
            plotlineV = createVLine(0, false);
            plotlineV.hideLabel();
            preparePlot();

            drawWorkerDelegate w = drawWorker;

            w.BeginInvoke(null, null);

            //addSignal(true);
        }
コード例 #5
0
        public MainWindow()
        {
            view = new ViewParams();
            InitializeComponent();
            scale   = new ScaleTransform(1, 1, 0, 0);
            pan     = new TranslateTransform(0, plot.Height);
            signals = new SignalCollection(this);
            signals.scaleSignalStrokes(scale);
            signals.updateLabels();
            resetTransform();
            ports = SerialPort.GetPortNames();

            Console.WriteLine("ports:");
            foreach (string port in ports)
            {
                comportList.Items.Add(port.ToString());
                Console.WriteLine(port);
            }
            arduinoPort             = new SerialPort();
            arduinoPort.Parity      = Parity.None;
            arduinoPort.StopBits    = StopBits.One;
            arduinoPort.DataBits    = 8;
            arduinoPort.BaudRate    = 9600;
            arduinoPort.ReadTimeout = 200;
            if (comportList.Items.Count > 0)
            {
                arduinoPort.PortName = comportList.Items[0].ToString();
            }
            else
            {
                Console.WriteLine("No ports available");
                connectButton.IsEnabled = false;
            }
        }
コード例 #6
0
ファイル: Signal.cs プロジェクト: DiLRandI/ArduinoMonitor
        public Signal(MainWindow main, bool fake=false)
        {
            this.view = main.view; //Refer to the view parameters
            values = new List<double>(0);
            window = main;
            line = new Path(); //Path, to be filled with streamgeometry
            line.Stroke = Brushes.Red;
            line.SnapsToDevicePixels = true;
            line.Visibility = Visibility.Visible;
            line.RenderTransform = new ScaleTransform(1.0, view.LINESCALE);
            createGeometry();
            window.plot.Children.Add(line);

            //Create pointer
            pointer = new Ellipse();
            pointer.Fill = line.Stroke;
            pointer.Width = 5;
            pointer.Height = 5;
            pointer.Name = "signalPointer";
            window.plot.Children.Add(pointer);
            setThickness(1 / (main.plot.Height / view.YMAX));
            Canvas.SetLeft(pointer, -10);
            Canvas.SetTop(pointer, -10);


            if (fake) { //Create dummy graph
                Random random = new Random();
                //Fill the signal with 200 random data points
                for (int i = 0; i < 2000; i++)
                {
                    int randomNumber = (int) Math.Floor(500 * Math.Sin(i * (Math.PI / 180))) + 500;
                    addValue(randomNumber);
                }
            }

        }
コード例 #7
0
ファイル: Signal.cs プロジェクト: huleg/ArduinoMonitor
        public Signal(MainWindow main, bool fake = false)
        {
            this.view   = main.view; //Refer to the view parameters
            values      = new List <double>(0);
            window      = main;
            line        = new Path(); //Path, to be filled with streamgeometry
            line.Stroke = Brushes.Red;
            line.SnapsToDevicePixels = true;
            line.Visibility          = Visibility.Visible;
            line.RenderTransform     = new ScaleTransform(1.0, view.LINESCALE);
            createGeometry();
            window.plot.Children.Add(line);

            //Create pointer
            pointer        = new Ellipse();
            pointer.Fill   = line.Stroke;
            pointer.Width  = 5;
            pointer.Height = 5;
            pointer.Name   = "signalPointer";
            window.plot.Children.Add(pointer);
            setThickness(1 / (main.plot.Height / view.YMAX));
            Canvas.SetLeft(pointer, -10);
            Canvas.SetTop(pointer, -10);


            if (fake)   //Create dummy graph
            {
                Random random = new Random();
                //Fill the signal with 200 random data points
                for (int i = 0; i < 2000; i++)
                {
                    int randomNumber = (int)Math.Floor(500 * Math.Sin(i * (Math.PI / 180))) + 500;
                    addValue(randomNumber);
                }
            }
        }