1
0
Fork 0
Browse Source

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.
pull/6/head
Craig Oates 3 years ago
parent
commit
8767f61397
  1. 29
      src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml
  2. 37
      src/EyesAndEars.UWP/EyesAndEars.UWP/Services/DataServices.cs

29
src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml

@ -22,7 +22,7 @@
<TextBlock x:Name="Time" Grid.Row="0" FontSize="78" <TextBlock x:Name="Time" Grid.Row="0" FontSize="78"
VerticalAlignment="Stretch" HorizontalAlignment="Right" VerticalAlignment="Stretch" HorizontalAlignment="Right"
Text="{x:Bind _vm.CurrentTime, Mode=OneWay, FallbackValue=00:00}" Text="{x:Bind _vm.CurrentTime, Mode=OneWay, FallbackValue=00}"
Margin="0" Padding="0"/> Margin="0" Padding="0"/>
<StackPanel Grid.Row="0" Orientation="Horizontal" <StackPanel Grid.Row="0" Orientation="Horizontal"
@ -86,16 +86,21 @@
</StackPanel> </StackPanel>
</Grid> </Grid>
<Grid Grid.Row="0" Grid.Column="2"> <Grid Grid.Row="0" Grid.Column="2" Grid.RowSpan="2">
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Rectangle Fill="SeaGreen" Width="92" Height="52"/> <Rectangle Fill="LightSeaGreen" Width="92" Height="52"/>
<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">
<Rectangle Fill="DarkRed" Width="92" Height="52"/> <Rectangle Fill="DarkSeaGreen" Width="92" Height="52"/>
<TextBlock Text="Device is off" FontSize="42" <TextBlock Text="Welding detected" FontSize="42"
VerticalAlignment="Center" Margin="12,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Rectangle Fill="LightSkyBlue" Width="92" Height="52"/>
<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">
@ -103,7 +108,19 @@
<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> <StackPanel Orientation="Horizontal">
<Rectangle Fill="DarkRed" Width="92" Height="52"/>
<TextBlock Text="Device is off" FontSize="42"
VerticalAlignment="Center" Margin="12,0"/>
</StackPanel>
<TextBlock Text="Factory: 07:00 - 16:00" FontSize="42"
VerticalAlignment="Center" Margin="0"/>
<TextBlock Text="Gallery: 10:00 - 18:00" FontSize="42"
VerticalAlignment="Center" Margin="0"/>
<TextBlock Text="Dashboard updates at slower rate than devices."
FontSize="18" Margin="0" Foreground="SlateGray"
VerticalAlignment="Center"/>
</StackPanel>
</Grid> </Grid>
<!-- This device is not in use. Uncomment if becomes available. --> <!-- This device is not in use. Uncomment if becomes available. -->

37
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); var c = UpdateStatusColour(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,12 +28,37 @@ namespace EyesAndEars.UWP.Services {
} }
} }
static SolidColorBrush UpdateStatusColour(string status) { static SolidColorBrush UpdateStatusColour(string status, int reading) {
try { try {
return status.Equals("on", StringComparison.OrdinalIgnoreCase) ? if (status.Equals("on", StringComparison.OrdinalIgnoreCase)) {
new SolidColorBrush(Colors.SeaGreen) : /* Note: Reading values breakdown.
new SolidColorBrush(Colors.DarkRed); * =======================================
} * 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) { catch (Exception e) {
Debug.WriteLine(e.Message); Debug.WriteLine(e.Message);
return new SolidColorBrush(Colors.DarkOrange); return new SolidColorBrush(Colors.DarkOrange);