Merged colours
This commit is contained in:
@@ -24,7 +24,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return $"Error during GET request: {ex.Message}";
|
||||
return $"Error during GET request: {ex.Message}{Level.ERROR}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return $"Error in HTTP_Update: {ex.Message}";
|
||||
return $"Error in HTTP_Update: {ex.Message}{Level.ERROR}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return $"Error in HTTP_Fetch: {ex.Message}";
|
||||
return $"Error in HTTP_Fetch: {ex.Message}{Level.ERROR}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,21 +101,22 @@ namespace AiQ_GUI
|
||||
string responseBody = await response.Content.ReadAsStringAsync();
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
return $"Server returned {(int)response.StatusCode}: {response.ReasonPhrase}. Details: {responseBody}";
|
||||
return $"Server returned {(int)response.StatusCode}: {response.ReasonPhrase}. Details: {responseBody}{Level.ERROR}";
|
||||
|
||||
return responseBody;
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
return $"Timeout uploading to {url}.";
|
||||
return $"Timeout uploading to {url}.{Level.ERROR}";
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
return $"HTTP error uploading to {url}: {ex.Message}";
|
||||
return $"HTTP error uploading to {url}: {ex.Message}{Level.ERROR}";
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return $"Unexpected error uploading to {url}: {ex.Message} {(ex.InnerException?.Message ?? "")}";
|
||||
return $"Unexpected error uploading to {url}: {ex.Message} {(ex.InnerException?.Message ?? string.Empty)} {Level.ERROR}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,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?" + Environment.NewLine + JSON);
|
||||
MainForm.Instance.AddToActionsList($"Error talking to Flexi, are you sure this is an AiQ?{Level.WARNING}" + Environment.NewLine + JSON);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -173,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).");
|
||||
Logging.LogMessage($"SetVaxtorMinMaxPlate: Camera applied config but closed connection early (safe to ignore).{Level.WARNING}");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (response.Contains("error", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
MainForm.Instance.DisplayQuestion($"SetVaxtorMinMaxPlate: failed - Please set manually");
|
||||
MainForm.Instance.DisplayQuestion($"SetVaxtorMinMaxPlate: failed - Please set manually{Level.WARNING}");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -187,7 +188,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Could not set Vaxtor Plate height and min confidence: {ex.Message}");
|
||||
MainForm.Instance.AddToActionsList($"Could not set Vaxtor Plate height and min confidence: {ex.Message}{Level.ERROR}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -216,7 +217,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
catch
|
||||
{
|
||||
MainForm.Instance.AddToActionsList("Error reading trim JSON - " + trimData);
|
||||
MainForm.Instance.AddToActionsList($"Error reading trim JSON - {Level.ERROR}" + trimData);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -225,7 +226,7 @@ namespace AiQ_GUI
|
||||
{
|
||||
if (RetryCount >= 3)
|
||||
{
|
||||
await MainForm.Instance.DisplayOK("Please align trim in webpage then click OK."); // Awaited till OK has been clicked
|
||||
await MainForm.Instance.DisplayOK($"Please align trim in webpage then click OK.{Level.WARNING}"); // Awaited till OK has been clicked
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -253,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"); // Awaited till OK has been clicked
|
||||
await MainForm.Instance.DisplayOK($"Please centralise plate in view THEN press OK {Level.WARNING}"); // Awaited till OK has been clicked
|
||||
|
||||
if (RetryCount >= 3)
|
||||
{
|
||||
await MainForm.Instance.DisplayOK("Please align trim in webpage then click OK."); // Awaited till OK has been clicked
|
||||
await MainForm.Instance.DisplayOK($"Please align trim in webpage then click OK. {Level.WARNING}"); // Awaited till OK has been clicked
|
||||
return;
|
||||
}
|
||||
await Task.Delay(5000); // Give 5 second delay for it to see a plate
|
||||
@@ -274,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");
|
||||
MainForm.Instance.AddToActionsList($"Could not set camera trim{Level.ERROR}");
|
||||
}
|
||||
|
||||
// Processes the network config from the camera and returns a string indicating the status
|
||||
@@ -292,7 +293,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Error in getting network config from camera: {ex.Message}");
|
||||
MainForm.Instance.AddToActionsList($"Error in getting network config from camera: {ex.Message}{Level.ERROR}");
|
||||
return null; // Return empty string if there is an error
|
||||
}
|
||||
}
|
||||
@@ -348,11 +349,11 @@ namespace AiQ_GUI
|
||||
|
||||
if (FoundCams.Contains("192.168.1.211"))
|
||||
{
|
||||
MainForm.Instance.AddToActionsList("Could not set camera to DHCP please check camera.");
|
||||
MainForm.Instance.AddToActionsList($"Could not set camera to DHCP please check camera.{Level.ERROR}");
|
||||
return false;
|
||||
}
|
||||
|
||||
MainForm.Instance.AddToActionsList("Camera successfully set to DHCP.");
|
||||
MainForm.Instance.AddToActionsList($"Camera successfully set to DHCP.{Level.Success}");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -410,14 +411,14 @@ namespace AiQ_GUI
|
||||
string result = await APIHTTPVISCA(ipAddress, command, isIR);
|
||||
|
||||
if (result.Contains(expectedResponse))
|
||||
MainForm.Instance.AddToActionsList($"{name}: Success ({(isIR ? "IR" : "Colour")})", Level.LOG);
|
||||
MainForm.Instance.AddToActionsList($"{name}: Success ({(isIR ? "IR" : "Colour")})", Level.Success);
|
||||
else
|
||||
MainForm.Instance.AddToActionsList($"{name}: Unexpected response ({result})", Level.ERROR);
|
||||
|
||||
await Task.Delay(150);
|
||||
}
|
||||
|
||||
MainForm.Instance.AddToActionsList($"Upload complete ({(isIR ? "IR" : "Colour")}).", Level.LOG);
|
||||
MainForm.Instance.AddToActionsList($"Upload complete ({(isIR ? "IR" : "Colour")}).", Level.Success);
|
||||
}
|
||||
|
||||
public static async void UploadBlob(List<Camera> soakCameraList)
|
||||
@@ -431,7 +432,7 @@ namespace AiQ_GUI
|
||||
|
||||
if (fileToUpload == null)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList("No .blob file found in the directory.", Level.ERROR);
|
||||
MainForm.Instance.AddToActionsList("No .blob file found in the directory.", Level.WARNING);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -472,7 +473,7 @@ namespace AiQ_GUI
|
||||
result = await SendBlobFileUpload(apiUrl, fileToUpload, fileName);
|
||||
}
|
||||
|
||||
MainForm.Instance.AddToActionsList($"Upload result for {cam.IP}: {result}", Level.LOG);
|
||||
MainForm.Instance.AddToActionsList($"Upload result for {cam.IP}: {result}");
|
||||
await Task.Delay(500);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user