Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
 public SyDevice(int ccdId, string portName)
 {
     CcdId    = ccdId;
     PortName = portName;
     Device   = new SyInfo(Channel, PortName);
 }