用到C#在名字空间System.IO.Ports下的SerialPort类来实现功能
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using System.IO.Ports;
namespace ComLibrary
{
public class EleRelay
{
#region 四路继电器属性区域
private SerialPort mycom = new SerialPort(); //com接口
private string portName; //com号
private bool flag = false;
private int numFlashing;
//设置几号灯闪烁
public int NumFlashing
{
set { this.numFlashing = value; }
get { return this.numFlashing; }
}
public Timer tickTimer;
public string PortName
{
set { this.portName = value; }
get { return this.portName; }
}
//控制开关量的指令
string[] str = {
"5501010200000059",
"5501010100000058",
"