コード例 #1
0
        public static SyInfo AddDevice(int channel, string portName)
        {
            SyInfo device = null;

            if (!Devices.ContainsKey(channel))
            {
                device           = new SyInfo(channel, portName);
                Devices[channel] = device;
            }

            return(device);
        }
コード例 #2
0
        public static bool Connect(this SyDevice device)
        {
            bool result  = true;
            bool isAvail = false;

            SyInfo sy = device.Device;

            int    connectNum = sy.GetConnectNum();
            string portName   = sy.GetPortName();
            int    portNum    = sy.GetPortNum();

            sy.IsAvail = false;

            isAvail = sy.Check();
            if (!isAvail)
            {
                result = false;
            }


            isAvail = sy.Config();
            if (!isAvail)
            {
                result = false;
            }

            sy.Connect();
            if (!isAvail)
            {
                result = false;
            }

            sy.Init();
            if (!isAvail)
            {
                result = false;
            }

            if (result)
            {
                sy.IsAvail = true;
            }
            LogStatusMessage(string.Format("连接串口{0}", portName), sy.IsAvail);
            return(result);
        }
コード例 #3
0
 public SyDevice(int ccdId, string portName)
 {
     CcdId    = ccdId;
     PortName = portName;
     Device   = new SyInfo(Channel, PortName);
 }