1
0
Fork 0
Browse Source

leave notes, remove unused code and general tidy-up.

pull/6/head
Craig Oates 4 years ago
parent
commit
8eb9311d95
  1. 2
      src/EyesAndEars.UWP/EyesAndEars.UWP/EyesAndEars.UWP.csproj
  2. 1
      src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml.cs
  3. 9
      src/EyesAndEars.UWP/EyesAndEars.UWP/Models/Device.cs
  4. 19
      src/EyesAndEars.UWP/EyesAndEars.UWP/Models/FactoryDevice.cs
  5. 15
      src/EyesAndEars.UWP/EyesAndEars.UWP/Models/GalleryDevice.cs
  6. 28
      src/EyesAndEars.UWP/EyesAndEars.UWP/Services/DataServices.cs
  7. 2
      src/EyesAndEars.UWP/EyesAndEars.UWP/ViewModels/MainPageVM.cs

2
src/EyesAndEars.UWP/EyesAndEars.UWP/EyesAndEars.UWP.csproj

@ -124,8 +124,6 @@
</Compile>
<Compile Include="Models\Device.cs" />
<Compile Include="Models\DeviceStatus.cs" />
<Compile Include="Models\FactoryDevice.cs" />
<Compile Include="Models\GalleryDevice.cs" />
<Compile Include="Models\LightReading.cs" />
<Compile Include="Services\DataServices.cs" />
<Compile Include="ViewModels\MainPageVM.cs" />

1
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;

9
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;

19
src/EyesAndEars.UWP/EyesAndEars.UWP/Models/FactoryDevice.cs

@ -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;
}
}
}

15
src/EyesAndEars.UWP/EyesAndEars.UWP/Models/GalleryDevice.cs

@ -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;
}
}
}

28
src/EyesAndEars.UWP/EyesAndEars.UWP/Services/DataServices.cs

@ -11,7 +11,7 @@ namespace EyesAndEars.UWP.Services {
public static async Task<Device> 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) {

2
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.
*/