Esempio n. 1
0
        public void InitBoard()
        {
            int i = CtrlCard.Init_Board();

            if (i <= 0)
            {
                ContraHelper.ShowError("控制卡初始化失败!");
                if (i == 0)
                {
                    ContraHelper.ShowError("没有安装ADT8940A1卡!");
                }
                if (i == -1)
                {
                    ContraHelper.ShowError("没有安装端口驱动程序!");
                }
                if (i == -2)
                {
                    ContraHelper.ShowError("PCI桥故障!");
                }
            }
            SetByRecord();
            SetupSpeed();
            SetIOMode();
            SetLimitMode();
            SetupHardStop();
        }
Esempio n. 2
0
 public PortHelper(string portName, int sleep)
 {
     try
     {
         this.sleep           = sleep;
         port                 = new SerialPort(portName);
         ar                   = new AutoResetEvent(false);
         port.BaudRate        = 19200;
         port.DataBits        = 8;                            //数据位
         port.Parity          = System.IO.Ports.Parity.None;  //校验位 无校验
         port.StopBits        = System.IO.Ports.StopBits.One; //停止位1位
         port.Encoding        = Encoding.GetEncoding("iso-8859-1");
         port.WriteBufferSize = 1024;
         port.Open();
         port.DataReceived          += new SerialDataReceivedEventHandler(port_DataReceived);
         port.ErrorReceived         += new SerialErrorReceivedEventHandler(port_ErrorReceived);
         port.ReceivedBytesThreshold = 1; //设置引发OnComm事件的字节长度
     }
     catch (Exception ex)
     {
         LogHelper.LogError(ex);
         ContraHelper.ShowMessage(string.Format(L.R("PortHelper.InitPortFailure", "初始化{0}口失败!"), portName));
     }
 }