Ejemplo n.º 1
0
        private void LoadProperties()
        {
            try
            {
                IsoNumber = new PropertyValue <int> {
                    Available = false
                };
                FNumber = new PropertyValue <int> {
                    Available = false
                };
                ExposureCompensation = new PropertyValue <int> {
                    Available = false
                };
                FocusMode = new PropertyValue <long> {
                    Available = false
                };
                ShutterSpeed = new PropertyValue <long> {
                    Available = false
                };
                WhiteBalance = new PropertyValue <long> {
                    Available = false
                };

                Properties.Add(AddNames("photo_size", "Photo size"));
                Properties.Add(AddNames("precise_selftime", "Capture delay"));
                Properties.Add(AddNames("burst_capture_number", "Burst capture number"));
                Properties.Add(AddNames("auto_low_light", "Auto low light"));

                AdvancedProperties.Add(AddNames("video_resolution", "Video resolution"));
                AdvancedProperties.Add(AddNames("led_mode", "Led mode"));
                AdvancedProperties.Add(AddNames("auto_power_off", "Auto power off"));
                AdvancedProperties.Add(AddNames("loop_record", "Loop record"));
                AdvancedProperties.Add(AddNames("warp_enable", "Lens correction"));
                AdvancedProperties.Add(AddNames("buzzer_ring", "Find device"));

                CompressionSetting.ValueChanged +=
                    (sender, key, val) => { Protocol.SendValue(CompressionSetting.Tag, key); };
                SendCommand(9, CompressionSetting.Tag);

                Mode.ValueChanged += Mode_ValueChanged;
                SendCommand(9, Mode.Tag);

                ExposureMeteringMode.ValueChanged +=
                    (sender, key, val) => { Protocol.SendValue(ExposureMeteringMode.Tag, key); };
                SendCommand(9, ExposureMeteringMode.Tag);

                foreach (var property in Properties)
                {
                    SendCommand(9, property.Tag);
                }
                foreach (var property in AdvancedProperties)
                {
                    SendCommand(9, property.Tag);
                }
            }
            catch (Exception ex)
            {
                Log.Error("Unable to load data", ex);
            }
        }
Ejemplo n.º 2
0
        public bool Init(DeviceDescriptor deviceDescriptor, DeviceDescription description)
        {
            base.Init(deviceDescriptor);
            StillImageDevice imageDevice = StillImageDevice as StillImageDevice;

            if (imageDevice != null)
            {
                imageDevice.DeviceEvent += StillImageDevice_DeviceEvent;
            }
            foreach (var property in description.Properties)
            {
                if (!string.IsNullOrEmpty(property.Name))
                {
                    try
                    {
                        MTPDataResponse result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, property.Code);

                        ErrorCodes.GetException(result.ErrorCode);
                        uint dataType   = BitConverter.ToUInt16(result.Data, 2);
                        int  dataLength = StaticHelper.GetDataLength(dataType);

                        var value = new PropertyValue <long> {
                            Code = property.Code, Name = property.Name
                        };
                        foreach (var propertyValue in property.Values)
                        {
                            value.AddValues(propertyValue.Name, propertyValue.Value);
                        }
                        value.ValueChanged += value_ValueChanged;

                        AdvancedProperties.Add(value);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("Error ger property ", ex);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
        public override void ReadDeviceProperties(uint prop)
        {
            //lock (Locker)
            //{
            try
            {
                HaveLiveView = true;
                switch (prop)
                {
                case CONST_PROP_Fnumber:
                    //FNumber.SetValue(_stillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_Fnumber));
                    ReInitFNumber(false);
                    break;

                case CONST_PROP_MovieFnumber:
                    //FNumber.SetValue(_stillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_Fnumber));
                    ReInitFNumber(false);
                    break;

                case CONST_PROP_ExposureIndex:
                    NormalIsoNumber.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue,
                                                                              CONST_PROP_ExposureIndex), false);
                    break;

                //case CONST_PROP_ExposureIndexEx:
                //    NormalIsoNumber.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue,
                //                                                        CONST_PROP_ExposureIndexEx), false);
                //    break;
                case CONST_PROP_MovieExposureIndex:
                    MovieFNumber.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue,
                                                                           CONST_PROP_MovieExposureIndex), false);
                    break;

                //case CONST_PROP_ExposureTime:
                //    NormalShutterSpeed.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue,
                //                                                           CONST_PROP_ExposureTime), false);
                //    break;
                case CONST_PROP_ShutterSpeed:
                    NormalShutterSpeed.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue,
                                                                                 CONST_PROP_ShutterSpeed), false);
                    break;

                case CONST_PROP_MovieShutterSpeed:
                    MovieShutterSpeed.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue,
                                                                                CONST_PROP_MovieShutterSpeed), false);
                    break;

                case CONST_PROP_WhiteBalance:
                    WhiteBalance.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue,
                                                                           CONST_PROP_WhiteBalance), false);
                    break;

                case CONST_PROP_ExposureProgramMode:
                    Mode.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue,
                                                                   CONST_PROP_ExposureProgramMode), true);
                    break;

                case CONST_PROP_ExposureBiasCompensation:
                    NormalExposureCompensation.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue,
                                                                                         CONST_PROP_ExposureBiasCompensation),
                                                        false);
                    break;

                case CONST_PROP_MovieExposureBiasCompensation:
                    MovieExposureCompensation.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue,
                                                                                        CONST_PROP_MovieExposureBiasCompensation),
                                                       false);
                    break;

                case CONST_PROP_CompressionSetting:
                    CompressionSetting.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue,
                                                                                 CONST_PROP_CompressionSetting),
                                                false);
                    break;

                case CONST_PROP_ExposureMeteringMode:
                    ExposureMeteringMode.SetValue(StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue,
                                                                                   CONST_PROP_ExposureMeteringMode),
                                                  false);
                    break;

                case CONST_PROP_AFModeSelect:
                    NormalFocusMode.SetValue(
                        StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_AFModeSelect),
                        false);
                    NormalFocusMode.IsEnabled = NormalFocusMode.NumericValue != 3;
                    break;

                case CONST_PROP_AfModeAtLiveView:
                    LiveViewFocusMode.SetValue(
                        StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_AfModeAtLiveView),
                        false);
                    LiveViewFocusMode.IsEnabled = LiveViewFocusMode.NumericValue != 3;
                    break;

                case CONST_PROP_BatteryLevel:
                {
                    var data = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_BatteryLevel);
                    if (data.Data != null && data.Data.Length > 0)
                    {
                        Battery = data.Data[0];
                    }
                }
                break;

                case CONST_PROP_ExposureIndicateStatus:
                {
                    var data =
                        StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue,
                                                         CONST_PROP_ExposureIndicateStatus);
                    if (data.Data != null && data.Data.Length > 0)
                    {
                        sbyte i =
                            unchecked (
                                (sbyte)data.Data[0]);
                        ExposureStatus = Convert.ToInt32(i);
                    }
                }
                break;

                case CONST_PROP_LiveViewStatus:
                {
                    MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, CONST_PROP_LiveViewStatus);
                    if (response.Data != null && response.Data.Length > 0)
                    {
                        LiveViewOn = response.Data[0] == 1;
                    }
                    else
                    {
                        LiveViewOn = false;
                    }
                    break;
                }

                case CONST_PROP_LiveViewSelector:
                {
                    MTPDataResponse response = ExecuteReadDataEx(CONST_CMD_GetDevicePropValue, CONST_PROP_LiveViewSelector);
                    if (response.Data != null && response.Data.Length > 0)
                    {
                        LiveViewMovieOn = response.Data[0] == 1;
                    }
                    else
                    {
                        LiveViewMovieOn = false;
                    }
                    break;
                }

                default:
                    // imrovements from: http://digicamcontrol.com/forum/testingbug-reports/buglet-nikonbasecs
                    foreach (PropertyValue <long> advancedProperty in AdvancedProperties.Where(advancedProperty => advancedProperty.Code == prop))
                    {
                        if (advancedProperty.Name == "Image Size")
                        {
                            var val = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue,
                                                                       advancedProperty.Code);
                            if (val.Data != null && val.Data.Length > 0)
                            {
                                advancedProperty.SetValue(
                                    Encoding.Unicode.GetString(val.Data, 1, 20), false);
                            }
                        }
                        else
                        {
                            advancedProperty.SetValue(
                                StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue,
                                                                 advancedProperty.Code), false);
                        }
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Log.Error("ReadDeviceProperties error", ex);
            }
            //}
        }
Ejemplo n.º 4
0
        public FakeCameraDevice()
        {
            HaveLiveView         = false;
            IsBusy               = false;
            DeviceName           = "Fake camera";
            SerialNumber         = "00000000";
            IsConnected          = true;
            HaveLiveView         = false;
            ExposureStatus       = 1;
            ExposureCompensation = new PropertyValue <long>()
            {
                IsEnabled = false
            };
            Mode = new PropertyValue <long> {
                IsEnabled = false
            };
            FNumber = new PropertyValue <long> {
                IsEnabled = false
            };
            ShutterSpeed = new PropertyValue <long> {
                IsEnabled = false
            };
            WhiteBalance = new PropertyValue <long> {
                IsEnabled = false
            };
            FocusMode = new PropertyValue <long> {
                IsEnabled = false
            };

            CompressionSetting = new PropertyValue <long> {
                IsEnabled = true
            };
            CompressionSetting.AddValues("jpg", 0);
            CompressionSetting.AddValues("cr2", 1);
            CompressionSetting.AddValues("new", 2);
            CompressionSetting.Value = "jpg";
            CompressionSetting.ReloadValues();

            IsoNumber = new PropertyValue <long> {
                IsEnabled = true
            };
            ExposureMeteringMode = new PropertyValue <long> {
                IsEnabled = false
            };
            Battery = 100;
            Capabilities.Add(CapabilityEnum.CaptureNoAf);
            Capabilities.Add(CapabilityEnum.LiveView);
            Capabilities.Add(CapabilityEnum.LiveViewStream);
            LiveViewImageZoomRatio = new PropertyValue <long>();
            LiveViewImageZoomRatio.AddValues("All", 0);
            LiveViewImageZoomRatio.Value = "All";

            IsoNumber.AddValues("100", 100);
            IsoNumber.AddValues("200", 200);
            IsoNumber.AddValues("300", 300);
            IsoNumber.Value = "100";
            IsoNumber.ReloadValues();

            var val = new PropertyValue <long>()
            {
                Name = "Test Test"
            };

            val.AddValues("Val 1", 1);
            val.AddValues("Val 2", 2);
            val.AddValues("Val 3", 3);
            val.Value = "Val 1";
            val.ReloadValues();
            AdvancedProperties.Add(val);
        }