77 lines
2.3 KiB
C#
77 lines
2.3 KiB
C#
using Prism.Mvvm;
|
||
|
||
namespace UIShare.UIViewModel
|
||
{
|
||
/// <summary>
|
||
/// CAN 连接配置(对应 ZLGCANFD 构造函数 + 初始化并启动通道 参数)。
|
||
/// </summary>
|
||
public class CANConfigVM : BindableBase
|
||
{
|
||
// ===== ZLGCANFD 构造函数参数 =====
|
||
|
||
private uint _deviceType = 43;
|
||
/// <summary>设备类型号(43 = USBCANFD-400U)</summary>
|
||
public uint DeviceType
|
||
{
|
||
get => _deviceType;
|
||
set => SetProperty(ref _deviceType, value);
|
||
}
|
||
|
||
private uint _deviceIndex = 0;
|
||
/// <summary>设备索引</summary>
|
||
public uint DeviceIndex
|
||
{
|
||
get => _deviceIndex;
|
||
set => SetProperty(ref _deviceIndex, value);
|
||
}
|
||
|
||
private string _abitBaud = "500000";
|
||
/// <summary>仲裁域波特率</summary>
|
||
public string ABitBaud
|
||
{
|
||
get => _abitBaud;
|
||
set => SetProperty(ref _abitBaud, value);
|
||
}
|
||
|
||
private string _dbitBaud = "2000000";
|
||
/// <summary>数据域波特率</summary>
|
||
public string DBitBaud
|
||
{
|
||
get => _dbitBaud;
|
||
set => SetProperty(ref _dbitBaud, value);
|
||
}
|
||
|
||
private bool _enableTerminalResistance = true;
|
||
/// <summary>是否开启终端电阻</summary>
|
||
public bool EnableTerminalResistance
|
||
{
|
||
get => _enableTerminalResistance;
|
||
set => SetProperty(ref _enableTerminalResistance, value);
|
||
}
|
||
|
||
public CANConfigVM() { }
|
||
|
||
/// <summary>拷贝构造,用于对话框编辑副本。</summary>
|
||
public CANConfigVM(CANConfigVM? src)
|
||
{
|
||
if (src == null) return;
|
||
DeviceType = src.DeviceType;
|
||
DeviceIndex = src.DeviceIndex;
|
||
ABitBaud = src.ABitBaud;
|
||
DBitBaud = src.DBitBaud;
|
||
EnableTerminalResistance = src.EnableTerminalResistance;
|
||
}
|
||
|
||
/// <summary>把字段拷回目标对象(保存时用)。</summary>
|
||
public void CopyTo(CANConfigVM? dst)
|
||
{
|
||
if (dst == null) return;
|
||
dst.DeviceType = DeviceType;
|
||
dst.DeviceIndex = DeviceIndex;
|
||
dst.ABitBaud = ABitBaud;
|
||
dst.DBitBaud = DBitBaud;
|
||
dst.EnableTerminalResistance = EnableTerminalResistance;
|
||
}
|
||
}
|
||
}
|