private static IModbusMaster master;
private static SerialPort port;
//写线圈或写寄存器数组
private bool[] coilsBuffer;
private ushort[] registerBuffer;
//功能码
private string functionCode;
//功能码序号
private int functionOder;
//参数(分别为从站地址,起始地址,长度)
private byte slaveAddress;
private ushort startAddress;
private ushort numberOfPoints;
//串口参数
private string portName;
private int baudRate;
private Parity parity;
private int dataBits;
private StopBits stopBits;
//自动测试标志位
private bool AutoFlag = false;
//获取当前时间
private System.DateTime Current_time;
//定时器初始化
private System.Timers.Timer t = new System.Timers.Timer(1000);
private const int WM_DEVICE_CHANGE = 0x219; //设备改变
private const int DBT_DEVICEARRIVAL = 0x8000; //设备插入
private const int DBT_DEVICE_REMOVE_COMPLETE = 0x8004; //设备移除
评论