示例#1
0
        public void Run(bool TestDiscardingUnsavedVideos = false, bool TestCancellingPostTriggerFill = false)
        {
            var multishots   = 3;
            var discardAfter = 0;
            var cancelPostTriggerFillAfter = 0;
            var requestedSettings          = new CamDictionary()
            {
                { "requested_iso", null },
                { "requested_exposure", 1 / 500.0 },
                { "requested_frame_rate", 60 },
                { "requested_horizontal", 640 },
                { "requested_vertical", 480 },
                { "requested_subsample", 1 },
                { "requested_duration", 10 },
                { "requested_pretrigger", 50 },
                { "requested_multishot_count", null },
            };

            var allowedSettings = api.ConfigureCamera(requestedSettings);
            var multiShotCount  = allowedSettings["multishot_count"];

            if (TestDiscardingUnsavedVideos)
            {
                discardAfter = 1;
                Console.WriteLine($"\nMultishot capture with discard (Max multishot captures: {multiShotCount}): fill pre-trigger buffer, trigger process, discard after {discardAfter} video saved)");
            }
            else if (TestCancellingPostTriggerFill)
            {
                cancelPostTriggerFillAfter = 2;
                Console.WriteLine($"\nMultishot capture with cancel post trigger fill (Max multishot captures: {multiShotCount}): fill pre-trigger buffer, trigger process, cancel after {cancelPostTriggerFillAfter} videos captured");
            }
            else
            {
                Console.WriteLine($"\nMultishot capture (Max multishot captures: {multiShotCount}): fill pre-trigger buffer, trigger process");
            }

            this.RunCamera(api, allowedSettings, "");

            for (int x = 0; x < multishots; x++)
            {
                var camStatus    = api.GetCamStatus();
                var activeBuffer = (long)camStatus["active_buffer"];

                Console.WriteLine($"    Multishot buffer in use: {activeBuffer}");
                MultishotCaptureVideo(CAMERA_STATE.RUNNING, activeBuffer == cancelPostTriggerFillAfter);
            }

            if (TestCancellingPostTriggerFill)
            {
                multishots = 1;
            }
            MultiShotSaveVideos(multishots, discardAfter, 30);
        }
示例#2
0
        public void Run()
        {
            Console.WriteLine($"\nDeleting all favorites");
            DeleteAllFavorites();
            Console.WriteLine($"\nNumber of favorite IDs (should be 0): {GetFavoriteIds().Count}");

            var settings = api.GetCurrentSettings();

            settings["id"]       = 5;
            settings["duration"] = 2;
            settings["notes"]    = "Favorite settings stored in ID slot 5";

            SaveFavorite(settings);
            Console.WriteLine("\nSaved settings in ID slot 5");

            settings = api.GetCurrentSettings();

            settings["id"]       = 3;
            settings["duration"] = 4;
            settings["notes"]    = "Favorite settings stored in ID slot 3";

            SaveFavorite(settings);
            Console.WriteLine("\nSaved settings in ID slot 3");

            Console.WriteLine($"\nSaved favorite ID list: {string.Join(", ", GetFavoriteIds())}");

            settings = GetFavorite("5");
            var allowedSettings = api.ConfigureCamera(settings);

            api.Run(allowedSettings);
            Console.WriteLine("\nRetreived favorite settings 5 and configured the camera using those settings");

            DeleteFavorite("3");
            Console.WriteLine("\nDeleted previously save favorite in ID slot 3");
            Console.WriteLine($"\nSaved favorite ID list: {string.Join(", ", GetFavoriteIds())}");
        }
示例#3
0
        public void TestCameraFunctionality()
        {
            try
            {
                var camStatus = api.GetCamStatus();

                Console.WriteLine($"Camera state {camStatus["state"]}, level {camStatus["level"]}, flags {camStatus["flags"]}");

                Console.WriteLine($"\nCamera extended status - state {camStatus["state"]}, level {camStatus["level"]}, flags {camStatus["flags"]}, IS temp (C) {camStatus["is_temp"]}, FPGA temp (C) {camStatus["fpga_temp"]}");

                Console.WriteLine($"\nStatus string: {api.GetStatusString()}");

                Console.WriteLine($"\nDirectory path to active storage device: {api.GetStorageDir()}");

                var storageInfo = api.GetStorageInfo();
                Console.WriteLine($"\nStorage information: {storageInfo["available_space"]} / " +
                                  $"{storageInfo["storage_size"]} bytes, mount point: {storageInfo["mount_point"]}");

                Console.WriteLine("\nCamera information:");
                Console.Write(api.GetInfoString("    "));

                var settings = api.GetSavedSettings();

                Console.WriteLine("\nSaved camera settings:");
                api.PrintSettings(settings, "requested_", "    ");

                settings = api.GetCurrentSettings();

                Console.WriteLine("\nCurrent requested camera settings:");
                api.PrintSettings(settings, "requested_", "    ");

                Console.WriteLine("\nCurrent allowed camera settings:");
                api.PrintSettings(settings, "", "    ");

                var requestedSettings = new CamDictionary()
                {
                    { "requested_iso", null },
                    { "requested_exposure", 1 / 500.0 },
                    { "requested_frame_rate", 60 },
                    { "requested_horizontal", 640 },
                    { "requested_vertical", 480 },
                    { "requested_subsample", 1 },
                    { "requested_duration", 10 },
                    { "requested_pretrigger", 50 },
                    { "requested_multishot_count", 1 }
                };

                settings = api.ConfigureCamera(requestedSettings);

                Console.WriteLine("\nRequested camera settings:");
                api.PrintSettings(settings, "requested_", "    ");

                Console.WriteLine("\nAllowed camera settings:");
                api.PrintSettings(settings, "", "    ");

                if (DoFavoritesTest)
                {
                    var favoritesTests = new FavoritesTests(api);
                    favoritesTests.Run();
                }

                if (DoCaptureTest)
                {
                    var captureTests = new CaptureTests(api);

                    captureTests.RunCaptureCancelPostFill(settings);
                    captureTests.RunCaptureSaveStop(settings);
                    captureTests.RunCaptureVideo(settings, "Last saved file: {0}");

                    requestedSettings["duration"] = 1;
                    settings = api.ConfigureCamera(requestedSettings);

                    captureTests.RunCaptureVideo(settings, "Last saved file - should be '/tmp/hcamapi_tmp_test': {0}", "/tmp/hcamapi_tmp_test");
                    captureTests.RunCaptureVideo(settings, "Last saved file - should be 'hcamapi_test': {0}", "hcamapi_test");
                }

                if (DoMultiCaptureTest)
                {
                    var multishotCaptureTests = new MultiCaptureTests(api);

                    multishotCaptureTests.Run();
                    multishotCaptureTests.Run(true);
                    multishotCaptureTests.Run(TestCancellingPostTriggerFill: true);
                }

                if (DoCaptureTest || DoMultiCaptureTest)
                {
                    Console.WriteLine("\nListing files in active storage video directory");

                    var fileList = api.FetchRemoteDirectoryListing();

                    foreach (var file in fileList)
                    {
                        Console.WriteLine($"    {file}");
                    }

                    string lastVideoFilename = api.GetLastSavedFilename();

                    api.DisplayRemoteFile($"{lastVideoFilename.Substring(1, lastVideoFilename.Length - 6)}.txt");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex.Message}");
            }
        }