Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StreamerDevice"/> class.
 /// </summary>
 /// <param name="context">The <see cref="NetMQContext"/> to use when creating the sockets.</param>
 /// <param name="poller">The <see cref="Poller"/> to use.</param>
 /// <param name="frontendBindAddress">The endpoint used to bind the frontend socket.</param>
 /// <param name="backendBindAddress">The endpoint used to bind the backend socket.</param>
 /// <param name="mode">The <see cref="DeviceMode"/> for the device.</param>		
 public StreamerDevice(NetMQContext context, Poller poller, string frontendBindAddress, string backendBindAddress,
     DeviceMode mode = DeviceMode.Threaded)
     : base(poller, context.CreatePullSocket(), context.CreatePushSocket(), mode)
 {
     FrontendSetup.Bind(frontendBindAddress);
     BackendSetup.Bind(backendBindAddress);
 }
Пример #2
0
        /// <summary>
        /// Create a new instance of the <see cref="DeviceBase"/> class.
        /// </summary>
        /// <param name="poller">the <see cref="INetMQPoller"/> to use for detecting when messages are available</param>
        /// <param name="frontendSocket">
        /// A <see cref="NetMQSocket"/> that will pass incoming messages to <paramref name="backendSocket"/>.
        /// </param>
        /// <param name="backendSocket">
        /// A <see cref="NetMQSocket"/> that will receive messages from (and optionally send replies to) <paramref name="frontendSocket"/>.
        /// </param>
        /// <param name="mode">the <see cref="DeviceMode"/> (either Blocking or Threaded) for this device</param>
        /// <exception cref="ArgumentNullException">frontendSocket must not be null.</exception>
        /// <exception cref="ArgumentNullException">backendSocket must not be null.</exception>
        protected DeviceBase(INetMQPoller poller,  NetMQSocket frontendSocket,  NetMQSocket backendSocket, DeviceMode mode)
        {
            m_isInitialized = false;

            if (frontendSocket == null)
                throw new ArgumentNullException("frontendSocket");

            if (backendSocket == null)
                throw new ArgumentNullException("backendSocket");

            FrontendSocket = frontendSocket;
            BackendSocket = backendSocket;

            FrontendSetup = new DeviceSocketSetup(FrontendSocket);
            BackendSetup = new DeviceSocketSetup(BackendSocket);

            m_poller = poller;

            FrontendSocket.ReceiveReady += FrontendHandler;
            BackendSocket.ReceiveReady += BackendHandler;

            m_poller.Add(FrontendSocket);
            m_poller.Add(BackendSocket);

            m_runner = mode == DeviceMode.Blocking
                ? new DeviceRunner(this)
                : new ThreadedDeviceRunner(this);
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ForwarderDevice"/> class.
 /// </summary>
 /// <param name="poller">The <see cref="INetMQPoller"/> to use.</param>
 /// <param name="frontendBindAddress">The endpoint used to bind the frontend socket.</param>
 /// <param name="backendBindAddress">The endpoint used to bind the backend socket.</param>
 /// <param name="mode">The <see cref="DeviceMode"/> for the device.</param>
 public ForwarderDevice(INetMQPoller poller, string frontendBindAddress, string backendBindAddress,
     DeviceMode mode = DeviceMode.Threaded)
     : base(poller, new SubscriberSocket(), new PublisherSocket(), mode)
 {
     FrontendSetup.Bind(frontendBindAddress);
     BackendSetup.Bind(backendBindAddress);
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ForwarderDevice"/> class.
 /// </summary>
 /// <param name="context">The <see cref="NetMQContext"/> to use when creating the sockets.</param>
 /// <param name="poller">The <see cref="Poller"/> to use.</param>
 /// <param name="frontendBindAddress">The endpoint used to bind the frontend socket.</param>
 /// <param name="backendBindAddress">The endpoint used to bind the backend socket.</param>
 /// <param name="mode">The <see cref="DeviceMode"/> for the device.</param>		
 public ForwarderDevice(NetMQContext context, Poller poller, string frontendBindAddress, string backendBindAddress,
     DeviceMode mode = DeviceMode.Threaded)
     : base(poller, context.CreateSubscriberSocket(), context.CreatePublisherSocket(), mode)
 {
     FrontendSetup.Bind(frontendBindAddress);
     BackendSetup.Bind(backendBindAddress);
 }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ForwarderDevice"/> class.
 /// </summary>
 /// <param name="context">The <see cref="ZmqContext"/> to use when creating the sockets.</param>
 /// <param name="frontendBindAddr">The address used to bind the frontend socket.</param>
 /// <param name="backendBindAddr">The endpoint used to bind the backend socket.</param>
 /// <param name="mode">The <see cref="DeviceMode"/> for the current device.</param>
 public XForwarderDevice(ZmqContext context, string frontendBindAddr, string backendBindAddr, DeviceMode mode)
     : this(context, mode)
 {
     FrontendSetup.Bind(frontendBindAddr);
     FrontendSetup.SubscribeAll();
     BackendSetup.Bind(backendBindAddr);
 }
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="QueueDevice"/> class.
        /// </summary>
        /// <param name="context">The <see cref="NetMQContext"/> to use when creating the sockets.</param>
        /// <param name="poller">The <see cref="Poller"/> to use.</param>
        /// <param name="frontendBindAddress">The endpoint used to bind the frontend socket.</param>
        /// <param name="backendBindAddress">The endpoint used to bind the backend socket.</param>
        /// <param name="mode">The <see cref="DeviceMode"/> for the device.</param>
        public QueueDevice(NetMQContext context, Poller poller, string frontendBindAddress, string backendBindAddress,
			DeviceMode mode = DeviceMode.Threaded)
            : base(poller, context.CreateRouterSocket(), context.CreateDealerSocket(), mode)
        {
            FrontendSetup.Bind(frontendBindAddress);
            BackendSetup.Bind(backendBindAddress);
        }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XForwarder"/> class.
 /// </summary>
 /// <param name="context">The <see cref="NetMQContext"/> to use when creating the sockets.</param>
 /// <param name="frontendBindAddress">The endpoint used to bind the frontend socket.</param>
 /// <param name="backendBindAddress">The endpoint used to bind the backend socket.</param>
 /// <param name="mode">The <see cref="DeviceMode"/> for the device.</param>
 public XForwarder(NetMQContext context, string frontendBindAddress, string backendBindAddress,
                   DeviceMode mode = DeviceMode.Threaded)
     : base(context.CreateXSubscriberSocket(), context.CreateXPublisherSocket(), mode)
 {
     this.FrontendSetup.Bind(frontendBindAddress);
     this.BackendSetup.Bind(backendBindAddress);
 }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StreamerDevice"/> class.
 /// </summary>
 /// <param name="poller">The <see cref="INetMQPoller"/> to use.</param>
 /// <param name="frontendBindAddress">The endpoint used to bind the frontend socket.</param>
 /// <param name="backendBindAddress">The endpoint used to bind the backend socket.</param>
 /// <param name="mode">The <see cref="DeviceMode"/> for the device.</param>
 public StreamerDevice(INetMQPoller poller, string frontendBindAddress, string backendBindAddress,
     DeviceMode mode = DeviceMode.Threaded)
     : base(poller, new PullSocket(), new PushSocket(), mode)
 {
     FrontendSetup.Bind(frontendBindAddress);
     BackendSetup.Bind(backendBindAddress);
 }
Пример #9
0
        /// <summary>
        /// 画面を指定量回転させるためのオブジェクトを生成
        /// </summary>
        /// <param name="monitorID">ディスプレイのデバイス番号</param>
        /// <returns>生成に失敗した場合はnull</returns>
        public static DisplayRotate Generate(int monitorID)
        {
            var mode = new DeviceMode(monitorID);

            return mode.IsSucceeded
                ? new DisplayRotate(mode)
                : null;
        }
Пример #10
0
 public HidDeviceMode(DeviceMode readMode, DeviceMode writeMode, ShareMode shareMode)
 {
     if (!_needChangeStatus) return;
     /* 
     If the flag is "false", then we have the previous values of the attributes.
     Update the values is not required. 
     */
     ReadMode = readMode;
     WriteMode = writeMode;
     ShareMode = shareMode;
     _needChangeStatus = false;
 }
Пример #11
0
        internal static IntPtr OpenDeviceIO(string devicePath, DeviceMode deviceMode, uint deviceAccess)
        {
            var security = new NativeMethods.SECURITY_ATTRIBUTES();
            var flags = 0;

            if (deviceMode == DeviceMode.Overlapped) flags = NativeMethods.FILE_FLAG_OVERLAPPED;

            security.lpSecurityDescriptor = IntPtr.Zero;
            security.bInheritHandle = true;
            security.nLength = Marshal.SizeOf(security);

            return NativeMethods.CreateFile(devicePath, deviceAccess, NativeMethods.FILE_SHARE_READ | NativeMethods.FILE_SHARE_WRITE, ref security, NativeMethods.OPEN_EXISTING, flags, 0);
        }
Пример #12
0
        public BMP085(byte address, DeviceMode deviceMode)
        {
            Address = address;
            _slaveConfig = new I2CDevice.Configuration(address, ClockRateKHz);
            _oversamplingSetting = (byte)deviceMode;

            // Get calibration data that will be used for future measurement taking.
            GetCalibrationData();

            // Take initial measurements.
            TakeMeasurements();

        }
        public BMP085(byte address, DeviceMode deviceMode)
        {
            Address = address;
            _slaveConfig = new I2CDevice.Configuration(address, ClockRateKHz);
            _oversamplingSetting = (byte)deviceMode;

            // Get calibration data that will be used for future measurement taking.
            GetCalibrationData();

            // Take initial measurements.
            TakeMeasurements();

            // Take new measurements every 30 seconds.
            //modificacion mia, en vez de tomar las mediciones aca, hago al metodo publico y lo llamo yo
            //_sensorTimer = new Timer(TakeMeasurements, null, 200, 30000);
        }
Пример #14
0
        public void OpenDevice(DeviceMode readMode, DeviceMode writeMode, ShareMode shareMode)
        {
            if (IsOpen) return;

            _deviceReadMode = readMode;
            _deviceWriteMode = writeMode;

            try
            {
                Handle = OpenDeviceIO(_devicePath, readMode, NativeMethods.GENERIC_READ | NativeMethods.GENERIC_WRITE, shareMode);
            }
            catch (Exception exception)
            {
                IsOpen = false;
                throw new Exception("Error opening HID device.", exception);
            }

            IsOpen = Handle.ToInt32() != NativeMethods.INVALID_HANDLE_VALUE;
        }
Пример #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Device"/> class.
        /// </summary>
        /// <param name="frontendSocket">
        /// A <see cref="ZmqSocket"/> that will pass incoming messages to <paramref name="backendSocket"/>.
        /// </param>
        /// <param name="backendSocket">
        /// A <see cref="ZmqSocket"/> that will receive messages from (and optionally send replies to) <paramref name="frontendSocket"/>.
        /// </param>
        /// <param name="mode">The <see cref="DeviceMode"/> for the current device.</param>
        protected Device(ZmqSocket frontendSocket, ZmqSocket backendSocket, DeviceMode mode)
        {
            if (frontendSocket == null)
            {
                throw new ArgumentNullException("frontendSocket");
            }

            if (backendSocket == null)
            {
                throw new ArgumentNullException("backendSocket");
            }

            FrontendSocket = frontendSocket;
            BackendSocket = backendSocket;
            FrontendSetup = new DeviceSocketSetup(FrontendSocket);
            BackendSetup = new DeviceSocketSetup(BackendSocket);
            DoneEvent = new ManualResetEvent(false);

            _poller = new Poller();
            _runner = mode == DeviceMode.Blocking ? new DeviceRunner(this) : new ThreadedDeviceRunner(this);
        }
Пример #16
0
        public HidDevice(HidDeviceInfo info, DeviceMode devideReadMode, DeviceMode deviceWriteMode)
        {
            Path = info.Path;
            Description = info.Description;
            ReportID = 0x0;
            DeviceReadMode = devideReadMode;
            DeviceWriteMode = deviceWriteMode;
            Timeout = 30;

            try
            {
                Handle = OpenDeviceIO();
                GetDeviceAttributes();
                GetDeviceCapabilities();
            }
            catch
            {
                Dispose();
                throw;
            }
        }
Пример #17
0
 public static extern bool EnumDisplaySettingsW(
     string lpszDeviceName,
     uint iModeNum,
     ref DeviceMode lpDevMode);
Пример #18
0
 private MobileDevice(int mode, Verbrosity flags)
 {
     mMode = (DeviceMode)mode;
     mType = (Verbrosity)flags;
 }
Пример #19
0
        public static Graphics.Renderer.Results Initialize(DeviceMode deviceMode)
        {
            if (!Directory.Exists(Graphics.Application.ApplicationDataFolder + "Logs"))
            {
                Directory.CreateDirectory(Graphics.Application.ApplicationDataFolder + "Logs");
            }
            SlimDX.Direct3D9.Direct3D d3d = new SlimDX.Direct3D9.Direct3D();
#if LOG_DEVICE_SETTINGS
            System.IO.StreamWriter deviceSettingsLogFile = new System.IO.StreamWriter(Graphics.Application.ApplicationDataFolder + "Logs/DeviceSettingsLog.txt");
            deviceSettingsLogFile.WriteLine("======== Graphics Device Capabilities ========");
#endif
            int maxWidth  = 700;
            int maxHeight = 500;
            foreach (SlimDX.Direct3D9.DisplayMode dm in d3d.Adapters[0].GetDisplayModes(SlimDX.Direct3D9.Format.X8R8G8B8))
            {
                if (!SettingConverters.ResolutionListConverter.Resolutions.Contains(new Resolution()
                {
                    Width = dm.Width, Height = dm.Height
                }))
                {
                    if (dm.Width > maxWidth || dm.Height > maxHeight)
                    {
                        SettingConverters.ResolutionListConverter.Resolutions.Add(new Resolution()
                        {
                            Width = dm.Width, Height = dm.Height
                        });

                        if (dm.Width > maxWidth)
                        {
                            maxWidth = dm.Width;
                        }

                        if (dm.Height > maxHeight)
                        {
                            maxHeight = dm.Height;
                        }
                    }
                }
            }

            if (d3d.CheckDeviceMultisampleType(0, SlimDX.Direct3D9.DeviceType.Hardware, SlimDX.Direct3D9.Format.X8R8G8B8,
                                               deviceMode == DeviceMode.Fullscreen ? false : true, SlimDX.Direct3D9.MultisampleType.None))
            {
                SettingConverters.AntiAliasingConverter.MultiSampleTypes.Add(SlimDX.Direct3D9.MultisampleType.None);
            }

            if (d3d.CheckDeviceMultisampleType(0, SlimDX.Direct3D9.DeviceType.Hardware, SlimDX.Direct3D9.Format.X8R8G8B8,
                                               deviceMode == DeviceMode.Fullscreen ? false : true, SlimDX.Direct3D9.MultisampleType.TwoSamples))
            {
                SettingConverters.AntiAliasingConverter.MultiSampleTypes.Add(SlimDX.Direct3D9.MultisampleType.TwoSamples);
            }

            if (d3d.CheckDeviceMultisampleType(0, SlimDX.Direct3D9.DeviceType.Hardware, SlimDX.Direct3D9.Format.X8R8G8B8,
                                               deviceMode == DeviceMode.Fullscreen ? false : true, SlimDX.Direct3D9.MultisampleType.FourSamples))
            {
                SettingConverters.AntiAliasingConverter.MultiSampleTypes.Add(SlimDX.Direct3D9.MultisampleType.FourSamples);
            }

            if (d3d.CheckDeviceMultisampleType(0, SlimDX.Direct3D9.DeviceType.Hardware, SlimDX.Direct3D9.Format.X8R8G8B8,
                                               deviceMode == DeviceMode.Fullscreen ? false : true, SlimDX.Direct3D9.MultisampleType.EightSamples))
            {
                SettingConverters.AntiAliasingConverter.MultiSampleTypes.Add(SlimDX.Direct3D9.MultisampleType.EightSamples);
            }

            if (d3d.CheckDeviceMultisampleType(0, SlimDX.Direct3D9.DeviceType.Hardware, SlimDX.Direct3D9.Format.X8R8G8B8,
                                               deviceMode == DeviceMode.Fullscreen ? false : true, SlimDX.Direct3D9.MultisampleType.SixteenSamples))
            {
                SettingConverters.AntiAliasingConverter.MultiSampleTypes.Add(SlimDX.Direct3D9.MultisampleType.SixteenSamples);
            }

            SlimDX.Direct3D9.Capabilities caps = d3d.GetDeviceCaps(0, SlimDX.Direct3D9.DeviceType.Hardware);

            SlimDX.Direct3D9.FilterCaps c = caps.TextureFilterCaps;

            if ((c & SlimDX.Direct3D9.FilterCaps.MinLinear) != 0 && (c & SlimDX.Direct3D9.FilterCaps.MagLinear) != 0)
            {
                SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Bilinear, new TextureFilters()
                {
                    TextureFilter    = TextureFilterEnum.Bilinear,
                    AnisotropicLevel = 1,
                    TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Linear,
                    TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Linear,
                    TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Point
                });

                if ((c & SlimDX.Direct3D9.FilterCaps.MipLinear) != 0)
                {
                    SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Trilinear, new TextureFilters()
                    {
                        TextureFilter    = TextureFilterEnum.Trilinear,
                        AnisotropicLevel = 1,
                        TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Linear,
                        TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Linear,
                        TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Linear
                    });
                }
            }
            if ((c & SlimDX.Direct3D9.FilterCaps.MinAnisotropic) != 0 && (c & SlimDX.Direct3D9.FilterCaps.MagAnisotropic) != 0)
            {
                if ((c & SlimDX.Direct3D9.FilterCaps.MipLinear) != 0)
                {
                    if (caps.MaxAnisotropy >= 2)
                    {
                        SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Anisotropic2x, new TextureFilters()
                        {
                            TextureFilter    = TextureFilterEnum.Anisotropic2x,
                            AnisotropicLevel = 2,
                            TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Linear
                        });
                    }
                    if (caps.MaxAnisotropy >= 4)
                    {
                        SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Anisotropic4x, new TextureFilters()
                        {
                            TextureFilter    = TextureFilterEnum.Anisotropic4x,
                            AnisotropicLevel = 4,
                            TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Linear
                        });
                    }
                    if (caps.MaxAnisotropy >= 8)
                    {
                        SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Anisotropic8x, new TextureFilters()
                        {
                            TextureFilter    = TextureFilterEnum.Anisotropic8x,
                            AnisotropicLevel = 8,
                            TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Linear
                        });
                    }
                    if (caps.MaxAnisotropy >= 16)
                    {
                        SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Anisotropic16x, new TextureFilters()
                        {
                            TextureFilter    = TextureFilterEnum.Anisotropic16x,
                            AnisotropicLevel = 16,
                            TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Linear
                        });
                    }
                }
            }
            else if ((c & SlimDX.Direct3D9.FilterCaps.MinAnisotropic) != 0)
            {
                if ((c & SlimDX.Direct3D9.FilterCaps.MipLinear) != 0)
                {
                    if (caps.MaxAnisotropy >= 2)
                    {
                        SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Anisotropic2x, new TextureFilters()
                        {
                            TextureFilter    = TextureFilterEnum.Anisotropic2x,
                            AnisotropicLevel = 2,
                            TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Linear,
                            TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Linear
                        });
                    }
                    if (caps.MaxAnisotropy >= 4)
                    {
                        SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Anisotropic4x, new TextureFilters()
                        {
                            TextureFilter    = TextureFilterEnum.Anisotropic4x,
                            AnisotropicLevel = 4,
                            TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Linear,
                            TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Linear
                        });
                    }
                    if (caps.MaxAnisotropy >= 8)
                    {
                        SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Anisotropic8x, new TextureFilters()
                        {
                            TextureFilter    = TextureFilterEnum.Anisotropic8x,
                            AnisotropicLevel = 8,
                            TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Linear,
                            TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Linear
                        });
                    }
                    if (caps.MaxAnisotropy >= 16)
                    {
                        SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Anisotropic16x, new TextureFilters()
                        {
                            TextureFilter    = TextureFilterEnum.Anisotropic16x,
                            AnisotropicLevel = 16,
                            TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Linear,
                            TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Linear
                        });
                    }
                }
            }
            else if ((c & SlimDX.Direct3D9.FilterCaps.MagAnisotropic) != 0)
            {
                throw new Exception("Weird setup, do something about it");
            }

            Application.Log("Vertex shader version: " + caps.VertexShaderVersion);
            Application.Log("Pixel shader version: " + caps.PixelShaderVersion);

            SettingConverters.PixelShaderVersion = caps.PixelShaderVersion;

            Graphics.Renderer.Results result = Graphics.Renderer.Results.OK;

            if (caps.PixelShaderVersion.Major < 3 || caps.VertexShaderVersion.Major < 3)
            {
                if (caps.PixelShaderVersion.Major == 2)
                {
                    Application.Log("Shader version is not recommended");
                    result = Graphics.Renderer.Results.VideoCardNotRecommended;
                }
                else
                {
                    Application.Log("Shader version not supported");
                    return(Graphics.Renderer.Results.VideoCardNotSupported);
                }
            }

            if ((caps.DeviceType & SlimDX.Direct3D9.DeviceType.Hardware) == 0)
            {
                Application.Log("The device is not a hardware device");
                return(Graphics.Renderer.Results.VideoCardNotSupported);
            }

            if ((caps.DeviceCaps & SlimDX.Direct3D9.DeviceCaps.HWTransformAndLight) == 0)
            {
                Application.Log("Hardware vertex processing is not supported. Trying with sotfware vertex processing");
                SettingConverters.VertexProcessing = SlimDX.Direct3D9.CreateFlags.SoftwareVertexProcessing;
                result = Graphics.Renderer.Results.VideoCardNotRecommended;
            }
            else
            {
                SettingConverters.VertexProcessing = SlimDX.Direct3D9.CreateFlags.HardwareVertexProcessing;
            }

            SettingConverters.DepthBufferFormats = new List <SlimDX.Direct3D9.Format>();

            if (d3d.CheckDeviceFormat(0, SlimDX.Direct3D9.DeviceType.Hardware, SlimDX.Direct3D9.Format.X8R8G8B8, SlimDX.Direct3D9.Usage.DepthStencil,
                                      SlimDX.Direct3D9.ResourceType.Surface, SlimDX.Direct3D9.Format.D16))
            {
                SettingConverters.DepthBufferFormats.Add(SlimDX.Direct3D9.Format.D16);
            }
            else
            {
                Application.Log("D16 is not supported");
                return(Graphics.Renderer.Results.VideoCardNotSupported);
            }

            if (d3d.CheckDeviceFormat(0, SlimDX.Direct3D9.DeviceType.Hardware, SlimDX.Direct3D9.Format.X8R8G8B8, SlimDX.Direct3D9.Usage.DepthStencil,
                                      SlimDX.Direct3D9.ResourceType.Surface, SlimDX.Direct3D9.Format.D24X8))
            {
                SettingConverters.DepthBufferFormats.Add(SlimDX.Direct3D9.Format.D24X8);
            }
            else
            {
                Application.Log("D24X8 is not supported");
            }

            if ((caps.PresentationIntervals & SlimDX.Direct3D9.PresentInterval.Immediate) == 0)
            {
                Application.Log("Presentation interval \"Immidiate\" is not supported");
                return(Graphics.Renderer.Results.VideoCardNotSupported);
            }
            if ((caps.PresentationIntervals & SlimDX.Direct3D9.PresentInterval.One) == 0)
            {
                Application.Log("Presentation interval \"One\" is not supported");
                return(Graphics.Renderer.Results.VideoCardNotSupported);
            }

            ManagementObjectSearcher searcher = new ManagementObjectSearcher("select AdapterRAM from Win32_VideoController");

            foreach (ManagementObject mo in searcher.Get())
            {
                var ram = mo.Properties["AdapterRAM"].Value as UInt32?;

                if (ram.HasValue)
                {
                    VideoMemory = ((int)ram / 1048576);
                    Application.Log("Video memory: " + VideoMemory + " MB");
                }
            }

#if LOG_DEVICE_SETTINGS
            deviceSettingsLogFile.WriteLine("Graphics Card: " + d3d.Adapters[0].Details.Description);
            deviceSettingsLogFile.WriteLine("Driver Version: " + d3d.Adapters[0].Details.DriverVersion);

            deviceSettingsLogFile.WriteLine();

            deviceSettingsLogFile.WriteLine("MaxAnisotropy: " + caps.MaxAnisotropy);
            deviceSettingsLogFile.WriteLine("Texture Filters: " + caps.TextureFilterCaps);
            deviceSettingsLogFile.WriteLine("Multisample types: | ");
            foreach (SlimDX.Direct3D9.MultisampleType m in SettingConverters.AntiAliasingConverter.MultiSampleTypes)
            {
                deviceSettingsLogFile.Write(m + " | ");
            }

            d3d.Dispose();

            deviceSettingsLogFile.Close();
#endif

            return(result);
        }
Пример #20
0
 private void StopOutput()
 {
     _decklink.StopOutput();
     _activeMode = null;
 }
Пример #21
0
 public static extern bool EnumDisplaySettings(
     string deviceName,
     DisplaySettingsMode mode,
     ref DeviceMode devMode
     );
Пример #22
0
 public void Open(DeviceMode mode)
 {
     Open();
 }
Пример #23
0
 /// <summary>
 /// Open the device. To start capturing call the 'StartCapture' function
 /// </summary>
 /// <param name="mode">
 /// A <see cref="DeviceMode"/>
 /// </param>
 /// <param name="read_timeout">
 /// A <see cref="System.Int32"/>
 /// </param>
 public virtual void Open(DeviceMode mode, int read_timeout)
 {
     throw new System.NotImplementedException();
 }
Пример #24
0
 public void Open(DeviceMode mode, int read_timeout, MonitorMode monitor_mode, uint kernel_buffer_size)
 {
     Open(mode, read_timeout, kernel_buffer_size);
 }
Пример #25
0
 public void Open(DeviceMode mode, int read_timeout, MonitorMode monitor_mode)
 {
     Open(mode, read_timeout);
 }
Пример #26
0
 public void Open(DeviceMode mode, int read_timeout, uint kernel_buffer_size)
 {
     Open();
     SetParam(WinDivertParam.QueueSize, kernel_buffer_size);
 }
Пример #27
0
 public void Open(DeviceMode mode, int read_timeout)
 {
     Open();
 }
Пример #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueDevice"/> class.
 /// </summary>
 /// <param name="context">The <see cref="NetMQContext"/> to use when creating the sockets.</param>
 /// <param name="poller">The <see cref="Poller"/> to use.</param>
 /// <param name="frontendBindAddress">The endpoint used to bind the frontend socket.</param>
 /// <param name="backendBindAddress">The endpoint used to bind the backend socket.</param>
 /// <param name="mode">The <see cref="DeviceMode"/> for the device.</param>
 public QueueDevice(NetMQContext context, Poller poller, string frontendBindAddress, string backendBindAddress, DeviceMode mode = DeviceMode.Threaded)
     : base(poller, context.CreateRouterSocket(), context.CreateDealerSocket(), mode)
 {
     FrontendSetup.Bind(frontendBindAddress);
     BackendSetup.Bind(backendBindAddress);
 }
Пример #29
0
        /// <summary>
        /// Create a new instance of the <see cref="DeviceBase"/> class.
        /// </summary>
        /// <param name="poller">the <see cref="INetMQPoller"/> to use for detecting when messages are available</param>
        /// <param name="frontendSocket">
        /// A <see cref="NetMQSocket"/> that will pass incoming messages to <paramref name="backendSocket"/>.
        /// </param>
        /// <param name="backendSocket">
        /// A <see cref="NetMQSocket"/> that will receive messages from (and optionally send replies to) <paramref name="frontendSocket"/>.
        /// </param>
        /// <param name="mode">the <see cref="DeviceMode"/> (either Blocking or Threaded) for this device</param>
        /// <exception cref="ArgumentNullException">frontendSocket must not be null.</exception>
        /// <exception cref="ArgumentNullException">backendSocket must not be null.</exception>
        protected DeviceBase(INetMQPoller poller, [NotNull] NetMQSocket frontendSocket, [NotNull] NetMQSocket backendSocket, DeviceMode mode)
        {
            m_isInitialized = false;

            if (frontendSocket == null)
            {
                throw new ArgumentNullException(nameof(frontendSocket));
            }

            if (backendSocket == null)
            {
                throw new ArgumentNullException(nameof(backendSocket));
            }

            FrontendSocket = frontendSocket;
            BackendSocket  = backendSocket;

            FrontendSetup = new DeviceSocketSetup(FrontendSocket);
            BackendSetup  = new DeviceSocketSetup(BackendSocket);

            m_poller = poller;

            FrontendSocket.ReceiveReady += FrontendHandler;
            BackendSocket.ReceiveReady  += BackendHandler;

            m_poller.Add(FrontendSocket);
            m_poller.Add(BackendSocket);

            m_runner = mode == DeviceMode.Blocking
                ? new DeviceRunner(this)
                : new ThreadedDeviceRunner(this);
        }
Пример #30
0
 public static extern ChangeDisplaySettingsExResults ChangeDisplaySettingsEx(
     string deviceName,
     ref DeviceMode devMode,
     IntPtr handler,
     ChangeDisplaySettingsFlags flags,
     IntPtr param);
Пример #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ForwarderDevice"/> class.
 /// </summary>
 /// <param name="context">The <see cref="ZmqContext"/> to use when creating the sockets.</param>
 /// <param name="frontendBindAddr">The address used to bind the frontend socket.</param>
 /// <param name="backendBindAddr">The endpoint used to bind the backend socket.</param>
 /// <param name="mode">The <see cref="DeviceMode"/> for the current device.</param>
 public ForwarderDevice(ZmqContext context, string frontendBindAddr, string backendBindAddr, DeviceMode mode)
     : this(context, mode)
 {
     FrontendSetup.Bind(frontendBindAddr);
     BackendSetup.Bind(backendBindAddr);
 }
Пример #32
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="deviceToCaptureInfo"></param>
        /// <param name="filter"></param>
        /// <param name="deviceMode"></param>
        /// <param name="reportMethods"></param>
        /// <param name="heartBeatDelay"></param>
        /// <param name="timeWindow">How big is the window we measure for a DoS attack</param>
        ///
        ///

        private WebServerDosSensor(CaptureDeviceDescription deviceToCaptureInfo, string filter, DeviceMode deviceMode, List <ISensorReport> reportMethods, int heartBeatDelay)
            : base(deviceToCaptureInfo, filter, deviceMode, reportMethods, heartBeatDelay, Enumerations.SensorMode.PacketCapture)
        {
        }
Пример #33
0
 public DebuggingForwarder(ZmqContext context, string publishAddressServer, string subscribeAddressServer, DeviceMode mode)
     : base(context, publishAddressServer, subscribeAddressServer, mode)
 {
 }
Пример #34
0
 internal DeviceTypeMode(DeviceType type, DeviceMode mode)
 {
     Type = type;
     Mode = mode;
 }
Пример #35
0
 private void StartOutput(DeviceMode mode)
 {
     StopOutput();
     _decklink._modeIndex = mode.Index;
     _decklink.Begin();
 }
Пример #36
0
		/// <summary>
		/// Open the device. To start capturing call the 'StartCapture' function
		/// </summary>
		/// <param name="mode">
		/// A <see cref="DeviceMode"/>
		/// </param>
		/// <param name="read_timeout">
		/// A <see cref="System.Int32"/>
		/// </param>
		public override void Open(DeviceMode mode, int read_timeout) {
			if (!Opened) {
				StringBuilder errbuf = new StringBuilder(Pcap.PCAP_ERRBUF_SIZE); //will hold errors

				// set the StopCaptureTimeout value to twice the read timeout to ensure that
				// we wait long enough before considering the capture thread to be stuck when stopping
				// a background capture via StopCapture()
				//
				// NOTE: Doesn't affect Mono if unix poll is available, doesn't affect Linux because
				//       Linux devices have no timeout, they always block. Only affects Windows devices.
				StopCaptureTimeout = new TimeSpan(0, 0, 0, 0, read_timeout * 2);

				PcapHandle = LibPcapSafeNativeMethods.pcap_open_live
					(Name,                   // name of the device
						Pcap.MAX_PACKET_SIZE,   // portion of the packet to capture. 
					// MAX_PACKET_SIZE (65536) grants that the whole packet will be captured on all the MACs.
						(int)mode,              // promiscuous mode
						read_timeout,           // read timeout
						errbuf);               // error buffer

				if (PcapHandle == IntPtr.Zero) {
					string err = "Unable to open the adapter (" + Name + "). " + errbuf.ToString();
					throw new PcapException(err);
				}
			}
		}
Пример #37
0
        public void OnGUI()
        {
            GUI.skin = _guiSkin;

            if (_modeListStyle == null)
            {
                _modeListStyle = GUI.skin.GetStyle("ModeList");
            }


            GUILayout.BeginHorizontal();
            // List the devices
            _deviceScrollPos = GUILayout.BeginScrollView(_deviceScrollPos, false, false);

            GUILayout.BeginVertical("box", GUILayout.MaxWidth(300));
            if (GUILayout.Button("Select Device:"))
            {
                _selectedDevice = null;
            }
            GUILayout.EndVertical();

            GUILayout.BeginVertical("box", GUILayout.MaxWidth(300));
            for (int i = 0; i < DeckLink.GetNumDevices(); i++)
            {
                Device device = DeckLink.GetDevice(i);

                if (device == _selectedDevice)
                {
                    GUI.color = Color.blue;
                }
                if (_activeMode != null && device == _selectedDevice && device.IsStreamingOutput)
                {
                    GUI.color = Color.green;
                }


                if (GUILayout.Button(device.Name + " " + device.ModelName, _modeListStyle))
                {
                    _selectedDevice = device;
                }
                GUI.color = Color.white;
            }
            GUILayout.EndVertical();
            GUILayout.EndScrollView();

            // For the selected device, list the modes available
            if (_selectedDevice != null)
            {
                GUILayout.BeginVertical();
                GUILayout.BeginVertical("box", GUILayout.MaxWidth(300));
                if (GUILayout.Button("Select Mode:"))
                {
                    _selectedDevice = null;
                }
                GUILayout.EndVertical();

                if (_selectedDevice != null)
                {
                    GUILayout.BeginVertical("box", GUILayout.MaxWidth(600));
                    _modeScrollPos = GUILayout.BeginScrollView(_modeScrollPos, false, false);
                    for (int j = 0; j < _selectedDevice.NumOutputModes; j++)
                    {
                        DeviceMode mode = _selectedDevice.GetOutputMode(j);

                        if (mode == _activeMode)
                        {
                            if (_selectedDevice.IsStreamingOutput)
                            {
                                GUI.color = Color.green;
                            }
                            else
                            {
                                GUI.color = Color.blue;
                            }
                        }
                        //GUILayout.BeginVertical("box", GUILayout.MaxWidth(300));
                        if (GUILayout.Button("" + j.ToString("D2") + ") " + mode.ModeDescription + " - " + mode.PixelFormatDescription + " - " + mode.Width + "x" + mode.Height, _modeListStyle))
                        {
                            _decklink.StopOutput();
                            _decklink.DeviceIndex = _selectedDevice.DeviceIndex;
                            _decklink.ModeIndex   = mode.Index;
                            _decklink.Begin();

                            _activeMode = mode;
                        }

                        GUI.color = Color.white;
                    }
                    GUILayout.EndScrollView();
                    GUILayout.EndVertical();
                }
                GUILayout.EndVertical();
            }

            if (_decklink.Device != null && _decklink.Device.IsStreamingOutput)
            {
                GUILayout.BeginVertical("box");
                int numDecklinkBufferedFrames = DeckLinkPlugin.GetOutputBufferedFramesCount(_decklink.Device.DeviceIndex);
                int numWaitingOutputFrames    = DeckLinkPlugin.GetWaitingOutputBufferCount(_decklink.Device.DeviceIndex);
                int numFreeOutputFrames       = DeckLinkPlugin.GetFreeOutputBufferCount(_decklink.Device.DeviceIndex);

                GUILayout.Space(20f);
                GUILayout.Label(string.Format("VSync {0}", QualitySettings.vSyncCount));
                GUILayout.Label(string.Format("{0:F3} {1}", _decklink.TargetFramerate, _decklink.OutputFramerate));
                GUILayout.Label(string.Format("Buffers: DeckLink {0:D2} << Full {1:D2} << Empty {2:D2}", numDecklinkBufferedFrames, numWaitingOutputFrames, numFreeOutputFrames));
                GUILayout.Label("Screen: " + Screen.currentResolution.width + "x" + Screen.currentResolution.height + " " + Screen.currentResolution.refreshRate);
                GUILayout.EndVertical();
            }

            GUILayout.EndHorizontal();
        }
Пример #38
0
		/// <summary>
		/// Open the device. To start capturing call the 'StartCapture' function
		/// </summary>
		/// <param name="mode">
		/// A <see cref="DeviceMode"/>
		/// </param>
		public override void Open(DeviceMode mode) {
			const int readTimeoutMilliseconds = 1000;
			this.Open(mode, readTimeoutMilliseconds);
		}
Пример #39
0
        public void RefreshDisplayDevices()
        {
            lock (display_lock)
            {
                // Store an array of the current available DisplayDevice objects.
                // This is needed to preserve the original resolution.
                DisplayDevice[] previousDevices = AvailableDevices.ToArray();

                AvailableDevices.Clear();

                // We save all necessary parameters in temporary variables
                // and construct the device when every needed detail is available.
                // The main DisplayDevice constructor adds the newly constructed device
                // to the list of available devices.
                DisplayDevice            opentk_dev;
                DisplayResolution        opentk_dev_current_res   = null;
                List <DisplayResolution> opentk_dev_available_res = new List <DisplayResolution>();
                bool opentk_dev_primary = false;
                int  device_count = 0, mode_count = 0;

                // Get available video adapters and enumerate all monitors
                WindowsDisplayDevice dev1 = new WindowsDisplayDevice();
                while (Functions.EnumDisplayDevices(null, device_count++, dev1, 0))
                {
                    if ((dev1.StateFlags & DisplayDeviceStateFlags.AttachedToDesktop) == DisplayDeviceStateFlags.None)
                    {
                        continue;
                    }

                    DeviceMode monitor_mode = new DeviceMode();

                    // The second function should only be executed when the first one fails
                    // (e.g. when the monitor is disabled)
                    if (Functions.EnumDisplaySettingsEx(dev1.DeviceName.ToString(), DisplayModeSettingsEnum.CurrentSettings, monitor_mode, 0) ||
                        Functions.EnumDisplaySettingsEx(dev1.DeviceName.ToString(), DisplayModeSettingsEnum.RegistrySettings, monitor_mode, 0))
                    {
                        VerifyMode(dev1, monitor_mode);

                        float scale = GetScale(ref monitor_mode);
                        opentk_dev_current_res = new DisplayResolution(
                            (int)(monitor_mode.Position.X / scale), (int)(monitor_mode.Position.Y / scale),
                            (int)(monitor_mode.PelsWidth / scale), (int)(monitor_mode.PelsHeight / scale),
                            monitor_mode.BitsPerPel, monitor_mode.DisplayFrequency);

                        opentk_dev_primary =
                            (dev1.StateFlags & DisplayDeviceStateFlags.PrimaryDevice) != DisplayDeviceStateFlags.None;
                    }

                    opentk_dev_available_res.Clear();
                    mode_count = 0;
                    while (Functions.EnumDisplaySettingsEx(dev1.DeviceName.ToString(), mode_count++, monitor_mode, 0))
                    {
                        VerifyMode(dev1, monitor_mode);

                        float             scale = GetScale(ref monitor_mode);
                        DisplayResolution res   = new DisplayResolution(
                            (int)(monitor_mode.Position.X / scale), (int)(monitor_mode.Position.Y / scale),
                            (int)(monitor_mode.PelsWidth / scale), (int)(monitor_mode.PelsHeight / scale),
                            monitor_mode.BitsPerPel, monitor_mode.DisplayFrequency);

                        opentk_dev_available_res.Add(res);
                    }

                    // Construct the osuTK DisplayDevice through the accumulated parameters.
                    // The constructor will automatically add the DisplayDevice to the list
                    // of available devices.
                    #pragma warning disable 612,618
                    opentk_dev = new DisplayDevice(
                        opentk_dev_current_res,
                        opentk_dev_primary,
                        opentk_dev_available_res,
                        opentk_dev_current_res.Bounds,
                        dev1.DeviceName);
                    #pragma warning restore 612,618

                    // Set the original resolution if the DisplayDevice was previously available.
                    foreach (DisplayDevice existingDevice in previousDevices)
                    {
                        if ((string)existingDevice.Id == (string)opentk_dev.Id)
                        {
                            opentk_dev.OriginalResolution = existingDevice.OriginalResolution;
                        }
                    }

                    AvailableDevices.Add(opentk_dev);

                    if (opentk_dev_primary)
                    {
                        Primary = opentk_dev;
                    }

                    Debug.Print("DisplayDevice {0} ({1}) supports {2} resolutions.",
                                device_count, opentk_dev.IsPrimary ? "primary" : "secondary", opentk_dev.AvailableResolutions.Count);
                }
            }
        }
Пример #40
0
        void Awake()
        {
            // Attach communication components.
            receiver = gameObject.AddComponent <Receiver>();
            receiver.DataReceived += (source, message) => OnDataReceivedFromNetwork(message);
            arduino = gameObject.AddComponent <Arduino>();
            arduino.DataReceived += (source, data) => {
                OnDataReceivedFromArduino(data);
            };

            // Setup UI components.
            menuCanvas      = GameObject.Find("MenuCanvas").GetComponent <Canvas>();
            intertrialImage = GameObject.Find("Blank").GetComponent <RawImage>();
            consoleText     = GameObject.Find("Console").GetComponent <Text>();

            InputField startPositionInput = GameObject.Find("StartPosition").GetComponent <InputField>();

            startPosition = PlayerPrefs.GetFloat(startPositionInput.name, startPosition);
            SetupCombo(GameObject.Find("SetStartPosition").GetComponent <Button>(), startPositionInput, startPosition.ToString(), TestFloat,
                       () => {
                startPosition = float.Parse(startPositionInput.text);
                PlayerPrefs.SetFloat(startPositionInput.name, startPosition);
                PlayerPrefs.Save();
            },
                       () => transform.position = new Vector3(transform.position.x, transform.position.y, startPosition)
                       );

            InputField finishPositionInput = GameObject.Find("FinishPosition").GetComponent <InputField>();

            finishPosition = PlayerPrefs.GetFloat(finishPositionInput.name, finishPosition);
            SetupCombo(GameObject.Find("SetFinishPosition").GetComponent <Button>(), finishPositionInput, finishPosition.ToString(), TestFloat,
                       () => {
                finishPosition = float.Parse(finishPositionInput.text);
                PlayerPrefs.SetFloat(finishPositionInput.name, finishPosition);
                PlayerPrefs.Save();
            },
                       () => transform.position = new Vector3(transform.position.x, transform.position.y, finishPosition)
                       );

            InputField intertrialDurationInput = GameObject.Find("IntertrialDuration").GetComponent <InputField>();

            intertrialDuration = PlayerPrefs.GetFloat(intertrialDurationInput.name, intertrialDuration);
            SetupCombo(GameObject.Find("SetIntertrialDuration").GetComponent <Button>(), intertrialDurationInput, intertrialDuration.ToString(), TestPositiveFloat,
                       () => {
                intertrialDuration = float.Parse(intertrialDurationInput.text);
                PlayerPrefs.SetFloat(intertrialDurationInput.name, intertrialDuration);
                PlayerPrefs.Save();
            },
                       () => StartIntertrial()
                       );

            InputField wheelRadiusInput = GameObject.Find("WheelRadius").GetComponent <InputField>();

            wheelRadius = PlayerPrefs.GetFloat(wheelRadiusInput.name, wheelRadius);
            SetupCombo(GameObject.Find("SetWheelRadius").GetComponent <Button>(), wheelRadiusInput, wheelRadius.ToString(), TestFloat,
                       () => {
                wheelRadius = float.Parse(wheelRadiusInput.text);
                wheelFactor = 2 * Mathf.PI / wheelSteps * wheelRadius;
                PlayerPrefs.SetFloat(wheelRadiusInput.name, wheelRadius);
                PlayerPrefs.Save();
            }
                       );

            InputField wheelStepsInput = GameObject.Find("WheelSteps").GetComponent <InputField>();

            wheelSteps = (int)PlayerPrefs.GetFloat(wheelStepsInput.name, wheelSteps);
            SetupCombo(GameObject.Find("SetWheelSteps").GetComponent <Button>(), wheelStepsInput, wheelSteps.ToString(), TestInt,
                       () => {
                wheelSteps  = int.Parse(wheelStepsInput.text);
                wheelFactor = 2 * Mathf.PI / wheelSteps * wheelRadius;
                PlayerPrefs.SetFloat(wheelStepsInput.name, wheelSteps);
                PlayerPrefs.Save();
            }
                       );

            InputField serialNameInput      = GameObject.Find("SerialName").GetComponent <InputField>();
            Button     serialNameButton     = GameObject.Find("SetSerialName").GetComponent <Button>();
            Text       serialNameButtonText = serialNameButton.GetComponentInChildren <Text>();

            serialNameButtonText.text = "Connect";
            serialName           = PlayerPrefs.GetString(serialNameInput.name, serialName);
            serialNameInput.text = serialName;
            bool serialConnected = false;

            serialNameInput.onValidateInput +=
                delegate(string input, int charIndex, char addedChar) {
                if (serialConnected)
                {
                    serialNameButton.interactable = true;
                    serialConnected = false;
                    arduino.Stop();
                }
                serialNameButtonText.text = "Connect";
                return(addedChar);
            };
            serialNameButton.onClick.AddListener(
                delegate {
                if (serialConnected)
                {
                    serialConnected           = false;
                    serialNameButtonText.text = "Connect";
                    arduino.Stop();
                }
                else
                {
                    serialNameButton.interactable = false;
                    arduino.Setup(serialNameInput.text, baudrate,
                                  (connected, message) => {
                        serialNameButton.interactable = true;
                        if (connected)
                        {
                            serialConnected           = true;
                            serialNameButtonText.text = "Disconnect";
                        }
                        else
                        {
                            Log(string.Format("Unable to connect to '{0}': {1}", serialNameInput.text, message.Trim()));
                        }
                    }
                                  );
                    // Always save regarless of connection outcome.
                    serialName = serialNameInput.text;
                    PlayerPrefs.SetString(serialNameInput.name, serialName);
                    PlayerPrefs.Save();
                }
            }
                );

            InputField ipsInput      = GameObject.Find("IPs").GetComponent <InputField>();
            Button     ipsButton     = GameObject.Find("SetIPs").GetComponent <Button>();
            Text       ipsButtonText = ipsButton.GetComponentInChildren <Text>();

            ipsButtonText.text = "Connect";
            ips           = PlayerPrefs.GetString(ipsInput.name, ips);
            ipsInput.text = ips;
            bool senderConnected = false;

            ipsInput.onValidateInput +=
                delegate(string input, int charIndex, char addedChar) {
                if (senderConnected)
                {
                    senderConnected = false;
                    sender.Stop();
                }
                ipsButtonText.text = "Connect";
                return(addedChar);
            };
            ipsButton.onClick.AddListener(
                delegate {
                if (senderConnected)
                {
                    senderConnected    = false;
                    ipsButtonText.text = "Connect";
                    sender.Stop();
                }
                else
                {
                    bool success     = true;
                    string[] ipArray = Regex.Split(ipsInput.text, @"[\s,]+");
                    foreach (string ip in ipArray)
                    {
                        if (ip.Trim() != String.Empty && !Sender.Validate(ip))
                        {
                            Log(string.Format("'{0}' is not a valid IP address.", ip));
                            success = false;
                        }
                    }
                    if (success)
                    {
                        senderConnected    = true;
                        ipsButtonText.text = "Disconnect";
                        ips = ipsInput.text;
                        PlayerPrefs.SetString(ipsInput.name, ips);
                        PlayerPrefs.Save();
                        sender.Setup(ipArray, port);
                    }
                }
            }
                );

            viewAngleText = GameObject.Find("ViewAngle").GetComponentInChildren <Text>();
            Button viewAngleButton = GameObject.Find("SetViewAngle").GetComponent <Button>();

            viewAngleIndex = PlayerPrefs.GetInt("ViewAngleIndex", viewAngleIndex);
            ViewAngle      = viewAngles[viewAngleIndex];
            // Rotate views.
            viewAngleButton.onClick.AddListener(
                () => {
                viewAngleIndex = (viewAngleIndex + 1) % viewAngles.Length;
                ViewAngle      = viewAngles[viewAngleIndex];
                PlayerPrefs.SetInt("ViewAngleIndex", viewAngleIndex);
                PlayerPrefs.Save();
            }
                );

            deviceModeText = GameObject.Find("DeviceMode").GetComponentInChildren <Text>();
            Button deviceModeButton = GameObject.Find("SetDeviceMode").GetComponent <Button>();

            deviceMode = (DeviceModes)Enum.Parse(typeof(DeviceModes), PlayerPrefs.GetString("DeviceMode", deviceMode.ToString()));
            DeviceMode = deviceMode;
            // Alternate device modes.
            deviceModeButton.onClick.AddListener(
                () => {
                switch (DeviceMode)
                {
                case DeviceModes.Control:
                    DeviceMode          = DeviceModes.Monitor;
                    deviceModeText.text = "Monitor";
                    break;

                case DeviceModes.Monitor:
                    DeviceMode          = DeviceModes.Control;
                    deviceModeText.text = "Control";
                    break;
                }
                PlayerPrefs.SetString("DeviceMode", DeviceMode.ToString());
                PlayerPrefs.Save();
            }
                );


            wheelFactor        = 2 * Mathf.PI / wheelSteps * wheelRadius;
            transform.position = new Vector3(transform.position.x, transform.position.y, startPosition);

            if (!receiver.Setup(port))
            {
                Log(string.Format("Port {0} is unavailable in this device and remote data won't reach this device.", port));
            }

            string filename = System.IO.Path.Combine(outputFolder, string.Format("VR{0}.csv", System.DateTime.Now.ToString("yyyyMMddHHmmss")));

            logger = new Logger(filename);
            Log("Version: " + version);
            Log("About: [email protected]");
            Log("Filename: " + filename);
        }
Пример #41
0
 public DebuggingForwarder(NetMQContext context, string publishAddressServer, string subscribeAddressServer, DeviceMode mode)
     : base(context, publishAddressServer, subscribeAddressServer, mode)
 {
 }
Пример #42
0
        public void OnGUI()
        {
            GUI.skin = _guiSkin;

            if (_modeListStyle == null)
            {
                _modeListStyle = GUI.skin.GetStyle("ModeList");
            }

            // List the devices
            GUILayout.BeginVertical("box", GUILayout.MaxWidth(400));
            if (GUILayout.Button("Select Input and Output Device:"))
            {
                _selectedInputDevice  = null;
                _selectedOutputDevice = null;
                _needsInputAutoScroll = _needsOutputAutoScroll = false;
            }
            GUILayout.EndVertical();

            GUILayout.BeginVertical("box", GUILayout.MaxWidth(400));
            for (int i = 0; i < DeckLink.GetNumDevices(); i++)
            {
                Device device = DeckLink.GetDevice(i);

                GUILayout.BeginHorizontal();
                GUILayout.Label(device.Name + " " + device.ModelName, _modeListStyle, GUILayout.Width(192f));

                GUI.color = Color.white;
                if (device == _selectedInputDevice)
                {
                    GUI.color = Color.blue;
                }
                if (device.IsStreamingInput)
                {
                    GUI.color = Color.green;
                }

                GUI.enabled = true;
                if (device.IsStreamingOutput && !device.FullDuplexSupported)
                {
                    GUI.enabled = false;
                }

                if (GUILayout.Button("Input", _modeListStyle))
                {
                    _selectedInputDevice  = device;
                    _needsInputAutoScroll = true;
                }

                GUI.color = Color.white;
                if (device == _selectedOutputDevice)
                {
                    GUI.color = Color.blue;
                }
                if (device.IsStreamingOutput)
                {
                    GUI.color = Color.green;
                }

                GUI.enabled = true;
                if (device.IsStreamingInput && !device.FullDuplexSupported)
                {
                    GUI.enabled = false;
                }

                if (GUILayout.Button("Output", _modeListStyle))
                {
                    _selectedOutputDevice  = device;
                    _needsOutputAutoScroll = true;
                }

                GUI.enabled = device.IsStreaming;
                GUI.color   = Color.white;
                if (GUILayout.Button("Stop", _modeListStyle))
                {
                    if (device.IsStreamingInput)
                    {
                        StopInput();
                    }
                    if (device.IsStreamingOutput)
                    {
                        StopOutput();
                    }
                }
                GUILayout.EndHorizontal();

                GUI.enabled = true;
                GUI.color   = Color.white;
            }
            GUILayout.EndVertical();

            _outputModeMatchInputMode = GUILayout.Toggle(_outputModeMatchInputMode, "Auto Match Output Mode To Input");

            GUILayout.BeginHorizontal();

            // For the selected device, list the INPUTmodes available
            if (_selectedInputDevice != null)
            {
                GUILayout.BeginVertical();
                GUILayout.BeginVertical("box", GUILayout.MaxWidth(500));
                if (GUILayout.Button("Select " + _selectedInputDevice.Name + " Input Mode:"))
                {
                    _selectedInputDevice = null;
                }
                GUILayout.EndVertical();

                if (_selectedInputDevice != null)
                {
                    GUILayout.BeginVertical("box", GUILayout.MaxWidth(500), GUILayout.MaxHeight(400));
                    _inputModeScrollPos = GUILayout.BeginScrollView(_inputModeScrollPos, false, false);

                    for (int j = 0; j < _selectedInputDevice.NumInputModes; j++)
                    {
                        DeviceMode mode = _selectedInputDevice.GetInputMode(j);

                        if (_inputDecklink.Device != null && _inputDecklink.Device.IsStreaming && _inputDecklink.Device.CurrentMode == mode)
                        {
                            GUI.color = Color.green;
                        }

                        if (GUILayout.Button("" + j.ToString("D2") + ") " + mode.ModeDescription + " - " + mode.PixelFormatDescription + " - " + mode.Width + "x" + mode.Height, _modeListStyle))
                        {
                            StartInput(mode);
                        }

                        GUI.color = Color.white;
                    }

                    if (Event.current.type == EventType.Repaint)
                    {
                        if (_needsInputAutoScroll)
                        {
                            if (_inputDecklink.Device != null && _inputDecklink.Device.IsStreaming && _inputDecklink.Device.CurrentMode != null)
                            {
                                float height = _modeListStyle.CalcHeight(new GUIContent("A"), 64);
                                float y      = _inputDecklink.Device.CurrentMode.Index * height;
                                GUI.ScrollTo(new Rect(0, y, 10, height * 8));
                            }
                            _needsInputAutoScroll = false;
                        }
                    }

                    GUILayout.EndScrollView();
                    GUILayout.EndVertical();
                }
                GUILayout.EndVertical();
            }

            // For the selected device, list the OUTPUT modes available
            if (_selectedOutputDevice != null)
            {
                GUILayout.BeginVertical();
                GUILayout.BeginVertical("box", GUILayout.MaxWidth(500));
                if (GUILayout.Button("Select " + _selectedOutputDevice.Name + " Output Mode:"))
                {
                    _selectedOutputDevice = null;
                }
                GUILayout.EndVertical();

                if (_selectedOutputDevice != null)
                {
                    GUILayout.BeginVertical("box", GUILayout.MaxWidth(500), GUILayout.MaxHeight(400));
                    _outputModeScrollPos = GUILayout.BeginScrollView(_outputModeScrollPos, false, false);

                    for (int j = 0; j < _selectedOutputDevice.NumOutputModes; j++)
                    {
                        DeviceMode mode = _selectedOutputDevice.GetOutputMode(j);

                        if (_outputDecklink.Device != null && _outputDecklink.Device.IsStreaming && _outputDecklink.Device.CurrentOutputMode == mode)
                        {
                            GUI.color = Color.green;
                        }

                        if (GUILayout.Button("" + j.ToString("D2") + ") " + mode.ModeDescription + " - " + mode.PixelFormatDescription + " - " + mode.Width + "x" + mode.Height, _modeListStyle))
                        {
                            StartOutput(mode);
                        }

                        GUI.color = Color.white;
                    }

                    if (Event.current.type == EventType.Repaint)
                    {
                        if (_needsOutputAutoScroll)
                        {
                            if (_outputDecklink.Device != null && _outputDecklink.Device.IsStreaming && _outputDecklink.Device.CurrentOutputMode != null)
                            {
                                float height = _modeListStyle.CalcHeight(new GUIContent("A"), 64);
                                float y      = _outputDecklink.Device.CurrentOutputMode.Index * height;
                                GUI.ScrollTo(new Rect(0, y, 10, height * 8));
                            }
                            _needsOutputAutoScroll = false;
                        }
                    }

                    GUILayout.EndScrollView();
                    GUILayout.EndVertical();
                }
                GUILayout.EndVertical();
            }

            GUILayout.EndHorizontal();


            // Active input output device summary
            GUILayout.BeginArea(new Rect(0, Screen.height - 64, Screen.width, 64));
            GUILayout.BeginVertical("box");
            string inputStr  = "None";
            string outputStr = "None";

            if (_inputDecklink.Device != null && _inputDecklink.Device.IsStreamingInput)
            {
                inputStr = "" + _inputDecklink.Device.Name + " - " + _inputDecklink.Device.CurrentMode.ModeDescription;
            }
            if (_outputDecklink.Device != null && _outputDecklink.Device.IsStreamingOutput)
            {
                outputStr = "" + _outputDecklink.Device.Name + " - " + _outputDecklink.Device.CurrentOutputMode.ModeDescription;
            }
            GUILayout.Label("Input: " + inputStr, _modeListStyle);
            GUILayout.Label("Output: " + outputStr, _modeListStyle);
            GUILayout.EndVertical();
            GUILayout.EndArea();

            // Output stats
            GUILayout.BeginArea(new Rect(Screen.width - 256, Screen.height - 192, 256, 192));
            GUILayout.BeginVertical("box", GUILayout.ExpandHeight(true));
            if (_outputDecklink.Device != null && _outputDecklink.Device.IsStreaming)
            {
                int numDecklinkBufferedFrames = DeckLinkPlugin.GetOutputBufferedFramesCount(_outputDecklink.Device.DeviceIndex);
                int numWaitingOutputFrames    = DeckLinkPlugin.GetWaitingOutputBufferCount(_outputDecklink.Device.DeviceIndex);
                int numFreeOutputFrames       = DeckLinkPlugin.GetFreeOutputBufferCount(_outputDecklink.Device.DeviceIndex);

                //GUILayout.Space(20f);
                GUILayout.Label(string.Format("VSync {0}", QualitySettings.vSyncCount));
                GUILayout.Label(string.Format("{0:F3} {1}", _outputDecklink.TargetFramerate, _outputDecklink.OutputFramerate));
                GUILayout.Label(string.Format("Buffers: DeckLink {0:D2} << Full {1:D2} << Empty {2:D2}", numDecklinkBufferedFrames, numWaitingOutputFrames, numFreeOutputFrames));

                //GUILayout.Label("Buffered Frames: " + AVProDeckLinkPlugin.GetOutputBufferedFramesCount(_outputDecklink.Device.DeviceIndex));
                //GUILayout.Label("Free Frames: " + AVProDeckLinkPlugin.GetFreeOutputBufferCount(_outputDecklink.Device.DeviceIndex));
                GUILayout.Label("Screen: " + Screen.currentResolution.width + "x" + Screen.currentResolution.height + " " + Screen.currentResolution.refreshRate);
            }
            else
            {
                GUILayout.Label("No Output Stats");
            }
            GUILayout.EndVertical();
            GUILayout.EndArea();
        }
Пример #43
0
        public static Graphics.Renderer.Results Initialize(DeviceMode deviceMode)
        {
            if (!Directory.Exists(Graphics.Application.ApplicationDataFolder + "Logs"))
                Directory.CreateDirectory(Graphics.Application.ApplicationDataFolder + "Logs");
            SlimDX.Direct3D9.Direct3D d3d = new SlimDX.Direct3D9.Direct3D();
#if LOG_DEVICE_SETTINGS
            System.IO.StreamWriter deviceSettingsLogFile = new System.IO.StreamWriter(Graphics.Application.ApplicationDataFolder + "Logs/DeviceSettingsLog.txt");
            deviceSettingsLogFile.WriteLine("======== Graphics Device Capabilities ========");
#endif
            int maxWidth = 700;
            int maxHeight = 500;
            foreach (SlimDX.Direct3D9.DisplayMode dm in d3d.Adapters[0].GetDisplayModes(SlimDX.Direct3D9.Format.X8R8G8B8))
            {
                if(!SettingConverters.ResolutionListConverter.Resolutions.Contains(new Resolution() { Width = dm.Width, Height = dm.Height }))
                {
                    if (dm.Width > maxWidth || dm.Height > maxHeight)
                    {
                        SettingConverters.ResolutionListConverter.Resolutions.Add(new Resolution() { Width = dm.Width, Height = dm.Height });

                        if(dm.Width > maxWidth)
                            maxWidth = dm.Width;

                        if (dm.Height > maxHeight)
                            maxHeight = dm.Height;
                    }
                }
            }

            if (d3d.CheckDeviceMultisampleType(0, SlimDX.Direct3D9.DeviceType.Hardware, SlimDX.Direct3D9.Format.X8R8G8B8,
                deviceMode == DeviceMode.Fullscreen ? false : true, SlimDX.Direct3D9.MultisampleType.None))
            {
                SettingConverters.AntiAliasingConverter.MultiSampleTypes.Add(SlimDX.Direct3D9.MultisampleType.None);
            }

            if (d3d.CheckDeviceMultisampleType(0, SlimDX.Direct3D9.DeviceType.Hardware, SlimDX.Direct3D9.Format.X8R8G8B8,
                deviceMode == DeviceMode.Fullscreen ? false : true, SlimDX.Direct3D9.MultisampleType.TwoSamples))
            {
                SettingConverters.AntiAliasingConverter.MultiSampleTypes.Add(SlimDX.Direct3D9.MultisampleType.TwoSamples);
            }

            if (d3d.CheckDeviceMultisampleType(0, SlimDX.Direct3D9.DeviceType.Hardware, SlimDX.Direct3D9.Format.X8R8G8B8,
                deviceMode == DeviceMode.Fullscreen ? false : true, SlimDX.Direct3D9.MultisampleType.FourSamples))
            {
                SettingConverters.AntiAliasingConverter.MultiSampleTypes.Add(SlimDX.Direct3D9.MultisampleType.FourSamples);
            }

            if (d3d.CheckDeviceMultisampleType(0, SlimDX.Direct3D9.DeviceType.Hardware, SlimDX.Direct3D9.Format.X8R8G8B8,
                deviceMode == DeviceMode.Fullscreen ? false : true, SlimDX.Direct3D9.MultisampleType.EightSamples))
            {
                SettingConverters.AntiAliasingConverter.MultiSampleTypes.Add(SlimDX.Direct3D9.MultisampleType.EightSamples);
            }

            if (d3d.CheckDeviceMultisampleType(0, SlimDX.Direct3D9.DeviceType.Hardware, SlimDX.Direct3D9.Format.X8R8G8B8,
                deviceMode == DeviceMode.Fullscreen ? false : true, SlimDX.Direct3D9.MultisampleType.SixteenSamples))
            {
                SettingConverters.AntiAliasingConverter.MultiSampleTypes.Add(SlimDX.Direct3D9.MultisampleType.SixteenSamples);
            }

            SlimDX.Direct3D9.Capabilities caps = d3d.GetDeviceCaps(0, SlimDX.Direct3D9.DeviceType.Hardware);
            
            SlimDX.Direct3D9.FilterCaps c = caps.TextureFilterCaps;

            if((c & SlimDX.Direct3D9.FilterCaps.MinLinear) != 0 && (c & SlimDX.Direct3D9.FilterCaps.MagLinear) != 0)
            {
                SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Bilinear, new TextureFilters()
                {
                    TextureFilter = TextureFilterEnum.Bilinear,
                    AnisotropicLevel = 1,
                    TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Linear,
                    TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Linear,
                    TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Point
                });

                if ((c & SlimDX.Direct3D9.FilterCaps.MipLinear) != 0)
                    SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Trilinear, new TextureFilters()
                    {
                        TextureFilter = TextureFilterEnum.Trilinear,
                        AnisotropicLevel = 1,
                        TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Linear,
                        TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Linear,
                        TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Linear
                    });
            }
            if((c & SlimDX.Direct3D9.FilterCaps.MinAnisotropic) != 0 && (c & SlimDX.Direct3D9.FilterCaps.MagAnisotropic) != 0)
            {
                if ((c & SlimDX.Direct3D9.FilterCaps.MipLinear) != 0)
                {
                    if (caps.MaxAnisotropy >= 2)
                        SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Anisotropic2x, new TextureFilters()
                        {
                            TextureFilter = TextureFilterEnum.Anisotropic2x,
                            AnisotropicLevel = 2,
                            TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Linear
                        });
                    if (caps.MaxAnisotropy >= 4)
                        SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Anisotropic4x, new TextureFilters()
                        {
                            TextureFilter = TextureFilterEnum.Anisotropic4x,
                            AnisotropicLevel = 4,
                            TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Linear
                        });
                    if (caps.MaxAnisotropy >= 8)
                        SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Anisotropic8x, new TextureFilters()
                        {
                            TextureFilter = TextureFilterEnum.Anisotropic8x,
                            AnisotropicLevel = 8,
                            TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Linear
                        });
                    if (caps.MaxAnisotropy >= 16)
                        SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Anisotropic16x, new TextureFilters()
                        {
                            TextureFilter = TextureFilterEnum.Anisotropic16x,
                            AnisotropicLevel = 16,
                            TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Linear
                        });
                }
            }
            else if ((c & SlimDX.Direct3D9.FilterCaps.MinAnisotropic) != 0)
            {
                if ((c & SlimDX.Direct3D9.FilterCaps.MipLinear) != 0)
                {
                    if (caps.MaxAnisotropy >= 2)
                        SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Anisotropic2x, new TextureFilters()
                        {
                            TextureFilter = TextureFilterEnum.Anisotropic2x,
                            AnisotropicLevel = 2,
                            TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Linear,
                            TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Linear
                        });
                    if (caps.MaxAnisotropy >= 4)
                        SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Anisotropic4x, new TextureFilters()
                        {
                            TextureFilter = TextureFilterEnum.Anisotropic4x,
                            AnisotropicLevel = 4,
                            TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Linear,
                            TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Linear
                        });
                    if (caps.MaxAnisotropy >= 8)
                        SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Anisotropic8x, new TextureFilters()
                        {
                            TextureFilter = TextureFilterEnum.Anisotropic8x,
                            AnisotropicLevel = 8,
                            TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Linear,
                            TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Linear
                        });
                    if (caps.MaxAnisotropy >= 16)
                        SettingConverters.TextureFilteringConverter.TextureFilteringTypesDict.Add(TextureFilterEnum.Anisotropic16x, new TextureFilters()
                        {
                            TextureFilter = TextureFilterEnum.Anisotropic16x,
                            AnisotropicLevel = 16,
                            TextureFilterMin = SlimDX.Direct3D9.TextureFilter.Anisotropic,
                            TextureFilterMag = SlimDX.Direct3D9.TextureFilter.Linear,
                            TextureFilterMip = SlimDX.Direct3D9.TextureFilter.Linear
                        });
                }
            }
            else if ((c & SlimDX.Direct3D9.FilterCaps.MagAnisotropic) != 0)
            {
                throw new Exception("Weird setup, do something about it");
            }

            Application.Log("Vertex shader version: " + caps.VertexShaderVersion);
            Application.Log("Pixel shader version: " + caps.PixelShaderVersion);

            SettingConverters.PixelShaderVersion = caps.PixelShaderVersion;

            Graphics.Renderer.Results result = Graphics.Renderer.Results.OK;

            if (caps.PixelShaderVersion.Major < 3 || caps.VertexShaderVersion.Major < 3)
            {
                if (caps.PixelShaderVersion.Major == 2)
                {
                    Application.Log("Shader version is not recommended");
                    result = Graphics.Renderer.Results.VideoCardNotRecommended;
                }
                else
                {
                    Application.Log("Shader version not supported");
                    return Graphics.Renderer.Results.VideoCardNotSupported;
                }                
            }

            if ((caps.DeviceType & SlimDX.Direct3D9.DeviceType.Hardware) == 0)
            {
                Application.Log("The device is not a hardware device");
                return Graphics.Renderer.Results.VideoCardNotSupported;
            }

            if ((caps.DeviceCaps & SlimDX.Direct3D9.DeviceCaps.HWTransformAndLight) == 0)
            {
                Application.Log("Hardware vertex processing is not supported. Trying with sotfware vertex processing");
                SettingConverters.VertexProcessing = SlimDX.Direct3D9.CreateFlags.SoftwareVertexProcessing;
                result = Graphics.Renderer.Results.VideoCardNotRecommended;
            }
            else
                SettingConverters.VertexProcessing = SlimDX.Direct3D9.CreateFlags.HardwareVertexProcessing;

            SettingConverters.DepthBufferFormats = new List<SlimDX.Direct3D9.Format>();

            if (d3d.CheckDeviceFormat(0, SlimDX.Direct3D9.DeviceType.Hardware, SlimDX.Direct3D9.Format.X8R8G8B8, SlimDX.Direct3D9.Usage.DepthStencil,
                SlimDX.Direct3D9.ResourceType.Surface, SlimDX.Direct3D9.Format.D16))
            {
                SettingConverters.DepthBufferFormats.Add(SlimDX.Direct3D9.Format.D16);
            }
            else
            {
                Application.Log("D16 is not supported");
                return Graphics.Renderer.Results.VideoCardNotSupported;
            }

            if (d3d.CheckDeviceFormat(0, SlimDX.Direct3D9.DeviceType.Hardware, SlimDX.Direct3D9.Format.X8R8G8B8, SlimDX.Direct3D9.Usage.DepthStencil,
                SlimDX.Direct3D9.ResourceType.Surface, SlimDX.Direct3D9.Format.D24X8))
            {
                SettingConverters.DepthBufferFormats.Add(SlimDX.Direct3D9.Format.D24X8);
            }
            else
            {
                Application.Log("D24X8 is not supported");
            }

            if ((caps.PresentationIntervals & SlimDX.Direct3D9.PresentInterval.Immediate) == 0)
            {
                Application.Log("Presentation interval \"Immidiate\" is not supported");
                return Graphics.Renderer.Results.VideoCardNotSupported;
            }
            if ((caps.PresentationIntervals & SlimDX.Direct3D9.PresentInterval.One) == 0)
            {
                Application.Log("Presentation interval \"One\" is not supported");
                return Graphics.Renderer.Results.VideoCardNotSupported;
            }

            ManagementObjectSearcher searcher = new ManagementObjectSearcher("select AdapterRAM from Win32_VideoController");

            foreach (ManagementObject mo in searcher.Get())
            {
                var ram = mo.Properties["AdapterRAM"].Value as UInt32?;

                if (ram.HasValue)
                {
                    VideoMemory = ((int)ram / 1048576);
                    Application.Log("Video memory: " + VideoMemory + " MB");
                }
            }

#if LOG_DEVICE_SETTINGS

            deviceSettingsLogFile.WriteLine("Graphics Card: " + d3d.Adapters[0].Details.Description);
            deviceSettingsLogFile.WriteLine("Driver Version: " + d3d.Adapters[0].Details.DriverVersion);

            deviceSettingsLogFile.WriteLine();

            deviceSettingsLogFile.WriteLine("MaxAnisotropy: " + caps.MaxAnisotropy);
            deviceSettingsLogFile.WriteLine("Texture Filters: " + caps.TextureFilterCaps);
            deviceSettingsLogFile.WriteLine("Multisample types: | ");
            foreach (SlimDX.Direct3D9.MultisampleType m in SettingConverters.AntiAliasingConverter.MultiSampleTypes)
                deviceSettingsLogFile.Write(m + " | ");

            d3d.Dispose();
            
            deviceSettingsLogFile.Close();
#endif

            return result;
        }
Пример #44
0
        /// <summary>
        /// Open the device. To start capturing call the 'StartCapture' function
        /// </summary>
        /// <param name="mode">
        /// A <see cref="DeviceMode"/>
        /// </param>
        public override void Open(DeviceMode mode)
        {
            const int readTimeoutMilliseconds = 1000;

            this.Open(mode, readTimeoutMilliseconds);
        }
Пример #45
0
 /// <summary>
 /// Create a new instance of the <see cref="DeviceBase"/> class.
 /// </summary>
 /// <param name="frontendSocket">
 /// A <see cref="NetMQSocket"/> that will pass incoming messages to <paramref name="backendSocket"/>.
 /// </param>
 /// <param name="backendSocket">
 /// A <see cref="NetMQSocket"/> that will receive messages from (and optionally send replies to) <paramref name="frontendSocket"/>.
 /// </param>
 /// <param name="mode">the <see cref="DeviceMode"/> (either Blocking or Threaded) for this device</param>
 protected DeviceBase(NetMQSocket frontendSocket, NetMQSocket backendSocket, DeviceMode mode)
     : this(new NetMQPoller(), frontendSocket, backendSocket, mode)
 {
     m_pollerIsOwned = true;
 }
Пример #46
0
		public static extern int ChangeDisplaySettingsEx([MarshalAs(UnmanagedType.LPTStr)] string lpszDeviceName, DeviceMode lpDevMode, IntPtr hwnd, ChangeDisplaySettingsEnum dwflags, IntPtr lParam);
Пример #47
0
 /// <summary>
 /// Open the device. To start capturing call the 'StartCapture' function
 /// </summary>
 /// <param name="mode">
 /// A <see cref="DeviceMode"/>
 /// </param>
 public virtual void Open(DeviceMode mode)
 {
     throw new System.NotImplementedException();
 }
Пример #48
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueDevice"/> class.
 /// </summary>
 /// <param name="frontendBindAddress">The endpoint used to bind the frontend socket.</param>
 /// <param name="backendBindAddress">The endpoint used to bind the backend socket.</param>
 /// <param name="mode">The <see cref="DeviceMode"/> for the device.</param>
 public QueueDevice(string frontendBindAddress, string backendBindAddress, DeviceMode mode = DeviceMode.Threaded)
     : base(new RouterSocket(), new DealerSocket(), mode)
 {
     FrontendSetup.Bind(frontendBindAddress);
     BackendSetup.Bind(backendBindAddress);
 }
Пример #49
0
 /// <summary>
 /// Open the device. To start capturing call the 'StartCapture' function
 /// </summary>
 /// <param name="mode">
 /// A <see cref="DeviceMode"/>
 /// </param>
 /// <param name="read_timeout">
 /// A <see cref="System.Int32"/>
 /// </param>
 /// <param name="monitor_mode">
 /// A <see cref="MonitorMode"/>
 /// </param>
 /// <param name="kernel_buffer_size">
 /// A <see cref="System.UInt32"/>
 /// </param>
 public virtual void Open(DeviceMode mode, int read_timeout, MonitorMode monitor_mode, uint kernel_buffer_size)
 {
     throw new NotImplementedException();
 }
Пример #50
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ForwarderDevice"/> class.
 /// </summary>
 /// <param name="context">The <see cref="ZmqContext"/> to use when creating the sockets.</param>
 /// <param name="mode">The <see cref="DeviceMode"/> for the current device.</param>
 public ForwarderDevice(ZmqContext context, DeviceMode mode)
     : base(context.CreateSocket(FrontendType), context.CreateSocket(BackendType), mode)
 {
 }
Пример #51
0
 private static extern bool EnumDisplaySettings(string deviceName, int modeNum, ref DeviceMode devMode);
Пример #52
0
 /// <summary>
 /// Open the device. To start capturing call the 'StartCapture' function
 /// </summary>
 /// <param name="mode">
 /// A <see cref="DeviceMode"/>
 /// </param>
 public virtual void Open(DeviceMode mode)
 {
     throw new System.NotImplementedException();
 }
Пример #53
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ForwarderDevice"/> class.
 /// </summary>
 /// <param name="context">The <see cref="Context"/> to use when creating the sockets.</param>
 /// <param name="frontendBindAddr">The address used to bind the frontend socket.</param>
 /// <param name="backendBindAddr">The endpoint used to bind the backend socket.</param>
 /// <param name="mode">The <see cref="DeviceMode"/> for the current device.</param>
 public ForwarderDevice(Context context, string frontendBindAddr, string backendBindAddr, DeviceMode mode)
     : this(context, mode)
 {
     FrontendSetup.Bind(frontendBindAddr);
     BackendSetup.Bind(backendBindAddr);
 }
Пример #54
0
 public DisplaySettings()
 {
     DevMode = GetCurrentDisplaySettings();
 }
Пример #55
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ForwarderDevice"/> class.
 /// </summary>
 /// <param name="context">The <see cref="ZmqContext"/> to use when creating the sockets.</param>
 /// <param name="mode">The <see cref="DeviceMode"/> for the current device.</param>
 public ForwarderDevice(ZmqContext context, DeviceMode mode)
     : base(context.CreateSocket(FrontendType), context.CreateSocket(BackendType), mode)
 {
 }
Пример #56
0
 public void OpenDevice(DeviceMode readMode, DeviceMode writeMode, ShareMode shareMode)
 {
     throw new NotImplementedException();
 }
Пример #57
0
 /// <summary>
 /// Open the device. To start capturing call the 'StartCapture' function
 /// </summary>
 /// <param name="mode">
 /// A <see cref="DeviceMode"/>
 /// </param>
 /// <param name="read_timeout">
 /// A <see cref="System.Int32"/>
 /// </param>
 public virtual void Open(DeviceMode mode, int read_timeout)
 {
     throw new System.NotImplementedException();
 }
Пример #58
0
 internal static extern int ChangeDisplaySettingsEx(string deviceName, ref DeviceMode devMode, IntPtr hWnd, int flags, IntPtr lParam);
Пример #59
0
        /// <summary>
        /// Open the device. To start capturing call the 'StartCapture' function
        /// </summary>
        /// <param name="mode">
        /// A <see cref="DeviceMode"/>
        /// </param>
        public override void Open(DeviceMode mode)
        {
            base.Open(mode);

            // reteieve the airpcap device given the winpcap handle
            AirPcapDeviceHandle = WinPcap.SafeNativeMethods.pcap_get_airpcap_handle(PcapHandle);
        }
Пример #60
0
 public MobileDevice(int mode, Verbrosity flags)
 {
     mMode = (DeviceMode)mode;
      //   mType = (Verbrosity)flags;
 }