Changed: MachinePage to new Machine API

This commit is contained in:
TheJoKlLa 2021-09-16 22:50:01 +02:00
parent 3be3bbabea
commit dfeb167691
6 changed files with 61 additions and 77 deletions

View File

@ -41,16 +41,18 @@ namespace Borepin
containerRegistry.RegisterForNavigation<MachinePage, MachinePageModel>(); containerRegistry.RegisterForNavigation<MachinePage, MachinePageModel>();
containerRegistry.RegisterForNavigation<SettingsPage>(); containerRegistry.RegisterForNavigation<SettingsPage>();
containerRegistry.RegisterForNavigation<MachineListPage, MachineListPageModel>(); containerRegistry.RegisterForNavigation<MachineListPage, MachineListPageModel>();
containerRegistry.RegisterForNavigation<LoginPasswordPage, LoginPasswordPageModel>("AddServerProcess_LoginPasswordPage");
containerRegistry.RegisterForNavigation<HostSelectPage, HostSelectPageModel>("AddServerProcess_HostSelectPage");
containerRegistry.RegisterForNavigation<LoginChoosePage, LoginChoosePageModel>("AddServerProcess_LoginChoosePage");
containerRegistry.RegisterForNavigation<ServerListPage, ServerListPageModel>(); containerRegistry.RegisterForNavigation<ServerListPage, ServerListPageModel>();
containerRegistry.RegisterForNavigation<ServerPage, ServerPageModel>(); containerRegistry.RegisterForNavigation<ServerPage, ServerPageModel>();
containerRegistry.RegisterForNavigation<ListPage, ListPageModel>(); containerRegistry.RegisterForNavigation<ListPage, ListPageModel>();
containerRegistry.RegisterForNavigation<TestPage, TestPageModel>(); containerRegistry.RegisterForNavigation<TestPage, TestPageModel>();
containerRegistry.RegisterForNavigation<WelcomePage, WelcomePageModel>("SetUpProcess_WelcomePage"); containerRegistry.RegisterForNavigation<WelcomePage, WelcomePageModel>("SetUpProcess_WelcomePage");
containerRegistry.RegisterForNavigation<ScanPage, ScanPageModel>("SetUpProcess_ScanPage"); containerRegistry.RegisterForNavigation<ScanPage, ScanPageModel>("SetUpProcess_ScanPage");
containerRegistry.RegisterForNavigation<LoginPasswordPage, LoginPasswordPageModel>("AddServerProcess_LoginPasswordPage");
containerRegistry.RegisterForNavigation<HostSelectPage, HostSelectPageModel>("AddServerProcess_HostSelectPage");
containerRegistry.RegisterForNavigation<LoginChoosePage, LoginChoosePageModel>("AddServerProcess_LoginChoosePage");
// Register Dialog // Register Dialog
containerRegistry.RegisterDialog<ConfirmDialog, ConfirmDialogModel>(); containerRegistry.RegisterDialog<ConfirmDialog, ConfirmDialogModel>();

View File

@ -98,6 +98,9 @@
<EmbeddedResource Update="Page\SetUpProcess\WelcomePage.xaml"> <EmbeddedResource Update="Page\SetUpProcess\WelcomePage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator> <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Update="Page\StartUpDistributorPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Page\TestPage.xaml"> <EmbeddedResource Update="Page\TestPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator> <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource> </EmbeddedResource>

View File

@ -21,8 +21,8 @@
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}"> <StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<Label Text="{Binding Name}" Style="{StaticResource LabelStyle_Title}"/> <Label Text="{Binding Name}" Style="{StaticResource LabelStyle_Title}"/>
<Button Text="Use" Command="{Binding UseMachineCommand}" IsVisible="{Binding CanUse}" Style="{StaticResource Style_Button_Primary}"/> <Button Text="Use" Command="{Binding UseMachineCommand}" IsVisible="{Binding MachineItem.Use, Converter=IsNotNullBoolConverter}" Style="{StaticResource Style_Button_Primary}"/>
<Button Text="GiveBack" Command="{Binding GiveBackMachineCommand}" IsVisible="{Binding CanGiveBack}" Style="{StaticResource Style_Button_Primary}"/> <Button Text="GiveBack" Command="{Binding GiveBackMachineCommand}" IsVisible="{Binding MachineItem.Inuse, Converter=IsNotNullBoolConverter}" Style="{StaticResource Style_Button_Primary}"/>
</StackLayout> </StackLayout>
</StackLayout> </StackLayout>
</ContentPage.Content> </ContentPage.Content>

View File

@ -5,8 +5,8 @@ using System.Windows.Input;
using Prism.Commands; using Prism.Commands;
using Prism.Navigation; using Prism.Navigation;
using Borepin.Service.BFFH; using Borepin.Service.BFFH;
using Borepin.Model;
using Borepin.Base; using Borepin.Base;
using FabAccessAPI.Schema;
namespace Borepin.PageModel namespace Borepin.PageModel
{ {
@ -37,22 +37,18 @@ namespace Borepin.PageModel
IsConnected = true; IsConnected = true;
} }
FabAccessAPI.Schema.IMachineSystem machineInterface = await _BFFHService.GetMachineSystemInterface(); IMachineSystem machineInterface = await _BFFHService.GetMachineSystemInterface();
FabAccessAPI.Schema.MachineSystem.IInfoInterface infoInterface = await machineInterface.Info(); MachineSystem.IInfoInterface infoInterface = await machineInterface.Info();
//IReadOnlyList<FabAccessAPI.Machine> machine_list = await machineInterface.Info(); IReadOnlyList<Machine> machine_list = await infoInterface.GetMachineList();
//foreach (FabAccessAPI.Machine machine in machine_list)
//{
// list.Add(new Machine() { Instance = machine, MInfo = await machine.GetMInfo() });
//}
//List<MachineListItemViewModel> viewmodel_list = new List<MachineListItemViewModel>(); List<MachineListItemViewModel> viewmodel_list = new List<MachineListItemViewModel>();
//foreach (Machine machine in list) foreach (Machine machine in machine_list)
//{ {
// viewmodel_list.Add(new MachineListItemViewModel(machine)); viewmodel_list.Add(new MachineListItemViewModel(machine));
//} }
MachineListItemViewModel_List = null;//viewmodel_list; MachineListItemViewModel_List = viewmodel_list;
IsBusy = false; IsBusy = false;
} }
@ -87,7 +83,7 @@ namespace Borepin.PageModel
NavigationParameters parameters = new NavigationParameters NavigationParameters parameters = new NavigationParameters
{ {
//{ "instance", viewmodel.Instance } { "id", viewmodel.Instance.Id }
}; };
INavigationResult result = await _NavigationService.NavigateAsync($"MachinePage", parameters); INavigationResult result = await _NavigationService.NavigateAsync($"MachinePage", parameters);

View File

@ -1,66 +1,56 @@
using Borepin.Base; using Borepin.Base;
using Borepin.Model;
using Prism.Commands; using Prism.Commands;
using Prism.Navigation; using Prism.Navigation;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Input; using System.Windows.Input;
using FabAccessAPI.Schema;
using Borepin.Service.BFFH;
using static FabAccessAPI.Schema.MachineSystem;
namespace Borepin.PageModel namespace Borepin.PageModel
{ {
public class MachinePageModel : PageModelBase public class MachinePageModel : PageModelBase
{ {
#region Private Properties
private IBFFHService _BFFHService;
private UUID _ID;
#endregion
#region Contructors #region Contructors
public MachinePageModel(INavigationService navigationService) : base(navigationService) public MachinePageModel(INavigationService navigationService, IBFFHService bffhService) : base(navigationService)
{ {
_BFFHService = bffhService;
UseMachineCommand = new DelegateCommand(UseMachineCommandExecuted); UseMachineCommand = new DelegateCommand(UseMachineCommandExecuted);
GiveBackMachineCommand = new DelegateCommand(GiveBackMachineCommandExecuted); GiveBackMachineCommand = new DelegateCommand(GiveBackMachineCommandExecuted);
} }
#endregion #endregion
#region Data #region Data
public override Task LoadData() public override async Task LoadData()
{ {
//Name = MachineItem.MInfo.Name; IMachineSystem machineSystem = await _BFFHService.GetMachineSystemInterface();
IInfoInterface info = await machineSystem.Info();
MachineItem = (await info.GetMachine(_ID)).Item1;
IsBusy = false; IsBusy = false;
return Task.CompletedTask;
} }
#endregion #endregion
#region Properties #region Properties
//private Machine _MachineItem; private Machine _MachineItem;
//public Machine MachineItem public Machine MachineItem
//{
// get => _MachineItem;
// set => SetProperty(ref _MachineItem, value);
//}
private string _Name;
public string Name
{ {
get => _Name; get => _MachineItem;
set => SetProperty(ref _Name, value); set => SetProperty(ref _MachineItem, value);
}
private bool _CanUse;
public bool CanUse
{
get => _CanUse;
set => SetProperty(ref _CanUse, value);
}
private bool _CanGiveBack;
public bool CanGiveBack
{
get => _CanGiveBack;
set => SetProperty(ref _CanGiveBack, value);
} }
#endregion #endregion
#region Commands #region Commands
private ICommand _UseMachineCommand; private ICommand _UseMachineCommand;
public ICommand UseMachineCommand public ICommand UseMachineCommand
{ {
get => _UseMachineCommand; get => _UseMachineCommand;
@ -69,12 +59,9 @@ namespace Borepin.PageModel
private async void UseMachineCommandExecuted() private async void UseMachineCommandExecuted()
{ {
//GiveBack = await MachineItem.Instance.Use(); Machine.IUseInterface useInterface = MachineItem.Use;
//CanGiveBack = GiveBack != null;
//MachineItem.MInfo = await MachineItem.Instance.GetMInfo(); await useInterface.Use();
//CanUse = MachineItem.MInfo.State == FabAccessAPI.Schema.Machine.MachineState.free;
} }
private ICommand _GiveBackMachineCommand; private ICommand _GiveBackMachineCommand;
@ -86,14 +73,9 @@ namespace Borepin.PageModel
private async void GiveBackMachineCommandExecuted() private async void GiveBackMachineCommandExecuted()
{ {
//await GiveBack.Ret(); Machine.IInUseInterface inUseInterface = MachineItem.Inuse;
//GiveBack = null; await inUseInterface.GiveBack();
//CanGiveBack = GiveBack != null;
//MachineItem.MInfo = await MachineItem.Instance.GetMInfo();
//CanUse = MachineItem.MInfo.State == FabAccessAPI.Schema.Machine.MachineState.free;
} }
#endregion #endregion
@ -105,7 +87,7 @@ namespace Borepin.PageModel
public override void OnNavigatedTo(INavigationParameters parameters) public override void OnNavigatedTo(INavigationParameters parameters)
{ {
//MachineItem = parameters["instance"] as Machine; MachineItem = parameters["instance"] as Machine;
IsBusy = true; IsBusy = true;
Task.Run(LoadData); Task.Run(LoadData);

View File

@ -1,23 +1,24 @@
using Prism.Mvvm; using Prism.Mvvm;
using FabAccessAPI.Schema;
namespace Borepin.ViewModel namespace Borepin.ViewModel
{ {
public class MachineListItemViewModel : BindableBase public class MachineListItemViewModel : BindableBase
{ {
public MachineListItemViewModel()//Model.Machine instance) public MachineListItemViewModel(Machine instance)
{ {
//_Instance = null; _Instance = instance;
//Name = instance.MInfo.Name; Name = instance.Name;
//State = instance.MInfo.State; State = instance.State;
} }
//private Model.Machine _Instance; private Machine _Instance;
//public Model.Machine Instance public Machine Instance
//{ {
// get => _Instance; get => _Instance;
// set => SetProperty(ref _Instance, value); set => SetProperty(ref _Instance, value);
//} }
private string _Name; private string _Name;
public string Name public string Name
@ -26,8 +27,8 @@ namespace Borepin.ViewModel
set => SetProperty(ref _Name, value); set => SetProperty(ref _Name, value);
} }
private FabAccessAPI.Schema.Machine.MachineState _State; private Machine.MachineState _State;
public FabAccessAPI.Schema.Machine.MachineState State public Machine.MachineState State
{ {
get => _State; get => _State;
set => SetProperty(ref _State, value); set => SetProperty(ref _State, value);