首页 新闻 会员 周边 捐助

txt文件中的按照数据前的名称进行打点显示折现图

0
悬赏园豆:50 [待解决问题]

[2023-01-12 15:14:14 465]AT+CGATT?
[2023-01-12 15:14:14 465]+CGATT:1
[2023-01-12 15:14:14 465]OK

[2023-01-12 15:14:15 427]AT+NUESTATS=RADIO
[2023-01-12 15:14:15 427]+Signal power:-1020
[2023-01-12 15:14:15 427]+Total power:-900
[2023-01-12 15:14:15 427]+TX power:230
[2023-01-12 15:14:15 427]+TX time:1682
[2023-01-12 15:14:15 427]+RX time:44481
[2023-01-12 15:14:15 427]+Cell ID:128523603
[2023-01-12 15:14:15 427]+ECL:0
[2023-01-12 15:14:15 427]+SNR:0
[2023-01-12 15:14:15 427]+EARFCN:3686
[2023-01-12 15:14:15 427]+PCI:502
[2023-01-12 15:14:15 427]+RSRQ:-120
[2023-01-12 15:14:15 427]+PLMN:46000
[2023-01-12 15:14:15 427]+TAC:002A
[2023-01-12 15:14:15 427]+SBAND:8
[2023-01-12 15:14:15 427]+OPERATION MODE:3
[2023-01-12 15:14:15 427]OK

[2023-01-12 15:14:16 430]AT+CESQ
[2023-01-12 15:14:16 430]+CESQ:21,0,255,255,16,39
[2023-01-12 15:14:16 430]OK

[2023-01-12 15:14:17 438]AT+NUESTATS
[2023-01-12 15:14:17 438]+Signal power:-1020
[2023-01-12 15:14:17 438]+Total power:-900
[2023-01-12 15:14:17 438]+TX power:230
[2023-01-12 15:14:17 438]+TX time:1682
[2023-01-12 15:14:17 438]+RX time:44481
[2023-01-12 15:14:17 438]+Cell ID:128523603
[2023-01-12 15:14:17 438]+ECL:0
[2023-01-12 15:14:17 438]+SNR:0
[2023-01-12 15:14:17 438]+EARFCN:3686
[2023-01-12 15:14:17 438]+PCI:502
[2023-01-12 15:14:17 438]+RSRQ:-120
[2023-01-12 15:14:17 438]+PLMN:46000
[2023-01-12 15:14:17 438]+TAC:002A
[2023-01-12 15:14:17 438]+SBAND:8
[2023-01-12 15:14:17 438]+OPERATION MODE:3
[2023-01-12 15:14:17 438]OK

[2023-01-12 15:14:18 427]ATEI
[2023-01-12 15:14:18 427]+CME ERROR:8003

[2023-01-12 15:14:21 012]AT+CGATT?
[2023-01-12 15:14:21 012]+CGATT:1
[2023-01-12 15:14:21 012]OK

[2023-01-12 15:14:22 094]AT+NUESTATS=RADIO
[2023-01-12 15:14:22 094]+Signal power:-1020
[2023-01-12 15:14:22 094]+Total power:-900
[2023-01-12 15:14:22 094]+TX power:230
[2023-01-12 15:14:22 094]+TX time:1682
[2023-01-12 15:14:22 094]+RX time:44481
[2023-01-12 15:14:22 094]+Cell ID:128523603
[2023-01-12 15:14:22 094]+ECL:0
[2023-01-12 15:14:22 094]+SNR:0
[2023-01-12 15:14:22 094]+EARFCN:3686
[2023-01-12 15:14:22 094]+PCI:502
[2023-01-12 15:14:22 094]+RSRQ:-120
[2023-01-12 15:14:22 094]+PLMN:46000
[2023-01-12 15:14:22 094]+TAC:002A
[2023-01-12 15:14:22 094]+SBAND:8
[2023-01-12 15:14:22 094]+OPERATION MODE:3
[2023-01-12 15:14:22 094]OK

[2023-01-12 15:14:23 086]AT+CESQ
[2023-01-12 15:14:23 086]+CESQ:21,0,255,255,16,39
[2023-01-12 15:14:23 086]OK

[2023-01-12 15:14:24 088]AT+NUESTATS
[2023-01-12 15:14:24 088]+Signal power:-1020
[2023-01-12 15:14:24 088]+Total power:-900
[2023-01-12 15:14:24 088]+TX power:230
[2023-01-12 15:14:24 088]+TX time:1682
[2023-01-12 15:14:24 088]+RX time:44481
[2023-01-12 15:14:24 088]+Cell ID:128523603
[2023-01-12 15:14:24 088]+ECL:0
[2023-01-12 15:14:24 088]+SNR:0
[2023-01-12 15:14:24 088]+EARFCN:3686
[2023-01-12 15:14:24 088]+PCI:502
[2023-01-12 15:14:24 088]+RSRQ:-120
[2023-01-12 15:14:24 088]+PLMN:46000
[2023-01-12 15:14:24 088]+TAC:002A
[2023-01-12 15:14:24 088]+SBAND:8
[2023-01-12 15:14:24 088]+OPERATION MODE:3
[2023-01-12 15:14:24 088]OK

[2023-01-12 15:14:25 129]ATEI
[2023-01-12 15:14:25 129]+CME ERROR:8003

[2023-01-12 15:14:27 580]AT+CGATT?
[2023-01-12 15:14:27 580]+CGATT:1
[2023-01-12 15:14:27 580]OK

[2023-01-12 15:14:28 722]AT+NUESTATS=RADIO
[2023-01-12 15:14:28 722]+Signal power:-1020
[2023-01-12 15:14:28 722]+Total power:-900
[2023-01-12 15:14:28 722]+TX power:230
[2023-01-12 15:14:28 722]+TX time:1682
[2023-01-12 15:14:28 722]+RX time:44481
[2023-01-12 15:14:28 722]+Cell ID:128523603
[2023-01-12 15:14:28 722]+ECL:0
[2023-01-12 15:14:28 722]+SNR:0
[2023-01-12 15:14:28 722]+EARFCN:3686
[2023-01-12 15:14:28 722]+PCI:502
[2023-01-12 15:14:28 722]+RSRQ:-120
[2023-01-12 15:14:28 722]+PLMN:46000
[2023-01-12 15:14:28 722]+TAC:002A
[2023-01-12 15:14:28 722]+SBAND:8
[2023-01-12 15:14:28 722]+OPERATION MODE:3
[2023-01-12 15:14:28 722]OK

[2023-01-12 15:14:29 995]AT+CESQ
[2023-01-12 15:14:29 995]+CESQ:21,0,255,255,16,39
[2023-01-12 15:14:29 995]OK

[2023-01-12 15:14:30 703]AT+NUESTATS
[2023-01-12 15:14:30 703]+Signal power:-1020
[2023-01-12 15:14:30 703]+Total power:-900
[2023-01-12 15:14:30 703]+TX power:230
[2023-01-12 15:14:30 703]+TX time:1682
[2023-01-12 15:14:30 703]+RX time:44481
[2023-01-12 15:14:30 703]+Cell ID:128523603
[2023-01-12 15:14:30 703]+ECL:0
[2023-01-12 15:14:30 703]+SNR:0
[2023-01-12 15:14:30 703]+EARFCN:3686
[2023-01-12 15:14:30 703]+PCI:502
[2023-01-12 15:14:30 703]+RSRQ:-120
[2023-01-12 15:14:30 703]+PLMN:46000
[2023-01-12 15:14:30 703]+TAC:002A
[2023-01-12 15:14:30 703]+SBAND:8
[2023-01-12 15:14:30 703]+OPERATION MODE:3
[2023-01-12 15:14:30 703]OK

[2023-01-12 15:14:31 721]ATEI
[2023-01-12 15:14:31 721]+CME ERROR:8003

[2023-01-12 15:14:34 135]AT+CGATT?
[2023-01-12 15:14:34 135]+CGATT:1
[2023-01-12 15:14:34 135]OK

[2023-01-12 15:14:35 129]AT+NUESTATS=RADIO
[2023-01-12 15:14:35 129]+Signal power:-1020
[2023-01-12 15:14:35 129]+Total power:-900
[2023-01-12 15:14:35 129]+TX power:230
[2023-01-12 15:14:35 129]+TX time:1682
[2023-01-12 15:14:35 129]+RX time:44481
[2023-01-12 15:14:35 129]+Cell ID:128523603
[2023-01-12 15:14:35 129]+ECL:0
[2023-01-12 15:14:35 129]+SNR:0
[2023-01-12 15:14:35 129]+EARFCN:3686
[2023-01-12 15:14:35 129]+PCI:502
[2023-01-12 15:14:35 129]+RSRQ:-120
[2023-01-12 15:14:35 129]+PLMN:46000
[2023-01-12 15:14:35 129]+TAC:002A
[2023-01-12 15:14:35 129]+SBAND:8
[2023-01-12 15:14:35 129]+OPERATION MODE:3
[2023-01-12 15:14:35 129]OK

[2023-01-12 15:14:36 120]AT+CESQ
[2023-01-12 15:14:36 120]+CESQ:21,0,255,255,16,39
[2023-01-12 15:14:36 120]OK

[2023-01-12 15:14:37 116]AT+NUESTATS
[2023-01-12 15:14:37 116]+Signal power:-1020
[2023-01-12 15:14:37 116]+Total power:-900
[2023-01-12 15:14:37 116]+TX power:230
[2023-01-12 15:14:37 116]+TX time:1682
[2023-01-12 15:14:37 116]+RX time:44481
[2023-01-12 15:14:37 116]+Cell ID:128523603
[2023-01-12 15:14:37 116]+ECL:0
[2023-01-12 15:14:37 116]+SNR:0
[2023-01-12 15:14:37 116]+EARFCN:3686
[2023-01-12 15:14:37 116]+PCI:502
[2023-01-12 15:14:37 116]+RSRQ:-120
[2023-01-12 15:14:37 116]+PLMN:46000
[2023-01-12 15:14:37 116]+TAC:002A
[2023-01-12 15:14:37 116]+SBAND:8
[2023-01-12 15:14:37 116]+OPERATION MODE:3
[2023-01-12 15:14:37 116]OK

[2023-01-12 15:14:38 105]ATEI
[2023-01-12 15:14:38 105]+CME ERROR:8003

[2023-01-12 15:14:40 707]AT+CGATT?
[2023-01-12 15:14:40 707]+CGATT:1
[2023-01-12 15:14:40 707]OK

[2023-01-12 15:14:41 683]AT+NUESTATS=RADIO
[2023-01-12 15:14:41 683]+Signal power:-1020
[2023-01-12 15:14:41 683]+Total power:-900
[2023-01-12 15:14:41 683]+TX power:230
[2023-01-12 15:14:41 683]+TX time:1682
[2023-01-12 15:14:41 683]+RX time:44481
[2023-01-12 15:14:41 683]+Cell ID:128523603
[2023-01-12 15:14:41 683]+ECL:0
[2023-01-12 15:14:41 683]+SNR:0
[2023-01-12 15:14:41 683]+EARFCN:3686
[2023-01-12 15:14:41 683]+PCI:502
[2023-01-12 15:14:41 683]+RSRQ:-120
[2023-01-12 15:14:41 683]+PLMN:46000
[2023-01-12 15:14:41 683]+TAC:002A
[2023-01-12 15:14:41 683]+SBAND:8
[2023-01-12 15:14:41 683]+OPERATION MODE:3
[2023-01-12 15:14:41 683]OK

本人急用这个数据显示打点情况,各位大佬请帮帮我哦

问题补充:

我是用C# 的控件Chart控件显示这些数据的值,在等待3秒后数据可以打点显示每个值得变化曲线,求大佬快来各显神通帮我一下哦

。LANGYUAN。的主页 。LANGYUAN。 | 初学一级 | 园豆:136
提问于:2023-01-13 14:26

我看你这不是做出来了

echo_lovely 1年前
< >
分享
所有回答(1)
0

这么长的数据,哪些是要显示的属性?哪些是值?没有数据结构吗?

echo_lovely | 园豆:1488 (小虾三级) | 2023-01-16 15:42

有,将这些数据重复的名称后的值进行打点如下:

支持(0) 反对(0) 。LANGYUAN。 | 园豆:136 (初学一级) | 2023-01-17 13:46

找到RSRP的信号每出现一次打点一次,各位大佬帮我看看呗

支持(0) 反对(0) 。LANGYUAN。 | 园豆:136 (初学一级) | 2023-01-17 13:47

@。LANGYUAN。: WinForm 还是wpf

支持(0) 反对(0) echo_lovely | 园豆:1488 (小虾三级) | 2023-01-17 13:49

@echo_lovely: C# ,WPF都可以,只要可以打点显示数据

支持(0) 反对(0) 。LANGYUAN。 | 园豆:136 (初学一级) | 2023-01-28 09:30

@。LANGYUAN。: 年前摸鱼没事干的时候,不回我,现在上班了,你才回。你这问题不难:
流程:

  • 读txt文件 String[] contents = System.IO.File.ReadAllLines(path)
  • 然后把读到的文件内容按行遍历 foreach
  • 设置一个Dictionary<String, List<int>>

    String键负责保存这是什么类型的信号
    List<int>负责存储该信号的值

  • 每遍历一行,
    • 判定当前行时候包含信号信息,不包含则跳过;
    • 若包含:
      • 则判断Dictionary中是否有该信号类型,没有则进行添加,
      • 有则将信号值添加近对应的list中
  • 按照添Dictionary的key加tab并按照Dictionary的value添加图表
支持(0) 反对(0) echo_lovely | 园豆:1488 (小虾三级) | 2023-01-28 09:43

@。LANGYUAN。:

using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;

namespace WindowsFormsApp3
{
    public partial class Form1 : Form
    {
        private string path = "F:\\System Icon\\Desktop\\signal.txt";
        private Dictionary<string, List<KeyValuePair<string, int>>> signals = new Dictionary<string, List<KeyValuePair<string, int>>>();
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string[] contents = File.ReadAllLines(path);
            foreach (var item in contents)
            {
                if (JudgeTextLine(item))
                {
                    string key = GetKey(item);
                    try
                    {
                        KeyValuePair<string, int> value = GetValue(item);
                        if (!signals.ContainsKey(key))
                        {
                            signals[key] = new List<KeyValuePair<string, int>>(); ;
                        }
                        signals[key].Add(value);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.ToString());
                        Debug.WriteLine(item);
                    }
                }
            }
            int i = 0;
            foreach(string key in signals.Keys)
            {
                List<KeyValuePair<string, int>> list = signals[key];
                List<string> xData = list.Select(ele => ele.Key).ToList();
                List<int> yData = list.Select(ele => ele.Value).ToList();
                TabPage tabPage = new TabPage(key);
                Chart chart = new Chart();
                chart.Dock= DockStyle.Fill;

                Series series= new Series(key);
                series.ChartType = SeriesChartType.Line;
                series.Color= Color.Green;
                series.BorderWidth = 2;
                series.MarkerStyle = MarkerStyle.Circle;
                series.MarkerBorderWidth= 3;
                series.Points.DataBindY(yData);

                ChartArea chartArea = new ChartArea();
                Legend legend= new Legend();
                chart.ChartAreas.Add(chartArea);
                chart.Legends.Add(legend);
                chart.Series.Add(series);
                tabPage.Controls.Add(chart);
                this.tabControlSignal.Controls.Add(tabPage);
            }
        }

        private string GetKey(string item)
        {
            return item.Split(']')[1].TrimStart('+').Split(':')[0];
        }

        private KeyValuePair<string, int> GetValue(string item)
        {
            string[] items = item.Split(']');
            string timeStr = items[0].TrimStart('[');
            int val = int.Parse(items[1].Split(':')[1]);
            return new KeyValuePair<string, int>(timeStr, val);
        }

        private bool JudgeTextLine(string item)
        {
            bool res = false;
            string[] unSignalString = new string[] { "OPERATION" };
            if(!string.IsNullOrWhiteSpace(item))
            {
                string[] strings = item.Split(']');
                if (strings.Length > 1)
                {
                    string[] keyVal = strings[1].TrimStart('+').Split(':');
                    if (keyVal.Length >1 && keyVal[0].All(e=>char.IsUpper(e)) && !unSignalString.Any(e => keyVal[0].Contains(e)))
                    {
                        res = true;
                    }
                }
            }
            return res;
        }
    }
}

我拿到的数据都是每种信号值是相同的,不清楚是谁的问题……

支持(1) 反对(0) echo_lovely | 园豆:1488 (小虾三级) | 2023-01-28 14:10

@echo_lovely: 哇塞

支持(0) 反对(0) 。LANGYUAN。 | 园豆:136 (初学一级) | 2023-01-30 16:52

@echo_lovely: 大佬如果这个txt的数据保存时就是动态保存的可以将这些数据打点显示吗,我就是需要这种相同的数据哦,如第二张图如果数据多了数据的值会发生浮动嘿嘿,我就是在循环发送数据后一边保存在txt上同时还能将一些值打点在chart上显示,还可以将值显示在listView上闪烁信号的变化,大佬可以再帮我看看这个怎么解决它呀

支持(0) 反对(0) 。LANGYUAN。 | 园豆:136 (初学一级) | 2023-01-30 17:00

@。LANGYUAN。:

如果这个txt的数据保存时就是动态保存的,可以将这些数据打点显示吗

就是动态将输出的内容保存到txt文件,然后读取文件,然后显示到折线图对吧?数据少了可以,数据多了会卡,毕竟在一直读硬盘

第二张图如果数据多了数据的值会发生浮动嘿嘿,我就是在循环发送数据后一边保存在txt上同时还能将一些值打点在chart上显示,还可以将值显示在listView上闪烁信号的变化

这个似乎是可以的,但是我没有试过,不清楚到底行不行

支持(1) 反对(0) echo_lovely | 园豆:1488 (小虾三级) | 2023-01-30 17:09

@。LANGYUAN。: 但是,我想你能不能换种方式,不要写到文件中,试试用MQ或者TCP发消息,这样避免了一直读写硬盘

支持(0) 反对(0) echo_lovely | 园豆:1488 (小虾三级) | 2023-01-30 17:11

@echo_lovely: 大佬我现在搞出来的就这样子!

支持(0) 反对(0) 。LANGYUAN。 | 园豆:136 (初学一级) | 2023-01-30 17:20

@echo_lovely:大佬机会摆在你面前要不要一起试一试

支持(0) 反对(0) 。LANGYUAN。 | 园豆:136 (初学一级) | 2023-01-30 17:26

如果大佬不介意有时间帮我看看哦,爱你

支持(0) 反对(0) 。LANGYUAN。 | 园豆:136 (初学一级) | 2023-01-30 17:27

@。LANGYUAN。: 那就把这几件事分开搞

  1. 发送指令
  2. 将接收到的数据,用一个变量储存起来
  3. 处理接收的数据
  4. 将处理后的数据,打轨迹图、显示在listView
  5. #2中的变量内容保存到txt文件
支持(0) 反对(0) echo_lovely | 园豆:1488 (小虾三级) | 2023-01-30 17:28

@。LANGYUAN。: 我这没有你的环境,估计得你自己搞了,遇到什么问题,可以交流

支持(0) 反对(0) echo_lovely | 园豆:1488 (小虾三级) | 2023-01-30 17:30

@echo_lovely: 好哒,大佬

支持(0) 反对(0) 。LANGYUAN。 | 园豆:136 (初学一级) | 2023-01-31 09:03

@echo_lovely: MQ是啥?

支持(0) 反对(0) 。LANGYUAN。 | 园豆:136 (初学一级) | 2023-01-31 09:11
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册