Beginning of the Implementing multple cameras into the AiQ GUI

Features added:
- Onvif discoverable
- New Camera Type combo box
- Access has be changed to be more scalable and dynamic in preparation for more cameras
This commit is contained in:
2025-12-19 16:14:13 +00:00
parent 760987fa75
commit 7aba890514
18 changed files with 455 additions and 333 deletions

View File

@@ -24,7 +24,7 @@ namespace AiQ_GUI
}
catch (Exception ex)
{
return $"Error during GET request: {ex.Message}{Level.ERROR}";
return $"Error during GET request: {ex.Message}";
}
}
@@ -42,7 +42,7 @@ namespace AiQ_GUI
}
catch (Exception ex)
{
return $"Error in HTTP_Update: {ex.Message}{Level.ERROR}";
return $"Error in HTTP_Update: {ex.Message}";
}
}
@@ -56,7 +56,7 @@ namespace AiQ_GUI
}
catch (Exception ex)
{
return $"Error in HTTP_Fetch: {ex.Message}{Level.ERROR}";
return $"Error in HTTP_Fetch: {ex.Message}";
}
}
@@ -101,22 +101,22 @@ namespace AiQ_GUI
string responseBody = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
return $"Server returned {(int)response.StatusCode}: {response.ReasonPhrase}. Details: {responseBody}{Level.ERROR}";
return $"Server returned {(int)response.StatusCode}: {response.ReasonPhrase}. Details: {responseBody}";
return responseBody;
}
catch (TaskCanceledException)
{
return $"Timeout uploading to {url}.{Level.ERROR}";
return $"Timeout uploading to {url}.";
}
catch (HttpRequestException ex)
{
return $"HTTP error uploading to {url}: {ex.Message}{Level.ERROR}";
return $"HTTP error uploading to {url}: {ex.Message}";
}
catch (Exception ex)
{
return $"Unexpected error uploading to {url}: {ex.Message} {(ex.InnerException?.Message ?? string.Empty)} {Level.ERROR}";
return $"Unexpected error uploading to {url}: {ex.Message} {(ex.InnerException?.Message ?? string.Empty)}";
}
}
@@ -146,7 +146,7 @@ namespace AiQ_GUI
if (JSON == null || JSON.Contains("Error") || JSON.Contains("Timeout"))
{
MainForm.Instance.AddToActionsList($"Error talking to Flexi, are you sure this is an AiQ?{Level.WARNING}" + Environment.NewLine + JSON);
MainForm.Instance.AddToActionsList($"Error talking to Flexi, are you sure this is an AiQ?" + Environment.NewLine + JSON, Level.WARNING);
return null;
}
@@ -174,13 +174,13 @@ namespace AiQ_GUI
// Treat "operation was canceled" as a successful apply
if (response.Contains("The operation was canceled", StringComparison.OrdinalIgnoreCase))
{
Logging.LogMessage($"SetVaxtorMinMaxPlate: Camera applied config but closed connection early (safe to ignore).{Level.WARNING}");
Logging.LogMessage($"SetVaxtorMinMaxPlate: Camera applied config but closed connection early (safe to ignore).");
return true;
}
if (response.Contains("error", StringComparison.OrdinalIgnoreCase))
{
MainForm.Instance.DisplayQuestion($"SetVaxtorMinMaxPlate: failed - Please set manually{Level.WARNING}");
MainForm.Instance.DisplayQuestion($"SetVaxtorMinMaxPlate: failed - Please set manually");
return false;
}
@@ -188,7 +188,7 @@ namespace AiQ_GUI
}
catch (Exception ex)
{
MainForm.Instance.AddToActionsList($"Could not set Vaxtor Plate height and min confidence: {ex.Message}{Level.ERROR}");
MainForm.Instance.AddToActionsList($"Could not set Vaxtor Plate height and min confidence: {ex.Message}", Level.ERROR);
return false;
}
}
@@ -217,7 +217,7 @@ namespace AiQ_GUI
}
catch
{
MainForm.Instance.AddToActionsList($"Error reading trim JSON - {Level.ERROR}" + trimData);
MainForm.Instance.AddToActionsList($"Error reading trim JSON - " + trimData, Level.ERROR);
return;
}
@@ -226,7 +226,7 @@ namespace AiQ_GUI
{
if (RetryCount >= 3)
{
await MainForm.Instance.DisplayOK($"Please align trim in webpage then click OK.{Level.WARNING}"); // Awaited till OK has been clicked
await MainForm.Instance.DisplayOK($"Please align trim in webpage then click OK."); // Awaited till OK has been clicked
return;
}
@@ -254,11 +254,11 @@ namespace AiQ_GUI
}
else // Ask user to centre the plate in the field of view
{
await MainForm.Instance.DisplayOK($"Please centralise plate in view THEN press OK {Level.WARNING}"); // Awaited till OK has been clicked
await MainForm.Instance.DisplayOK($"Please centralise plate in view THEN press OK "); // Awaited till OK has been clicked
if (RetryCount >= 3)
{
await MainForm.Instance.DisplayOK($"Please align trim in webpage then click OK. {Level.WARNING}"); // Awaited till OK has been clicked
await MainForm.Instance.DisplayOK($"Please align trim in webpage then click OK. "); // Awaited till OK has been clicked
return;
}
await Task.Delay(5000); // Give 5 second delay for it to see a plate
@@ -275,7 +275,7 @@ namespace AiQ_GUI
string TrimResp = await HTTP_Update("SightingCreator", IPAddress, Trim_JSON);
if (!TrimResp.Contains($"\"propInterCameraOffsetX\": {{\"value\": \"{Convert.ToString(TrimX)}\", \"datatype\": \"int\"}}, \"propInterCameraOffsetY\": {{\"value\": \"{Convert.ToString(TrimY)}\", \"datatype\": \"int\"}},"))
MainForm.Instance.AddToActionsList($"Could not set camera trim{Level.ERROR}");
MainForm.Instance.AddToActionsList($"Could not set camera trim", Level.ERROR);
}
// Processes the network config from the camera and returns a string indicating the status
@@ -349,7 +349,7 @@ namespace AiQ_GUI
if (FoundCams.Contains("192.168.1.211"))
{
MainForm.Instance.AddToActionsList($"Could not set camera to DHCP please check camera.{Level.ERROR}");
MainForm.Instance.AddToActionsList($"Could not set camera to DHCP please check camera.", Level.ERROR);
return false;
}