internal static SensorInformation GetSensorInformation(IntPtr handle)
        {
            SensorInformation info = new SensorInformation();

            _E(_GetSensorInformation(handle, ref info));
            return(info);
        }
        public static Sensor GetSensorByHandle(IntPtr handle)
        {
            SensorInformation info = new SensorInformation();

            _E(_GetSensorInformation(handle, ref info));
            if (SensorDictionary.TryGetValue(info.serial_number, out Sensor s))
            {
                return(s);
            }
            return(SensorDictionary[info.serial_number] = SensorFactory(ref info));
        }
        public static void UpdateSensors()
        {
            int ns      = _GetSensorCount();
            var handles = new HashSet <ulong>(SensorDictionary.Keys);

            SensorInformation info = new SensorInformation();

            for (int i = 0; i < ns; i++)
            {
                if (_GetSensorInformationByIndex(i, ref info) == SensorErrorCode.SUCCESS)
                {
                    SensorDictionary.GetOrAdd(info.serial_number, (sn) => SensorFactory(ref info));
                    handles.Remove(info.serial_number);
                }
            }
            foreach (ulong key in handles)
            {
                SensorDictionary.TryRemove(key, out _);
            }
        }
 protected internal Sensor(ref SensorInformation information) => info = information;
 private static extern SensorErrorCode _GetSensorInformationByIndex(int idx, [In, Out] ref SensorInformation info);
 private static extern SensorErrorCode _GetSensorInformation(IntPtr handle, [In, Out] ref SensorInformation info);