修改了两个页面的交互与保存,完善了其他测试逻辑,增加新GSENSOR逻辑

main
xxq 1 week ago
parent 757953bb41
commit c9c4c5c45d

@ -1,7 +1,8 @@
{ {
"ExpandedNodes": [ "ExpandedNodes": [
"" "",
"\\YD10测试机"
], ],
"SelectedNode": "\\C:\\Users\\Administrator\\Source\\Repos\\YD10-YD07k_SMT", "SelectedNode": "\\YD10测试机\\Form3.cs",
"PreviewInSolutionExplorer": false "PreviewInSolutionExplorer": false
} }

Binary file not shown.

Binary file not shown.

@ -1,15 +1,20 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Windows.Devices.Bluetooth; using Windows.Devices.Bluetooth;
using Windows.Devices.Bluetooth.Advertisement;
using Windows.Devices.Bluetooth.GenericAttributeProfile; using Windows.Devices.Bluetooth.GenericAttributeProfile;
using Windows.Devices.Enumeration; using Windows.Devices.Enumeration;
using Windows.Foundation;
using Windows.Security.Cryptography; using Windows.Security.Cryptography;
using System.Diagnostics;
namespace BluetoothLibrary
namespace Bluetoolth
{ {
public enum BlueStatus public enum BlueStatus
{ {
DisConnected, //未连接 DisConnected, //未连接
@ -27,171 +32,709 @@ namespace BluetoothLibrary
public class BleCore public class BleCore
{ {
private BluetoothLEDevice _currentDevice;
private GattDeviceService _currentService;
private GattCharacteristic _writeCharacteristic;
private GattCharacteristic _notifyCharacteristic;
private List<BluetoothLEDevice> _discoveredDevices = new List<BluetoothLEDevice>();
public event Action<MsgType, string, byte[]> MessageChanged; private bool asyncLock = false;
/// <summary>
/// 搜索蓝牙设备对象
/// </summary>
private DeviceWatcher deviceWatcher;
/// <summary>
/// 当前连接的服务
/// </summary>
public GattDeviceService CurrentService { get; set; }
/// <summary>
/// 当前连接的蓝牙设备
/// </summary>
public BluetoothLEDevice CurrentDevice { get; set; }
/// <summary>
/// 写特征对象
/// </summary>
public GattCharacteristic CurrentWriteCharacteristic { get; set; }
/// <summary>
/// 写名称特征对象
/// </summary>
public GattCharacteristic CurrentNameCharacteristic { get; set; }
/// <summary>
/// 通知特征对象
/// </summary>
public GattCharacteristic CurrentNotifyCharacteristic { get; set; }
/// <summary>
/// 特性通知类型通知启用
/// </summary>
private const GattClientCharacteristicConfigurationDescriptorValue
CHARACTERSITIC_NOTIFICATION_TYPE = GattClientCharacteristicConfigurationDescriptorValue.Notify;
/// <summary>
/// 存储检测到的设备
/// </summary>
private List<string> DevicesList = new List<string>();
/// <summary>
/// 定义搜索蓝牙设备委托
/// </summary>
/// <param name="type"></param>
/// <param name="bluetoothLEDevice"></param>
public delegate void DevicewatcherChangedEvent(MsgType type, BluetoothLEDevice bluetoothLEDevice);
/// <summary>
/// 搜索蓝牙事件
/// </summary>
public event DevicewatcherChangedEvent DevicewatcherChanged;
/// <summary>
/// 获取服务委托
/// </summary>
/// <param name="gattDeviceService"></param>
public delegate void GattDeviceServiceAddedEvent(GattDeviceService gattDeviceService);
/// <summary>
/// 获取服务事件
/// </summary>
public event GattDeviceServiceAddedEvent GattDeviceServiceAdded;
/// <summary>
/// 获取特征委托
/// </summary>
/// <param name="gattCharacteristic"></param>
public delegate void CharacteristicAddedEvent(GattCharacteristic gattCharacteristic);
/// <summary>
/// 获取特征事件
/// </summary>
public event CharacteristicAddedEvent CharacteristicAdded;
/// <summary>
/// 提示信息委托
/// </summary>
/// <param name="type"></param>
/// <param name="message"></param>
/// <param name="data"></param>
public delegate void MessageChangedEvent(MsgType type, string message, byte[] data = null);
/// <summary>
/// 提示信息事件
/// </summary>
public event MessageChangedEvent MessageChanged;
/// <summary>
/// 当前连接蓝牙的Mac
/// </summary>
private string CurrentDeviceMAC { get; set; }
public BleCore()
{
}
public async Task StartDeviceDiscoveryAsync() /// <summary>
/// 搜索蓝牙设备 方法1
/// </summary>
public void StartBleDevicewatcher_1()
{ {
try
string[] requestedProperties = {
"System.Devices.Aep.DeviceAddress",
"System.Devices.Aep.IsConnected",
"System.Devices.Aep.Bluetooth.Le.IsConnectable" ,
"System.Devices.Aep.SignalStrength",
"System.Devices.Aep.IsPresent"
};
string aqsAllBluetoothLEDevices = "(System.Devices.Aep.ProtocolId:=\"{bb7bb05e-5972-42b5-94fc-76eaa7084d49}\")";
string Selector = "System.Devices.Aep.ProtocolId:=\"{bb7bb05e-5972-42b5-94fc-76eaa7084d49}\"";
string selector = "(" + Selector + ")" + " AND (System.Devices.Aep.CanPair:=System.StructuredQueryType.Boolean#True OR System.Devices.Aep.IsPaired:=System.StructuredQueryType.Boolean#True)";
this.deviceWatcher =
DeviceInformation.CreateWatcher(
// aqsAllBluetoothLEDevices,
// BluetoothLEDevice.GetDeviceSelectorFromPairingState(false),
selector,
requestedProperties,
DeviceInformationKind.AssociationEndpoint);
//在监控之前注册事件
this.deviceWatcher.Added += DeviceWatcher_Added;
this.deviceWatcher.Stopped += DeviceWatcher_Stopped;
this.deviceWatcher.Updated += DeviceWatcher_Updated; ;
this.deviceWatcher.Start();
string msg = "自动发现设备中..";
this.MessageChanged(MsgType.NotifyTxt, msg);
}
BluetoothLEAdvertisementWatcher watcher;
/// <summary>
/// 搜索蓝牙设备 方法2
/// </summary>
public void StartBleDevicewatcher()
{
watcher = new BluetoothLEAdvertisementWatcher();
watcher.ScanningMode = BluetoothLEScanningMode.Active;
// only activate the watcher when we're recieving values >= -80
watcher.SignalStrengthFilter.InRangeThresholdInDBm = -80;
// stop watching if the value drops below -90 (user walked away)
watcher.SignalStrengthFilter.OutOfRangeThresholdInDBm = -90;
// register callback for when we see an advertisements
watcher.Received += OnAdvertisementReceived;
watcher.Stopped += Watcher_Stopped;
// wait 5 seconds to make sure the device is really out of range
watcher.SignalStrengthFilter.OutOfRangeTimeout = TimeSpan.FromMilliseconds(5000);
watcher.SignalStrengthFilter.SamplingInterval = TimeSpan.FromMilliseconds(2000);
// starting watching for advertisements
watcher.Start();
string msg = "自动发现设备中..";
// this.MessageChanged(MsgType.NotifyTxt, msg);
}
private void Watcher_Stopped(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementWatcherStoppedEventArgs args)
{
DevicesList.Clear();
string msg = "自动发现设备停止";
this.MessageChanged(MsgType.NotifyTxt, msg);
}
private void OnAdvertisementReceived(BluetoothLEAdvertisementWatcher watcher, BluetoothLEAdvertisementReceivedEventArgs eventArgs)
{
BluetoothLEDevice.FromBluetoothAddressAsync(eventArgs.BluetoothAddress).Completed = async (asyncInfo, asyncStatus) =>
{
if (asyncStatus == AsyncStatus.Completed)
{
if (asyncInfo.GetResults() == null)
{
//this.MessAgeChanged(MsgType.NotifyTxt, "没有得到结果集");
}
else
{ {
string selector = BluetoothLEDevice.GetDeviceSelectorFromPairingState(false); BluetoothLEDevice currentDevice = asyncInfo.GetResults();
var devices = await DeviceInformation.FindAllAsync(selector); if (currentDevice.Name.StartsWith("Bluetooth"))
{
return;
}
foreach (var deviceInfo in devices) Boolean contain = false;
foreach (string deviceId in DevicesList)//过滤重复的设备
{ {
var device = await BluetoothLEDevice.FromIdAsync(deviceInfo.Id); if (deviceId == currentDevice.DeviceId)
if (device != null && !_discoveredDevices.Any(d => d.DeviceId == device.DeviceId))
{ {
_discoveredDevices.Add(device); contain = true; break;
OnMessageChanged(MsgType.BleDevice, $"Discovered device: {device.Name}", null);
} }
} }
string tmpMAC = "";
byte[] _Bytes1 = BitConverter.GetBytes(currentDevice.BluetoothAddress);
Array.Reverse(_Bytes1);
tmpMAC = BitConverter.ToString(_Bytes1, 2, 6).Replace('-', ':').ToLower();
if (!contain)
{
this.DevicesList.Add(currentDevice.DeviceId);
this.MessageChanged(MsgType.NotifyTxt, "发现设备:" + currentDevice.Name + " address:" + tmpMAC);
this.DevicewatcherChanged(MsgType.BleDevice, currentDevice);
// currentDevice = null;
} }
catch (Exception ex) /*
if (CurrentDevice == null && CurrentDeviceMAC == tmpMAC)
{//自动重连
CurrentDevice = currentDevice;
//获取服务
this.CurrentDevice.GetGattServicesAsync().Completed = (asynServe, asyncStatu) =>
{
if (asyncStatu == AsyncStatus.Completed)
{
var sevices = asynServe.GetResults().Services;
foreach (GattDeviceService ser in sevices)
{
if (ser.Uuid.ToString() == Utility.UUID_SERVER)
{ {
OnMessageChanged(MsgType.NotifyTxt, $"Error during device discovery: {ex.Message}", null); this.CurrentService = ser;
break;
}
} }
} }
else
{
this.CurrentDevice = null;
}
};
public async Task ConnectToDeviceAsync(string deviceId) if (this.CurrentService != null)
{ {
try //获取特征值
this.CurrentService.GetCharacteristicsAsync().Completed = (asynChara, asyncStatu) =>
{
if (asyncStatu == AsyncStatus.Completed)
{
var chara = asynChara.GetResults().Characteristics;
foreach (GattCharacteristic c in chara)
{ {
_currentDevice = await BluetoothLEDevice.FromIdAsync(deviceId); if (c.Uuid.ToString() == Utility.UUID_Name)
if (_currentDevice != null)
{ {
_currentDevice.ConnectionStatusChanged += OnConnectionStatusChanged; this.CurrentNameCharacteristic = c;
OnMessageChanged(MsgType.NotifyTxt, $"Connecting to device: {_currentDevice.Name}", null); break;
await DiscoverServicesAsync(); }
}
}
};
} }
else else
{//删除设备
this.CurrentDevice = null;
this.CurrentService = null;
return;
}
if (this.CurrentNameCharacteristic != null)
{
string msg = "已重连设备连接设备<" + this.CurrentDeviceMAC + "> ..";
this.MessageChanged(MsgType.NotifyTxt, msg);
}
}
*/
}
}
};
}
/// <summary>
/// 停止搜索
/// </summary>
public void StopBleDeviceWatcher()
{ {
OnMessageChanged(MsgType.NotifyTxt, "Device not found", null); if (deviceWatcher != null)
this.deviceWatcher.Stop();
if (watcher != null && watcher.Status == BluetoothLEAdvertisementWatcherStatus.Started)
watcher.Stop();
}
/// <summary>
/// 获取发现的蓝牙设备
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
private void DeviceWatcher_Added(DeviceWatcher sender, DeviceInformation args)
{
this.MessageChanged(MsgType.NotifyTxt, "发现设备:" + args.Id);
this.Matching(args.Id, args);
} }
private void DeviceWatcher_Updated(DeviceWatcher sender, DeviceInformationUpdate args)
{
} }
catch (Exception ex)
/// <summary>
/// 停止搜索蓝牙设备
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
private void DeviceWatcher_Stopped(DeviceWatcher sender, object args)
{ {
OnMessageChanged(MsgType.NotifyTxt, $"Error connecting to device: {ex.Message}", null); string msg = "自动发现设备停止";
this.MessageChanged(MsgType.NotifyTxt, msg);
} }
/// <summary>
/// 匹配
/// </summary>
/// <param name="device"></param>
public void StartMatching(BluetoothLEDevice device)
{
// Dispose(false);
this.CurrentDevice = device;
} }
private async Task DiscoverServicesAsync() /// <summary>
/// 获取蓝牙服务
/// </summary>
public async void FindService()
{ {
try /*var gattServices = this.CurrentDevice.GattServices;
foreach(GattDeviceService ser in gattServices)
{ {
var services = await _currentDevice.GetGattServicesAsync(); this.GattDeviceServiceAdded(ser);
foreach (var service in services.Services) }*/
this.CurrentDevice.GetGattServicesAsync().Completed = async (asyncInfo, asyncStatu) =>
{ {
if (service.Uuid.ToString() == "your-service-uuid-here") // Replace with your service UUID if (asyncStatu == AsyncStatus.Completed)
{ {
_currentService = service; var sevices = asyncInfo.GetResults().Services;
await DiscoverCharacteristicsAsync(); foreach (GattDeviceService ser in sevices)
break; {
this.GattDeviceServiceAdded(ser);
// FindCharacteristic(ser);
} }
} }
};
} }
catch (Exception ex)
public async void FindCharacteristic(GattDeviceService gattDeviceService)
{
/* this.CurrentService = gattDeviceService;
foreach(var c in gattDeviceService.GetAllCharacteristics())
{
this.CharacteristicAdded(c);
}*/
gattDeviceService.GetCharacteristicsAsync().Completed = async (asyncInfo, asyncStatu) =>
{
if (asyncStatu == AsyncStatus.Completed)
{ {
OnMessageChanged(MsgType.NotifyTxt, $"Error discovering services: {ex.Message}", null); var chara = asyncInfo.GetResults().Characteristics;
foreach (GattCharacteristic c in chara)
{
this.CharacteristicAdded(c);
} }
} }
};
}
private async Task DiscoverCharacteristicsAsync() /// <summary>
/// 获取操作
/// </summary>
/// <param name="gattCharacteristic"></param>
/// <returns></returns>
public async Task SetOpteron(GattCharacteristic gattCharacteristic)
{ {
try if (gattCharacteristic.CharacteristicProperties == GattCharacteristicProperties.WriteWithoutResponse)
{ {
var characteristics = await _currentService.GetCharacteristicsAsync(); this.CurrentWriteCharacteristic = gattCharacteristic;
foreach (var characteristic in characteristics.Characteristics) }
if (gattCharacteristic.CharacteristicProperties == GattCharacteristicProperties.Notify)
{ {
if (characteristic.Uuid.ToString() == "your-write-uuid-here") // Replace with your write UUID this.CurrentNotifyCharacteristic = gattCharacteristic;
this.CurrentNotifyCharacteristic.ProtectionLevel = GattProtectionLevel.Plain;
this.CurrentNotifyCharacteristic.ValueChanged += Characteristic_ValueChanged;
await this.EnableNotifications(CurrentNotifyCharacteristic);
}
if (gattCharacteristic.CharacteristicProperties == (GattCharacteristicProperties.Read | GattCharacteristicProperties.Write))
{ {
_writeCharacteristic = characteristic; this.CurrentNameCharacteristic = gattCharacteristic;
} }
else if (characteristic.Uuid.ToString() == "your-notify-uuid-here") // Replace with your notify UUID
if (!IsConnect)
this.Connect();
}
bool IsConnect = false;
private async Task Connect()
{ {
_notifyCharacteristic = characteristic; IsConnect = true;
await EnableNotificationsAsync(characteristic); byte[] _Bytes1 = BitConverter.GetBytes(this.CurrentDevice.BluetoothAddress);
Array.Reverse(_Bytes1);
this.CurrentDeviceMAC = BitConverter.ToString(_Bytes1, 2, 6).Replace('-', ':').ToLower();
string msg = "正在连接设备<" + this.CurrentDeviceMAC + "> ..";
this.MessageChanged(MsgType.NotifyTxt, msg);
this.CurrentDevice.ConnectionStatusChanged += CurrentDevice_ConnectionStatusChanged;
} }
private void CurrentDevice_ConnectionStatusChanged(BluetoothLEDevice sender, object args)
{
if (sender.ConnectionStatus == BluetoothConnectionStatus.Disconnected &&
CurrentDeviceMAC != null)
{
this.DevicesList.Remove(sender.DeviceId);
string msg = "设备已断开";
MessageChanged(MsgType.NotifyTxt, msg);
// if(!asyncLock)
{
asyncLock = true;
this.CurrentDevice?.Dispose();
this.CurrentDevice = null;
this.CurrentNotifyCharacteristic = null;
this.CurrentWriteCharacteristic = null;
this.CurrentNameCharacteristic = null;
// SelectDeviceFromIdAsync(CurrentDeviceMAC);
} }
} }
catch (Exception ex) else
{ {
OnMessageChanged(MsgType.NotifyTxt, $"Error discovering characteristics: {ex.Message}", null); string msg = "设备已连接";
MessageChanged(MsgType.NotifyTxt, msg);
} }
} }
private async Task EnableNotificationsAsync(GattCharacteristic characteristic) /// <summary>
/// 搜索到的蓝牙设备
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
private async Task Matching(string id, DeviceInformation args = null)
{ {
try try
{ {
await characteristic.WriteClientCharacteristicConfigurationDescriptorAsync( BluetoothLEDevice.FromIdAsync(id).Completed = async (asyncInfo, asyncStatus) =>
GattClientCharacteristicConfigurationDescriptorValue.Notify); {
characteristic.ValueChanged += OnCharacteristicValueChanged; if (asyncStatus == AsyncStatus.Completed)
OnMessageChanged(MsgType.NotifyTxt, "Notifications enabled", null); {
BluetoothLEDevice bleDevice = asyncInfo.GetResults();
if (bleDevice.Name.StartsWith("Bluetooth"))
{
return;
} }
catch (Exception ex) if (CurrentDeviceMAC != null)
{//自动重连
CurrentDevice = bleDevice;
//获取服务
this.CurrentDevice.GetGattServicesAsync().Completed = async (asynServe, asyncStatu) =>
{
if (asyncStatu == AsyncStatus.Completed)
{
var sevices = asynServe.GetResults().Services;
foreach (GattDeviceService ser in sevices)
{ {
OnMessageChanged(MsgType.NotifyTxt, $"Error enabling notifications: {ex.Message}", null); if (ser.Uuid.ToString() == Utility.UUID_SERVER)
{
this.CurrentService = ser;
break;
}
} }
} }
};
private void OnCharacteristicValueChanged(GattCharacteristic sender, GattValueChangedEventArgs args) if (this.CurrentService != null)
{ {
byte[] data; //获取特征值
CryptographicBuffer.CopyToByteArray(args.CharacteristicValue, out data); this.CurrentService.GetCharacteristicsAsync().Completed = async (asynChara, asyncStatu) =>
OnMessageChanged(MsgType.BleRecData, "Data received", data); {
if (asyncStatu == AsyncStatus.Completed)
{
var chara = asynChara.GetResults().Characteristics;
foreach (GattCharacteristic c in chara)
{
if (c.Uuid.ToString() == Utility.UUID_Name)
{
this.CurrentNameCharacteristic = c;
break;
}
}
}
};
} }
public async Task WriteDataAsync(byte[] data)
{ if (this.CurrentNameCharacteristic != null)
try
{ {
if (_writeCharacteristic != null) string msg = "已重连设备连接设备<" + this.CurrentDeviceMAC + "> ..";
this.MessageChanged(MsgType.NotifyTxt, msg);
}
}
string tmp = this.DevicesList.Where(p => p == bleDevice.DeviceId).FirstOrDefault();
if (tmp == null)
{//没有添加过
this.DevicesList.Add(bleDevice.DeviceId);
this.DevicewatcherChanged(MsgType.BleDevice, bleDevice);
bleDevice = null;
}
}
};
}
catch (Exception e)
{ {
await _writeCharacteristic.WriteValueAsync(CryptographicBuffer.CreateFromByteArray(data)); string msg = "没有发现设备" + e.ToString();
OnMessageChanged(MsgType.BleSendData, "Data sent", data); this.MessageChanged(MsgType.NotifyTxt, msg);
this.StopBleDeviceWatcher();
} }
else }
public void DisConnect()
{
/* GattSession.FromDeviceIdAsync(CurrentDevice.BluetoothDeviceId).Completed = async (asyncInfo, asyncStatus) =>
{ {
OnMessageChanged(MsgType.NotifyTxt, "Write characteristic not found", null); if (asyncStatus == AsyncStatus.Completed)
{
GattSession session = asyncInfo.GetResults();
if(session != null)
{
session.Dispose();
this.MessageChanged(MsgType.NotifyTxt, "主动断开session");
Dispose();
}
} }
};*/
Dispose();
} }
catch (Exception ex)
/// <summary>
/// 主动断开连接
/// </summary>
public void Dispose(bool IsTip = true)
{ {
OnMessageChanged(MsgType.NotifyTxt, $"Error writing data: {ex.Message}", null); IsConnect = false;
CurrentDeviceMAC = null;
CurrentService?.Dispose();
if (CurrentDevice != null)
CurrentDevice.ConnectionStatusChanged -= CurrentDevice_ConnectionStatusChanged;
CurrentDevice?.Dispose();
CurrentDevice = null;
CurrentService = null;
CurrentNameCharacteristic = null;
CurrentWriteCharacteristic = null;
CurrentNotifyCharacteristic = null;
// if(IsTip)
this.MessageChanged(MsgType.NotifyTxt, "主动断开连接");
// else
{//清除蓝牙列表
this.DevicesList.Clear();
} }
} }
private void OnConnectionStatusChanged(BluetoothLEDevice sender, object args) /// <summary>
/// 按MAC地址直接组装设备ID查找设备
/// </summary>
/// <param name="MAC"></param>
/// <returns></returns>
public async Task SelectDeviceFromIdAsync(string MAC)
{
CurrentDeviceMAC = MAC;
CurrentDevice = null;
BluetoothAdapter.GetDefaultAsync().Completed = async (asyncInfo, asyncStatus) =>
{ {
if (sender.ConnectionStatus == BluetoothConnectionStatus.Disconnected) if (asyncStatus == AsyncStatus.Completed)
{ {
OnMessageChanged(MsgType.NotifyTxt, "Device disconnected", null); BluetoothAdapter bluetoothAdapter = asyncInfo.GetResults();
// ulong 转为byte数组
byte[] _Bytes1 = BitConverter.GetBytes(bluetoothAdapter.BluetoothAddress);
Array.Reverse(_Bytes1);
string macAddress = BitConverter.ToString(_Bytes1, 2, 6).Replace('-', ':').ToLower();
string Id = "BluetoothLe#BluetoothLe" + macAddress + "-" + MAC;
await Matching(Id);
} }
else };
}
/// <summary>
/// 设置特征对象为接收通知对象
/// </summary>
/// <param name="characteristic"></param>
/// <returns></returns>
public async Task EnableNotifications(GattCharacteristic characteristic)
{
string msg = "收通知对象=" + CurrentDevice.ConnectionStatus;
this.MessageChanged(MsgType.NotifyTxt, msg);
characteristic.WriteClientCharacteristicConfigurationDescriptorAsync(CHARACTERSITIC_NOTIFICATION_TYPE).Completed = async (asyncInfo, asyncStatus) =>
{
if (asyncStatus == AsyncStatus.Completed)
{
GattCommunicationStatus status = asyncInfo.GetResults();
if (status == GattCommunicationStatus.Unreachable)
{
msg = "设备不可用";
this.MessageChanged(MsgType.NotifyTxt, msg);
if (CurrentNotifyCharacteristic != null && !asyncLock)
{ {
OnMessageChanged(MsgType.NotifyTxt, "Device connected", null); await this.EnableNotifications(CurrentNotifyCharacteristic);
} }
} }
asyncLock = false;
msg = "设备连接状态" + status;
this.MessageChanged(MsgType.NotifyTxt, msg);
}
};
}
/// <summary>
/// 接受到蓝牙数据
/// </summary>
private void Characteristic_ValueChanged(GattCharacteristic sender, GattValueChangedEventArgs args)
{
byte[] data;
CryptographicBuffer.CopyToByteArray(args.CharacteristicValue, out data);
string str = BitConverter.ToString(data);
this.MessageChanged(MsgType.BleRecData, str, data);
}
private void OnMessageChanged(MsgType type, string message, byte[] data) /// <summary>
/// 发送数据接口
/// </summary>
/// <returns></returns>
public async Task Write(byte[] data)
{
if (CurrentWriteCharacteristic != null)
{ {
MessageChanged?.Invoke(type, message, data); CurrentWriteCharacteristic.WriteValueAsync(CryptographicBuffer.CreateFromByteArray(data), GattWriteOption.WriteWithResponse);
string str = "发送数据:" + BitConverter.ToString(data);
this.MessageChanged(MsgType.BleSendData, str, data);
}
} }
public void Dispose() /// <summary>
/// 发送数据接口
/// </summary>
/// <returns></returns>
public async Task WriteName(byte[] data)
{ {
// 不需要调用 Dispose 方法 if (CurrentNameCharacteristic != null)
_currentDevice?.Dispose(); // 如果 BluetoothLEDevice 实现了 IDisposable则可以调用 Dispose {
_currentService = null; CurrentNameCharacteristic.WriteValueAsync(CryptographicBuffer.CreateFromByteArray(data), GattWriteOption.WriteWithResponse);
_writeCharacteristic = null; string str = "发送数据:" + BitConverter.ToString(data);
_notifyCharacteristic = null; this.MessageChanged(MsgType.BleSendData, str, data);
_discoveredDevices.Clear(); }
} }
} }
} }

@ -429,14 +429,14 @@ namespace YD10测试机
// yD10ToolStripMenuItem // yD10ToolStripMenuItem
// //
this.yD10ToolStripMenuItem.Name = "yD10ToolStripMenuItem"; this.yD10ToolStripMenuItem.Name = "yD10ToolStripMenuItem";
this.yD10ToolStripMenuItem.Size = new System.Drawing.Size(180, 24); this.yD10ToolStripMenuItem.Size = new System.Drawing.Size(122, 24);
this.yD10ToolStripMenuItem.Text = "YD10"; this.yD10ToolStripMenuItem.Text = "YD10";
this.yD10ToolStripMenuItem.Click += new System.EventHandler(this.yD10ToolStripMenuItem_Click); this.yD10ToolStripMenuItem.Click += new System.EventHandler(this.yD10ToolStripMenuItem_Click);
// //
// yD07KToolStripMenuItem // yD07KToolStripMenuItem
// //
this.yD07KToolStripMenuItem.Name = "yD07KToolStripMenuItem"; this.yD07KToolStripMenuItem.Name = "yD07KToolStripMenuItem";
this.yD07KToolStripMenuItem.Size = new System.Drawing.Size(180, 24); this.yD07KToolStripMenuItem.Size = new System.Drawing.Size(122, 24);
this.yD07KToolStripMenuItem.Text = "YD07K"; this.yD07KToolStripMenuItem.Text = "YD07K";
this.yD07KToolStripMenuItem.Click += new System.EventHandler(this.yD07KToolStripMenuItem_Click); this.yD07KToolStripMenuItem.Click += new System.EventHandler(this.yD07KToolStripMenuItem_Click);
// //
@ -508,6 +508,7 @@ namespace YD10测试机
this.textBox3.Name = "textBox3"; this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(355, 21); this.textBox3.Size = new System.Drawing.Size(355, 21);
this.textBox3.TabIndex = 67; this.textBox3.TabIndex = 67;
this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged);
// //
// label9 // label9
// //
@ -556,8 +557,9 @@ namespace YD10测试机
this.Controls.Add(this.menuStrip1); this.Controls.Add(this.menuStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Form1"; this.Name = "Form1";
this.Text = "YD10上位机测试V2.0"; this.Text = "YD10上位机测试V2.1";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed);
this.Load += new System.EventHandler(this.Form1_Load); this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();

@ -74,40 +74,18 @@ namespace YD10测试机
} }
private void Form1_Load(object sender, EventArgs e) int flag_yd07close = 0;
{ public void ShowMessage(bool message1, bool message2, bool message3,string printname,string znum)
cmbBox_Port_Update();
my_set();
read();
read_set();
GetPrinter();
// 添加第四列(按钮列)
DataGridViewButtonColumn buttonColumn = new DataGridViewButtonColumn
{ {
Name = "ButtonColumn", // 列的名称 flag_yd07close = 1;
HeaderText = "操作", // 列头显示的文本 yd_ble = message1;
Text = "写", // 按钮显示的文本 checkBox2.Checked = message2;
AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells, checkBox3.Checked = message3;
UseColumnTextForButtonValue = true, // 将按钮文本设置为列的值 comboBox1.Text = printname;
DefaultCellStyle = new DataGridViewCellStyle comboBox2.Text = znum;
{
Font = new Font("宋体", 9), // 设置按钮字体为 Arial大小为 12加粗
} }
}; private void Form1_Load(object sender, EventArgs e)
{
dataGridView2.Columns.Add(buttonColumn);
// 注册按钮点击事件
dataGridView2.CellClick += DataGridView2_CellClick;
//set_ready();
ServicePointManager.ServerCertificateValidationCallback = (obj, certificate, chain, sslPolicyErrors) => true;
this.Resize += new EventHandler(Form1_Resize);//窗体调整大小时引发事件
X = this.Width;//获取窗体的宽度
Y = this.Height;//获取窗体的高度
setTag(this);//调用方法
if (checkBox3.Checked) if (checkBox3.Checked)
{ {
index = this.dataGridView2.Rows.Add(); index = this.dataGridView2.Rows.Add();
@ -146,6 +124,58 @@ namespace YD10测试机
dataGridView2.Rows[index].Cells[0].Value = "物料编码"; dataGridView2.Rows[index].Cells[0].Value = "物料编码";
dataGridView2.Rows[index].Cells[1].Value = writeConfig[12].threshold; dataGridView2.Rows[index].Cells[1].Value = writeConfig[12].threshold;
} }
read_set();
if (che_kind == "YD07k")
{
if (serialPort.IsOpen)
{
_yd_disconnet();
serialPort.Close();
}//关闭串口
// 创建 Form3 的实例
Form3 form3 = new Form3(this);
// 隐藏 Form1
this.Hide();
// 显示 Form3
form3.ShowDialog();
return;
}
//timer1.Enabled = true;
//timer2.Enabled = true;
cmbBox_Port_Update();
my_set();
read();
GetPrinter();
// 添加第四列(按钮列)
DataGridViewButtonColumn buttonColumn = new DataGridViewButtonColumn
{
Name = "ButtonColumn", // 列的名称
HeaderText = "操作", // 列头显示的文本
Text = "写", // 按钮显示的文本
AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells,
UseColumnTextForButtonValue = true, // 将按钮文本设置为列的值
DefaultCellStyle = new DataGridViewCellStyle
{
Font = new Font("宋体", 9), // 设置按钮字体为 Arial大小为 12加粗
}
};
dataGridView2.Columns.Add(buttonColumn);
// 注册按钮点击事件
dataGridView2.CellClick += DataGridView2_CellClick;
//set_ready();
ServicePointManager.ServerCertificateValidationCallback = (obj, certificate, chain, sslPolicyErrors) => true;
this.Resize += new EventHandler(Form1_Resize);//窗体调整大小时引发事件
X = this.Width;//获取窗体的宽度
Y = this.Height;//获取窗体的高度
setTag(this);//调用方法
} }
@ -221,10 +251,12 @@ namespace YD10测试机
} }
} }
bool yd_ble = false;
string che_kind = "";
private void read_set() private void read_set()
{ {
string strLoadConfigFilePath = Application.StartupPath + @"\YD10配置.json";//路径 // string strLoadConfigFilePath = Application.StartupPath + @"\配置.json";//路径
string strLoadConfigFilePath = Path.Combine(Application.StartupPath, "配置.json");
try try
{ {
using (StreamReader configFile = new StreamReader(strLoadConfigFilePath)) using (StreamReader configFile = new StreamReader(strLoadConfigFilePath))
@ -234,18 +266,20 @@ namespace YD10测试机
JObject object_data_prase_json = (JObject)JsonConvert.DeserializeObject(str_data_json); JObject object_data_prase_json = (JObject)JsonConvert.DeserializeObject(str_data_json);
if (object_data_prase_json != null) if (object_data_prase_json != null)
{ {
che_kind= (string)object_data_prase_json["车型"];
comboBox1.Text = (string)object_data_prase_json["打印机"]; comboBox1.Text = (string)object_data_prase_json["打印机"];
comboBox2.Text = (string)object_data_prase_json["张数"]; comboBox2.Text = (string)object_data_prase_json["张数"];
checkBox2.Checked = (bool)object_data_prase_json["自动打印机"]; checkBox2.Checked = (bool)object_data_prase_json["自动打印机"];
//checkBox1.Checked = (bool)object_data_prase_json["自动蓝牙连接"]; yd_ble = (bool)object_data_prase_json["自动蓝牙连接"];
checkBox3.Checked = (bool)object_data_prase_json["号码校验"]; checkBox3.Checked = (bool)object_data_prase_json["号码校验"];
} }
// configFile.Close(); // 显式关闭文件(可选,通常不需要)
} }
} }
catch (Exception) catch (Exception ex)
{ {
MessageBox.Show($"发生错误: {ex.Message}");
} }
} }
@ -671,8 +705,6 @@ namespace YD10测试机
{ {
} }
} }
@ -1015,7 +1047,7 @@ namespace YD10测试机
// 数字1 // 数字1
if ((did == 0xCF40) || (did == 0xCF41)) if ((did == 0xCF40) || (did == 0xCF41))
{ {
writeConfig[index2].threshold = Convert.ToString(data[3]); writeConfig[index2].threshold = Convert.ToString(data[3]).PadLeft(2, '0');
} }
if (did == 0xCF42) if (did == 0xCF42)
{ {
@ -1514,8 +1546,6 @@ namespace YD10测试机
writeConfig[14].DID = "CF50"; writeConfig[14].DID = "CF50";
writeConfig[14].name = "批次号"; writeConfig[14].name = "批次号";
writeConfig[14].status = true; writeConfig[14].status = true;
} }
int index = 0; int index = 0;
@ -2415,8 +2445,9 @@ namespace YD10测试机
private void save_zb() private void save_zb()
{ {
string str_get_sn = "YD" + writeConfig[7].threshold.Substring(1, 1) + writeConfig[6].threshold.Substring(1, 1) + writeConfig[5].threshold + writeConfig[8].threshold.Substring(2, 4); string str_get_sn = "YD" + writeConfig[7].threshold.Substring(1, 1) + writeConfig[6].threshold.Substring(1, 1) + writeConfig[5].threshold + writeConfig[8].threshold.Substring(2, 4);
string str_sw = "X" + writeConfig[1].threshold + readConfig[1].threshold.Substring(0, 2) + readConfig[1].threshold.Substring(3, 2);
tempData = tempData + get_date_time() + "," + "E-2" + writeConfig[0].threshold + "," + tempData = tempData + get_date_time() + "," + "E-2" + writeConfig[0].threshold + "," +
readConfig[1].threshold + "," +str_get_sn+ ","+readConfig[2].threshold+","+ readConfig[3].threshold+","+flag_pass; str_sw + "," +str_get_sn+ ","+readConfig[2].threshold+","+ readConfig[3].threshold+","+flag_pass;
writeA883SmtLogCSV2(tempData); writeA883SmtLogCSV2(tempData);
tempData = " "; tempData = " ";
} }
@ -2436,7 +2467,8 @@ namespace YD10测试机
//string path = Application.StartupPath + @"\configfile\研发\" + sArray[0]; //string path = Application.StartupPath + @"\configfile\研发\" + sArray[0];
string path = @"C:\YD10日志\";//+ sArray[0]; // string path = @"C:\YD10日志\";//+ sArray[0];
string path = Application.StartupPath + @"\YD10日志\";
if (!Directory.Exists(path)) if (!Directory.Exists(path))
{ {
Directory.CreateDirectory(path); Directory.CreateDirectory(path);
@ -2476,7 +2508,7 @@ namespace YD10测试机
// 使用正确的 Split 方法 // 使用正确的 Split 方法
string[] sArray = str.Split(' '); // 以空格分隔 string[] sArray = str.Split(' '); // 以空格分隔
string smt_log_path2 = @"C:\YD10日志\";//+ sArray[0]; string smt_log_path2 = Application.StartupPath + @"\YD10日志\";
string str_get_sn = "YD" + writeConfig[7].threshold.Substring(1, 1) + writeConfig[6].threshold.Substring(1, 1) + writeConfig[5].threshold + writeConfig[8].threshold.Substring(2,4); string str_get_sn = "YD" + writeConfig[7].threshold.Substring(1, 1) + writeConfig[6].threshold.Substring(1, 1) + writeConfig[5].threshold + writeConfig[8].threshold.Substring(2,4);
//判断是否已经有了这个文件 //判断是否已经有了这个文件
@ -2568,6 +2600,7 @@ namespace YD10测试机
string tm = "#3-" + readConfig[2].threshold + " " + readConfig[3].threshold + "&" + writeConfig[12].threshold + "3560820" + string tm = "#3-" + readConfig[2].threshold + " " + readConfig[3].threshold + "&" + writeConfig[12].threshold + "3560820" +
writeConfig[7].threshold + writeConfig[6].threshold + writeConfig[5].threshold + writeConfig[8].threshold; writeConfig[7].threshold + writeConfig[6].threshold + writeConfig[5].threshold + writeConfig[8].threshold;
string str_get_sn = "YD" + writeConfig[7].threshold.Substring(1, 1) + writeConfig[6].threshold.Substring(1, 1) + writeConfig[5].threshold + writeConfig[8].threshold.Substring(2, 4); string str_get_sn = "YD" + writeConfig[7].threshold.Substring(1, 1) + writeConfig[6].threshold.Substring(1, 1) + writeConfig[5].threshold + writeConfig[8].threshold.Substring(2, 4);
string str_sw = "X" + writeConfig[1].threshold + readConfig[1].threshold.Substring(0, 2) + readConfig[1].threshold.Substring(3, 2);
bcc.QuickMarkHeight = 100; bcc.QuickMarkHeight = 100;
bcc.QuickMarkWidth = 100; bcc.QuickMarkWidth = 100;
Image image = bcc.CreateQuickMark(tm); Image image = bcc.CreateQuickMark(tm);
@ -2578,7 +2611,7 @@ namespace YD10测试机
//e.Graphics.DrawString("电压:48-72V", new Font(new FontFamily("宋体"), 6, FontStyle.Bold), System.Drawing.Brushes.Black, 130, 23); //e.Graphics.DrawString("电压:48-72V", new Font(new FontFamily("宋体"), 6, FontStyle.Bold), System.Drawing.Brushes.Black, 130, 23);
e.Graphics.DrawString("HW:" +"E-2"+ writeConfig[0].threshold, new Font(new FontFamily("宋体"), 6, FontStyle.Bold), System.Drawing.Brushes.Black, 3, 33); e.Graphics.DrawString("HW:" +"E-2"+ writeConfig[0].threshold, new Font(new FontFamily("宋体"), 6, FontStyle.Bold), System.Drawing.Brushes.Black, 3, 33);
// e.Graphics.DrawString("类型:一键启动/无电池/无手柄", new Font(new FontFamily("宋体"), 6, FontStyle.Bold), System.Drawing.Brushes.Black, 50, 33); // e.Graphics.DrawString("类型:一键启动/无电池/无手柄", new Font(new FontFamily("宋体"), 6, FontStyle.Bold), System.Drawing.Brushes.Black, 50, 33);
e.Graphics.DrawString("SW:" + readConfig[1].threshold, new Font(new FontFamily("宋体"), 6, FontStyle.Bold), System.Drawing.Brushes.Black, 3, 43); e.Graphics.DrawString("SW:" + str_sw, new Font(new FontFamily("宋体"), 6, FontStyle.Bold), System.Drawing.Brushes.Black, 3, 43);
e.Graphics.DrawString("SN:" + str_get_sn, new Font(new FontFamily("宋体"), 6, FontStyle.Bold), System.Drawing.Brushes.Black, 70, 43); e.Graphics.DrawString("SN:" + str_get_sn, new Font(new FontFamily("宋体"), 6, FontStyle.Bold), System.Drawing.Brushes.Black, 70, 43);
e.Graphics.DrawString("IMEI:" + readConfig[2].threshold, new Font(new FontFamily("宋体"), 6, FontStyle.Bold), System.Drawing.Brushes.Black, 3, 53); e.Graphics.DrawString("IMEI:" + readConfig[2].threshold, new Font(new FontFamily("宋体"), 6, FontStyle.Bold), System.Drawing.Brushes.Black, 3, 53);
e.Graphics.DrawString("ICCID:" + readConfig[3].threshold, new Font(new FontFamily("宋体"), 6, FontStyle.Bold), System.Drawing.Brushes.Black, 3, 63); e.Graphics.DrawString("ICCID:" + readConfig[3].threshold, new Font(new FontFamily("宋体"), 6, FontStyle.Bold), System.Drawing.Brushes.Black, 3, 63);
@ -2655,6 +2688,38 @@ namespace YD10测试机
string bd_wl="", bd_cs = "", bd_year = "", bd_year2 = "", bd_month = "", bd_day = "", bd_day1 = "", bd_ls = ""; string bd_wl="", bd_cs = "", bd_year = "", bd_year2 = "", bd_month = "", bd_day = "", bd_day1 = "", bd_ls = "";
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
JObject setData_jsonObject = new Newtonsoft.Json.Linq.JObject();
if (flag_yd07close == 0)
{
setData_jsonObject.Add("车型", "YD10");
}
else
{
setData_jsonObject.Add("车型", "YD07k");
}
setData_jsonObject.Add("打印机", comboBox1.Text);
setData_jsonObject.Add("张数", comboBox2.Text);
setData_jsonObject.Add("自动打印机", checkBox2.Checked);
setData_jsonObject.Add("自动蓝牙连接", yd_ble);
setData_jsonObject.Add("号码校验", checkBox3.Checked);
string config_file_str = setData_jsonObject.ToString();
//string savePath = Application.StartupPath + @"\配置.json";
string savePath = Path.Combine(Application.StartupPath, "配置.json");
System.IO.File.WriteAllText(savePath, config_file_str, Encoding.UTF8);
//this.Invoke(new Action(() =>
//{
//
//}));
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void yD10ToolStripMenuItem_Click(object sender, EventArgs e) private void yD10ToolStripMenuItem_Click(object sender, EventArgs e)
{ {
this.Text = "YD10上位机测试V1.9"; this.Text = "YD10上位机测试V1.9";
@ -2806,15 +2871,7 @@ namespace YD10测试机
private void Form1_FormClosing(object sender, FormClosingEventArgs e) private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{ {
JObject setData_jsonObject = new Newtonsoft.Json.Linq.JObject();
setData_jsonObject.Add("打印机", comboBox1.Text);
setData_jsonObject.Add("张数", comboBox2.Text);
setData_jsonObject.Add("自动打印机", checkBox2.Checked);
// setData_jsonObject.Add("自动蓝牙连接", checkBox1.Checked);
setData_jsonObject.Add("号码校验", checkBox3.Checked);
string config_file_str = setData_jsonObject.ToString();
string savePath = Application.StartupPath + @"\YD10配置.json";
System.IO.File.WriteAllText(savePath, config_file_str, Encoding.UTF8);
} }
int flag_sn = 0; int flag_sn = 0;

@ -33,6 +33,7 @@ namespace YD10测试机
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form3));
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label();
this.checkBox3 = new System.Windows.Forms.CheckBox(); this.checkBox3 = new System.Windows.Forms.CheckBox();
@ -76,6 +77,7 @@ namespace YD10测试机
this.label9 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label();
this.checkBox1 = new System.Windows.Forms.CheckBox(); this.checkBox1 = new System.Windows.Forms.CheckBox();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
@ -204,6 +206,7 @@ namespace YD10测试机
this.checkBox2.TabIndex = 72; this.checkBox2.TabIndex = 72;
this.checkBox2.Text = "自动打印"; this.checkBox2.Text = "自动打印";
this.checkBox2.UseVisualStyleBackColor = true; this.checkBox2.UseVisualStyleBackColor = true;
this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
// //
// dataGridView2 // dataGridView2
// //
@ -225,12 +228,12 @@ namespace YD10测试机
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.False; dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dataGridView2.DefaultCellStyle = dataGridViewCellStyle1; this.dataGridView2.DefaultCellStyle = dataGridViewCellStyle1;
this.dataGridView2.EnableHeadersVisualStyles = false; this.dataGridView2.EnableHeadersVisualStyles = false;
this.dataGridView2.Location = new System.Drawing.Point(699, 163); this.dataGridView2.Location = new System.Drawing.Point(704, 163);
this.dataGridView2.Name = "dataGridView2"; this.dataGridView2.Name = "dataGridView2";
this.dataGridView2.RowHeadersVisible = false; this.dataGridView2.RowHeadersVisible = false;
this.dataGridView2.RowHeadersWidth = 45; this.dataGridView2.RowHeadersWidth = 45;
this.dataGridView2.RowTemplate.Height = 21; this.dataGridView2.RowTemplate.Height = 21;
this.dataGridView2.Size = new System.Drawing.Size(375, 561); this.dataGridView2.Size = new System.Drawing.Size(375, 586);
this.dataGridView2.TabIndex = 71; this.dataGridView2.TabIndex = 71;
// //
// dataGridViewTextBoxColumn9 // dataGridViewTextBoxColumn9
@ -283,7 +286,7 @@ namespace YD10测试机
this.dataGridView1.RowHeadersVisible = false; this.dataGridView1.RowHeadersVisible = false;
this.dataGridView1.RowHeadersWidth = 45; this.dataGridView1.RowHeadersWidth = 45;
this.dataGridView1.RowTemplate.Height = 19; this.dataGridView1.RowTemplate.Height = 19;
this.dataGridView1.Size = new System.Drawing.Size(316, 601); this.dataGridView1.Size = new System.Drawing.Size(316, 626);
this.dataGridView1.TabIndex = 70; this.dataGridView1.TabIndex = 70;
// //
// Column1 // Column1
@ -359,7 +362,7 @@ namespace YD10测试机
this.ToolStripMenuItem}); this.ToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(1098, 28); this.menuStrip1.Size = new System.Drawing.Size(1109, 28);
this.menuStrip1.TabIndex = 79; this.menuStrip1.TabIndex = 79;
this.menuStrip1.Text = "menuStrip1"; this.menuStrip1.Text = "menuStrip1";
this.menuStrip1.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.menuStrip1_ItemClicked); this.menuStrip1.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.menuStrip1_ItemClicked);
@ -439,7 +442,7 @@ namespace YD10测试机
this.dataGridView3.RowHeadersVisible = false; this.dataGridView3.RowHeadersVisible = false;
this.dataGridView3.RowHeadersWidth = 45; this.dataGridView3.RowHeadersWidth = 45;
this.dataGridView3.RowTemplate.Height = 19; this.dataGridView3.RowTemplate.Height = 19;
this.dataGridView3.Size = new System.Drawing.Size(316, 561); this.dataGridView3.Size = new System.Drawing.Size(316, 586);
this.dataGridView3.TabIndex = 87; this.dataGridView3.TabIndex = 87;
// //
// dataGridViewTextBoxColumn1 // dataGridViewTextBoxColumn1
@ -489,6 +492,7 @@ namespace YD10测试机
this.textBox3.Name = "textBox3"; this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(355, 21); this.textBox3.Size = new System.Drawing.Size(355, 21);
this.textBox3.TabIndex = 89; this.textBox3.TabIndex = 89;
this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged);
// //
// label9 // label9
// //
@ -519,11 +523,23 @@ namespace YD10测试机
this.checkBox1.Text = "蓝牙连接"; this.checkBox1.Text = "蓝牙连接";
this.checkBox1.UseVisualStyleBackColor = true; this.checkBox1.UseVisualStyleBackColor = true;
// //
// button1
//
this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button1.Location = new System.Drawing.Point(775, 131);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(279, 26);
this.button1.TabIndex = 93;
this.button1.Text = "开始测试";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form3 // Form3
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1098, 737); this.ClientSize = new System.Drawing.Size(1109, 762);
this.Controls.Add(this.button1);
this.Controls.Add(this.checkBox1); this.Controls.Add(this.checkBox1);
this.Controls.Add(this.label10); this.Controls.Add(this.label10);
this.Controls.Add(this.textBox3); this.Controls.Add(this.textBox3);
@ -549,6 +565,7 @@ namespace YD10测试机
this.Controls.Add(this.cmbPort); this.Controls.Add(this.cmbPort);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Controls.Add(this.menuStrip1); this.Controls.Add(this.menuStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Form3"; this.Name = "Form3";
this.Text = "YD07K上位机测试V1.9"; this.Text = "YD07K上位机测试V1.9";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form3_FormClosing); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form3_FormClosing);
@ -609,5 +626,6 @@ namespace YD10测试机
private System.Windows.Forms.Label label9; private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10; private System.Windows.Forms.Label label10;
private System.Windows.Forms.CheckBox checkBox1; private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Button button1;
} }
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -194,7 +194,7 @@ namespace YD10测试机
}; };
myUnitClass2[] readConfig = new myUnitClass2[31]; myUnitClass2[] readConfig = new myUnitClass2[31];
myUnitClass2[] writeConfig = new myUnitClass2[15]; myUnitClass2[] writeConfig = new myUnitClass2[17];
myUnitClass2[] alm_readConfig = new myUnitClass2[23]; myUnitClass2[] alm_readConfig = new myUnitClass2[23];
myUnitClass2[] alm_writeConfig = new myUnitClass2[5]; myUnitClass2[] alm_writeConfig = new myUnitClass2[5];
@ -513,6 +513,14 @@ namespace YD10测试机
writeConfig[14].name = "批次号"; writeConfig[14].name = "批次号";
writeConfig[14].status = true; writeConfig[14].status = true;
writeConfig[15].DID = "CF51";
writeConfig[15].name = "GSENSOR旋转轴";
writeConfig[15].status = true;
writeConfig[16].DID = "CF52";
writeConfig[16].name = "GSENSOR倾倒角度";
writeConfig[16].status = true;
} }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)

@ -27,10 +27,10 @@
"外电电压值": "30(误差1)", "外电电压值": "30(误差1)",
"K线通讯状态": "1(不可更改)", "K线通讯状态": "1(不可更改)",
"GSENSOR地址": null, "GSENSOR地址": null,
"六轴数据校准值": null, "六轴数据校准值": "有一个ffff就是不过",
"六轴传感器状态": null, "六轴传感器状态": "1(不可更改)",
"音频文件状态": null, "音频文件状态": "1(不可更改)",
"外电电平": null, "外电电平": "0(不可更改)",
"硬件版本号": "12", "硬件版本号": "12",
"产品型号": "50", "产品型号": "50",
"产品识别码": "IOT", "产品识别码": "IOT",
@ -46,29 +46,29 @@
"物料编码": "(不填)", "物料编码": "(不填)",
"供应商编码": "(不填)", "供应商编码": "(不填)",
"批次号": "(不填)", "批次号": "(不填)",
"alm软件版本号": null, "alm软件版本号": "00.02",
"ACC1输出": null, "ACC1输出": "1(不可更改)",
"ACC1预充": null, "ACC1预充": "1(不可更改)",
"ACC2输出": null, "ACC2输出": "1(不可更改)",
"ACC2预充": null, "ACC2预充": "1(不可更改)",
"ACC1输入": null, "ACC1输入": "1(不可更改)",
"机械钥匙": null, "机械钥匙": "1(不可更改)",
"ACC2输入": null, "ACC2输入": "1(不可更改)",
"右转向灯输入": null, "右转向灯输入": "1(不可更改)",
"蓝牙指示灯输出": null, "蓝牙指示灯输出": "1(不可更改)",
"双闪输出": null, "双闪输出": "1(不可更改)",
"轮动输入": null, "轮动输入": "1(不可更改)",
"左转向灯输入": null, "左转向灯输入": "1(不可更改)",
"MOTO_A输出": null, "MOTO_A输出": "1(不可更改)",
"MOTO_B输出": null, "MOTO_B输出": "1(不可更改)",
"锁电机输出": null, "锁电机输出": "1(不可更改)",
"电磁阀输出": null, "电磁阀输出": "1(不可更改)",
"一键启动输入": null, "一键启动输入": "1(不可更改)",
"坐垫感应输入": null, "坐垫感应输入": "1(不可更改)",
"alm_外电电压值": null, "alm_外电电压值": "1(不可更改)",
"alm_K线通讯": null, "alm_K线通讯": "1(不可更改)",
"蓝牙连接": null, "蓝牙连接": "1(不可更改)",
"弹簧振子": null, "弹簧振子": "1(不可更改)",
"alm_外电电压AD比例值": null, "alm_外电电压AD比例值": null,
"alm_音量等级": null, "alm_音量等级": null,
"alm_声音主题": null, "alm_声音主题": null,

@ -1,7 +0,0 @@
{
"打印机": "",
"张数": "",
"自动打印机": true,
"自动蓝牙连接": true,
"号码校验": false
}

@ -27,7 +27,7 @@
"外电电压值": "30(误差1)", "外电电压值": "30(误差1)",
"K线通讯状态": "1(不可更改)", "K线通讯状态": "1(不可更改)",
"硬件版本号": "12", "硬件版本号": "12",
"产品型号": "50", "产品型号": "00",
"产品识别码": "IOT", "产品识别码": "IOT",
"产商识别码": "嘉为", "产商识别码": "嘉为",
"客户识别码": null, "客户识别码": null,

@ -0,0 +1,6 @@
2025/4/7 16:37:24,E-212,00.01,YD52170002,864979076757426,89860858102470401406,PASS
2025/4/7 16:38:30,E-212,00.01,YD52170002,864979076757426,89860858102470401406,PASS
2025/4/7 16:38:57,E-212,00.01,YD52170002,864979076757426,89860858102470401406,PASS
2025/4/7 16:39:58,E-212,00.01,YD52170002,864979076757426,89860858102470401406,PASS
2025/4/7 16:42:40,E-212,00.01,YD52170002,864979076757426,89860858102470401406,PASS
2025/4/7 16:44:42,E-212,X000001,YD52170002,864979076757426,89860858102470401406,PASS
1 2025/4/7 16:37:24 E-212 00.01 YD52170002 864979076757426 89860858102470401406 PASS
2 2025/4/7 16:38:30 E-212 00.01 YD52170002 864979076757426 89860858102470401406 PASS
3 2025/4/7 16:38:57 E-212 00.01 YD52170002 864979076757426 89860858102470401406 PASS
4 2025/4/7 16:39:58 E-212 00.01 YD52170002 864979076757426 89860858102470401406 PASS
5 2025/4/7 16:42:40 E-212 00.01 YD52170002 864979076757426 89860858102470401406 PASS
6 2025/4/7 16:44:42 E-212 X000001 YD52170002 864979076757426 89860858102470401406 PASS

@ -1,6 +0,0 @@
{
"打印机": "",
"张数": "",
"自动打印机": true,
"号码校验": false
}

@ -1,6 +1,8 @@
{ {
"车型": "YD07k",
"打印机": "导出为WPS PDF", "打印机": "导出为WPS PDF",
"张数": "1", "张数": "1",
"自动打印机": true, "自动打印机": true,
"自动蓝牙连接": true,
"号码校验": false "号码校验": false
} }

@ -1 +1 @@
80cfbf33494ef7ebc9674e6fc57c5dc51e43a69d 09981f47e9a0ec78680c73280e06f446dc9438e3

@ -12,3 +12,17 @@ C:\Users\Administrator\Documents\YD10测试机\YD10测试机\bin\Debug\YD10测
C:\Users\Administrator\Documents\YD10测试机\YD10测试机\obj\Debug\YD10测试机.csproj.CopyComplete C:\Users\Administrator\Documents\YD10测试机\YD10测试机\obj\Debug\YD10测试机.csproj.CopyComplete
C:\Users\Administrator\Documents\YD10测试机\YD10测试机\obj\Debug\YD10测试机.Form3.resources C:\Users\Administrator\Documents\YD10测试机\YD10测试机\obj\Debug\YD10测试机.Form3.resources
C:\Users\Administrator\Documents\YD10测试机\YD10测试机\obj\Debug\YD10测试机.Form4.resources C:\Users\Administrator\Documents\YD10测试机\YD10测试机\obj\Debug\YD10测试机.Form4.resources
C:\Users\Administrator\source\repos\YD10-YD07k_SMT\YD10测试机\bin\Debug\YD10测试机.exe.config
C:\Users\Administrator\source\repos\YD10-YD07k_SMT\YD10测试机\bin\Debug\YD10测试机.exe
C:\Users\Administrator\source\repos\YD10-YD07k_SMT\YD10测试机\bin\Debug\YD10测试机.pdb
C:\Users\Administrator\source\repos\YD10-YD07k_SMT\YD10测试机\obj\Debug\YD10测试机.csproj.AssemblyReference.cache
C:\Users\Administrator\source\repos\YD10-YD07k_SMT\YD10测试机\obj\Debug\YD10测试机.Form1.resources
C:\Users\Administrator\source\repos\YD10-YD07k_SMT\YD10测试机\obj\Debug\YD10测试机.Form2.resources
C:\Users\Administrator\source\repos\YD10-YD07k_SMT\YD10测试机\obj\Debug\YD10测试机.Form3.resources
C:\Users\Administrator\source\repos\YD10-YD07k_SMT\YD10测试机\obj\Debug\YD10测试机.Form4.resources
C:\Users\Administrator\source\repos\YD10-YD07k_SMT\YD10测试机\obj\Debug\YD10测试机.Properties.Resources.resources
C:\Users\Administrator\source\repos\YD10-YD07k_SMT\YD10测试机\obj\Debug\YD10测试机.csproj.GenerateResource.cache
C:\Users\Administrator\source\repos\YD10-YD07k_SMT\YD10测试机\obj\Debug\YD10测试机.csproj.CoreCompileInputs.cache
C:\Users\Administrator\source\repos\YD10-YD07k_SMT\YD10测试机\obj\Debug\YD10测试机.csproj.CopyComplete
C:\Users\Administrator\source\repos\YD10-YD07k_SMT\YD10测试机\obj\Debug\YD10测试机.exe
C:\Users\Administrator\source\repos\YD10-YD07k_SMT\YD10测试机\obj\Debug\YD10测试机.pdb

@ -1,17 +1,17 @@
{ {
"format": 1, "format": 1,
"restore": { "restore": {
"C:\\Users\\Administrator\\Documents\\YD10测试机\\YD10测试机\\YD10测试机.csproj": {} "C:\\Users\\Administrator\\source\\repos\\YD10-YD07k_SMT\\YD10测试机\\YD10测试机.csproj": {}
}, },
"projects": { "projects": {
"C:\\Users\\Administrator\\Documents\\YD10测试机\\YD10测试机\\YD10测试机.csproj": { "C:\\Users\\Administrator\\source\\repos\\YD10-YD07k_SMT\\YD10测试机\\YD10测试机.csproj": {
"version": "1.0.0", "version": "1.0.0",
"restore": { "restore": {
"projectUniqueName": "C:\\Users\\Administrator\\Documents\\YD10测试机\\YD10测试机\\YD10测试机.csproj", "projectUniqueName": "C:\\Users\\Administrator\\source\\repos\\YD10-YD07k_SMT\\YD10测试机\\YD10测试机.csproj",
"projectName": "YD10测试机", "projectName": "YD10测试机",
"projectPath": "C:\\Users\\Administrator\\Documents\\YD10测试机\\YD10测试机\\YD10测试机.csproj", "projectPath": "C:\\Users\\Administrator\\source\\repos\\YD10-YD07k_SMT\\YD10测试机\\YD10测试机.csproj",
"packagesPath": "C:\\Users\\Administrator\\.nuget\\packages\\", "packagesPath": "C:\\Users\\Administrator\\.nuget\\packages\\",
"outputPath": "C:\\Users\\Administrator\\Documents\\YD10测试机\\YD10测试机\\obj\\", "outputPath": "C:\\Users\\Administrator\\source\\repos\\YD10-YD07k_SMT\\YD10测试机\\obj\\",
"projectStyle": "PackageReference", "projectStyle": "PackageReference",
"skipContentFileWrite": true, "skipContentFileWrite": true,
"configFilePaths": [ "configFilePaths": [

@ -610,11 +610,11 @@
"project": { "project": {
"version": "1.0.0", "version": "1.0.0",
"restore": { "restore": {
"projectUniqueName": "C:\\Users\\Administrator\\Documents\\YD10测试机\\YD10测试机\\YD10测试机.csproj", "projectUniqueName": "C:\\Users\\Administrator\\source\\repos\\YD10-YD07k_SMT\\YD10测试机\\YD10测试机.csproj",
"projectName": "YD10测试机", "projectName": "YD10测试机",
"projectPath": "C:\\Users\\Administrator\\Documents\\YD10测试机\\YD10测试机\\YD10测试机.csproj", "projectPath": "C:\\Users\\Administrator\\source\\repos\\YD10-YD07k_SMT\\YD10测试机\\YD10测试机.csproj",
"packagesPath": "C:\\Users\\Administrator\\.nuget\\packages\\", "packagesPath": "C:\\Users\\Administrator\\.nuget\\packages\\",
"outputPath": "C:\\Users\\Administrator\\Documents\\YD10测试机\\YD10测试机\\obj\\", "outputPath": "C:\\Users\\Administrator\\source\\repos\\YD10-YD07k_SMT\\YD10测试机\\obj\\",
"projectStyle": "PackageReference", "projectStyle": "PackageReference",
"skipContentFileWrite": true, "skipContentFileWrite": true,
"configFilePaths": [ "configFilePaths": [

@ -1,8 +1,8 @@
{ {
"version": 2, "version": 2,
"dgSpecHash": "/hxHqHvKBHnTl2nY1vWC4fuQQf174zQl3otU2850yc80/h+OrdqXX0C/e/FuA7cLxwkrBT9ct9texSHNfNfHoA==", "dgSpecHash": "oCZi0SwUapJ7/sIPKtktKGcSfKEdxjkL1/MkxRHZ7xLAF4Wr93elWIo7bnFXSfg8wty9KDw6l7gk13hWtYE+QA==",
"success": true, "success": true,
"projectFilePath": "C:\\Users\\Administrator\\Documents\\YD10测试机\\YD10测试机\\YD10测试机.csproj", "projectFilePath": "C:\\Users\\Administrator\\source\\repos\\YD10-YD07k_SMT\\YD10测试机\\YD10测试机.csproj",
"expectedPackageFiles": [ "expectedPackageFiles": [
"C:\\Users\\Administrator\\.nuget\\packages\\microsoft.windows.sdk.contracts\\10.0.26100.1742\\microsoft.windows.sdk.contracts.10.0.26100.1742.nupkg.sha512", "C:\\Users\\Administrator\\.nuget\\packages\\microsoft.windows.sdk.contracts\\10.0.26100.1742\\microsoft.windows.sdk.contracts.10.0.26100.1742.nupkg.sha512",
"C:\\Users\\Administrator\\.nuget\\packages\\system.runtime.interopservices.windowsruntime\\4.3.0\\system.runtime.interopservices.windowsruntime.4.3.0.nupkg.sha512", "C:\\Users\\Administrator\\.nuget\\packages\\system.runtime.interopservices.windowsruntime\\4.3.0\\system.runtime.interopservices.windowsruntime.4.3.0.nupkg.sha512",

Loading…
Cancel
Save