diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-12-13 02:14:37 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-12-13 02:14:37 +0200 |
| commit | cc2b95c9144d8a3486314766b645021a9a914d25 (patch) | |
| tree | 41653955cb214cb45b655c89efc8d51cb46b0433 /Software/Visual_Studio/PPC/Tango.PPC.UI | |
| parent | fea4547613d57f8fcc8cb94671c54d82a5b11dbb (diff) | |
| download | Tango-cc2b95c9144d8a3486314766b645021a9a914d25.tar.gz Tango-cc2b95c9144d8a3486314766b645021a9a914d25.zip | |
Implemented power up screen.
Implemented power on emulator.
Implemented power via machine operator.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/PowerUpView.xaml | 32 | ||||
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/PowerUpView.xaml.cs | 34 | ||||
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/PowerUpViewVM.cs | 120 | ||||
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/Images/powerup.gif | bin | 0 -> 380322 bytes | |||
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 9 | ||||
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs | 71 |
6 files changed, 266 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/PowerUpView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/PowerUpView.xaml new file mode 100644 index 000000000..776233955 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/PowerUpView.xaml @@ -0,0 +1,32 @@ +<UserControl x:Class="Tango.PPC.UI.Dialogs.PowerUpView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:local="clr-namespace:Tango.PPC.UI.Dialogs" + mc:Ignorable="d" + Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DesignHeight="555" d:DesignWidth="560" Width="600" Height="800" d:DataContext="{d:DesignInstance Type=local:PowerUpViewVM, IsDesignTimeCreatable=False}"> + <Grid> + <StackPanel Margin="0 100 0 0" HorizontalAlignment="Center"> + <touch:TouchGifAnimation Source="../Images/powerup.gif" EnableAnimation="{Binding IsVisible}" /> + <TextBlock HorizontalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}" Margin="0 30 0 0">Continue getting ready for:</TextBlock> + <DockPanel HorizontalAlignment="Center" Margin="0 40 0 0"> + <touch:TouchRadioButton IsChecked="{Binding IsSelectedRml}" /> + <touch:TouchComboBox Margin="20 0 0 0" Width="300" ItemsSource="{Binding Rmls}" SelectedItem="{Binding SelectedRml}" DisplayMemberPath="Name"></touch:TouchComboBox> + </DockPanel> + <DockPanel HorizontalAlignment="Left" Margin="0 40 0 0"> + <touch:TouchRadioButton IsChecked="{Binding IsMinimalTemperature}" /> + <TextBlock VerticalAlignment="Center" Margin="20 0 0 0">Minimal temperature</TextBlock> + </DockPanel> + + <touch:TouchButton Command="{Binding OKCommand}" Margin="0 150 0 0" Style="{StaticResource TangoHollowButton}" HorizontalAlignment="Center" Padding="60 15">CONTINUE</touch:TouchButton> + + <TextBlock HorizontalAlignment="Center" Margin="0 10 0 0" Visibility="{Binding IsTimeoutEnabled,Converter={StaticResource BooleanToVisibilityConverter}}"> + <Run>auto select in</Run> + <Run Text="{Binding RemainingSeconds}"></Run> + <Run>sec</Run> + </TextBlock> + </StackPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/PowerUpView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/PowerUpView.xaml.cs new file mode 100644 index 000000000..a9767276a --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/PowerUpView.xaml.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.UI.Dialogs +{ + /// <summary> + /// Interaction logic for PowerUpView.xaml + /// </summary> + public partial class PowerUpView : UserControl + { + public PowerUpView() + { + InitializeComponent(); + } + + protected override void OnPreviewMouseUp(MouseButtonEventArgs e) + { + base.OnPreviewMouseUp(e); + (DataContext as PowerUpViewVM).IsTimeoutEnabled = false; + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/PowerUpViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/PowerUpViewVM.cs new file mode 100644 index 000000000..0215e2456 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/PowerUpViewVM.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Timers; +using Tango.BL.Entities; +using Tango.SharedUI; + +namespace Tango.PPC.UI.Dialogs +{ + public class PowerUpViewVM : DialogViewVM + { + private Timer _timer; + + private List<Rml> _rmls; + public List<Rml> Rmls + { + get { return _rmls; } + set { _rmls = value; RaisePropertyChangedAuto(); } + } + + private Rml _selectedRml; + public Rml SelectedRml + { + get { return _selectedRml; } + set { _selectedRml = value; RaisePropertyChangedAuto(); } + } + + private bool _isSelectedRml; + public bool IsSelectedRml + { + get { return _isSelectedRml; } + set + { + _isSelectedRml = value; + RaisePropertyChangedAuto(); + + if (_isSelectedRml) + { + IsMinimalTemperature = false; + } + } + } + + private bool _isMinimalTemperature; + public bool IsMinimalTemperature + { + get { return _isMinimalTemperature; } + set + { + _isMinimalTemperature = value; + RaisePropertyChangedAuto(); + + if (_isMinimalTemperature) + { + IsSelectedRml = false; + } + } + } + + private int _remainingSeconds; + public int RemainingSeconds + { + get { return _remainingSeconds; } + set { _remainingSeconds = value; RaisePropertyChangedAuto(); } + } + + private bool _isTimeoutEnabled; + public bool IsTimeoutEnabled + { + get { return _isTimeoutEnabled; } + set + { + _isTimeoutEnabled = value; RaisePropertyChangedAuto(); + + if (!_isTimeoutEnabled) + { + _timer.Stop(); + } + } + } + + public PowerUpViewVM() + { + RemainingSeconds = 20; + IsMinimalTemperature = true; + IsTimeoutEnabled = true; + _timer = new Timer(); + _timer.Interval = TimeSpan.FromSeconds(1).TotalMilliseconds; + _timer.Elapsed += _timer_Elapsed; + } + + private void _timer_Elapsed(object sender, ElapsedEventArgs e) + { + RemainingSeconds--; + + if (RemainingSeconds == 0) + { + _timer.Stop(); + + InvokeUI(() => + { + Accept(); + }); + } + } + + protected override void Cancel() + { + base.Cancel(); + } + + public override void OnShow() + { + base.OnShow(); + _timer.Start(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/powerup.gif b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/powerup.gif Binary files differnew file mode 100644 index 000000000..f435d38d1 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/powerup.gif diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index 4e4e760f9..893b1a02c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -132,6 +132,10 @@ <DependentUpon>InsufficientLiquidQuantityView.xaml</DependentUpon> </Compile> <Compile Include="Dialogs\InsufficientLiquidQuantityViewVM.cs" /> + <Compile Include="Dialogs\PowerUpView.xaml.cs"> + <DependentUpon>PowerUpView.xaml</DependentUpon> + </Compile> + <Compile Include="Dialogs\PowerUpViewVM.cs" /> <Compile Include="Dialogs\ScreenLockView.xaml.cs"> <DependentUpon>ScreenLockView.xaml</DependentUpon> </Compile> @@ -225,6 +229,10 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="Dialogs\PowerUpView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Dialogs\ScreenLockView.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -374,6 +382,7 @@ <Resource Include="Images\GlobalStatus\error.png" /> <Resource Include="Images\GlobalStatus\service.png" /> <Resource Include="Images\update_available.png" /> + <Resource Include="Images\powerup.gif" /> <Content Include="Manifests\release.xml" /> <Content Include="Manifests\debug.xml" /> <None Include="firmware_package.tfp"> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs index 01a47539e..48e59562c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs @@ -4,6 +4,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Threading; +using Tango.BL; +using Tango.BL.Builders; +using Tango.BL.Entities; using Tango.Core.DI; using Tango.Integration.ExternalBridge; using Tango.Integration.Operation; @@ -17,6 +20,7 @@ using Tango.PPC.Common.Notifications; using Tango.PPC.Common.WatchDog; using Tango.PPC.UI.Dialogs; using Tango.SharedUI; +using System.Data.Entity; namespace Tango.PPC.UI.ViewModels { @@ -58,6 +62,7 @@ namespace Tango.PPC.UI.ViewModels { base.OnApplicationReady(); MachineProvider.MachineOperator.CartridgeValidationRequestReceived += MachineOperator_CartridgeValidationRequestReceived; + MachineProvider.MachineOperator.PowerUpStarted += MachineOperator_PowerUpStarted; } #region Event Handlers @@ -92,6 +97,72 @@ namespace Tango.PPC.UI.ViewModels }); } + private async void MachineOperator_PowerUpStarted(object sender, EventArgs e) + { + LogManager.Log("Power up detected, showing power up screen..."); + + PowerUpViewVM vm; + + try + { + List<Rml> rmls = new List<Rml>(); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + rmls = await db.Rmls.ToListAsync(); + } + + var selectedRml = rmls.SingleOrDefault(x => x.Guid == Settings.LastPowerUpSelectedRmlGuid); + + vm = new PowerUpViewVM(); + vm.Rmls = rmls; + vm.SelectedRml = selectedRml != null ? selectedRml : rmls.FirstOrDefault(); + vm.IsSelectedRml = selectedRml != null; + } + catch (Exception ex) + { + LogManager.Log(ex, "Error initializing power up screen."); + return; + } + + InvokeUI(async () => + { + await NotificationProvider.ShowDialog<PowerUpViewVM>(vm); + + await Task.Factory.StartNew(() => + { + try + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + List<ProcessParametersTable> processTables = new List<ProcessParametersTable>(); + + if (vm.IsSelectedRml) + { + processTables = new RmlBuilder(db).Set(vm.SelectedRml.Guid).WithActiveParametersGroup().Build().GetActiveProcessGroup().ProcessParametersTables.ToList(); + } + else + { + var rmlsToAvg = new RmlsCollectionBuilder(db).SetAll().WithActiveParametersGroup().Build(); + processTables = rmlsToAvg.Select(x => x.GetActiveProcessGroup()).SelectMany(x => x.ProcessParametersTables).ToList(); + } + + var processToLoad = processTables.OrderBy(x => x.GetAverageTemperature()).First(); + + var r = MachineProvider.MachineOperator.UploadProcessParameters(processToLoad).Result; + + Settings.LastPowerUpSelectedRmlGuid = vm.IsSelectedRml ? vm.SelectedRml.Guid : null; + Settings.Save(); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error occurred while trying to get and upload the proper process parameters after power screen closed."); + } + }); + }); + } + #endregion } } |
