Exemple #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     #region Circular Buffer
     mycircularbuffer   = new CircularBuffer <string>(4);
     btnDequeue.Enabled = false;
     btnEnqueue.Enabled = true;
     #endregion
     #region ThreadHandler
     mythread      = new ThreadHandler(threadFuction);
     threadcounter = 0;
     #endregion
     #region ArduinoHandler
     myarduinohandler            = new ArduinoHandler();
     aduinodataconsumer          = new ThreadHandler(ArduinoConsumer);
     arduinoBufferLabel          = new Timer();
     arduinoBufferLabel.Interval = 50;
     arduinoBufferLabel.Tick    += updateLabelBuffer;
     #endregion
     #region ChartHandler
     mychart = new ChartHandler(ref chart1);
     #endregion
     #region ArduinoPlotter
     myArduinoPlotter = new ArduinoPlotter(ref chart2, ref label9);
     #endregion
 }
Exemple #2
0
        public ArduinoHandler(string port_name = "None", int baudrate = 115200, int readtimeout = 1000)
        {
            _port_name = port_name;

            serialPort             = new SerialPort();
            serialPort.BaudRate    = baudrate;
            serialPort.ReadTimeout = readtimeout;

            threadAquisition = new ThreadHandler(AquireRoutine);
            threadAquisition.setOnEndFunction(() => { serialPort.Close(); });

            bufferAquisition = new CircularBuffer <ushort>(1024);
        }
Exemple #3
0
        public ArduinoPlotter(ref Chart chart, ref Label _lblBufferStatus)
        {
            chartHandler = new ChartHandler(ref chart, 1000);

            chartHandler.ConfigureChart("Leituras", "Arduino Plotter", "Pontos", "Valores");


            arduinoHandler = new ArduinoHandler();

            dataconsumer = new ThreadHandler(() => {
                if (arduinoHandler.dataWaiting)
                {
                    chartHandler.AddYToBuffer(arduinoHandler.bufferAquisition.SecureDequeue() * 5 / 1024.0);
                }
            });

            bufferLabelUpdater          = new Timer();
            lblBufferStatus             = _lblBufferStatus;
            bufferLabelUpdater.Interval = 50;
            bufferLabelUpdater.Tick    += bufferLabelUpdater_Tick;
        }