updates in UI, added present counter

main
Jonas Arnold 4 years ago
parent 949b936ed6
commit 89e9e10b6e
  1. 2
      ADIS_Csharp/RobotClientWpf/MainWindow.xaml
  2. 4
      ADIS_Csharp/RobotClientWpf/MainWindow.xaml.cs
  3. 7
      ADIS_Csharp/RobotClientWpf/Views/MainView.xaml
  4. 24
      ADIS_Csharp/RobotClientWpf/Views/MainView.xaml.cs
  5. 2
      ADIS_Csharp/RobotLib/Battery/DevBattery.cs

@ -12,7 +12,7 @@
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="40"/> <RowDefinition Height="40"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="260"/> <RowDefinition Height="220"/>
<!-- <RowDefinition Height="30"/> Bottom message (NOT USED) --> <!-- <RowDefinition Height="30"/> Bottom message (NOT USED) -->
</Grid.RowDefinitions> </Grid.RowDefinitions>

@ -61,7 +61,7 @@ namespace RobotClientWpf
// set color according to assessed state // set color according to assessed state
if(e.Online == false) if(e.Online == false)
{ {
log.Warn("Robot Stationary seems to be offline."); log.Warn($"Robot Stationary seems to be offline. No response in {e.Seconds}s.");
} }
else else
{ {
@ -75,7 +75,7 @@ namespace RobotClientWpf
// set color according to assessed state // set color according to assessed state
if (e.Online == false) if (e.Online == false)
{ {
log.Warn("Robot Mobile seems to be offline."); log.Warn($"Robot Mobile seems to be offline. No response in {e.Seconds}s.");
} }
else else
{ {

@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:RobotClientWpf.Views" xmlns:local="clr-namespace:RobotClientWpf.Views"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="430" d:DesignWidth="1200" FontSize="15" KeyDown="UserControl_KeyDown"> d:DesignHeight="430" d:DesignWidth="1200" FontSize="15">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
@ -19,7 +19,10 @@
<!-- RIGHT SIDE --> <!-- RIGHT SIDE -->
<StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="1" Grid.RowSpan="2"> <StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="1" Grid.RowSpan="2">
<GroupBox Header="Splitflap Display" Margin="10" HorizontalAlignment="Right"> <GroupBox Header="Splitflap Display" Margin="10" HorizontalAlignment="Right">
<TextBox x:Name="tbSplitflapText" Height="100" Width="300" FontSize="40" IsReadOnly="True" TextWrapping="NoWrap" HorizontalAlignment="Left"/> <TextBox x:Name="tbSplitflapText" Height="100" Width="250" FontSize="70" IsReadOnly="True" TextWrapping="NoWrap" TextAlignment="Center"/>
</GroupBox>
<GroupBox Header="Presents Counted" Margin="10" HorizontalAlignment="Right">
<TextBox x:Name="tbPresentCount" Height="100" Width="250" FontSize="70" IsReadOnly="True" TextWrapping="NoWrap" TextAlignment="Center"/>
</GroupBox> </GroupBox>
</StackPanel> </StackPanel>

@ -1,4 +1,5 @@
using RobotClientWpf.Utilities; using RobotClientWpf.Utilities;
using RobotLib.Status;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
@ -12,7 +13,7 @@ namespace RobotClientWpf.Views
private static readonly NLog.Logger log = NLog.LogManager.GetCurrentClassLogger(); private static readonly NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
private ChallengeFactory? challenge; private ChallengeFactory? challenge;
private MainWindow? mainWindow; private MainWindow? mainWindow;
private const int AMOUNT_SPEED_ADDED_PER_CLICK = 200; private const int AMOUNT_SPEED_ADDED_PER_CLICK = 350;
private const int TURN_ANGLE_PER_CLICK = 30; private const int TURN_ANGLE_PER_CLICK = 30;
public MainView() public MainView()
@ -27,6 +28,22 @@ namespace RobotClientWpf.Views
// subscribe to events // subscribe to events
this.challenge.RobotStationary.SplitFlap.SplitFlapDisplayChanged += this.SplitFlap_SplitFlapDisplayChanged; this.challenge.RobotStationary.SplitFlap.SplitFlapDisplayChanged += this.SplitFlap_SplitFlapDisplayChanged;
this.challenge.RobotMobile.Battery.BatteryChanged += Battery_BatteryChanged; this.challenge.RobotMobile.Battery.BatteryChanged += Battery_BatteryChanged;
this.challenge.RobotMobile.Status.PresentChanged += Status_PresentChanged;
this.challenge.RobotMobile.Status.StatusChanged += Status_StatusChanged;
}
private void Status_StatusChanged(object? sender, RobotLib.Status.StatusEventArgs e)
{
// if status manual is set => reset present counter
if(e.Status == RoboStatus.Manual || e.Status == RoboStatus.Auto)
{
UIAccessHelpers.SetTextboxText(tbPresentCount, "");
}
}
private void Status_PresentChanged(object? sender, RobotLib.Status.PresentEventArgs e)
{
UIAccessHelpers.SetTextboxText(tbPresentCount, e.Present.ToString());
} }
private void Battery_BatteryChanged(object? sender, RobotLib.Battery.BatteryEventArgs e) private void Battery_BatteryChanged(object? sender, RobotLib.Battery.BatteryEventArgs e)
@ -101,10 +118,5 @@ namespace RobotClientWpf.Views
e.Handled = true; e.Handled = true;
} }
} }
private void UserControl_KeyDown(object sender, KeyEventArgs e)
{
this.HandleKeyDownEvent(sender, e);
}
} }
} }

@ -11,7 +11,7 @@ namespace RobotLib.Battery
{ {
private float voltage; private float voltage;
private int lastResponseS = 1000; // seconds since last response private int lastResponseS = 1000; // seconds since last response
private const int offlineTresholdS = 11; // treshold when to assess a robot as offline (no response for x sec) private const int offlineTresholdS = 25; // treshold when to assess a robot as offline (no response for x sec)
private Stopwatch stopwatchLastResponse = new(); private Stopwatch stopwatchLastResponse = new();
private const string TOPIC_ROBO_REQ_BATTERY = "/both/cmd/battery/get_volt"; private const string TOPIC_ROBO_REQ_BATTERY = "/both/cmd/battery/get_volt";

Loading…
Cancel
Save