diff --git a/src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml b/src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml index 757992b..0d2f1d4 100644 --- a/src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml +++ b/src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml @@ -55,7 +55,8 @@ + FallbackValue=Pink}" Margin="0,0,0,12" Width="300" Height="300" + CornerRadius="10"> + FallbackValue=Orange}" Margin="12,0,12,12" Width="300" Height="300" + CornerRadius="10"> - - + + - - + + - - + + - - + + - - + + @@ -143,7 +150,8 @@ + FallbackValue=Pink}" Margin="0,0,0,12" Width="300" Height="150" + CornerRadius="10"> + FallbackValue=Pink}" Margin="0,0,0,12" Width="300" Height="150" + CornerRadius="10"> + Version="2021.1.14.0" /> diff --git a/src/EyesAndEars.UWP/EyesAndEars.UWP/Services/DataServices.cs b/src/EyesAndEars.UWP/EyesAndEars.UWP/Services/DataServices.cs index b93de54..fa2916a 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, r.reading); + var c = UpdateStatusColour(deviceId, s.status, r.reading); return new Device(deviceId, r, s, c); } catch (Exception e) { @@ -28,38 +28,44 @@ namespace EyesAndEars.UWP.Services { } } - static SolidColorBrush UpdateStatusColour(string status, int reading) { + private static SolidColorBrush UpdateStatusColour(int device, string status, int reading) { try { 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. + + /* Note: 'Negative Light' Levels. + * ======================================================== + * The light meters will record 'negative light' values + * when the factory lights are off. This does not mean + * the light meters are not functioning properly. With that + * said, this dashboard make it look like they are. Because + * of this, the blocks in the dashboard will change to + * 'LightSkyBlue' to help indicate the change is something + * the system knows about and everything is fine -- nothing + * is broken. + */ + + if (device == 1) { + if (reading > 0 && reading <= 38) // No weld detected. + return new SolidColorBrush(Colors.LightSeaGreen); + if (reading > 38) // Weld detected. + return new SolidColorBrush(Colors.DarkSeaGreen); + } + else if (device == 2) { + if (reading > 0 && reading <= 48) // No weld detected. + return new SolidColorBrush(Colors.LightSeaGreen); + if (reading > 48) // Weld detected. + return new SolidColorBrush(Colors.DarkSeaGreen); + } + else if (reading < 0) { + // The device is on but factory lights are off. return new SolidColorBrush(Colors.LightSkyBlue); } } - else return new SolidColorBrush(Colors.DarkRed); } + // The device is off. + return new SolidColorBrush(Colors.DarkRed); + } catch (Exception e) { + // Extra protection to if-check at top of this try block. Debug.WriteLine(e.Message); return new SolidColorBrush(Colors.DarkOrange); }