예제 #1
0
        void PollAttachedDeviceChanges()
        {
            // check to see if the user attached a device or removed a device
            //  this is also how we find devices attached at start up

            TimeSpan    frameTimeOut           = new TimeSpan(0, 0, 1);
            S2255Device DeviceToRemoveFromList = null;

            while (!m_StopThreads)
            {
                int attachedCount = GetNumberAttached2255Devices();

                if (attachedCount < GetOpenDeviceCount())
                {
                    DeviceToRemoveFromList = null;

                    // we lost a device, but which one?
                    //   look for one with no video frames comming
                    foreach (S2255Device dev in m_S2255Devices)
                    {
                        if (DateTime.Now.Subtract(frameTimeOut).CompareTo(dev.TimeAtLastFrame) > 0)
                        {
                            // this is the lost device, close the physical device and release the controller instance, and release the device index
                            CloseDevice(dev);
                            DeviceToRemoveFromList = dev;
                            break;
                        }
                    }
                    if (DeviceToRemoveFromList != null)
                    {
                        m_S2255Devices.Remove(DeviceToRemoveFromList);
                    }
                }
                else if (attachedCount > GetOpenDeviceCount() && GetOpenDeviceCount() < MAX_S2255DEVICE_COUNT)
                {
                    // we gained one, try to find its assigned index by trial and error

                    for (int d = 0; d < MAX_2255DEVICE_HANDLE_VALUE; d++)
                    {
                        int handleToTry = m_DeviceHandlePool.GetNextOpenDeviceValue();
                        if (S2255Device.TestOpenDevice(handleToTry))
                        {
                            // we found a new device at this index

                            int index = m_UsedDeviceIndexes.GetNextOpenDeviceValue();

                            S2255Device dev = CreateAndStartNew2255(index, handleToTry); // reserves the device index, starts video flowing into the system
                            m_S2255Devices.Add(dev);
                            break;
                        }
                    }
                }

                if (m_StopThreads)
                {
                    break;
                }
                Thread.Sleep(2000);
            }
        }
예제 #2
0
        void CloseDevice(S2255Device dev)
        {
            m_Log.Log("stopped 2255 FrameGrabber at index " + dev.DeviceIndex.ToString(), ErrorLog.LOG_TYPE.INFORMATIONAL);

            dev.CloseDevice();

            m_UsedDeviceIndexes.ReleaseValue(dev.DeviceIndex); // free this index

            m_DeviceHandlePool.ReleaseValue(dev.DeviceHandle); // free the handle

            // this indicator does not really tell you which device is lost, only that a device is lost. the user will see one or two device present indicators,
            // but no indication of which device is there
            if (GetOpenDeviceCount() == 1)
            {
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_frameGrabber_2].StatString.SetValue = "No Device";
            }
            else if (GetOpenDeviceCount() == 0)
            {
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_frameGrabber_1].StatString.SetValue = "No Device";
            }
        }
예제 #3
0
        S2255Device CreateAndStartNew2255(int index, int handle)
        {
            string[] chanNames        = null;
            bool[]   configedchannels = GetConfiguredChannels(out chanNames);

            S2255Device device = new S2255Device(index, handle, m_AppData, m_VideoStandard, m_S2255DevicePortChannelMappsings[index]);

            device.SetSourceNames(chanNames);
            device.State          = S2255Device.DEVICE_STATE.CLOSED;
            device.Model          = S2255Device.DEVICE_MODEL.S2255;
            device.UserConfigured = true;

            for (int c = 0; c < m_AppData.MAX_PHYSICAL_CHANNELS; c++)
            {
                device.RegisterToReceiveFrames(c, OnNewFrameFromDevice);
            }

            device.OpenDevice();


            m_Log.Log("started 2255 FrameGrabber at handle " + handle.ToString(), ErrorLog.LOG_TYPE.INFORMATIONAL);

            m_DeviceHandlePool.MarkValueAsUsed(handle);
            m_UsedDeviceIndexes.MarkValueAsUsed(index);

            if (GetOpenDeviceCount() == 2)
            {
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_frameGrabber_2].StatString.SetValue = "Have Device";
            }
            else if (GetOpenDeviceCount() == 1)
            {
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_frameGrabber_1].StatString.SetValue = "Have Device";
            }


            return(device);
        }
예제 #4
0
        S2255Device CreateAndStartNew2255( int index, int handle)
        {
            string[] chanNames = null;
            bool[] configedchannels = GetConfiguredChannels(out chanNames);

            S2255Device device = new S2255Device(index, handle, m_AppData, m_VideoStandard, m_S2255DevicePortChannelMappsings[index]);
            device.SetSourceNames(chanNames);
            device.State = S2255Device.DEVICE_STATE.CLOSED;
            device.Model = S2255Device.DEVICE_MODEL.S2255;
            device.UserConfigured = true;

            for (int c = 0; c < m_AppData.MAX_PHYSICAL_CHANNELS; c++)
            {

                    device.RegisterToReceiveFrames(c, OnNewFrameFromDevice);

            }

            device.OpenDevice();

            m_Log.Log("started 2255 FrameGrabber at handle " + handle.ToString(), ErrorLog.LOG_TYPE.INFORMATIONAL);

            m_DeviceHandlePool.MarkValueAsUsed(handle);
            m_UsedDeviceIndexes.MarkValueAsUsed(index);

            if (GetOpenDeviceCount() == 2)
            {
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_frameGrabber_2].StatString.SetValue = "Have Device";
            }
            else if (GetOpenDeviceCount() == 1)
            {
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_frameGrabber_1].StatString.SetValue = "Have Device";
            }

            return (device);
        }
예제 #5
0
        void CloseDevice( S2255Device dev)
        {
            m_Log.Log("stopped 2255 FrameGrabber at index " + dev.DeviceIndex.ToString(), ErrorLog.LOG_TYPE.INFORMATIONAL);

            dev.CloseDevice();

            m_UsedDeviceIndexes.ReleaseValue(dev.DeviceIndex); // free this index

            m_DeviceHandlePool.ReleaseValue(dev.DeviceHandle);// free the handle

            // this indicator does not really tell you which device is lost, only that a device is lost. the user will see one or two device present indicators,
            // but no indication of which device is there
            if (GetOpenDeviceCount() == 1)
            {
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_frameGrabber_2].StatString.SetValue = "No Device";
            }
            else if (GetOpenDeviceCount() == 0)
            {
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_frameGrabber_1].StatString.SetValue = "No Device";
            }
        }