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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace AiQ_GUI
|
||||
HttpResponseMessage response = await httpClient.GetAsync(requestUrl);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"No success from {requestUrl} replied {response.StatusCode}{Level.ERROR}");
|
||||
MainForm.Instance.AddToActionsList($"No success from {requestUrl} replied {response.StatusCode}", Level.ERROR);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace AiQ_GUI
|
||||
|
||||
if (imageBytes.Length == 0) // Check if the imageBytes is empty
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"No image data received from {requestUrl}{Level.ERROR}");
|
||||
MainForm.Instance.AddToActionsList($"No image data received from {requestUrl}", Level.ERROR);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace AiQ_GUI
|
||||
CvInvoke.Imdecode(imageBytes, ImreadModes.AnyColor, mat);
|
||||
if (mat.IsEmpty)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Failed to decode image with Emgu CV.{Level.ERROR}");
|
||||
MainForm.Instance.AddToActionsList($"Failed to decode image with Emgu CV.", Level.ERROR);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -70,12 +70,12 @@ namespace AiQ_GUI
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"HTTP error: {ex.Message}{Level.ERROR}");
|
||||
MainForm.Instance.AddToActionsList($"HTTP error: {ex.Message}", Level.ERROR);
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Error processing image: {ex.Message} {Level.ERROR}");
|
||||
MainForm.Instance.AddToActionsList($"Error processing image: {ex.Message}", Level.ERROR);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Error awaiting Colour snapshot: {ex.Message} {Level.ERROR}");
|
||||
MainForm.Instance.AddToActionsList($"Error awaiting Colour snapshot: {ex.Message}", Level.ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Error calculating luminance: {ex.Message} {Level.ERROR}");
|
||||
MainForm.Instance.AddToActionsList($"Error calculating luminance: {ex.Message}",Level.ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Error checking LEDs: {ex.Message} {Level.ERROR}");
|
||||
MainForm.Instance.AddToActionsList($"Error checking LEDs: {ex.Message}", Level.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,13 +25,13 @@ namespace AiQ_GUI
|
||||
else if (Type == "Audit")
|
||||
salt = Auditsalt;
|
||||
else
|
||||
return $"Unrecognised challenge type:{Level.ERROR}" + Type;
|
||||
return $"Unrecognised challenge type:" + Type;
|
||||
|
||||
if (string.IsNullOrEmpty(challenge) || challenge.Length != 6) // Check challenge format
|
||||
return $"Invalid challenge format. Challenge must be 6 characters.{Level.ERROR}";
|
||||
return $"Invalid challenge format. Challenge must be 6 characters.";
|
||||
|
||||
if (string.IsNullOrEmpty(salt) || salt.Length != 32) // Check salt format
|
||||
return $"Invalid salt format. Salt must be 32 characters.{Level.ERROR}";
|
||||
return $"Invalid salt format. Salt must be 32 characters.";
|
||||
|
||||
// Hash computation using SHA256 algorithm
|
||||
byte[] inputBytes = Encoding.UTF8.GetBytes(challenge + " " + salt); // SHA hash format challenge and salt with space between
|
||||
@@ -60,7 +60,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return $"Error: Could not generate password{Level.ERROR}" + ex.Message;
|
||||
return $"Error: Could not generate password" + ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Exception in FetchDevPassword: {Level.ERROR}" + ex.Message);
|
||||
MainForm.Instance.AddToActionsList($"Exception in FetchDevPassword:" + ex.Message, Level.ERROR);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
catch
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Is the router on the network? Has the MAV Config file been applied?{Level.WARNING}");
|
||||
MainForm.Instance.AddToActionsList($"Is the router on the network? Has the MAV Config file been applied?", Level.WARNING);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -48,31 +48,31 @@ namespace AiQ_GUI
|
||||
|
||||
if (Strength < 25.0)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Router signal strength is {Strength} which is below 25%. Please check the router connection.{Level.WARNING}");
|
||||
MainForm.Instance.AddToActionsList($"Router signal strength is {Strength} which is below 25%. Please check the router connection.", Level.WARNING);
|
||||
PassTest = false;
|
||||
}
|
||||
|
||||
if (!Router.SimStatus.Contains("SIM Ready"))
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"SIM card is not ready. {Router.SimStatus} Please check the SIM card status.{Level.WARNING}");
|
||||
MainForm.Instance.AddToActionsList($"SIM card is not ready. {Router.SimStatus} Please check the SIM card status.", Level.WARNING);
|
||||
PassTest = false;
|
||||
}
|
||||
|
||||
if (!Router.Port3Status.Contains("port:3 link:up speed:100baseT full-duplex"))
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Port 3 is not connected properly. {Router.Port3Status} Please check the connection. {Level.WARNING}");
|
||||
MainForm.Instance.AddToActionsList($"Port 3 is not connected properly. {Router.Port3Status} Please check the connection.", Level.WARNING);
|
||||
PassTest = false;
|
||||
}
|
||||
|
||||
if (!Router.Port4Status.Contains("port:4 link:up speed:100baseT full-duplex"))
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Port 4 is not connected properly. {Router.Port4Status} Please check the connection. {Level.WARNING}");
|
||||
MainForm.Instance.AddToActionsList($"Port 4 is not connected properly. {Router.Port4Status} Please check the connection. ", Level.WARNING);
|
||||
PassTest = false;
|
||||
}
|
||||
|
||||
if (!Router.GoodPing)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Router could not ping 8.8.8.8. Please check the online connection.{Level.WARNING}");
|
||||
MainForm.Instance.AddToActionsList($"Router could not ping 8.8.8.8. Please check the online connection.", Level.WARNING);
|
||||
PassTest = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
catch (Exception Ex)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"SSH connection failed: {Ex.Message}. Check password or network. {Level.WARNING}");
|
||||
MainForm.Instance.AddToActionsList($"SSH connection failed: {Ex.Message}. Check password or network. ", Level.WARNING);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -75,7 +75,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"SSH connection failed: {ex.Message}. Check password or network. {Level.WARNING}");
|
||||
MainForm.Instance.AddToActionsList($"SSH connection failed: {ex.Message}. Check password or network. ", Level.WARNING);
|
||||
}
|
||||
|
||||
string LogMssg = string.Join(" | ", typeof(SSHData).GetProperties().Select(p => $"{p.Name}: {p.GetValue(Data)}"));
|
||||
@@ -170,7 +170,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"SSH connection failed: {ex.Message}. Check password or network. {Level.WARNING}");
|
||||
MainForm.Instance.AddToActionsList($"SSH connection failed: {ex.Message}. Check password or network. ", Level.WARNING);
|
||||
}
|
||||
|
||||
return (string.Empty, string.Empty);
|
||||
@@ -323,7 +323,7 @@ namespace AiQ_GUI
|
||||
|
||||
if (checkDevice.Result.Trim() != "OK") // Device not found
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Block device {device} not found. {Level.WARNING}");
|
||||
MainForm.Instance.AddToActionsList($"Block device {device} not found. ", Level.WARNING);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -378,7 +378,7 @@ namespace AiQ_GUI
|
||||
|
||||
if (checkDevice.Result.Trim().Length > 1) // Device not found
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Cannot sync files to disk. Replied: {checkDevice.Result}. DO NOT TURN OFF, GET SUPERVISOR {Level.ERROR}");
|
||||
MainForm.Instance.AddToActionsList($"Cannot sync files to disk. Replied: {checkDevice.Result}. DO NOT TURN OFF, GET SUPERVISOR", Level.ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Cannot sync becuase: {ex.Message}. DO NOT TURN OFF, GET SUPERVISOR {Level.ERROR}");
|
||||
MainForm.Instance.AddToActionsList($"Cannot sync becuase: {ex.Message}. DO NOT TURN OFF, GET SUPERVISOR", Level.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user