51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
namespace Common.UI.ViewModels
|
|
{
|
|
using Common.UI.Infrastructure;
|
|
|
|
using System.Collections.ObjectModel;
|
|
using System.Windows.Input;
|
|
|
|
public class ManualProgrammingVM : VM<ManualProgrammingVM>
|
|
{
|
|
private readonly string[] comPorts;
|
|
|
|
public ManualProgrammingVM()
|
|
{
|
|
this.comPorts = Appsettings.GetSIRTComPorts();
|
|
this.Logging = new ObservableCollection<string>();
|
|
this.ActivateSIRTS = new Command(this.ActivateSIRTSCommand);
|
|
}
|
|
|
|
public ICommand ActivateSIRTS { get; }
|
|
|
|
public ObservableCollection<string> Logging { get; }
|
|
|
|
private void ActivateSIRTSCommand()
|
|
{
|
|
this.InvokeTaskAsync(() =>
|
|
{
|
|
this.Logging.Clear();
|
|
|
|
foreach (var comPort in comPorts)
|
|
{
|
|
this.InvokeTaskAsync(() =>
|
|
{
|
|
var portName = comPort;
|
|
var sirtId = default(string);
|
|
var frequency = default(int);
|
|
|
|
AppHost.SIRTHub.Close(comPort);
|
|
|
|
for (var i = 0; i < 3 && !AppHost.SIRTHub.TryOpen(comPort, out sirtId, out frequency); i++)
|
|
{
|
|
this.Logging.Add($"{comPort} - {frequency} - {sirtId}");
|
|
}
|
|
|
|
this.Logging.Add($"{comPort} - {frequency} - {sirtId}");
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|