コード例 #1
0
ファイル: CameraClasses.cs プロジェクト: jekain314/Waldo_FCS
        public void update(PhotoParameters photoParameters)
        {
            if (photoParameters.downloadSuccess)
            {
                avgDownloadTime = (avgDownloadTime * numberPhotosDownloaded +
                         photoParameters.timeToDownloadComplete) / (numberPhotosDownloaded+1);
                avgPhotoSize = (avgPhotoSize * numberPhotosDownloaded +
                    photoParameters.photoSize) / (numberPhotosDownloaded + 1);
                //avgTimeToPrefireAck = (avgTimeToPrefireAck * numberPhotosDownloaded +
                //    photoParameters.prefireAcknowledge) / (numberPhotosDownloaded + 1);
                //avgTimeToFireAck = (avgTimeToFireAck * numberPhotosDownloaded +
                //    photoParameters.fireAcknowledge) / (numberPhotosDownloaded + 1);
                avgTimeToFirstVolChanged = (avgTimeToFirstVolChanged * numberPhotosDownloaded +
                    photoParameters.timeToFirstVolChanged) / (numberPhotosDownloaded + 1);
                avgTimeToSecondVolChanged = (avgTimeToSecondVolChanged * numberPhotosDownloaded +
                    photoParameters.timeToSecondVolChanged) / (numberPhotosDownloaded + 1);
                avgTimeToDirItemTransfer = (avgTimeToDirItemTransfer * numberPhotosDownloaded +
                    photoParameters.timeToDirItemTransfer) / (numberPhotosDownloaded + 1);
                AvgTimetToDirItemCreated = (AvgTimetToDirItemCreated * numberPhotosDownloaded +
                    photoParameters.timeToDirItemCreated) / (numberPhotosDownloaded + 1);

                numberPhotosRequested++;
                numberPhotosDownloaded++;
            }
            else
            {
                numberPhotosRequested++;

                ///////////////////////////////////////////////////////////////////////////
                //if the download was not completed successfully, dont add to the stats
                ///////////////////////////////////////////////////////////////////////////
            }
        }
コード例 #2
0
ファイル: CameraClasses.cs プロジェクト: jekain314/Waldo_FCS
        int volumeChangedCounter; //used to measure the times of the "volume changed" events (two per download)

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Initialises the SDK and adds events
        /// </summary>
        public SDKHandler(LogFile  _logFile, SettingsManager settings)
        {
            Error = EDSDK.EdsInitializeSDK();

            SDKStateEvent               += new EDSDK.EdsStateEventHandler(Camera_SDKStateEvent);
            SDKPropertyEvent            += new EDSDK.EdsPropertyEventHandler(Camera_SDKPropertyEvent);
            SDKObjectEvent              += new EDSDK.EdsObjectEventHandler(Camera_SDKObjectEvent);

            logFile = _logFile;

            photoParameters = new PhotoParameters();
            photoStats = new PhotoStats();

            PhotoInProgress = false;
            photoTimer = new Stopwatch();
            volumeChangedCounter = 0;

            //get the camera list of attached cameras
            CamList = GetCameraList();

            if (CamList.Count == 0)
            {
                logFile.WriteLine("There are no attached cameras");
                MessageBox.Show("There are no attached cameras");
                return;
            }
            else if (CamList.Count > 1)
            {
                MessageBox.Show("Found more than one attached Canon camera");
                logFile.WriteLine("There is more than one attached camera");
                return;
            }

            //open the session with the first camera (only a single camera is allowed)
            OpenSession(CamList[0]);

            //label the camera type
            String cameraDescription = MainCamera.Info.szDeviceDescription;
            //label camera serial number
            String cameraSN = GetSettingString((uint)EDSDK.PropID_BodyIDEx);
            //label firmware
            String cameraFirmware = GetSettingString((uint)EDSDK.PropID_FirmwareVersion);

            //CameraHandler.SetSetting(EDSDK.PropID_SaveTo, (uint)EDSDK.EdsSaveTo.Camera);
            //CameraHandler.SetSetting(EDSDK.PropID_SaveTo, (uint)EDSDK.EdsSaveTo.Host);
            SetSetting(EDSDK.PropID_SaveTo, (uint)EDSDK.EdsSaveTo.Both);
            SetCapacity();  //used to tell camera there is enough room on the PC HD (see codeproject tutorial)

            //get the capacity and loading of the camera card storage drive
            //also write out the names of the images to output
            cameraStats = StorageAssessment();

            //fill in the remainder of the camera parameters
            cameraStats.cameraDescription = cameraDescription;
            cameraStats.cameraSN = cameraSN;
            cameraStats.cameraFirmware = cameraFirmware;

            missionPlansFolder = settings.SaveToFolder;
            if (!Directory.Exists(missionPlansFolder)) Directory.CreateDirectory(missionPlansFolder);

            if (!Directory.Exists(missionPlansFolder + @"/TestImages/"))
                Directory.CreateDirectory(missionPlansFolder + @"/TestImages/");

            //default value -- update this
            ImageSaveDirectory = missionPlansFolder + @"/TestImages/";

            /////////////////////////////////////////////////////
            // camera settings for WaldoAir Flight Operations
            /////////////////////////////////////////////////////

            try
            {
                //set the aperture ---
                SetSetting(EDSDK.PropID_Av, CameraValues.AV(settings.Camera_fStop));
                logFile.WriteLine("Set the fStop:  " + settings.Camera_fStop);
                //set the shutter speed
                SetSetting(EDSDK.PropID_Tv, CameraValues.TV(settings.Camera_shutter));
                logFile.WriteLine("Set the shutter:  " + settings.Camera_shutter);
                //set the ISO
                SetSetting(EDSDK.PropID_ISOSpeed, CameraValues.ISO(settings.Camera_ISO));
                logFile.WriteLine("Set the ISO:   " + settings.Camera_ISO);
                //set the white balance to Daylight
                SetSetting(EDSDK.PropID_WhiteBalance, EDSDK.WhiteBalance_Daylight);
                logFile.WriteLine("Set the WhiteBalance:  DayLight");
            }
            catch
            {
                logFile.WriteLine(" could not set the camera parameters");
                MessageBox.Show("Problem setting the Camera parameters");
            }
        }
コード例 #3
0
ファイル: CameraClasses.cs プロジェクト: jekain314/Waldo_FCS
        public void resetPhotoTimer()
        {
            //photo timer times the events during a photo taking session
            photoTimer.Restart();

            volumeChangedCounter = 0;  //this counts the two volume change events. (incremented after first event)

            //reset all the photoparameters to default values;
            photoParameters = new PhotoParameters();
        }