using Community;
using MahApps.Metro.Controls.Dialogs;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Documents;
using static Community.ZLGCAN;
namespace ViewModel
{
partial class MainWindowVM
{
public static IntPtr devHandle = IntPtr.Zero; // 设备句柄
public static IntPtr[] linHandle = new IntPtr[2]; // lin 通道句柄
public static volatile bool isRunning = true; // 线程标志
public static uint isMerge = 0; // 合并接收标志
public static readonly object _consoleLock = new object(); // 控制台输出锁对象
#region 各种方法
///
/// 连接
///
public DelegateCommand OpenDeviceCommand { get; set; }
///
/// 关闭
///
public DelegateCommand CloseDeviceCommand { get; set; }
///
/// 唤醒
///
public DelegateCommand AwakenCommand { get; set; }
///
/// 运行指令群组
///
public DelegateCommand RunCommandGroupCommand { get; set; }
///
/// 运行单个指令
///
public DelegateCommand RunCommandModeCommand { get; set; }
///
/// 新增群组
///
public DelegateCommand AddCommandGroupCommand { get; set; }
///
/// 新增指令
///
public DelegateCommand AddCommandModeCommand { get; set; }
///
/// 删除群组
///
public DelegateCommand DeleteCommandGroupCommand { get; set; }
///
/// 删除项目指令
///
public DelegateCommand DeleteCommandModecCommand { get; set; }
#endregion
#region 选中的指令组
private CommandGroup selectCommandGroup;
///
/// 选中的指令组
///
public CommandGroup SelectCommandGroup
{
get { return selectCommandGroup; }
set
{
selectCommandGroup = value;
RaisePropertyChanged("SelectCommandGroup");
}
}
#endregion
#region 选中的指令
private CommandModel selectCommandModel;
///
/// 选中的指令
///
public CommandModel SelectCommandModel
{
get { return selectCommandModel; }
set
{
selectCommandModel = value;
RaisePropertyChanged("SelectCommandModel");
}
}
#endregion
// 线程传递参数
class ThreadParams
{
///
/// 设备句柄
///
public IntPtr devHandle { get; set; }
///
/// 通道句柄
///
public IntPtr chnHandle { get; set; }
///
/// 通道号
///
public int chnNum { get; set; }
}
///
/// 通道1
///
ThreadParams Lin0 { get; set; }
private string showStr;
///
/// 显示的信息
///
public string ShowStr
{
get { return showStr; }
set
{
showStr = value;
RaisePropertyChanged(nameof(ShowStr));
}
}
///
/// 测试仪器初始化
///
public void InitializeAginTestVM()
{
OpenDeviceCommand = new DelegateCommand() { ExecuteAction = new Action