diff options
28 files changed, 233 insertions, 39 deletions
diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf Binary files differindex 0f273386b..130d19d2c 100644 --- a/Software/DB/Tango.mdf +++ b/Software/DB/Tango.mdf diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf Binary files differindex c3111484f..91540b46c 100644 --- a/Software/DB/Tango_log.ldf +++ b/Software/DB/Tango_log.ldf diff --git a/Software/Graphics/Mobile/dyeing.png b/Software/Graphics/Mobile/dyeing.png Binary files differnew file mode 100644 index 000000000..fbace4fa5 --- /dev/null +++ b/Software/Graphics/Mobile/dyeing.png diff --git a/Software/Graphics/Mobile/dyeing@2x.png b/Software/Graphics/Mobile/dyeing@2x.png Binary files differnew file mode 100644 index 000000000..b16c3ccae --- /dev/null +++ b/Software/Graphics/Mobile/dyeing@2x.png diff --git a/Software/Graphics/Mobile/dyeing@3x.png b/Software/Graphics/Mobile/dyeing@3x.png Binary files differnew file mode 100644 index 000000000..54d9f4bd2 --- /dev/null +++ b/Software/Graphics/Mobile/dyeing@3x.png diff --git a/Software/Graphics/standby.png b/Software/Graphics/standby.png Binary files differnew file mode 100644 index 000000000..6b46c22c0 --- /dev/null +++ b/Software/Graphics/standby.png diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt index 40f8c54f4..18188ca96 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt @@ -1 +1 @@ -Thu 07/12/2018 16:28:40.38 +Thu 07/12/2018 19:06:42.65 diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs index d9f961479..26b903ce0 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs @@ -35,13 +35,7 @@ namespace Tango.PPC.Jobs.ViewModels public override void OnApplicationStarted() { - MachineProvider.MachineOperatorChanged += MachineProvider_MachineOperatorChanged; - } - - private void MachineProvider_MachineOperatorChanged(object sender, Common.Connection.MachineOperatorChangedEventArgs e) - { - e.NewMachineOperator.PrintingStarted -= PrintingStarted; - e.NewMachineOperator.PrintingStarted += PrintingStarted; + MachineProvider.MachineOperator.PrintingStarted += PrintingStarted; } private void PrintingStarted(object sender, JobHandler jobHandler) diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobSummeryView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobSummeryView.xaml index 377348581..330a916f4 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobSummeryView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobSummeryView.xaml @@ -36,10 +36,10 @@ <TextBlock Margin="20 0 0 0" VerticalAlignment="Center">EDIT</TextBlock> </StackPanel> </touch:TouchButton> - <touch:TouchButton FontSize="{StaticResource TangoExpanderHeaderFontSize}" Margin="20 0 0 0" Height="80" Padding="0" Width="270" CornerRadius="40" BlurRadius="20" HorizontalAlignment="Right" Command="{Binding DyeCommand}"> + <touch:TouchButton IsEnabled="{Binding MachineProvider.MachineOperator.CanPrint}" FontSize="{StaticResource TangoExpanderHeaderFontSize}" Margin="20 0 0 0" Height="80" Padding="0" Width="270" CornerRadius="40" BlurRadius="20" HorizontalAlignment="Right" Command="{Binding DyeCommand}"> <StackPanel Orientation="Horizontal"> <TextBlock VerticalAlignment="Center">DYE</TextBlock> - <fa:ImageAwesome Margin="20 0 0 0" Icon="ChevronRight" Width="14" Foreground="{StaticResource TangoPrimaryBackgroundBrush}" /> + <touch:TouchIcon Margin="20 0 0 0" Icon="ChevronRight" Width="14" /> </StackPanel> </touch:TouchButton> </StackPanel> @@ -56,7 +56,7 @@ <TextBlock Margin="40 10 0 0" FontSize="{StaticResource TangoTitleFontSize}">Tap 'DYE' to start the dying process...</TextBlock> </StackPanel> - <controls:JobSummeryViewer Height="50" DataContext="{Binding Job}" VerticalAlignment="Bottom" /> + <controls:JobSummeryViewer Height="50" DataContext="{Binding Job}" VerticalAlignment="Bottom" Margin="20 0" /> </Grid> </DockPanel> </Grid> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml index cf1c3fa37..656b0b33a 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml @@ -654,7 +654,7 @@ <Border Padding="20 20"> <Grid> <DockPanel> - <touch:TouchButton DockPanel.Dock="Right" Height="54" Padding="0" Width="184" CornerRadius="30" BlurRadius="20" HorizontalAlignment="Right" Command="{Binding DyeCommand}"> + <touch:TouchButton IsEnabled="{Binding MachineProvider.MachineOperator.CanPrint}" DockPanel.Dock="Right" Height="54" Padding="0" Width="184" CornerRadius="30" BlurRadius="20" HorizontalAlignment="Right" Command="{Binding DyeCommand}"> DYE </touch:TouchButton> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs index 636a73d3c..1fd5fdd0a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs @@ -53,6 +53,11 @@ namespace Tango.PPC.Common.Connection MachineOperatorChanged?.Invoke(this, new MachineOperatorChangedEventArgs(oldOperator, newOperator)); } + public DefaultMachineProvider() + { + MachineOperator = new MachineOperator(); + } + public void Init() { if (!_isInitialized) @@ -69,9 +74,9 @@ namespace Tango.PPC.Common.Connection Transport.Discovery.UsbCommunicationScanner<ConnectRequest, ConnectResponse> scanner = new Transport.Discovery.UsbCommunicationScanner<ConnectRequest, ConnectResponse>(UsbSerialBaudRates.BR_9600); var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, TimeSpan.FromSeconds(10)); - var machine = new MachineOperator(response.Adapter); - await machine.Connect(); - MachineOperator = machine; + await MachineOperator.Disconnect(); + MachineOperator.Adapter = response.Adapter; + await MachineOperator.Connect(); } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/MachineOperatorChangedEventArgs.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/MachineOperatorChangedEventArgs.cs index 0ffc17abd..15cb66e05 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/MachineOperatorChangedEventArgs.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/MachineOperatorChangedEventArgs.cs @@ -10,12 +10,12 @@ namespace Tango.PPC.Common.Connection public class MachineOperatorChangedEventArgs : EventArgs { public IMachineOperator OldMachineOperator { get; private set; } - public IMachineOperator NewMachineOperator { get; private set; } + public IMachineOperator MachineOperator { get; private set; } public MachineOperatorChangedEventArgs(IMachineOperator oldOperator, IMachineOperator newOperator) { OldMachineOperator = oldOperator; - NewMachineOperator = newOperator; + MachineOperator = newOperator; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Diagnostics/DefaultDiagnosticsFrameProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Diagnostics/DefaultDiagnosticsFrameProvider.cs index e44bb6172..28255820c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Diagnostics/DefaultDiagnosticsFrameProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Diagnostics/DefaultDiagnosticsFrameProvider.cs @@ -50,9 +50,9 @@ namespace Tango.PPC.Common.Diagnostics private void MachineProvider_MachineOperatorChanged(object sender, MachineOperatorChangedEventArgs e) { - if (e.NewMachineOperator != null) + if (e.MachineOperator != null) { - e.NewMachineOperator.DiagnosticsDataAvailable += DefaultDiagnosticsFrameProvider_DiagnosticsDataAvailable; + e.MachineOperator.DiagnosticsDataAvailable += DefaultDiagnosticsFrameProvider_DiagnosticsDataAvailable; } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs index 8fa0ec05f..da904b74e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs @@ -108,7 +108,7 @@ namespace Tango.PPC.Common.EventLogging private void _machineProvider_MachineOperatorChanged(object sender, MachineOperatorChangedEventArgs e) { - var machine = e.NewMachineOperator; + var machine = e.MachineOperator; if (machine != null) { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml index b6f60fd3f..1a8bfa15d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml @@ -37,6 +37,7 @@ <converters:OneToPercentConverter x:Key="OneToPercentConverter" /> <converters:SmallerThanToBooleanConverter x:Key="SmallerThanToBooleanConverter" /> <converters:EnumToItemsSourceConverter x:Key="EnumToItemsSourceConverter" /> + <converters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter" /> <converters:TimeSpanToTwoDigitsTimeConverter x:Key="TimeSpanToTwoDigitsTimeConverter" /> <converters:TimeSpanToLabelConverter x:Key="TimeSpanToLabelConverter" /> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/GlobalStatus/dyeing.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/GlobalStatus/dyeing.png Binary files differnew file mode 100644 index 000000000..fbace4fa5 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/GlobalStatus/dyeing.png diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/GlobalStatus/standby.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/GlobalStatus/standby.png Binary files differnew file mode 100644 index 000000000..6b46c22c0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/GlobalStatus/standby.png 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 159484c0b..637b29dd1 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 @@ -329,6 +329,8 @@ <Link>Tango.ColorLib.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> + <Resource Include="Images\GlobalStatus\standby.png" /> + <Resource Include="Images\GlobalStatus\dyeing.png" /> <Resource Include="Images\preloader_rectangles.gif" /> <Resource Include="Images\logo.png" /> </ItemGroup> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs index 405c19eb7..b3a0c5b1a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using Tango.Core.Commands; using Tango.Core.DI; +using Tango.Integration.Operation; using Tango.PPC.Common; using Tango.PPC.Common.Modules; using Tango.PPC.Common.Navigation; @@ -20,6 +21,8 @@ namespace Tango.PPC.UI.ViewModels /// <seealso cref="Tango.PPC.Common.PPCViewModel{Tango.PPC.UI.ViewsContracts.ILayoutView}" /> public class LayoutViewVM : PPCViewModel<ILayoutView> { + private JobHandler _jobHandler; + /// <summary> /// Gets or sets the module loader. /// </summary> @@ -67,6 +70,11 @@ namespace Tango.PPC.UI.ViewModels public RelayCommand NotificationsAreaPressedCommand { get; set; } /// <summary> + /// Gets or sets the stop printing command. + /// </summary> + public RelayCommand StopPrintingCommand { get; set; } + + /// <summary> /// Initializes a new instance of the <see cref="LayoutViewVM"/> class. /// </summary> public LayoutViewVM() @@ -75,6 +83,21 @@ namespace Tango.PPC.UI.ViewModels HomeCommand = new RelayCommand(NavigateHome); MenuOrBackCommand = new RelayCommand(OpenMenuOrNavigateBack); NotificationsAreaPressedCommand = new RelayCommand(OpenFirstNotificationOrDisplayAll); + + StopPrintingCommand = new RelayCommand(StopPrinting); + } + + private void StopPrinting() + { + if (_jobHandler != null) + { + _jobHandler.Cancel(); + } + } + + private void MachineOperator_PrintingStarted(object sender, Integration.Operation.JobHandler jobHandler) + { + _jobHandler = jobHandler; } /// <summary> @@ -118,6 +141,7 @@ namespace Tango.PPC.UI.ViewModels { base.OnApplicationStarted(); ModuleLoader.ModulesLoaded += ModuleLoader_ModulesLoaded; + MachineProvider.MachineOperator.PrintingStarted += MachineOperator_PrintingStarted; } /// <summary> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml index 2f1b7dd59..e9d6113d5 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -10,6 +10,7 @@ xmlns:vm="clr-namespace:Tango.PPC.UI.ViewModels" xmlns:global="clr-namespace:Tango.PPC.UI" xmlns:localConverters="clr-namespace:Tango.PPC.UI.Converters" + xmlns:operations="clr-namespace:Tango.Integration.Operation;assembly=Tango.Integration" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:commonControls="clr-namespace:Tango.PPC.Common.Controls;assembly=Tango.PPC.Common" xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" @@ -105,12 +106,66 @@ </touch:TouchHamburgerButton> </Border> <Grid DockPanel.Dock="Right" Margin="0 0 20 0"> - <StackPanel VerticalAlignment="Center" > - <Image Source="/Images/GlobalStatus/ready-to-dye.png" Width="33" /> - <TextBlock Margin="0 10 0 0">Ready to Dye</TextBlock> + <StackPanel Orientation="Horizontal"> + <StackPanel VerticalAlignment="Center"> + <Image Width="33" HorizontalAlignment="Center"> + <Image.Style> + <Style TargetType="Image"> + <Setter Property="Source" Value="/Images/GlobalStatus/standby.png"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding MachineProvider.MachineOperator.Status}" Value="{x:Static operations:MachineStatuses.Standby}"> + <Setter Property="Source" Value="/Images/GlobalStatus/standby.png"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding MachineProvider.MachineOperator.Status}" Value="{x:Static operations:MachineStatuses.ReadyToDye}"> + <Setter Property="Source" Value="/Images/GlobalStatus/ready-to-dye.png"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding MachineProvider.MachineOperator.Status}" Value="{x:Static operations:MachineStatuses.Printing}"> + <Setter Property="Source" Value="/Images/GlobalStatus/dyeing.png"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Image.Style> + </Image> + <TextBlock Margin="0 10 0 0" Text="{Binding MachineProvider.MachineOperator.Status,Converter={StaticResource EnumToDescriptionConverter}}"></TextBlock> + </StackPanel> + + <Grid Margin="40 0 0 0"> + <Grid.Style> + <Style TargetType="Grid"> + <Setter Property="Visibility" Value="Collapsed"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding MachineProvider.MachineOperator.IsPrinting}" Value="True"> + <Setter Property="Visibility" Value="Visible"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Grid.Style> + <touch:TouchButton Height="54" Padding="0" Width="184" CornerRadius="30" BlurRadius="20" Command="{Binding StopPrintingCommand}"> + STOP + </touch:TouchButton> + </Grid> </StackPanel> </Grid> <Grid> + + <Grid Margin="20 10 60 10" Visibility="{Binding MachineProvider.MachineOperator.IsPrinting,Converter={StaticResource BooleanToVisibilityConverter}}"> + <StackPanel VerticalAlignment="Center"> + <TextBlock Text="{Binding MachineProvider.MachineOperator.RunningJob.Name,FallbackValue='Job Name'}" FontSize="{StaticResource TangoTitleFontSize}"></TextBlock> + <ProgressBar Maximum="{Binding MachineProvider.MachineOperator.RunningJobStatus.TotalProgress}" Value="{Binding MachineProvider.MachineOperator.RunningJobStatus.Progress}" Margin="0 10 0 5" Background="{StaticResource TangoGrayBrush}" Height="5" Foreground="{StaticResource TangoPrimaryAccentBrush}" BorderThickness="0" /> + <DockPanel LastChildFill="False"> + <TextBlock DockPanel.Dock="Left"> + <Run>Completed</Run> + <Run Text="{Binding MachineProvider.MachineOperator.RunningJobStatus.Progress,StringFormat=0}"></Run><Run>/</Run><Run Text="{Binding MachineProvider.MachineOperator.RunningJobStatus.TotalProgress,StringFormat=0}"></Run><Run>m</Run> + </TextBlock> + + <TextBlock DockPanel.Dock="Right"> + <Run Text="{Binding MachineProvider.MachineOperator.RunningJobStatus.RemainingTime,Converter={StaticResource TimeSpanToTwoDigitsTimeConverter},FallbackValue=5}"></Run> + <Run FontSize="16" Text="{Binding MachineProvider.MachineOperator.RunningJobStatus.RemainingTime,Converter={StaticResource TimeSpanToLabelConverter},FallbackValue=min}"></Run> + </TextBlock> + </DockPanel> + </StackPanel> + </Grid> + <!--External Header Content Here--> <commonControls:AsyncAdornerControl> <commonControls:AsyncAdornerControl.Style> diff --git a/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs b/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs index 147309f54..7b8a576f5 100644 --- a/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs +++ b/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs @@ -115,7 +115,7 @@ namespace Tango.BL.ColorConversion conversionInput.ForwardData = ByteString.CopyFrom(brushStop.Segment.Job.Rml.Ccts.FirstOrDefault().ForwardData); - foreach (var ids_pack in brushStop.Segment.Job.Machine.Configuration.IdsPacks.OrderBy(x => x.PackIndex)) + foreach (var ids_pack in brushStop.Segment.Job.Machine.Configuration.NoneEmptyIdsPacks.OrderBy(x => x.PackIndex)) { conversionInput.InputCoordinates.InputLiquids.Add(new InputLiquid() { diff --git a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs index e171a2738..da6abe031 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs @@ -34,6 +34,26 @@ namespace Tango.Integration.Operation MachineStatuses Status { get; } /// <summary> + /// Gets the running job. + /// </summary> + Job RunningJob { get; } + + /// <summary> + /// Gets the running job status. + /// </summary> + RunningJobStatus RunningJobStatus { get; } + + /// <summary> + /// Gets a value indicating whether this instance is printing. + /// </summary> + bool IsPrinting { get; } + + /// <summary> + /// Gets a value indicating whether this instance can print. + /// </summary> + bool CanPrint { get; } + + /// <summary> /// Occurs when the machine <see cref="Status"/> has changed. /// </summary> event EventHandler<MachineStatuses> StatusChanged; diff --git a/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs b/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs index 5502f52cc..f2aa261e4 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs @@ -43,6 +43,11 @@ namespace Tango.Integration.Operation public event EventHandler Canceled; /// <summary> + /// Occurs when the job has been canceled, failed or completed. + /// </summary> + public event EventHandler Stopped; + + /// <summary> /// Occurs when a segment has started. /// </summary> public event EventHandler<Segment> SegmentStarted; @@ -150,6 +155,7 @@ namespace Tango.Integration.Operation internal void RaiseFailed(Exception ex) { Failed?.Invoke(this, ex); + Stopped?.Invoke(this, new EventArgs()); } /// <summary> @@ -158,6 +164,7 @@ namespace Tango.Integration.Operation internal void RaiseCompleted() { Completed?.Invoke(this, new EventArgs()); + Stopped?.Invoke(this, new EventArgs()); } /// <summary> @@ -166,6 +173,7 @@ namespace Tango.Integration.Operation internal void RaiseCanceled() { Canceled?.Invoke(this, new EventArgs()); + Stopped?.Invoke(this, new EventArgs()); } #endregion diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 3a02006fd..20968385d 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -39,6 +39,11 @@ namespace Tango.Integration.Operation public static String EmbeddedLogsFolder { get; private set; } public static String EmbeddedLogsTag { get; private set; } + #region Constructors + + /// <summary> + /// Initializes the <see cref="MachineOperator"/> class. + /// </summary> static MachineOperator() { if (EmbeddedLogManager == null) @@ -53,6 +58,9 @@ namespace Tango.Integration.Operation } } + /// <summary> + /// Initializes a new instance of the <see cref="MachineOperator"/> class. + /// </summary> public MachineOperator() : base() { DeviceInformation = new DeviceInformation(); @@ -70,6 +78,8 @@ namespace Tango.Integration.Operation Adapter = adapter; } + #endregion + #region Events /// <summary> @@ -138,7 +148,56 @@ namespace Tango.Integration.Operation public MachineStatuses Status { get { return _status; } - private set { _status = value; RaisePropertyChangedAuto(); OnMachineStatusChanged(value); } + private set + { + _status = value; + RaisePropertyChangedAuto(); + OnMachineStatusChanged(value); + RaisePropertyChanged(nameof(IsPrinting)); + RaisePropertyChanged(nameof(CanPrint)); + } + } + + /// <summary> + /// Gets a value indicating whether this instance is printing. + /// </summary> + public bool IsPrinting + { + get + { + return Status == MachineStatuses.Printing; + } + } + + /// <summary> + /// Gets a value indicating whether this instance can print. + /// </summary> + public bool CanPrint + { + get + { + return Status == MachineStatuses.ReadyToDye; + } + } + + private Job _runningJob; + /// <summary> + /// Gets the running job. + /// </summary> + public Job RunningJob + { + get { return _runningJob; } + set { _runningJob = value; RaisePropertyChangedAuto(); } + } + + private RunningJobStatus _runningJobStatus; + /// <summary> + /// Gets the running job status. + /// </summary> + public RunningJobStatus RunningJobStatus + { + get { return _runningJobStatus; } + set { _runningJobStatus = value; RaisePropertyChangedAuto(); } } /// <summary> @@ -477,6 +536,8 @@ namespace Tango.Integration.Operation { var response = await SendRequest<DisconnectRequest, DisconnectResponse>(request); LogResponseReceived(response.Message); + + Status = MachineStatuses.Standby; } catch (Exception ex) { @@ -487,6 +548,10 @@ namespace Tango.Integration.Operation await base.Disconnect(); } + /// <summary> + /// Connects the transport component. + /// </summary> + /// <returns></returns> public async override Task Connect() { await base.Connect(); @@ -501,6 +566,8 @@ namespace Tango.Integration.Operation var response = await SendRequest<ConnectRequest, ConnectResponse>(request); LogResponseReceived(response.Message); + Status = MachineStatuses.ReadyToDye; + DeviceInformation = response.Message.DeviceInformation; OnEnableDiagnosticsChanged(EnableDiagnostics); @@ -595,6 +662,14 @@ namespace Tango.Integration.Operation /// <returns></returns> public JobHandler Print(Job job, ProcessParametersTable processParameters) { + if (Status != MachineStatuses.ReadyToDye) + { + throw new InvalidOperationException("Could not print while status = " + Status); + } + + RunningJob = null; + RunningJobStatus = null; + var originalJob = job; CurrentProcessParameters = processParameters; @@ -687,6 +762,11 @@ namespace Tango.Integration.Operation } }, originalJob, processParameters); + handler.StatusChanged += (x, s) => + { + RunningJobStatus = s; + }; + LogRequestSent(request); bool responseLogged = false; @@ -697,6 +777,7 @@ namespace Tango.Integration.Operation if (!responseLogged) { Status = MachineStatuses.Printing; + RunningJob = originalJob; PrintingStarted?.Invoke(this, handler); responseLogged = true; LogResponseReceived(response.Message); diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineStatuses.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineStatuses.cs index 60874c5e9..3850ba769 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineStatuses.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineStatuses.cs @@ -9,12 +9,12 @@ namespace Tango.Integration.Operation { public enum MachineStatuses { + [Description("Standby")] + Standby, [Description("Ready To Dye")] ReadyToDye, [Description("Dyeing")] Printing, - [Description("Standby")] - Standby, [Description("Service")] Service, [Description("Error")] diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchButton.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchButton.xaml index 34716f740..5b1861623 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchButton.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchButton.xaml @@ -30,20 +30,16 @@ <ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> </components:Ripple> </Border> - <ControlTemplate.Triggers> - <!--<Trigger Property="IsPressed" Value="true"> - <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/> - <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/> - </Trigger>--> - <Trigger Property="IsEnabled" Value="false"> - <Setter Property="Background" TargetName="border" Value="{StaticResource TangoDisabledBackgroundBrush}"/> - <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TangoDisabledBackgroundBrush}"/> - <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource TangoDisabledForegroundBrush}"/> - </Trigger> - </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> + <Style.Triggers> + <Trigger Property="IsEnabled" Value="False"> + <Setter Property="Background" Value="{StaticResource TangoDisabledBackgroundBrush}"></Setter> + <Setter Property="BorderBrush" Value="{StaticResource TangoDisabledBackgroundBrush}"></Setter> + <Setter Property="Foreground" Value="{StaticResource TangoDisabledForegroundBrush}"></Setter> + </Trigger> + </Style.Triggers> </Style> </ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchIcon.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchIcon.xaml index 0fed41c26..f1fd30b99 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchIcon.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchIcon.xaml @@ -6,7 +6,7 @@ <localConverters:TouchIconKindToGeometryConverter x:Key="TouchIconKindToGeometryConverter" /> <Style TargetType="{x:Type local:TouchIcon}"> - <Setter Property="Foreground" Value="{Binding Path=(TextElement.Foreground), RelativeSource={RelativeSource AncestorType=ContentPresenter}}"></Setter> + <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType=Control},Path=Foreground}"></Setter> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:TouchIcon}"> diff --git a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs index 03e5f6671..d78905472 100644 --- a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs +++ b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs @@ -126,6 +126,14 @@ namespace Tango.Transport /// <param name="newAdapter">The adapter.</param> protected async virtual void OnAdapterChanged(ITransportAdapter oldAdapter, ITransportAdapter newAdapter) { + if (oldAdapter != newAdapter) + { + _pendingRequests.Clear(); + _pendingResponses.Clear(); + _arrivedResponses = new ConcurrentQueue<byte[]>(); + _sendingQueue = new ConcurrentQueue<TransportMessageBase>(); + } + if (oldAdapter != null) { oldAdapter.StateChanged -= OnAdapterStateChanged; |
