// Start is called before the first frame update private void OnTriggerExit2D(Collider2D collision) { if (collision.gameObject.layer == 8) { CamDictionary.ChangeToCameraIndex(changeToCamera); } }
public void PrintSettings(CamDictionary settings, string keyPrefix, string prefix) { PrintSettingLine(prefix + "Sensitivity", settings[keyPrefix + "iso"]); var exposure = (double)settings[keyPrefix + "exposure"]; if (exposure == 0) { Console.WriteLine($"{prefix}Shutter: None"); } else { Console.WriteLine($"{prefix}Shutter: {1 / exposure:g6}"); } PrintSettingLine(prefix + "Frame Rate", settings[keyPrefix + "frame_rate"]); PrintSettingLine(prefix + "Horizontal", settings[keyPrefix + "horizontal"]); PrintSettingLine(prefix + "Vertical", settings[keyPrefix + "vertical"]); Console.Write($"{prefix}Sub-sampling: "); Console.WriteLine((!settings.ContainsKey(keyPrefix + "subsample") || (long)settings[keyPrefix + "subsample"] == 0) ? "Off" : "On"); PrintSettingLine(prefix + "Duration", settings[keyPrefix + "duration"]); PrintSettingLine(prefix + "Pre-trigger", settings[keyPrefix + "pretrigger"]); }
public void RunCaptureSaveStop(CamDictionary allowedSettings) { // Example showing partial pre-trigger buffer fill, trigger, save video, then truncate save leaving playable video file this.RunCamera(api, allowedSettings, "\nPartial pre-trigger buffer fill, trigger, start video save, then truncate save leaving playable video file"); api.WaitForTransition(" Letting pre-trigger buffer partially fill", CAMERA_STATE.RUNNING, 10); Thread.Sleep(4000); Console.WriteLine($" {api.GetStatusString()}"); this.TriggerCamera(api, "Camera triggered, starting to fill post-trigger buffer"); Console.WriteLine($" Percentage pre-trigger buffer filled before trigger: {api.GetPretriggerFillLevel()}"); api.WaitForTransition("Waiting for post-trigger buffer to fill", CAMERA_STATE.TRIGGERED, 10); api.ExpectState(CAMERA_STATE.SAVING); Thread.Sleep(1000); Console.WriteLine($" Truncating save before complete, video file still playable"); Console.WriteLine($" {api.GetStatusString()}"); api.SaveStop(); api.WaitForTransition("Waiting for save to finish", CAMERA_STATE.SAVING, 10); api.WaitForTransition("Waiting for post-trigger buffer to fill", CAMERA_STATE.SAVE_TRUNCATING, 10); api.ExpectRunningState(); }
public CAMAPI_STATUS SaveFavorite(CamDictionary settings) { // Save a set of camera settings. The supplied settings must have an id key set to a valid value. // returns: CAMAPI_STATUS.OKAY, CAMAPI_STATUS.INVALID_PARAMETER, or CAMAPI_STATUS.STORAGE_ERROR string jdata = api.PostTarget("/save_favorite", settings); return((CAMAPI_STATUS)JsonConvert.DeserializeObject(jdata, typeof(CAMAPI_STATUS))); }
private void OnTriggerExit2D(Collider2D collision) { if (collision.gameObject.layer == 8) { CamDictionary.ChangeToCameraIndex(1); ToggleTreeInner(false); } }
private void OnTriggerStay2D(Collider2D collision) { if (collision.gameObject.layer == 8) { CamDictionary.ChangeToCameraIndex(2); ToggleTreeInner(true); } }
public CamDictionary ConfigureCamera(CamDictionary settings) // API { // Configure camera using the requested_settings dictionary. // Calculates a camera configuration based on the requested values, camera limitations, and // a prioritized scheme to to eliminate inconsistencies. // return: dictionary of requested setting values along with the allowed values. string jdata = PostTarget("/configure_camera", settings); return((CamDictionary)JsonConvert.DeserializeObject(jdata, typeof(CamDictionary))); }
public CamDictionary GetCamStatus() // API { // Returns camera status dictionary. string jdata = FetchTarget("/get_camstatus"); CamDictionary result = (CamDictionary)JsonConvert.DeserializeObject(jdata, typeof(CamDictionary)); result["state"] = (CAMERA_STATE)Enum.ToObject(typeof(CAMERA_STATE), result["state"]); return(result); }
public static void buildIntegerDictionary(CamDictionary <int> dictionary, int datasetSize) { if (datasetSize == 1) { return; } if (datasetSize == 2) { dictionary.add(1); dictionary.add(4); dictionary.add(7); dictionary.add(8); dictionary.add(13); dictionary.add(12); dictionary.add(3); dictionary.add(25); dictionary.add(108); dictionary.add(9); return; } else if (datasetSize == 3) { dictionary.add(1); dictionary.add(2); dictionary.add(3); dictionary.add(4); dictionary.add(5); dictionary.add(6); dictionary.add(7); dictionary.add(8); dictionary.add(9); dictionary.add(10); dictionary.add(11); dictionary.add(12); dictionary.add(13); dictionary.add(14); dictionary.add(15); dictionary.add(16); dictionary.add(17); dictionary.add(18); dictionary.add(19); dictionary.add(20); return; } else { Console.WriteLine("Building dictionary. Stand by."); Random random = new Random(); for (int i = 0; i < 10000; i++) { dictionary.add(random.Next(100000)); } } }
public CAMAPI_STATUS Run(CamDictionary settings) // API { // Reconfigures the camara to use the best match values based on the requested values, // calibrates the camera using those values, and starts capturing the pre-trigger video frames. // The best match values are the same balues as those returned by configure_camera(). // return: outcome, either CAMAPI_STATUS.OKAY or CAMAPI_STATUS.INVALID_STATE string jdata = PostTarget("/run", settings); return((CAMAPI_STATUS)JsonConvert.DeserializeObject(jdata, typeof(CAMAPI_STATUS))); }
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); }
// Update is called once per frame public void TakeDamage(int damage) { if (currHealth > damage) { pm.enabled = false; currHealth -= damage; CamDictionary.CamShake(0.2f, 10f); rb.AddForce(getDamageForce, ForceMode2D.Impulse); pm.enabled = true; } else { UnityEngine.SceneManagement.SceneManager.LoadScene("Menu"); } }
public void RunCaptureCancelPostFill(CamDictionary allowedSettings) { // Example showing full pre-trigger buffer fill, trigger, cancel while post-trigger buffer is filling this.RunCamera(api, allowedSettings, "\nFill pre-trigger buffer, trigger, cancel while post-trigger buffer is filling"); api.WaitForTransition("Waiting for pre-trigger buffer to fill", CAMERA_STATE.RUNNING, 10); api.ExpectState(CAMERA_STATE.RUNNING_PRETRIGGER_FULL); this.TriggerCamera(api, "Camera triggered, starting to fill post-trigger buffer"); Console.WriteLine(" Canceling trigger while post-trigger buffer is filling"); Console.WriteLine($" {api.GetStatusString()}"); api.Cancel(); api.WaitForTransition("Waiting for cancel to be processed", CAMERA_STATE.TRIGGERED, 10); api.ExpectRunningState(); }
public void RunCaptureVideo(CamDictionary allowedSettings, string message, string baseFilename = null) { // Example showing full pre-trigger buffer fill, trigger, save video capture process this.RunCamera(api, allowedSettings, "\nPartial pre-trigger buffer fill, trigger, save video capture process"); api.WaitForTransition(" Waiting for pre-trigger buffer to fill", CAMERA_STATE.RUNNING, 10); api.ExpectState(CAMERA_STATE.RUNNING_PRETRIGGER_FULL); this.TriggerCamera(api, "Camera triggered, filling post-trigger buffer", baseFilename); Console.WriteLine($" Percentage pre-trigger buffer filled before trigger: {api.GetPretriggerFillLevel()}"); api.WaitForTransition("Waiting for post-trigger buffer to fill", CAMERA_STATE.TRIGGERED, 10); api.ExpectState(CAMERA_STATE.SAVING); api.WaitForTransition("Waiting for save to complete", CAMERA_STATE.SAVING, 30); api.ExpectRunningState(); Console.WriteLine(string.Format(" " + message, api.GetLastSavedFilename())); }
// Accepts dictionary to be posted to uri. public string PostTarget(string target, CamDictionary data) { string result = null; string url = "http://" + this.camAddr + target; try { if (debug) { Console.WriteLine($" Posting: {url}"); } WebRequest request = WebRequest.Create(url); string jsonData = JsonConvert.SerializeObject(data); request.Method = "POST"; request.ContentType = "application/json"; using (var writer = new StreamWriter(request.GetRequestStream())) { writer.Write(jsonData); writer.Flush(); writer.Close(); } var response = request.GetResponse(); var reader = new StreamReader(response.GetResponseStream()); result = reader.ReadToEnd(); if (debug) { Console.WriteLine($" Response: {result}"); } } catch (Exception ex) { Console.WriteLine($"ERROR: unable to post: {url}"); Console.WriteLine(ex.Message); } return(result); }
private void FixedUpdate() { if (damageItems) { if (GroundCheck.isGrounded) { rb.velocity = new Vector2(0, rb.velocity.y); } Collider2D[] damageableColliders = Physics2D.OverlapCircleAll(damageCenter.position, damageRadius, whatIsDamageableByPlayer); Collider2D[] enemyColliders = Physics2D.OverlapCircleAll(damageCenter.position, damageRadius, whatIsEnemy); Collider2D[] hitableColliders = Physics2D.OverlapCircleAll(damageCenter.position, damageRadius, whatIsHitableByPlayer); foreach (Collider2D c in enemyColliders) { c.gameObject.GetComponent <EnemyHealth>().TakeDamage(40); } if (damageableColliders.Length > 0) { /*if (transform.localScale.x < 0) * { * rb.AddForce(attackForce, ForceMode2D.Impulse); * } * else if (transform.localScale.x > 0) * { * Vector2 negAttackForce = new Vector2(-attackForce.x, attackForce.y); * rb.AddForce(negAttackForce, ForceMode2D.Impulse); * }*/ //#TODO Add damage //CamDictionary.CamShake(0.02f, 2f); } else { Collider2D[] allCollidersInRange = Physics2D.OverlapCircleAll(damageCenter.position, damageRadius, whatIsHitableByPlayer); if (allCollidersInRange.Length > 0) { CamDictionary.CamShake(0.07f, 3f); } } damageItems = false; } }
private static void DoRunCamera(CamApiLib api, CamDictionary allowedSettings, string message) { api.ExpectRunningState(); if (!string.IsNullOrEmpty(message)) { Console.WriteLine(message); } Console.WriteLine(" Calibrating camera using allowed settings"); CAMAPI_STATUS status = api.Run(allowedSettings); if (status == CAMAPI_STATUS.OKAY) { Console.WriteLine(" Run started"); } else { Console.WriteLine(" Error: Run() returned {status}"); Environment.Exit(1); } api.ExpectState(CAMERA_STATE.RUNNING); }
public static void buildStringDictionary(CamDictionary <String> dictionary, int datasetSize) { if (datasetSize == 1) { return; } if (datasetSize == 2) { dictionary.add("dog"); dictionary.add("cat"); dictionary.add("brown"); dictionary.add("zebra"); dictionary.add("horse"); dictionary.add("antelope"); dictionary.add("cameron"); dictionary.add("harrison"); dictionary.add("mauricio"); dictionary.add("david"); dictionary.add("aardvark"); return; } else if (datasetSize == 3) { dictionary.add("A"); dictionary.add("B"); dictionary.add("C"); dictionary.add("D"); dictionary.add("E"); dictionary.add("F"); dictionary.add("G"); dictionary.add("H"); dictionary.add("I"); dictionary.add("J"); dictionary.add("K"); dictionary.add("L"); dictionary.add("M"); dictionary.add("N"); dictionary.add("O"); dictionary.add("P"); dictionary.add("Q"); dictionary.add("R"); dictionary.add("S"); dictionary.add("T"); dictionary.add("U"); dictionary.add("V"); dictionary.add("W"); dictionary.add("X"); dictionary.add("Y"); dictionary.add("Z"); return; } else { Console.WriteLine("Building dictionary. Stand by."); const string characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; Random random = new Random(); StringBuilder sb = new StringBuilder(10); for (int entry = 0; entry < 10000; entry++) { for (int i = 0; i < 7; i++) { sb.Append(characters.ElementAt(random.Next(characters.Length))); } dictionary.add(sb.ToString()); sb.Remove(0, 7); } } }
public static void performanceAnalysis() { CamDictionary <int> optimisedDictionary = new CamDictionary <int>(); CamDictionary <int> unoptimisedDictionary = new CamDictionary <int>(); unoptimisedDictionary.noOptimisations = true; Console.WriteLine("This mode will compare the performance of 2 randomly generated dictionaries with"); Console.WriteLine("the same data but one is optimised and the other is not."); Console.WriteLine("Enter the size of the dictionary."); int size = Convert.ToInt32(Console.ReadLine()); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Building dictionaries. Stand by."); Console.WriteLine(""); Random random = new Random(); for (int i = 0; i < size; i++) { int data = random.Next(10 * size); optimisedDictionary.add(data); unoptimisedDictionary.add(data); } int insertionTotalUnoptimised = unoptimisedDictionary.totalComparisons; int insertionTotalOptimised = optimisedDictionary.totalComparisons; int insertionMeanUnoptimised = unoptimisedDictionary.totalComparisons / size; int insertionMeanOptimised = optimisedDictionary.totalComparisons / size; int insertionMaxUnoptimised = unoptimisedDictionary.maxComparisons; int insertionMaxOptimised = optimisedDictionary.maxComparisons; double insertPercentage = (double)-(insertionTotalUnoptimised - insertionTotalOptimised) / (double)insertionTotalUnoptimised * 100.0; unoptimisedDictionary.maxComparisons = 0; optimisedDictionary.maxComparisons = 0; unoptimisedDictionary.totalComparisons = 0; optimisedDictionary.totalComparisons = 0; for (int i = 0; i < size; i++) { int data = random.Next(10 * size); optimisedDictionary.contains(data); unoptimisedDictionary.contains(data); } Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("\t\t\tUnoptimised \tOptimised"); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\t\t\t=========== \t========="); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("INSERTION"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Total operations\t" + insertionTotalUnoptimised + "\t\t" + insertionTotalOptimised); Console.WriteLine("Mean operations\t\t" + insertionMeanUnoptimised + "\t\t" + insertionMeanOptimised); Console.WriteLine("Max operations\t\t" + insertionMaxUnoptimised + "\t\t" + insertionMaxOptimised); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("SEARCHING"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Total operations\t" + unoptimisedDictionary.totalComparisons + "\t\t" + optimisedDictionary.totalComparisons); Console.WriteLine("Mean operations\t\t" + unoptimisedDictionary.totalComparisons / size + "\t\t" + optimisedDictionary.totalComparisons / size); Console.WriteLine("Max operations\t\t" + unoptimisedDictionary.maxComparisons + "\t\t" + optimisedDictionary.maxComparisons); Console.WriteLine(""); double searchPercentage = (double)(unoptimisedDictionary.totalComparisons - optimisedDictionary.totalComparisons) / (double)unoptimisedDictionary.totalComparisons * 100.0; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("The optimised dictionary is {0:0.00}% more efficient for searches with a cost of {1:0.00}% reduced efficiency for insertions.\n\n", searchPercentage, insertPercentage); Console.ReadKey(); }
public static void createDictionary() { int dictionaryNumber = 0; while (dictionaryNumber < 1 || dictionaryNumber > 2) { Console.WriteLine("What will we be inserting into the dictionary?"); Console.WriteLine("1. Strings"); Console.WriteLine("2. Integers"); dictionaryNumber = Convert.ToInt32(Console.ReadLine()); } CamDictionary <string> dictionary1 = new CamDictionary <string>(); CamDictionary <int> dictionary2 = new CamDictionary <int>(); int i = 0; while (i < 1 || i > 4) { Console.WriteLine("Select option:"); Console.WriteLine("1. Manually build dictionary"); Console.WriteLine("2. Automatic build with small dataset"); Console.WriteLine("3. Automatic build with large dataset"); Console.WriteLine("4. Automatic build with hardcore dataset"); i = Convert.ToInt32(Console.ReadLine()); } int j = 0; while (j < 1 || j > 2) { Console.WriteLine("Enable optimisations (AVL tree balancing)?"); Console.WriteLine("1. Yes"); Console.WriteLine("2. No"); j = Convert.ToInt32(Console.ReadLine()); } if (j == 2) { dictionary1.noOptimisations = true; dictionary2.noOptimisations = true; } int k = 0; while (k < 1 || k > 2) { Console.WriteLine("Enable live feedback of every operation?"); Console.WriteLine("Note: If optimisations are disabled, heights will all be shown as zero."); Console.WriteLine("Note 2: It is recommended to turn this OFF for large datasets."); Console.WriteLine("It will crash on systems with low RAM if you try!!"); Console.WriteLine("1. Yes"); Console.WriteLine("2. No"); k = Convert.ToInt32(Console.ReadLine()); } if (k == 1) { dictionary1.visualFeedback = true; dictionary2.visualFeedback = true; } if (dictionaryNumber == 1) { buildStringDictionary(dictionary1, i); } else { buildIntegerDictionary(dictionary2, i); } bool inProgram = true; while (inProgram) { int choice = 0; Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine("Which operation would you like to perform?"); Console.WriteLine("1. Add"); Console.WriteLine("2. Delete"); Console.WriteLine("3. Search"); Console.WriteLine("4. Min"); Console.WriteLine("5. Max"); Console.WriteLine("6. Predecessor"); Console.WriteLine("7. Successor"); Console.WriteLine("8. Display dictionary diagram"); Console.WriteLine("9. List all entries"); Console.WriteLine("10. Display log"); Console.WriteLine("11. Exit"); choice = Convert.ToInt32(Console.ReadLine()); Console.ForegroundColor = ConsoleColor.Yellow; if (dictionaryNumber == 1) { switch (choice) { case 1: Console.WriteLine("Add a string to the dictionary"); dictionary1.add(Console.ReadLine()); break; case 2: Console.WriteLine("Delete a string from the dictionary"); dictionary1.delete(Console.ReadLine()); break; case 3: Console.WriteLine("Search for a string in the dictionary"); string stringToSearch = Console.ReadLine(); bool found = dictionary1.contains(stringToSearch); if (found) { Console.WriteLine("String " + stringToSearch + " was found!"); } else { Console.WriteLine("String " + stringToSearch + " not found!"); } break; case 4: Console.WriteLine("The min value is: " + dictionary1.min()); break; case 5: Console.WriteLine("The max value is: " + dictionary1.max()); break; case 6: Console.WriteLine("Find the predecessor of a string in the dictionary"); stringToSearch = Console.ReadLine(); Console.WriteLine("The predecessor of " + stringToSearch + " is " + dictionary1.predecessor(stringToSearch)); break; case 7: Console.WriteLine("Find the successor of a string in the dictionary"); stringToSearch = Console.ReadLine(); Console.WriteLine("The successor of " + stringToSearch + " is " + dictionary1.successor(stringToSearch)); break; case 8: dictionary1.print(); break; case 9: Console.WriteLine(dictionary1.toString()); break; case 10: Console.WriteLine(dictionary1.getLogString()); break; case 11: inProgram = false; break; } } else { switch (choice) { case 1: Console.WriteLine("Add an integer to the dictionary"); dictionary2.add(Convert.ToInt32(Console.ReadLine())); break; case 2: Console.WriteLine("Delete an integer from the dictionary"); dictionary2.delete(Convert.ToInt32(Console.ReadLine())); break; case 3: Console.WriteLine("Search for an integer in the dictionary"); int integer = Convert.ToInt32(Console.ReadLine()); bool found = dictionary2.contains(integer); if (found) { Console.WriteLine("Integer " + integer + " was found!"); } else { Console.WriteLine("Integer " + integer + " not found!"); } break; case 4: Console.WriteLine("The min value is: " + dictionary2.min()); break; case 5: Console.WriteLine("The max value is: " + dictionary2.max()); break; case 6: Console.WriteLine("Find the predecessor of an integer in the dictionary"); integer = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("The predecessor of " + integer + " is " + dictionary2.predecessor(integer)); break; case 7: Console.WriteLine("Find the successor of an integer in the dictionary"); integer = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("The successor of " + integer + " is " + dictionary2.successor(integer)); break; case 8: dictionary2.print(); break; case 9: Console.WriteLine(dictionary2.toString()); break; case 10: Console.WriteLine(dictionary2.getLogString()); break; case 11: inProgram = false; break; } } } }
public static void RunCamera(this MultiCaptureTests _this, CamApiLib api, CamDictionary allowedSettings, string message) { DoRunCamera(api, allowedSettings, message); }
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}"); } }