From 8767f613975b4826fcef0c1e10595ee357a2fd5a Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Thu, 14 Jan 2021 18:42:59 +0000 Subject: [PATCH] add extra status levels and project info. to legend. The new levels are extra colour codes which describe the various states of the system with finer detail. --- .../EyesAndEars.UWP/MainPage.xaml | 29 ++++++++++++--- .../EyesAndEars.UWP/Services/DataServices.cs | 37 ++++++++++++++++--- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml b/src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml index 60a73c8..757992b 100644 --- a/src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml +++ b/src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml @@ -22,7 +22,7 @@ - + - + - - + + + + + @@ -103,7 +108,19 @@ - + + + + + + + + diff --git a/src/EyesAndEars.UWP/EyesAndEars.UWP/Services/DataServices.cs b/src/EyesAndEars.UWP/EyesAndEars.UWP/Services/DataServices.cs index a469d1e..b93de54 100644 --- a/src/EyesAndEars.UWP/EyesAndEars.UWP/Services/DataServices.cs +++ b/src/EyesAndEars.UWP/EyesAndEars.UWP/Services/DataServices.cs @@ -19,7 +19,7 @@ namespace EyesAndEars.UWP.Services { var statusJSON = await WebServices.GetJSON(statusAPI); var r = MapToLightReading(readingJSON); var s = MapToDeviceStatus(statusJSON); - var c = UpdateStatusColour(s.status); + var c = UpdateStatusColour(s.status, r.reading); return new Device(deviceId, r, s, c); } catch (Exception e) { @@ -28,12 +28,37 @@ namespace EyesAndEars.UWP.Services { } } - static SolidColorBrush UpdateStatusColour(string status) { + static SolidColorBrush UpdateStatusColour(string status, int reading) { try { - return status.Equals("on", StringComparison.OrdinalIgnoreCase) ? - new SolidColorBrush(Colors.SeaGreen) : - new SolidColorBrush(Colors.DarkRed); - } + if (status.Equals("on", StringComparison.OrdinalIgnoreCase)) { + /* Note: Reading values breakdown. + * ======================================= + * 1. When testing the light meters, the base line for normal + * light is 48 or below. Anything above this is when one of + * the guys in the factory was welding. Becuase of this, + * I have set 0 to 48 as the 'default' status on the + * dashboard. + * + * 2. During testing we noticed the light meters would + * return 'negative light' values. There is a reason for + * this but that is out of the scope of this project. This + * project just needs to process the data. The negative + * light values are when the lights in the factory are off. + * The light meter is still running but there is no light + * to measure. So, everything is fine but it looks broken. + * The 'LightSkyBlue' colour is used to help relay this + * bit of information. + */ + if (reading > 0 && reading < 48) // On but no weld detected. + return new SolidColorBrush(Colors.LightSeaGreen); + if (reading > 48) // On and weld detected. + return new SolidColorBrush(Colors.DarkSeaGreen); + else { + // On but factory lights are off. + return new SolidColorBrush(Colors.LightSkyBlue); + } + } + else return new SolidColorBrush(Colors.DarkRed); } catch (Exception e) { Debug.WriteLine(e.Message); return new SolidColorBrush(Colors.DarkOrange);