Exemplo n.º 1
0
        protected virtual void UpdateChartTrades <T>(List <T> newTrades, int newTradesCount, int tradesChartDisplayCount, ref ChartValues <T> tradesChart)
        {
            if (newTrades == null)
            {
                throw new ArgumentNullException(nameof(newTrades));
            }

            if (tradesChart == null)
            {
                throw new ArgumentNullException(nameof(tradesChart));
            }

            var tradesChartCount = tradesChart.Count;

            if (tradesChartCount >= tradesChartDisplayCount)
            {
                // For each additional new trade remove the oldest then add the new trade
                for (int i = 0; i < newTradesCount; i++)
                {
                    tradesChart.RemoveAt(0);
                    tradesChart.Add(newTrades[i]);
                }
            }
            else
            {
                // Get the difference between the number of trades the chart can take and the number it currently holds.
                var chartDisplayTopUpTradesCount = tradesChartDisplayCount - tradesChartCount;

                if (newTradesCount > chartDisplayTopUpTradesCount)
                {
                    // There are more new trades than the chart can take.

                    if (chartDisplayTopUpTradesCount > 0)
                    {
                        // The top up trades can simply be added to the chart as it will take it to the total the chart can hold
                        var chartDisplayTopUpTrades = newTrades.Take(chartDisplayTopUpTradesCount).ToList();
                        tradesChart.AddRange(chartDisplayTopUpTrades);
                    }

                    for (int i = chartDisplayTopUpTradesCount; i < newTradesCount; i++)
                    {
                        // For each additional new trade remove the oldest then add the new trade
                        tradesChart.RemoveAt(0);
                        tradesChart.Add(newTrades[i]);
                    }
                }
                else
                {
                    // Simply add new trades to current list as it wont be more than the total the chart can take.
                    tradesChart.AddRange(newTrades);
                }
            }
        }
 public void SetValues(double passed, double failed)
 {
     _passed.RemoveAt(0);
     _failed.RemoveAt(0);
     _passed.Add(passed);
     _failed.Add(failed);
 }
Exemplo n.º 3
0
        private void Read()
        {
            var r = new Random();

            try {
                while (IsReading)
                {
                    Thread.Sleep(150);
                    var now = DateTime.Now;

                    _trend = double.Parse(Act_Hight);

                    ChartValues.Add(new MeasureModel
                    {
                        DateTime = now,
                        Value    = _trend
                    });

                    SetAxisLimits(now);

                    //lets only use the last 150 values
                    if (ChartValues.Count > 50)
                    {
                        ChartValues.RemoveAt(0);
                    }
                }
            }
            catch (Exception x)
            { NoticeX.Show("Error", Panuon.UI.Silver.MessageBoxIcon.Error); NoticeX.Show(x.ToString(), Panuon.UI.Silver.MessageBoxIcon.Error); }
        }
Exemplo n.º 4
0
        private void ChartRefreshTimer_Tick(object sender, EventArgs e)
        {
            int val = App.AppDBManager.CountDetectedDevices(timeInterval);

            detectedDevicesCountValues.Add(new Tuple <DateTime, int>(DateTime.Now, val));
            detectedDevicesCountValues.RemoveAt(0);
        }
        private void Read()
        {
            var r = new Random();

            while (IsReading)
            {
                Thread.Sleep(150);
                var now = DateTime.Now;

                _trend += r.Next(-8, 10);

                try
                {
                    ChartValues.Add(new Classes.GraphData
                    {
                        DateTime = now,
                        Value    = DataFromPump[0].Value
                    });
                }
                catch (Exception) { throw; }

                SetAxisLimits(now);

                //lets only use the last 150 values
                if (ChartValues.Count > 150)
                {
                    ChartValues.RemoveAt(0);
                }
            }
        }
        /// <summary>
        /// Add new Point on Chart
        /// </summary>
        /// <param name="value"></param>
        public void AddPoint(double value)
        {
            if (value < 32 && value > 22)
            {
                if (value < _minValue)
                {
                    _minValue = Math.Ceiling(value) - 1;
                    YAxisMin  = _minValue;
                }
                if (value > _maxValue)
                {
                    _maxValue = Math.Ceiling(value);
                    YAxisMax  = _maxValue;
                }

                ChartValues.Add(new MeasureModel
                {
                    Counter = _counter,
                    Value   = value
                });

                AxisMax = _counter < 150 ? 150 : _counter;
                AxisMin = _counter <= 150 ? 0 : _counter - 150;



                //lets only use the last 150 values
                if (ChartValues.Count > 150)
                {
                    ChartValues.RemoveAt(0);
                }

                _counter++;
            }
        }
        private void Read()
        {
            var r = new Random();

            while (IsReading)
            {
                Thread.Sleep(150);
                var now = DateTime.Now;

                _trend += r.Next(-8, 10);
                foreach (KeyValuePair <DateTime, double> entry in dict)
                {
                    ChartValues.Add(new MeasureModel
                    {
                        DateTime = entry.Key,
                        Value    = entry.Value
                                   //DateTime = now,
                                   //Value = _trend
                    });
                }
                SetAxisLimits(now);

                //lets only use the last 150 values
                if (ChartValues.Count > 150)
                {
                    ChartValues.RemoveAt(0);
                }
            }
        }
Exemplo n.º 8
0
        public void Read()
        {
            //Connects to the FIU database to read the data.
            Db fiu = new Db();

            //This is always true, so the only way to exit out is to close the application or change the window to a tab that clears the container it resides in.
            while (IsReading)
            {
                Thread.Sleep(1000);     //The thread needs to pause in order prevent the gui from locking up
                var now = DateTime.Now; //Gets the current date and time


                ChartValues.Add(new MeasureModel     //Sets the date and time, along with the current temperature sensor value.
                {
                    DateTime = now,
                    Value    = fiu.getLastVirtualEntry(procedureName)
                });

                SetAxisLimits(now);
                //lets only use the last 11 values to prevent the graphics from slowing down.
                if (ChartValues.Count > 62)
                {
                    ChartValues.RemoveAt(0);
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void TimerOnTick(object sender, EventArgs eventArgs)
        {
            var now = DateTime.Now;

            if (!clientSocket.Connected)
            {
                clientSocket.Connect("192.168.1.15", 8888);
                //Thread.Sleep(60000);
            }
            else
            {
                NetworkStream serverStream = clientSocket.GetStream();
                logger.LogInfo("Client Socket Program - Server Connected ...");
                logger.LogInfo("worker thread: working...");
                byte[] inStream = new byte[10025];
                serverStream.Read(inStream, 0, (int)clientSocket.ReceiveBufferSize);
                string output      = System.Text.Encoding.ASCII.GetString(inStream);
                string replacement = Regex.Replace(output, @"\t|\n|\r|\0", "");
                ChartValues.Add(new MeasureModel
                {
                    DateTime = now,
                    Value    = Convert.ToDouble(replacement) // R.Next(0, 10)
                });
            }


            SetAxisLimits(now);

            //lets only use the last 30 values
            if (ChartValues.Count > 60)
            {
                ChartValues.RemoveAt(0);
            }
        }
Exemplo n.º 10
0
        private void TimerOnTick(object sender, EventArgs eventArgs)
        {
            var now = System.DateTime.Now;

            //PreValSale.Add(_Sale);
            //PreValTime.Add(now);
            //ScrollBar.Maximum = PreValSale.Count - 1;
            //ScrollBar.Value = PreValSale.Count - 1;

            ChartValues.Add(new CHSalesRealTime_Data
            {
                Time = now,
                Sale = _Sale
            });

            if (_refSale)
            {
                _Sale = 0;
            }

            SetAxisLimits(now);
            if (ChartValues.Count > 12)
            {
                ChartValues.RemoveAt(0);
            }
        }
        private void ReadData()
        {
            //ToDo: Populate the collection ChartValues
            string filename = @"SampleDataFile.csv";

            foreach (var ft in FactoryTelemetry.Load(filename))
            {
                if (!readingData)
                {
                    return; //This allows us to stop the data read when we click the stop button
                }
                ChartValues.Add(ft);

                this.EngineEfficiency = ft.Efficiency;

                AdjustAxis(ft.TimeStamp.Ticks);

                if (ChartValues.Count > 30)
                {
                    ChartValues.RemoveAt(0);
                }

                Thread.Sleep(50); //This controls the speed at which the data is read, the higher the number the slower it goes
            }
        }
Exemplo n.º 12
0
        private void AddPoint(int connCount, long recvBytes, long sendBytes)
        {
            var now = System.DateTime.Now;

            sendValues.Add(new MeasureModel
            {
                DateTime = now,
                Value    = sendBytes
            });
            recvValues.Add(new MeasureModel
            {
                DateTime = now,
                Value    = recvBytes
            });
            connValues.Add(new MeasureModel
            {
                DateTime = now,
                Value    = connCount
            });
            SetAxisLimits(now);
            if (currentCount == 1)
            {
                var count = connValues.Count - displayCount;
                for (int i = 0; i < count; i++)
                {
                    sendValues.RemoveAt(0);
                    recvValues.RemoveAt(0);
                    connValues.RemoveAt(0);
                }
            }
        }
Exemplo n.º 13
0
 private void AddPoint(DateTime now, int connCount, long recvBytes, long sendBytes)
 {
     sendValues.Add(new MeasureModel
     {
         DateTime = now,
         Value    = sendBytes
     });
     recvValues.Add(new MeasureModel
     {
         DateTime = now,
         Value    = recvBytes
     });
     connValues.Add(new MeasureModel
     {
         DateTime = now,
         Value    = connCount
     });
     SetAxisLimits(now);
     if (sendValues.Count > displayTimeSpan)
     {
         sendValues.RemoveAt(0);
         recvValues.RemoveAt(0);
         connValues.RemoveAt(0);
     }
 }
Exemplo n.º 14
0
        private void Read()
        {
            var r = new Random();

            while (IsReading)
            {
                Thread.Sleep(150);
                var now = DateTime.Now;

                _trend += r.Next(-8, 10);

                ChartValues.Add(new CoilChangeModel
                {
                    DateTime = now,
                    Value    = _trend
                });

                SetAxisLimits(now);

                //lets only use the last 150 values
                if (ChartValues.Count > 150)
                {
                    ChartValues.RemoveAt(0);
                }

                CurrentLecture = _trend;
            }
        }
Exemplo n.º 15
0
        private void TimerOnTick(object sender, EventArgs eventArgs) // Class is referencing from here!
        {
            var now = DateTime.Now;


            ChartValuesTwo.Add(new Graph1SecondVal
            {
                DateTime = stopWatch,
                Value    = R.Next(0, 10)
            });


            ChartValues.Add(new MeasureModel
            {
                DateTime = stopWatch,
                Value    = R.Next(0, 20)
            });

            SetAxisLimits(stopWatch);

            //lets only use the last 30 values
            if (ChartValues.Count > 30)
            {
                ChartValues.RemoveAt(0);
            }
        }
        private void Read()
        {
            var r = new Random();

            int counter = 0;

            while (IsReading)
            {
                Thread.Sleep(500);
                var now = DateTime.Now;

                _trend = Math.Sin(counter / (Math.PI));
                counter++;

                ChartValues.Add(new MeasureModel
                {
                    DateTime = now,
                    Value    = _trend
                });

                SetAxisLimits(now);

                //lets only use the last 30 values
                if (ChartValues.Count > 30)
                {
                    ChartValues.RemoveAt(0);
                }
                Application.Current.Dispatcher.Invoke(() => CChart.Update(false, true));
            }
        }
Exemplo n.º 17
0
        private void Read()
        {
            var r = new Random();

            while (IsReading)
            {
                Thread.Sleep(150);
                var now = DateTime.Now;

                _trend += r.Next(-8, 10);

                ChartValues.Add(new TimeOutModel
                {
                    DateTime = now,
                    Value    = _trend
                });

                SetAxisLimits(now);

                //lets only use the last 150 values
                if (ChartValues.Count > 150)
                {
                    ChartValues.RemoveAt(0);
                }

                CurrentLecture = _trend;


                // CMABIAR CONFORME AL INDICADOR DE CADA TURNO, SE PONE AQUI COMO MUESTRA
                Turno1 = DateTime.Now.ToString("dd MMMM yyyy");
                Turno2 = DateTime.Now.ToString("dd MMMM yyyy");
                Turno3 = DateTime.Now.ToString("dd MMMM yyyy");
            }
        }
Exemplo n.º 18
0
        private void timer_livechart_Tick(object sender, EventArgs e)
        {
            GetCoordinates();

            headingIndicatorInstrumentControl1.SetHeadingIndicatorParameters((int)mad_yaw_angle);

            textBox_incoming.Text = number_of_satellite.ToString() + " " + M8N_latitude.ToString() + " " + M8N_longitude + " " + ismission.ToString() + ", vscheck/check : " + visual_studio_check.ToString() + " / " + check.ToString();

            current_value += 1;
            if (current_value > 200)
            {
                current_value = 0;
            }
            //solidGauge1.Value = current_value;

            x += 1;
            var now = System.DateTime.Now;

            ChartValues.Add(new MeasureModel
            {
                DateTime = now,
                Value    = baro_height
            });;;

            SetAxisLimits(now);

            //lets only use the last 30 values

            if (ChartValues.Count > 205)
            {
                ChartValues.RemoveAt(0);
            }
        }
        private void ReadData()
        {
            // TODO: Populate the collection ChartValues

            string filename = @"..\..\..\..\..\dashBoardData.csv";

            foreach (var ft in FactoryTelemetry.Load(filename))
            {
                if (!readingData)
                {
                    return;
                }

                ChartValues.Add(ft);

                this.EngineEfficiency = ft.Efficiency;

                AdjustAxis(ft.TimeStamp.Ticks);

                if (ChartValues.Count > 30)
                {
                    ChartValues.RemoveAt(0);
                }

                Thread.Sleep(50);
            }
        }
        private void ReadData()
        {
            // TODO: Populate the collection ChartValues

            string filename = @"C:\Users\SoftwareDevelopment\Downloads\Ex_Files_Code_Clinic_C_Sharp\Exercise Files\Ch06\dashBoardData.csv";

            foreach (var ft in FactoryTelemetry.Load(filename))
            {
                if (!readingData)
                {
                    return;
                }

                ChartValues.Add(ft);

                this.EngineEfficiency = ft.Efficiency;

                AdjustAxis(ft.TimeStamp.Ticks);

                if (ChartValues.Count > 30)
                {
                    ChartValues.RemoveAt(0);
                }

                Thread.Sleep(60);
            }
        }
Exemplo n.º 21
0
        private async void AddPlot(object sender, object e) //センサから値を受け取った時に呼ばれる
        {
            if (e == null)
            {
                return;
            }
            MeasureModel mm = new MeasureModel();

            mm.DateTime = ((HeartRateEventArgs)e).datetime;
            mm.Value    = ((HeartRateEventArgs)e).heart_rate;

            if (mm.DateTime == null)
            {
                return;
            }

            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                                      () => ChartValues.Add(mm)); //UIスレッドからしか呼べないらしい


            SetAxisLimits(((HeartRateEventArgs)e).datetime); //X軸を更新

            if (ChartValues[0] == null)                      //ヌルポ回避
            {
                return;
            }
            if (ChartValues[0].DateTime.Ticks < AxisMin)
            {
                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                                          () => ChartValues.RemoveAt(0)); //ChartValuesの書き換えをUIスレッドでしか行わないようにすることでスレッドセーフでないChartValuesを安全に操作する
            }
        }
Exemplo n.º 22
0
 private void UpdateCollectionData(ChartValues <float> _chartValues, float _receivedValue)
 {
     _chartValues.Add(_receivedValue);
     if (_chartValues.Count > 20)
     {
         _chartValues.RemoveAt(0);
     }
 }
Exemplo n.º 23
0
        public void SetFailed(double val)
        {
            while (_failedValues.Count > 0)
            {
                _failedValues.RemoveAt(0);
            }

            _failedValues.Add(val);
        }
Exemplo n.º 24
0
        public void SetPassed(double val)
        {
            while (_passedValues.Count > 0)
            {
                _passedValues.RemoveAt(0);
            }

            _passedValues.Add(val);
        }
Exemplo n.º 25
0
        public void SetTotal(double val)
        {
            while (_totalValues.Count > 0)
            {
                _totalValues.RemoveAt(0);
            }

            _totalValues.Add(val);
        }
Exemplo n.º 26
0
 private void Downloader_DownloadSpeedChanged(object sender, DownloadSpeedChangedArg e)
 {
     this.Dispatcher.Invoke(new Action(() =>
     {
         speedTextBlock.Text = e.SpeedValue.ToString() + e.SpeedUnit;
         speedValues.Add(e.SizePerSec);
         speedValues.RemoveAt(0);
     }));
 }
Exemplo n.º 27
0
        private void Emg1c_MessageReceived(object sender, MessageReceiveEventArgs e)
        {
            //string[] values = e.Message.Split(new[] {':','#'}, StringSplitOptions.None);
            Match[] values = Regex.Matches(e.Message, @":+[0-9]+#").Cast <Match>().ToArray();
            try
            {
                for (int i = 0; i < values.Length; i++)
                {
                    string temp1 = values[i].Value;
                    string temp  = temp1.Substring(1, temp1.IndexOf('#') - 1);
                    // threshold
                    if (emg1cThresholdCheck.Checked)
                    {
                        if (int.Parse(temp) > numEmg1cThreshold.Value && !emg1cThresholdReach)
                        {
                            Console.WriteLine(SendMessageConfig.HandFist());
                            hand.SendMessage(SendMessageConfig.HandFist());
                            emg1cThresholdReach = true;
                        }
                        else if (int.Parse(temp) < numEmg1cThreshold.Value && emg1cThresholdReach)
                        {
                            Console.WriteLine(SendMessageConfig.HandOpen());
                            hand.SendMessage(SendMessageConfig.HandOpen());
                            emg1cThresholdReach = false;
                        }
                    }

                    //Thread.Sleep(emg1c.Delay);
                    if (int.TryParse(temp, out int j))
                    {
                        emg1cChartValue.Add(new ChartModel()
                        {
                            Data = double.Parse(temp),
                            Time = DateTime.Now
                        });
                        Invoke(new Action(() =>
                        {
                            emg1cChart.AxisX[0].MaxValue = DateTime.Now.Ticks + TimeSpan.FromSeconds(2).Ticks;
                            emg1cChart.AxisX[0].MinValue = DateTime.Now.Ticks - TimeSpan.FromSeconds(10).Ticks;
                        }));
                        if (emg1cChartValue.Count > 100)
                        {
                            emg1cChartValue.RemoveAt(0);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.GetBaseException().ToString() + "\n\nFROM EMG1C RECEIVE");
            }
        }
Exemplo n.º 28
0
        private void AddSpeedMeasurement(SpeedMeasurement measurement)
        {
            CHART_VALUES.Add(measurement);
            if (TIMER.IsEnabled)
            {
                SetAxisLimits(measurement.DateTime);
            }

            if (DateTime.Now.Subtract(CHART_VALUES.Last().DateTime).TotalSeconds > 60)
            {
                CHART_VALUES.RemoveAt(0);
            }
        }
        private void Form1_DataLive(double weightReal, double powerReal, double wHour, double wDay, double wMonth)
        {
            try
            {
                this.Invoke((MethodInvoker) delegate
                {
                    textBox4.Text = weightReal.ToString("F2");
                    textBox5.Text = powerReal.ToString("F2");

                    textBox8.Text  = wHour.ToString("F2");
                    textBox9.Text  = wDay.ToString("F2");
                    textBox10.Text = wMonth.ToString("F2");
                });
                //textBox4.Text = Form1.WEIGHT_STATIC_SHIFT.ToString();


                var now = System.DateTime.Now;

                ChartValues.Add(new MeasureModel
                {
                    Value = powerReal
                });

                ChartValuesWEIGHT.Add(new MeasureModel
                {
                    Value = weightReal
                            //Value = dbs.Weight.Value
                });

                lableX.Add(now.ToString("HH:mm:ss") + "\n" + now.ToString("dd.MM.yy"));
                this.Invoke((MethodInvoker) delegate
                {
                    cartesianChart3.AxisX[0].Labels = lableX;
                    cartesianChart2.AxisX[0].Labels = lableX;
                    //MessageBox.Show(TimeSpan.FromSeconds(1).Ticks.ToString(),"");
                    //SetAxisLimits(now);
                    cartesianChart3.Refresh();
                    cartesianChart2.Refresh();
                });
                //lets only use the last 30 values
                if (ChartValues.Count > 14)
                {
                    ChartValues.RemoveAt(0);
                    ChartValuesWEIGHT.RemoveAt(0);
                    lableX.RemoveAt(0);
                }
            }
            catch (Exception e)
            { }
        }
Exemplo n.º 30
0
        /// <summary>
        /// Data retrieveing section
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        public async void export()
        {
            int i = 0;

            while (true)
            {
                Thread.Sleep(1000);


                FirebaseResponse resp1 = await client.GetTaskAsync("Counter/Node");

                CounterClass obj1 = resp1.ResultAs <CounterClass>();
                int          cnt  = Convert.ToInt32(obj1.cnt);

                while (true)
                {
                    if (i == cnt)
                    {
                        break;
                    }
                    i++;
                    try
                    {
                        FirebaseResponse resp2 = await client.GetTaskAsync("Data/" + i);

                        if (resp2 != null)
                        {
                            Data obj2 = resp2.ResultAs <Data>();

                            double Weight = getweight(obj2.DataPackage);
                            ChartValues.Add(new MeasureModel
                            {
                                DateTime = System.DateTime.Now,
                                Value    = Weight
                            });
                            //Move axis right limit to current time
                            SetAxisLimits(DateTime.Now);
                            if (ChartValues.Count > 1500)
                            {
                                ChartValues.RemoveAt(0);
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }