aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-08-04 12:59:34 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-08-04 12:59:34 +0300
commitc2471c200471e62b80133542183eb14af7c79bc7 (patch)
treeb8171eb2bbc94cac456c4b653efad315e17ae681 /Software/Visual_Studio/PPC/Tango.PPC.UI
parenta21bffd43acbffcec36cc34bc8d03c2eb8358769 (diff)
downloadTango-c2471c200471e62b80133542183eb14af7c79bc7.tar.gz
Tango-c2471c200471e62b80133542183eb14af7c79bc7.zip
Implemented emergency switch.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj10
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs9
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/EmergencyViewVM.cs51
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/EmergencyView.xaml21
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/EmergencyView.xaml.cs28
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml1
6 files changed, 119 insertions, 1 deletions
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 9b3b58c67..389f5d59b 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
@@ -143,6 +143,7 @@
<Compile Include="Printing\DefaultPrintingManager.cs" />
<Compile Include="Threading\DefaultDispatcherProvider.cs" />
<Compile Include="ViewModelLocator.cs" />
+ <Compile Include="ViewModels\EmergencyViewVM.cs" />
<Compile Include="ViewModels\ExternalBridgeViewVM.cs" />
<Compile Include="ViewModels\LayoutViewVM.cs" />
<Compile Include="ViewModels\LoadingErrorViewVM.cs" />
@@ -162,6 +163,9 @@
<Compile Include="Views\LayoutView.xaml.cs">
<DependentUpon>LayoutView.xaml</DependentUpon>
</Compile>
+ <Compile Include="Views\EmergencyView.xaml.cs">
+ <DependentUpon>EmergencyView.xaml</DependentUpon>
+ </Compile>
<Compile Include="Views\LoadingErrorView.xaml.cs">
<DependentUpon>LoadingErrorView.xaml</DependentUpon>
</Compile>
@@ -234,6 +238,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="Views\EmergencyView.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
<Page Include="Views\LoadingErrorView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -538,7 +546,7 @@ del "$(TargetDir)firmware_package.tfp"</PostBuildEvent>
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
+ <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs
index 3517abbb2..67b5dc19b 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs
@@ -106,6 +106,7 @@ namespace Tango.PPC.UI
TangoIOC.Default.Register<LoadingErrorViewVM>();
TangoIOC.Default.Register<NoPermissionsViewVM>();
TangoIOC.Default.Register<RestartingSystemViewVM>();
+ TangoIOC.Default.Register<EmergencyViewVM>();
TangoIOC.Default.GetInstance<IPPCApplicationManager>().ContentRendered += (_, __) =>
@@ -203,5 +204,13 @@ namespace Tango.PPC.UI
return TangoIOC.Default.GetInstance<RestartingSystemViewVM>();
}
}
+
+ public static EmergencyViewVM EmergencyViewVM
+ {
+ get
+ {
+ return TangoIOC.Default.GetInstance<EmergencyViewVM>();
+ }
+ }
}
} \ No newline at end of file
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/EmergencyViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/EmergencyViewVM.cs
new file mode 100644
index 000000000..87b3c012b
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/EmergencyViewVM.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Integration.Emergency;
+using Tango.PPC.Common;
+using Tango.PPC.Common.Navigation;
+
+namespace Tango.PPC.UI.ViewModels
+{
+ public class EmergencyViewVM : PPCViewModel
+ {
+ private bool _isActive;
+
+ public override void OnApplicationStarted()
+ {
+
+ }
+
+ public override void OnApplicationReady()
+ {
+ base.OnApplicationReady();
+ MachineProvider.MachineOperator.EmergencyNotificationProvider.StatusChanged += EmergencyNotificationProvider_StatusChanged;
+ }
+
+ private void EmergencyNotificationProvider_StatusChanged(object sender, EmergencyStatusChangedEventArgs e)
+ {
+ InvokeUI(async () =>
+ {
+ if (e.Status == EmergencyStatus.On && !_isActive)
+ {
+ LogManager.Log("Emergency switch activated...");
+ _isActive = true;
+ await NavigationManager.NavigateTo(NavigationView.EmergencyView);
+ }
+ else if (_isActive)
+ {
+ LogManager.Log("Emergency switch deactivated...");
+ _isActive = false;
+ await NavigationManager.NavigateTo(NavigationView.LayoutView);
+ }
+
+ if (e.Status == EmergencyStatus.Error && e.ErrorException != null)
+ {
+ LogManager.Log(e.ErrorException, "Error occurred while detecting emergency switch.");
+ }
+ });
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/EmergencyView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/EmergencyView.xaml
new file mode 100644
index 000000000..dfc70e602
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/EmergencyView.xaml
@@ -0,0 +1,21 @@
+<UserControl x:Class="Tango.PPC.UI.Views.EmergencyView"
+ 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:vm="clr-namespace:Tango.PPC.UI.ViewModels"
+ xmlns:global="clr-namespace:Tango.PPC.UI"
+ xmlns:local="clr-namespace:Tango.PPC.UI.Views"
+ mc:Ignorable="d"
+ d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:EmergencyViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.EmergencyViewVM}">
+ <Grid>
+ <DockPanel Margin="20 60 20 20">
+ <StackPanel DockPanel.Dock="Top">
+ <Image Source="../Images/warning-red.png" Width="300" Stretch="Uniform" HorizontalAlignment="Center"></Image>
+ <TextBlock HorizontalAlignment="Center" Margin="0 40 0 0" FontSize="{StaticResource TangoHeaderFontSize}">Emergency Switch Activated</TextBlock>
+ <TextBlock HorizontalAlignment="Center" Margin="0 20 0 0" FontSize="{StaticResource TangoTitleFontSize}">Please release the emergency switch to exit this screen.</TextBlock>
+ </StackPanel>
+ </DockPanel>
+ </Grid>
+</UserControl>
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/EmergencyView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/EmergencyView.xaml.cs
new file mode 100644
index 000000000..6c5020fbe
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/EmergencyView.xaml.cs
@@ -0,0 +1,28 @@
+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.Views
+{
+ /// <summary>
+ /// Interaction logic for LoadingErrorView.xaml
+ /// </summary>
+ public partial class EmergencyView : UserControl
+ {
+ public EmergencyView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml
index 005edb182..5accd8ff3 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml
@@ -92,6 +92,7 @@
<local:MachineSetupView></local:MachineSetupView>
<local:MachineUpdateView></local:MachineUpdateView>
<local:RestartingSystemView></local:RestartingSystemView>
+ <local:EmergencyView></local:EmergencyView>
</controls:NavigationControl>
</touch:TouchPanel>
</Grid>