1
0
Fork 0
Browse Source

fine-tune the colour changes for each device and its status.

There was a case where the device status would change to the 'low light detected' (light sky blue) when on the border between a weld being detected and not. This commit addresses that. Also, both Light Meters have been installed at this point and it is apparent both of the welding booths have different light levels. Becuase of this, the dashboard now has code in place which seperates the update-checks to match the device/welding booth. In other words, factory1 does not go dark see green at factory2's light levels.
stable
Craig Oates 3 years ago
parent
commit
690a9dd5dd
  1. 37
      src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml
  2. 2
      src/EyesAndEars.UWP/EyesAndEars.UWP/Package.appxmanifest
  3. 60
      src/EyesAndEars.UWP/EyesAndEars.UWP/Services/DataServices.cs

37
src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml

@ -55,7 +55,8 @@
<Grid x:Name="Factory1Grid" Grid.Row="0" Grid.Column="0" <Grid x:Name="Factory1Grid" Grid.Row="0" Grid.Column="0"
Background="{x:Bind _vm.Device1.StatusColour, Mode=OneWay, Background="{x:Bind _vm.Device1.StatusColour, Mode=OneWay,
FallbackValue=Pink}" Margin="0,0,0,12" Width="300" Height="300"> FallbackValue=Pink}" Margin="0,0,0,12" Width="300" Height="300"
CornerRadius="10">
<StackPanel Margin="12" VerticalAlignment="Stretch"> <StackPanel Margin="12" VerticalAlignment="Stretch">
<TextBlock x:Name="Factory1Time" <TextBlock x:Name="Factory1Time"
Text="{x:Bind _vm.Device1.LatestReading.time, Text="{x:Bind _vm.Device1.LatestReading.time,
@ -72,7 +73,8 @@
<Grid x:Name="Factory2Grid" Grid.Row="0" Grid.Column="1" <Grid x:Name="Factory2Grid" Grid.Row="0" Grid.Column="1"
Background="{x:Bind _vm.Device2.StatusColour, Mode=OneWay, Background="{x:Bind _vm.Device2.StatusColour, Mode=OneWay,
FallbackValue=Orange}" Margin="12,0,12,12" Width="300" Height="300"> FallbackValue=Orange}" Margin="12,0,12,12" Width="300" Height="300"
CornerRadius="10">
<StackPanel Margin="12" VerticalAlignment="Stretch"> <StackPanel Margin="12" VerticalAlignment="Stretch">
<TextBlock x:Name="Factory2Time" Foreground="White" FontSize="24" <TextBlock x:Name="Factory2Time" Foreground="White" FontSize="24"
Text="{x:Bind _vm.Device2.LatestReading.time, Text="{x:Bind _vm.Device2.LatestReading.time,
@ -88,28 +90,33 @@
<Grid Grid.Row="0" Grid.Column="2" Grid.RowSpan="2"> <Grid Grid.Row="0" Grid.Column="2" Grid.RowSpan="2">
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
<Rectangle Fill="LightSeaGreen" Width="92" Height="52"/> <Rectangle Fill="LightSeaGreen" Width="92" Height="52"
RadiusX="5" RadiusY="5"/>
<TextBlock Text="Device is on" FontSize="42" <TextBlock Text="Device is on" FontSize="42"
VerticalAlignment="Center" Margin="12,0"/> VerticalAlignment="Center" Margin="12,0"/>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
<Rectangle Fill="DarkSeaGreen" Width="92" Height="52"/> <Rectangle Fill="DarkSeaGreen" Width="92" Height="52"
RadiusX="5" RadiusY="5"/>
<TextBlock Text="Welding detected" FontSize="42" <TextBlock Text="Welding detected" FontSize="42"
VerticalAlignment="Center" Margin="12,0"/> VerticalAlignment="Center" Margin="12,0"/>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
<Rectangle Fill="LightSkyBlue" Width="92" Height="52"/> <Rectangle Fill="LightSkyBlue" Width="92" Height="52"
RadiusX="5" RadiusY="5"/>
<TextBlock Text="Low light in factory" FontSize="42" <TextBlock Text="Low light in factory" FontSize="42"
VerticalAlignment="Center" Margin="12,0"/> VerticalAlignment="Center" Margin="12,0"/>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
<Rectangle Fill="DarkOrange" Width="92" Height="52"/> <Rectangle Fill="DarkOrange" Width="92" Height="52"
RadiusX="5" RadiusY="5"/>
<TextBlock Text="Unable to retrieve data" FontSize="42" <TextBlock Text="Unable to retrieve data" FontSize="42"
VerticalAlignment="Center" Margin="12,0"/> VerticalAlignment="Center" Margin="12,0"/>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
<Rectangle Fill="DarkRed" Width="92" Height="52"/> <Rectangle Fill="DarkRed" Width="92" Height="52"
RadiusX="5" RadiusY="5"/>
<TextBlock Text="Device is off" FontSize="42" <TextBlock Text="Device is off" FontSize="42"
VerticalAlignment="Center" Margin="12,0"/> VerticalAlignment="Center" Margin="12,0"/>
</StackPanel> </StackPanel>
@ -143,7 +150,8 @@
<Grid x:Name="Gallery1Grid" Grid.Row="1" Grid.Column="0" <Grid x:Name="Gallery1Grid" Grid.Row="1" Grid.Column="0"
Background="{x:Bind _vm.Device4.StatusColour, Mode=OneWay, Background="{x:Bind _vm.Device4.StatusColour, Mode=OneWay,
FallbackValue=Pink}" Margin="0,0,0,12" Width="300" Height="150"> FallbackValue=Pink}" Margin="0,0,0,12" Width="300" Height="150"
CornerRadius="10">
<StackPanel Margin="12" VerticalAlignment="Bottom"> <StackPanel Margin="12" VerticalAlignment="Bottom">
<TextBlock x:Name="Gallery1Time" Foreground="White" <TextBlock x:Name="Gallery1Time" Foreground="White"
Text="{x:Bind _vm.Device4.LatestStatus.time, Text="{x:Bind _vm.Device4.LatestStatus.time,
@ -159,7 +167,8 @@
<Grid x:Name="Gallery2Grid" Grid.Row="1" Grid.Column="1" <Grid x:Name="Gallery2Grid" Grid.Row="1" Grid.Column="1"
Background="{x:Bind _vm.Device5.StatusColour, Mode=OneWay, Background="{x:Bind _vm.Device5.StatusColour, Mode=OneWay,
FallbackValue=Pink}" Margin="0,0,0,12" Width="300" Height="150"> FallbackValue=Pink}" Margin="0,0,0,12" Width="300" Height="150"
CornerRadius="10">
<StackPanel Margin="12" VerticalAlignment="Bottom"> <StackPanel Margin="12" VerticalAlignment="Bottom">
<TextBlock x:Name="Gallery2Time" Foreground="White" FontSize="24" <TextBlock x:Name="Gallery2Time" Foreground="White" FontSize="24"
Text="{x:Bind _vm.Device5.LatestStatus.time, Text="{x:Bind _vm.Device5.LatestStatus.time,

2
src/EyesAndEars.UWP/EyesAndEars.UWP/Package.appxmanifest

@ -9,7 +9,7 @@
<Identity <Identity
Name="55acd946-60d4-4776-b6c6-03fef750e3da" Name="55acd946-60d4-4776-b6c6-03fef750e3da"
Publisher="CN=Craig Oates" Publisher="CN=Craig Oates"
Version="2020.1.14.0" /> Version="2021.1.14.0" />
<mp:PhoneIdentity PhoneProductId="55acd946-60d4-4776-b6c6-03fef750e3da" PhonePublisherId="00000000-0000-0000-0000-000000000000"/> <mp:PhoneIdentity PhoneProductId="55acd946-60d4-4776-b6c6-03fef750e3da" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

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

@ -19,7 +19,7 @@ namespace EyesAndEars.UWP.Services {
var statusJSON = await WebServices.GetJSON(statusAPI); var statusJSON = await WebServices.GetJSON(statusAPI);
var r = MapToLightReading(readingJSON); var r = MapToLightReading(readingJSON);
var s = MapToDeviceStatus(statusJSON); 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); return new Device(deviceId, r, s, c);
} }
catch (Exception e) { 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 { try {
if (status.Equals("on", StringComparison.OrdinalIgnoreCase)) { if (status.Equals("on", StringComparison.OrdinalIgnoreCase)) {
/* Note: Reading values breakdown.
* ======================================= /* Note: 'Negative Light' Levels.
* 1. When testing the light meters, the base line for normal * ========================================================
* light is 48 or below. Anything above this is when one of * The light meters will record 'negative light' values
* the guys in the factory was welding. Becuase of this, * when the factory lights are off. This does not mean
* I have set 0 to 48 as the 'default' status on the * the light meters are not functioning properly. With that
* dashboard. * said, this dashboard make it look like they are. Because
* * of this, the blocks in the dashboard will change to
* 2. During testing we noticed the light meters would * 'LightSkyBlue' to help indicate the change is something
* return 'negative light' values. There is a reason for * the system knows about and everything is fine -- nothing
* this but that is out of the scope of this project. This * is broken.
* 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 if (device == 1) {
* to measure. So, everything is fine but it looks broken. if (reading > 0 && reading <= 38) // No weld detected.
* The 'LightSkyBlue' colour is used to help relay this return new SolidColorBrush(Colors.LightSeaGreen);
* bit of information. if (reading > 38) // Weld detected.
*/ return new SolidColorBrush(Colors.DarkSeaGreen);
if (reading > 0 && reading < 48) // On but no weld detected. }
return new SolidColorBrush(Colors.LightSeaGreen); else if (device == 2) {
if (reading > 48) // On and weld detected. if (reading > 0 && reading <= 48) // No weld detected.
return new SolidColorBrush(Colors.DarkSeaGreen); return new SolidColorBrush(Colors.LightSeaGreen);
else { if (reading > 48) // Weld detected.
// On but factory lights are off. return new SolidColorBrush(Colors.DarkSeaGreen);
}
else if (reading < 0) {
// The device is on but factory lights are off.
return new SolidColorBrush(Colors.LightSkyBlue); return new SolidColorBrush(Colors.LightSkyBlue);
} }
} }
else return new SolidColorBrush(Colors.DarkRed); } // The device is off.
return new SolidColorBrush(Colors.DarkRed);
}
catch (Exception e) { catch (Exception e) {
// Extra protection to if-check at top of this try block.
Debug.WriteLine(e.Message); Debug.WriteLine(e.Message);
return new SolidColorBrush(Colors.DarkOrange); return new SolidColorBrush(Colors.DarkOrange);
} }