Exemplo n.º 1
0
        private void closePort_Click(object sender, RoutedEventArgs e)
        {
            close();
            //screenshot();

            //Harf.Content = sending;

            voltagePointCollection.Clear();
        }
Exemplo n.º 2
0
        void x_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            voltagePointCollection.Clear();
            voltagepoint1 = new VoltagePointCollection();
            voltagepoint2 = new VoltagePointCollection();
            voltagepoint3 = new VoltagePointCollection();
            var ds1 = new EnumerableDataSource <VoltagePoint>(voltagepoint1);

            ds1.SetXMapping(x => dateAxis.ConvertToDouble(x.Date));
            ds1.SetYMapping(y => y.Voltage);
            plotter.AddLineGraph(ds1, Colors.Green, 2, "0kg"); // to use this method you need "using Microsoft.Research.DynamicDataDisplay;"
            MaxVoltage = 1;
            MinVoltage = -1;
            var ds2 = new EnumerableDataSource <VoltagePoint>(voltagepoint2);

            ds2.SetXMapping(x => dateAxis.ConvertToDouble(x.Date));
            ds2.SetYMapping(y => y.Voltage);
            plotter.AddLineGraph(ds2, Colors.Red, 2, "5kg"); // to use this method you need "using Microsoft.Research.DynamicDataDisplay;"
            MaxVoltage = 1;
            MinVoltage = -1;
            var ds3 = new EnumerableDataSource <VoltagePoint>(voltagepoint3);

            ds3.SetXMapping(x => dateAxis.ConvertToDouble(x.Date));
            ds3.SetYMapping(y => y.Voltage);
            plotter.AddLineGraph(ds3, Colors.Black, 2, "25kg"); // to use this method you need "using Microsoft.Research.DynamicDataDisplay;"
            MaxVoltage = 1;
            MinVoltage = -1;
            for (int i = 0; i < values[0].Count; i++)
            {
                if (i % 50 == 0)
                {
                    voltagepoint1.Clear(); voltagepoint2.Clear(); voltagepoint3.Clear(); screenshot();
                }

                DateTime now = DateTime.Now;
                voltagepoint1.Add(new VoltagePoint(values[0][i], now));
                voltagepoint2.Add(new VoltagePoint(values[1][i], now));
                voltagepoint3.Add(new VoltagePoint(values[2][i], now));
            }
            MessageBox.Show("Tebrikler başardınız.");
        }
Exemplo n.º 3
0
        private void btn_reset_Click(object sender, RoutedEventArgs e)
        {
            if ((dateTimePicker2.DateTime - dateTimePicker1.DateTime).TotalHours > 1)
            {
                MessageBox.Show("所选时间不可超过2个小时!");
                return;
            }

            var time1      = GetTimestamp(dateTimePicker1.DateTime);
            var time2      = GetTimestamp(dateTimePicker2.DateTime);
            var result     = HTHistorySDK.GetString($"http://jwhdm.com/api/services/app/RTHistoryService/GetDatas?tenantid=0001&pointid={txtPointId.Text}&beginTimestamp={time1}&endtimestamp={time2}");
            var jsonObj    = JObject.Parse(result);
            var resultJson = jsonObj["result"];

            if (resultJson == null)
            {
                return;
            }

            var voltagePointCollection = new List <VoltagePoint>();

            foreach (var item in resultJson)
            {
                var value    = Convert.ToDouble(item["value"]);
                var datetime = NewDate(Convert.ToInt64(item["timestampclient"]));
                var interval = Convert.ToInt32(item["interval"]);
                if (voltagePointCollection.Count > 0 && voltagePointCollection[voltagePointCollection.Count - 1].Date == datetime)
                {
                    continue;
                }
                voltagePointCollection.Add(new VoltagePoint(value, datetime, interval));
            }

            var valueUnCompressed = new List <VoltagePoint>();
            //var firstItem = voltagePointCollection.First();
            //var endItem= voltagePointCollection.Last();
            int i = 0;

            foreach (var item in voltagePointCollection)
            {
                i++;
                var firstItem = voltagePointCollection.First();
                //var endItem = voltagePointCollection.Last();
                if (valueUnCompressed.Count > 0 && valueUnCompressed[valueUnCompressed.Count - 1].Date == item.Date)
                {
                    continue;
                }
                var currentItemCompressed = UnCompress(voltagePointCollection, dateTimePicker1.DateTime.AddMilliseconds(i * firstItem.Interval));
                if (currentItemCompressed != null && currentItemCompressed.Date >= dateTimePicker1.DateTime && currentItemCompressed.Date <= dateTimePicker2.DateTime)
                {
                    valueUnCompressed.Add(currentItemCompressed);
                }
                if (valueUnCompressed.Count > 300)
                {
                    break;
                }
            }

            this.historyplotter.Dispatcher.BeginInvoke(new Action(delegate
            {
                historyPointCollection.Clear();
                historyPointCollection.AddMany(valueUnCompressed);
            }));
            this.tbMultiLine.Text = result;
        }