コード例 #1
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);
            }
            //}
        }
コード例 #2
0
        protected override void ReInitShutterSpeed()
        {
            lock (Locker)
            {
                DeviceReady();
                try
                {
                    byte datasize = 4;
                    var  result   = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc,
                                                                     CONST_PROP_ShutterSpeed);
                    if (result.Data == null)
                    {
                        return;
                    }
                    NormalShutterSpeed.Clear();
                    int    type     = BitConverter.ToInt16(result.Data, 2);
                    byte   formFlag = result.Data[(2 * datasize) + 5];
                    UInt32 defval   = BitConverter.ToUInt32(result.Data, datasize + 5);
                    for (int i = 0; i < result.Data.Length - ((2 * datasize) + 6 + 2); i += datasize)
                    {
                        UInt32 val = BitConverter.ToUInt32(result.Data, ((2 * datasize) + 6 + 2) + i);
                        NormalShutterSpeed.AddValues(_shutterTable.ContainsKey(val) ? _shutterTable[val] : val.ToString(), val);
                    }
                    // force to add Bulb mode for some cameras which not support it
                    if (Mode != null && (Mode.Value == "S" || Mode.Value == "M") && !NormalShutterSpeed.Values.Contains("Bulb"))
                    {
                        NormalShutterSpeed.AddValues("Bulb", 0xFFFFFFFF);
                    }
                    NormalShutterSpeed.ReloadValues();
                    NormalShutterSpeed.SetValue(defval, false);
                    ShutterSpeed = NormalShutterSpeed;
                }
                catch (Exception)
                {
                }
                try
                {
                    byte datasize = 4;
                    var  result   = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc,
                                                                     CONST_PROP_MovieShutterSpeed);
                    if (result.Data == null || result.Data.Length == 0)
                    {
                        return;
                    }
                    MovieShutterSpeed.Clear();
                    int    type     = BitConverter.ToInt16(result.Data, 2);
                    byte   formFlag = result.Data[(2 * datasize) + 5];
                    UInt32 defval   = BitConverter.ToUInt32(result.Data, datasize + 5);
                    for (int i = 0; i < result.Data.Length - ((2 * datasize) + 6 + 2); i += datasize)
                    {
                        UInt32 val = BitConverter.ToUInt32(result.Data, ((2 * datasize) + 6 + 2) + i);
                        MovieShutterSpeed.AddValues("1/" + (val - 0x10000), val);
                    }
                    // force to add Bulb mode for some cameras which not support it
                    if (Mode != null && (Mode.Value == "S" || Mode.Value == "M") && !MovieShutterSpeed.Values.Contains("Bulb"))
                    {
                        MovieShutterSpeed.AddValues("Bulb", 0xFFFFFFFF);
                    }

                    MovieShutterSpeed.SetValue(defval, false);
                }
                catch (Exception)
                {
                }
            }
        }