From 8eb9311d953d8c8b72ec5d2c8a544aee890ca5e1 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 18 Jan 2020 18:28:02 +0000 Subject: [PATCH] leave notes, remove unused code and general tidy-up. --- .../EyesAndEars.UWP/EyesAndEars.UWP.csproj | 2 -- .../EyesAndEars.UWP/MainPage.xaml.cs | 1 - .../EyesAndEars.UWP/Models/Device.cs | 9 ++---- .../EyesAndEars.UWP/Models/FactoryDevice.cs | 19 ------------- .../EyesAndEars.UWP/Models/GalleryDevice.cs | 15 ---------- .../EyesAndEars.UWP/Services/DataServices.cs | 28 +++++++++++++++++-- .../EyesAndEars.UWP/ViewModels/MainPageVM.cs | 2 +- 7 files changed, 28 insertions(+), 48 deletions(-) delete mode 100644 src/EyesAndEars.UWP/EyesAndEars.UWP/Models/FactoryDevice.cs delete mode 100644 src/EyesAndEars.UWP/EyesAndEars.UWP/Models/GalleryDevice.cs diff --git a/src/EyesAndEars.UWP/EyesAndEars.UWP/EyesAndEars.UWP.csproj b/src/EyesAndEars.UWP/EyesAndEars.UWP/EyesAndEars.UWP.csproj index 18666d5..d1df64f 100644 --- a/src/EyesAndEars.UWP/EyesAndEars.UWP/EyesAndEars.UWP.csproj +++ b/src/EyesAndEars.UWP/EyesAndEars.UWP/EyesAndEars.UWP.csproj @@ -124,8 +124,6 @@ - - diff --git a/src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml.cs b/src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml.cs index 7e8dd33..9c5f58d 100644 --- a/src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml.cs +++ b/src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml.cs @@ -1,7 +1,6 @@ using EyesAndEars.UWP.Services; using EyesAndEars.UWP.ViewModels; using System; -using System.Diagnostics; using Windows.ApplicationModel; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; diff --git a/src/EyesAndEars.UWP/EyesAndEars.UWP/Models/Device.cs b/src/EyesAndEars.UWP/EyesAndEars.UWP/Models/Device.cs index 3622127..e51532f 100644 --- a/src/EyesAndEars.UWP/EyesAndEars.UWP/Models/Device.cs +++ b/src/EyesAndEars.UWP/EyesAndEars.UWP/Models/Device.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Windows.UI; -using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Media; namespace EyesAndEars.UWP.Models { public class Device { @@ -20,7 +15,7 @@ namespace EyesAndEars.UWP.Models { public Device(int id, LightReading reading, DeviceStatus status, SolidColorBrush colour) { - + Id = id; LatestReading = reading; LatestStatus = status; diff --git a/src/EyesAndEars.UWP/EyesAndEars.UWP/Models/FactoryDevice.cs b/src/EyesAndEars.UWP/EyesAndEars.UWP/Models/FactoryDevice.cs deleted file mode 100644 index 080b53e..0000000 --- a/src/EyesAndEars.UWP/EyesAndEars.UWP/Models/FactoryDevice.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace EyesAndEars.UWP.Models { - public class FactoryDevice { - - public int Id { get; set; } - - public LightReading LatestReading { get; set; } - - public DeviceStatus LatestStatus { get; set; } - - public FactoryDevice() { } - - public FactoryDevice(int id, LightReading reading, DeviceStatus status) { - Id = id; - LatestReading = reading; - LatestStatus = status; - } - - } -} diff --git a/src/EyesAndEars.UWP/EyesAndEars.UWP/Models/GalleryDevice.cs b/src/EyesAndEars.UWP/EyesAndEars.UWP/Models/GalleryDevice.cs deleted file mode 100644 index 23c83f2..0000000 --- a/src/EyesAndEars.UWP/EyesAndEars.UWP/Models/GalleryDevice.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace EyesAndEars.UWP.Models { - public class GalleryDevice { - - public readonly int Id; - - public readonly DeviceStatus LatestStatus; - - public GalleryDevice() { } - - public GalleryDevice(int id, DeviceStatus status) { - Id = id; - LatestStatus = status; - } - } -} diff --git a/src/EyesAndEars.UWP/EyesAndEars.UWP/Services/DataServices.cs b/src/EyesAndEars.UWP/EyesAndEars.UWP/Services/DataServices.cs index 9da75a2..c67c2e2 100644 --- a/src/EyesAndEars.UWP/EyesAndEars.UWP/Services/DataServices.cs +++ b/src/EyesAndEars.UWP/EyesAndEars.UWP/Services/DataServices.cs @@ -11,7 +11,7 @@ namespace EyesAndEars.UWP.Services { public static async Task UpdateDevice(string url, int deviceId) { try { - var id = MapFactoryDeviceToGalleyDevice(deviceId); + var id = MapFactoryDeviceToGalleyDevice(deviceId); // Has note. var readingAPI = $"{url}/api/readings/latest/{id}"; var statusAPI = $"{url}/api/status/latest/{deviceId}"; var readingJSON = await WebServices.GetJSON(readingAPI); @@ -28,11 +28,33 @@ namespace EyesAndEars.UWP.Services { } static SolidColorBrush UpdateStatusColour(string status) { - return status.Equals("on", StringComparison.OrdinalIgnoreCase) ? - new SolidColorBrush(Colors.SeaGreen) : + return status.Equals("on", StringComparison.OrdinalIgnoreCase) ? + new SolidColorBrush(Colors.SeaGreen) : new SolidColorBrush(Colors.DarkRed); } + /* + * Note: The Purpose of Mapping a Factory to a Gallery Device. + * ================================================================ + * Every device in the project is paired up with another. + * Factory1 => Gallery1 | Device1 => Device4 + * Factory1 => Gallery2 | Device2 => Device5 + * Factory1 => Gallery3 | Device3 => Device6 + * At the moment, when a device completes a status update, each one + * is ran throught the "UpdateDevice" function (above). This means + * the latest light reading for a light meter (factory) must be + * retrieved when a galley-based device's status is updated. + * From a strict point-of-view, the gallery device does not need it + * so I should/could seperate out this functionality into seperate + * functions. For now though, a light reading is still needed to be + * retrieved because of the way the functions are called. + * This function just maps/pairs the (factory) light reading to the + * appropriate gallery device. By doing this, the gallery device + * has extra information on its paired up light meter. One way I + * have used that information is to show a small piece of text in + * the gallery status box to quickly check the accuracy of the + * synchronisation between the factory and gallery devices. + */ static int MapFactoryDeviceToGalleyDevice(int deviceId) { int id = 0; if (deviceId > 3) { diff --git a/src/EyesAndEars.UWP/EyesAndEars.UWP/ViewModels/MainPageVM.cs b/src/EyesAndEars.UWP/EyesAndEars.UWP/ViewModels/MainPageVM.cs index 74f86fb..7d4c379 100644 --- a/src/EyesAndEars.UWP/EyesAndEars.UWP/ViewModels/MainPageVM.cs +++ b/src/EyesAndEars.UWP/EyesAndEars.UWP/ViewModels/MainPageVM.cs @@ -10,7 +10,7 @@ namespace EyesAndEars.UWP.ViewModels { * Because the projects requirements are fixed in-place and this * program does not have long-term requirements, I decided to not worry * about long-term maintenance benefits. If something comes from this - * projects afterwards, the duplicated nature of the code below will + * project afterwards, the duplicated nature of the code below will * probably need refacorting but I will leave that to the person * needing to make that call at that time. */