Пример #1
0
        public void Connect(string deviceName, VISASessionType sessionType)
        {
            switch (sessionType)
            {
            case VISASessionType.USB:
            {
                session = new UsbSession(deviceName);
                break;
            }

            case VISASessionType.Serial:
            {
                session = new SerialSession(deviceName);
                break;
            }

            case VISASessionType.TcpIp:
            {
                session = new TcpipSession(deviceName);
                break;
            }

            case VISASessionType.TcpIpSocket:
            {
                session = new TcpipSocketSession(deviceName);
                break;
            }

            case VISASessionType.GPIB:
            {
                session = new GpibSession(deviceName);
                break;
            }

            case VISASessionType.PXI:
            {
                registerSession = new PxiSession(deviceName);
                break;
            }

            case VISASessionType.VXI:
            {
                session = new VxiSession(deviceName);
                break;
            }

            default:
                break;
            }

            if (session != null)
            {
                try
                {
                    session.EnableEvent(EventType.UsbInterrupt);
                    io = session.FormattedIO;

                    return;
                }
                catch (Exception exception)
                {
                    throw CreateThrowUpException(exception);
                }
            }
        }