namespace AiQ_GUI { internal class CameraModules { // Chack camera modules are in default state according to what the diagnostics API. public static void CheckCamModule(Module CamMod, Label Lbl) { if (CamMod == null || Lbl == null) { MainForm.Instance.AddToActionsList("Camera module or label was null in CheckCamModule."); return; } string errMssg = ""; if (CamMod.zoom != 0) // Check camera module is at full wide errMssg += $"Zoom not at 0 - {CamMod.zoom} "; if (CamMod.firmwareVer != UniversalData.WonwooFirmware) // Check camera module firmware version is up to date. errMssg += $"Firmware: {CamMod.firmwareVer} should be {UniversalData.WonwooFirmware} "; if (CamMod.expMode != 0) // Auto 0=0x00 errMssg += $"Exp mode not set: {CamMod.expMode} "; try { Lbl.Invoke(() => { if (string.IsNullOrWhiteSpace(errMssg)) { Lbl.Text += "OK"; Lbl.ForeColor = Color.LightGreen; } else { Lbl.Text += errMssg; Lbl.ForeColor = Color.Red; } }); } catch (Exception ex) { MainForm.Instance.AddToActionsList("Exception in CheckCamModule: " + ex.Message); } } // Sets shutter, iris and gain to the values given in the dropdowns on the GUI. public static async Task SetSIG(ComboBox Shutter, ComboBox Iris, ComboBox Gain, string IPAddress) // Set SIG according to the comboboxes on the images tab { if (Shutter.SelectedIndex == -1 || Iris.SelectedIndex == -1 || Gain.SelectedIndex == -1) { MainForm.Instance.AddToActionsList("Shutter, Iris and Gain need selecting in images tab."); return; } string ShutterVISCA = BuildVISCACommand("A", Shutter.SelectedIndex + 7); // Offset for not starting at the beggining of the VISCA table string IrisVISCA = BuildVISCACommand("B", Iris.SelectedIndex + 4); // Offset for not starting at the beggining of the VISCA table string GainVISCA = BuildVISCACommand("C", Gain.SelectedIndex); if (ShutterVISCA.Contains("ERROR") || IrisVISCA.Contains("ERROR") || GainVISCA.Contains("ERROR")) { MainForm.Instance.AddToActionsList("Problem with selected SIG values"); return; } string ShutterReply = await FlexiAPI.APIHTTPVISCA(IPAddress, ShutterVISCA, true); // Set Shutter string IrisReply = await FlexiAPI.APIHTTPVISCA(IPAddress, IrisVISCA, true); // Set Iris string GainReply = await FlexiAPI.APIHTTPVISCA(IPAddress, GainVISCA, true); // Set Gain string OneshotReply = await FlexiAPI.APIHTTPVISCA(IPAddress, "8101041801FF", true); // Oneshot auto focus if (!ShutterReply.Contains("41") || !IrisReply.Contains("41") || !GainReply.Contains("41") || !OneshotReply.Contains("41")) { MainForm.Instance.AddToActionsList("Could not set Shutter, Iris, Gain correctly" + Environment.NewLine + "Shutter: " + ShutterReply + Environment.NewLine + "Iris: " + IrisReply + Environment.NewLine + "Gain: " + GainReply + Environment.NewLine + "Oneshot: " + OneshotReply); } } // Sets back to the latest factory defaults CSV that is in Flexi. public static async Task FactoryResetModules(string IPAddress) { // Set both camera modules back to MAV defaults. Found in WonwooDefaultSettingsIR.csv & WonwooDefaultSettingsOV.csv Task IRReply = FlexiAPI.APIHTTPRequest("/Infrared-camera-factory-reset", IPAddress, 10); Task OVReply = FlexiAPI.APIHTTPRequest("/Colour-camera-factory-reset", IPAddress, 10); await Task.WhenAll(IRReply, OVReply); if (IRReply.Result != "Factory reset OK." || OVReply.Result != "Factory reset OK.") MainForm.Instance.AddToActionsList($"Could not reset camera modules to factory default.{Environment.NewLine}{IRReply}{Environment.NewLine}{OVReply}"); } public static string BuildVISCACommand(string command, int hexValue) { // Take the augmented Selected index into a two nibble hex value. string hex = $"{hexValue:X2}"; // Build the final VISCA command string using the input characters split as p and q return $"8101044{command}00000{hex[0]}0{hex[1]}FF"; } } }