|
|
|
@ -1,6 +1,7 @@ |
|
|
|
using RobotClientWpf.Utilities; |
|
|
|
using RobotClientWpf.Utilities; |
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Windows; |
|
|
|
using System.Windows; |
|
|
|
using System.Windows.Controls; |
|
|
|
using System.Windows.Controls; |
|
|
|
|
|
|
|
|
|
|
|
@ -13,15 +14,18 @@ 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; |
|
|
|
|
|
|
|
|
|
|
|
public ConfigView() |
|
|
|
public ConfigView() |
|
|
|
{ |
|
|
|
{ |
|
|
|
InitializeComponent(); |
|
|
|
InitializeComponent(); |
|
|
|
|
|
|
|
this.EnableRobotConfigurationOptions(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void SetChallengeFactory(ChallengeFactory challenge) |
|
|
|
public void InitializeChildView(ChallengeFactory challenge, MainWindow parent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
this.challenge = challenge; |
|
|
|
this.challenge = challenge; |
|
|
|
|
|
|
|
this.mainWindow = parent; |
|
|
|
this.challenge.RobotMobile.LineSensor.NewCalibrationDataArrived += LineSensor_NewCalibrationDataArrived; |
|
|
|
this.challenge.RobotMobile.LineSensor.NewCalibrationDataArrived += LineSensor_NewCalibrationDataArrived; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -89,5 +93,57 @@ namespace RobotClientWpf.Views |
|
|
|
{ |
|
|
|
{ |
|
|
|
this.challenge?.RobotStationary.SplitFlap.InitializeAllSplitflaps(); |
|
|
|
this.challenge?.RobotStationary.SplitFlap.InitializeAllSplitflaps(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void tbRobotConfiguratorHostname_TextChanged(object sender, TextChangedEventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
this.EnableRobotConfigurationOptions(String.IsNullOrEmpty(UIAccessHelpers.GetTextboxText(this.tbRobotConfiguratorHostname)) == false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void EnableRobotConfigurationOptions(bool enabled) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UIAccessHelpers.SetButtonState(btnSetBrokerIp, enabled); |
|
|
|
|
|
|
|
UIAccessHelpers.SetButtonState(btnReboot, enabled); |
|
|
|
|
|
|
|
UIAccessHelpers.SetButtonState(btnSetModeStationary, enabled); |
|
|
|
|
|
|
|
UIAccessHelpers.SetButtonState(btnSetModeMobile, enabled); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void btnClearRobotConfHostname_Click(object sender, RoutedEventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UIAccessHelpers.SetTextboxText(tbRobotConfiguratorHostname, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async void btnSetBrokerIp_Click(object sender, RoutedEventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (this.mainWindow == null) return; |
|
|
|
|
|
|
|
UIAccessHelpers.SetButtonState(btnSetBrokerIp, false); |
|
|
|
|
|
|
|
var brokerIp = UIAccessHelpers.GetTextboxText(this.mainWindow.tbIp); |
|
|
|
|
|
|
|
var robotHostname = UIAccessHelpers.GetTextboxText(this.tbRobotConfiguratorHostname); |
|
|
|
|
|
|
|
await Task.Run(() => RobotLib.IndependentRobotConfigurator.Adopt(robotHostname, brokerIp)); |
|
|
|
|
|
|
|
UIAccessHelpers.SetButtonState(btnSetBrokerIp, true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async void btnReboot_Click(object sender, RoutedEventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UIAccessHelpers.SetButtonState(btnReboot, false); |
|
|
|
|
|
|
|
var robotHostname = UIAccessHelpers.GetTextboxText(this.tbRobotConfiguratorHostname); |
|
|
|
|
|
|
|
await Task.Run(() => RobotLib.IndependentRobotConfigurator.RebootEsp32(robotHostname)); |
|
|
|
|
|
|
|
UIAccessHelpers.SetButtonState(btnReboot, true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async void btnSetModeStationary_Click(object sender, RoutedEventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UIAccessHelpers.SetButtonState(btnSetModeStationary, false); |
|
|
|
|
|
|
|
var robotHostname = UIAccessHelpers.GetTextboxText(this.tbRobotConfiguratorHostname); |
|
|
|
|
|
|
|
await Task.Run(() => RobotLib.IndependentRobotConfigurator.SetRobotMode(robotHostname, "s")); |
|
|
|
|
|
|
|
UIAccessHelpers.SetButtonState(btnSetModeStationary, true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async void btnSetModeMobile_Click(object sender, RoutedEventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UIAccessHelpers.SetButtonState(btnSetModeMobile, false); |
|
|
|
|
|
|
|
var robotHostname = UIAccessHelpers.GetTextboxText(this.tbRobotConfiguratorHostname); |
|
|
|
|
|
|
|
await Task.Run(() => RobotLib.IndependentRobotConfigurator.SetRobotMode(robotHostname, "m")); |
|
|
|
|
|
|
|
UIAccessHelpers.SetButtonState(btnSetModeMobile, true); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|