【用C# WPF+lua写了一个电子常用的调试测试数据采集软件,数据采集测试项,采用excel编写,函数采用lua编写,生成csv log】

本文介绍了使用C#WPF和lua技术开发的一款电子设备数据采集软件,支持多种接口,通过Excel编写的测试项目,Lua函数执行并生成CSV日志。文章详细展示了关键函数调用和测试过程控制。
摘要由CSDN通过智能技术生成

【用C# WPF+lua写了一个电子常用的调试测试数据采集软件,数据采集测试项,采用excel编写,函数采用lua编写,生成csv log】

支持串口、USB、TCPIP、GPIB 等……

视频链接:
https://www.bilibili.com/video/BV131421S7dN/

测试界面如下:
在这里插入图片描述
导入数据采集测试项目
在这里插入图片描述
测试自动跑测试项在这里插入图片描述
Log目录:存放 CSV log 文件,测试结果
Profile:测试项 excel 文件
Script:函数,txt文件
Setting:串口、USB、TCPIP、GPIB

生成的LOG文件
在这里插入图片描述
函数文件,采用lua格式:
在这里插入图片描述

配置文件ini
在这里插入图片描述

主要的函数调用在这里插入图片描述
代码片段:

						dynamic obj = MainView.Items[step];
                        var objName = obj.GetType().GetProperty("Function").GetValue(obj);
                        string Lower = obj.GetType().GetProperty("Lower").GetValue(obj).ToString();
                        string Upper = obj.GetType().GetProperty("Upper").GetValue(obj).ToString();
                        string Unit = obj.GetType().GetProperty("Unit").GetValue(obj).ToString();
                        try
                        {
                            LuaFunction function = LuaVM.GetFunction(objName.ToString());
                            if (function != null)
                            {
                                object[] values = function.Call();
                                foreach (var value in values) //遍历 values 数组中的元素
                            {
                                    Console.WriteLine(value); //输出
                                string res = value.ToString();
                                    users[step].DUT1 = res;
                                    if (res != "")
                                    {
                                        if ((Unit.ToUpper() == "A") ||
                                        (Unit.ToUpper() == "MA") ||
                                        (Unit.ToUpper() == "K") ||
                                        (Unit.ToUpper() == "R") ||
                                        (Unit.ToUpper() == "KV") ||
                                        (Unit.ToUpper() == "V") ||
                                        (Unit.ToUpper() == "MMV") ||
                                        (Unit.ToUpper() == "HZ"))
                                        {
                                            if ((float.Parse(res) >= float.Parse(Lower)) && (float.Parse(res) <= float.Parse(Upper)))
                                            {
                                                users[step].DUT1_Color = "Blue";
                                            }
                                            else
                                            {
                                                users[step].DUT1_Color = "Red";
                                            }
                                        }
                                        else
                                        {
                                            if ((res == Lower) || (res == Upper))
                                            {
                                                users[step].DUT1_Color = "Blue";
                                            }
                                            else
                                            {
                                                users[step].DUT1_Color = "Red";
                                            }
                                        }
                                    }
                                    this.Dispatcher.Invoke(new Action(() =>
                                    {
                                        MainView.SelectedIndex = step;
                                        MainView.Items.Refresh();
                                        MainView.ScrollIntoView(MainView.Items[step]);
                                    }), null);
                                }

感兴趣的小伙伴请联系我,交流学习,谢谢!

资源下载链接:https://download.csdn.net/download/weixin_43645564/89075882

  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
以下是一个简单的C# WPF扫码软件示例: 1. 创建一个新的WPF应用程序目。 2. 在MainWindow.xaml中添加一个Grid,并在其中添加一个TextBlock和一个Button。 3. 在TextBlock中输入“请扫描二维码”,并设置其HorizontalAlignment和VerticalAlignment属性为Center。 4. 在Button中输入“扫描”,并设置其HorizontalAlignment和VerticalAlignment属性为Center。 5. 在MainWindow.xaml.cs中添加以下代码: ```csharp using System.Windows; using System.Windows.Controls; using System.Windows.Media.Imaging; using ZXing; namespace QRCodeScanner { public partial class MainWindow : Window { private readonly BarcodeReader _reader; public MainWindow() { InitializeComponent(); _reader = new BarcodeReader(); } private void ScanButton_Click(object sender, RoutedEventArgs e) { var dialog = new Microsoft.Win32.OpenFileDialog { Filter = "PNG|*.png|JPEG|*.jpg|BMP|*.bmp" }; var result = dialog.ShowDialog(); if (result == true) { var bitmap = new BitmapImage(new System.Uri(dialog.FileName)); var barcodeResult = _reader.Decode(bitmap); if (barcodeResult != null) { TextBlock.Text = barcodeResult.Text; } else { TextBlock.Text = "未找到二维码"; } } } } } ``` 6. 将Button的Click事件绑定到ScanButton_Click方法。 7. 运行程序,点击扫描按钮,选择一个二维码图片,程序将在TextBlock中显示二维码的内容。 以上示例使用ZXing库来解码二维码。你可以在NuGet中安装ZXing.Net包,然后在代码中添加using ZXing;来使用它。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值