From c38f1c80f1fbdfdb758c5a0b93d045a9a5b526ad Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 3 Mar 2020 18:56:58 +0200 Subject: Machine Studio v4.1.2 PPC v1.1.5 Added BYPASS_ROCKERS to SQLExaminer config. Started integrating FSE Remote/Console To PPC. Added support for generic continuous request. --- .../Machine Studio Installer.aip | 6 +- .../PPC Installer-cache/cacheIndex.txt | Bin 52 -> 52 bytes .../Advanced Installer Projects/PPC Installer.aip | 10 +- .../Tango.FSE.PPCConsole.csproj | 29 ++- .../ViewModels/RemoteDesktopViewVM.cs | 96 ++++++++++ .../Tango.FSE.PPCConsole/Views/ConsoleView.xaml | 4 +- .../Views/RemoteDesktopView.xaml | 46 +++-- .../FSE/Modules/Tango.FSE.PPCConsole/app.config | 4 + .../Modules/Tango.FSE.PPCConsole/packages.config | 6 + .../Connection/IMachineProvider.cs | 10 ++ .../Connection/MachineConnectedEventArgs.cs | 14 ++ .../Connection/MachineDisconnectedEventArgs.cs | 15 ++ .../FSE/Tango.FSE.Common/Tango.FSE.Common.csproj | 2 + Software/Visual_Studio/FSE/Tango.FSE.UI/App.config | 4 + .../Connection/DefaultMachineProvider.cs | 33 ++++ .../FSE/Tango.FSE.UI/Views/LayoutView.xaml | 23 ++- .../Views/JobView.xaml | 2 +- .../Properties/AssemblyInfo.cs | 2 +- .../Console/DefaultConsoleEngineService.cs | 5 + .../PPC/Tango.PPC.Common/PPCSettings.cs | 12 ++ .../RemoteDesktop/DefaultRemoteDesktopService.cs | 198 +++++++++++++++++++++ .../RemoteDesktop/IRemoteDesktopService.cs | 15 ++ .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 6 + .../PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs | 2 +- .../PPC/Tango.PPC.UI/ViewModelLocator.cs | 3 + .../Visual_Studio/Tango.Core/Tango.Core.csproj | 3 +- .../Tango.Core/Threading/SequencerThread.cs | 71 ++++++++ .../ExternalBridge/ExternalBridgeService.cs | 10 ++ .../IExternalBridgeRequestHandler.cs | 2 +- .../Tango.RemoteDesktop/Clipping/BitmapCliper.cs | 20 +-- .../Visual_Studio/Tango.RemoteDesktop/Frame.cs | 10 ++ .../Network/RemoteDesktopPacket.cs | 26 +++ .../Network/StartRemoteDesktopSessionRequest.cs | 16 ++ .../Network/StartRemoteDesktopSessionResponse.cs | 25 +++ .../Tango.RemoteDesktop/ScreenCaptureEngine.cs | 43 +++-- .../Tango.RemoteDesktop/Tango.RemoteDesktop.csproj | 3 + .../SQLExaminer/Configurations/OverrideData.xml | Bin 83900 -> 83988 bytes .../Visual_Studio/Tango.Transport/ITransporter.cs | 9 + .../Tango.Transport/TransporterBase.cs | 55 ++++++ 39 files changed, 771 insertions(+), 69 deletions(-) create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/MachineConnectedEventArgs.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/MachineDisconnectedEventArgs.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/IRemoteDesktopService.cs create mode 100644 Software/Visual_Studio/Tango.Core/Threading/SequencerThread.cs create mode 100644 Software/Visual_Studio/Tango.RemoteDesktop/Network/RemoteDesktopPacket.cs create mode 100644 Software/Visual_Studio/Tango.RemoteDesktop/Network/StartRemoteDesktopSessionRequest.cs create mode 100644 Software/Visual_Studio/Tango.RemoteDesktop/Network/StartRemoteDesktopSessionResponse.cs (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip b/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip index 7a98315e6..a1d8353fe 100644 --- a/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip +++ b/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip @@ -16,10 +16,10 @@ - + - + @@ -810,7 +810,7 @@ - + diff --git a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/cacheIndex.txt b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/cacheIndex.txt index a603ff06b..993ced97e 100644 Binary files a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/cacheIndex.txt and b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/cacheIndex.txt differ diff --git a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip index bae639a22..e3bea2a1b 100644 --- a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip +++ b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip @@ -18,10 +18,10 @@ - + - + @@ -142,6 +142,7 @@ + @@ -406,6 +407,8 @@ + + @@ -415,7 +418,7 @@ - + @@ -656,6 +659,7 @@ + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Tango.FSE.PPCConsole.csproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Tango.FSE.PPCConsole.csproj index bcb1242a3..75cae76a9 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Tango.FSE.PPCConsole.csproj +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Tango.FSE.PPCConsole.csproj @@ -61,6 +61,23 @@ + + + ..\..\..\packages\System.Reactive.Core.3.1.1\lib\net46\System.Reactive.Core.dll + + + ..\..\..\packages\System.Reactive.Interfaces.3.1.1\lib\net45\System.Reactive.Interfaces.dll + + + ..\..\..\packages\System.Reactive.Linq.3.1.1\lib\net46\System.Reactive.Linq.dll + + + ..\..\..\packages\System.Reactive.PlatformServices.3.1.1\lib\net46\System.Reactive.PlatformServices.dll + + + ..\..\..\packages\System.Reactive.Windows.Threading.3.1.1\lib\net45\System.Reactive.Windows.Threading.dll + + ..\..\..\packages\ControlzEx.3.0.2.4\lib\net45\System.Windows.Interactivity.dll @@ -111,8 +128,12 @@ ResXFileCodeGenerator Resources.Designer.cs - - + + Designer + + + Designer + SettingsSingleFileGenerator Settings.Designer.cs @@ -147,6 +168,10 @@ {e4927038-348d-4295-aaf4-861c58cb3943} Tango.PMR + + {a78068d4-2061-4376-8ede-583d8d880dec} + Tango.RemoteDesktop + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} Tango.Settings diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/RemoteDesktopViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/RemoteDesktopViewVM.cs index 32a85ada6..eb5d57447 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/RemoteDesktopViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/RemoteDesktopViewVM.cs @@ -1,13 +1,109 @@ using System; using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Media.Imaging; +using Tango.Core.Commands; +using Tango.Core.Threading; using Tango.FSE.Common; +using Tango.RemoteDesktop.Frames; +using Tango.RemoteDesktop.Network; namespace Tango.FSE.PPCConsole.ViewModels { public class RemoteDesktopViewVM : FSEViewModel { + private RasterFrame _currentFrame; + + private BitmapSource _source; + public BitmapSource Source + { + get { return _source; } + set { _source = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand StartCommand { get; set; } + public RelayCommand StopCommand { get; set; } + + public RemoteDesktopViewVM() + { + StartCommand = new RelayCommand(StartRemoteDesktop, () => MachineProvider.IsConnected); + StopCommand = new RelayCommand(StopRemoteDesktop); + } + + public override void OnApplicationStarted() + { + base.OnApplicationStarted(); + + MachineProvider.MachineConnected += (_, __) => InvalidateRelayCommands(); + MachineProvider.MachineDisconnected += (_, __) => InvalidateRelayCommands(); + } + + private void StartRemoteDesktop() + { + SequencerThread sequencer = null; + sequencer = new SequencerThread((response) => + { + if (response.Packet == null) + { + sequencer.FrameRate = 1000 / response.FrameRate; + return; //Returned just to notice that there was no timeout.. + } + + try + { + if (!response.Packet.IsPartial) + { + using (MemoryStream ms = new MemoryStream(response.Packet.Bitmap)) + { + if (_currentFrame != null) + { + _currentFrame.Dispose(); + } + + _currentFrame = new RasterFrame(new Bitmap(ms)); + } + } + else + { + using (MemoryStream ms = new MemoryStream(response.Packet.Bitmap)) + { + var diffFrame = new RasterFrame(new Bitmap(ms), response.Packet.PartialRegion.Left, response.Packet.PartialRegion.Top); + diffFrame.Apply(_currentFrame); + diffFrame.Dispose(); + } + } + + Source = _currentFrame.ToBitmapSource(); + } + catch (Exception ex) + { + Debug.WriteLine($"Error on remote desktop packet received: {ex.Message}"); + } + }); + + sequencer.Start(); + + MachineProvider.MachineOperator.SendGenericContinuousRequest(new StartRemoteDesktopSessionRequest() { }, new Transport.TransportContinuousRequestConfig() + { + ContinuousTimeout = TimeSpan.FromSeconds(30), + }).Subscribe((response) => + { + sequencer.Push(response); + + }, (ex) => + { + Debug.WriteLine(ex); + }, () => { }); + } + + private void StopRemoteDesktop() + { + + } } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/ConsoleView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/ConsoleView.xaml index 4e2afa884..9514db919 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/ConsoleView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/ConsoleView.xaml @@ -11,8 +11,8 @@ mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:ConsoleViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.ConsoleViewVM}"> - - + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml index 8d986a04a..b6a4eec62 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml @@ -11,27 +11,41 @@ mc:Ignorable="d" d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:RemoteDesktopViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.RemoteDesktopViewVM}"> - - - - - - - - - + + + + + + + + + + + + + + - - - + + - - - + + + + + + + + + + + + + - + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/app.config b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/app.config index 36bc04f85..5d8d17458 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/app.config +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/app.config @@ -74,6 +74,10 @@ + + + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/packages.config b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/packages.config index dd8c723e4..d17a56d7d 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/packages.config +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/packages.config @@ -7,4 +7,10 @@ + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/IMachineProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/IMachineProvider.cs index c5886fb3c..be4748617 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/IMachineProvider.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/IMachineProvider.cs @@ -15,6 +15,16 @@ namespace Tango.FSE.Common.Connection /// public interface IMachineProvider { + /// + /// Occurs when machine operator has connected. + /// + event EventHandler MachineConnected; + + /// + /// Occurs when the machine operator has disconnected. + /// + event EventHandler MachineDisconnected; + /// /// Gets the database machine entity associated with the current machine. /// diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/MachineConnectedEventArgs.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/MachineConnectedEventArgs.cs new file mode 100644 index 000000000..ae4d18538 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/MachineConnectedEventArgs.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Integration.ExternalBridge; + +namespace Tango.FSE.Common.Connection +{ + public class MachineConnectedEventArgs : EventArgs + { + public IExternalBridgeClient MachineOperator { get; set; } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/MachineDisconnectedEventArgs.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/MachineDisconnectedEventArgs.cs new file mode 100644 index 000000000..1a4534baf --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/MachineDisconnectedEventArgs.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Integration.ExternalBridge; + +namespace Tango.FSE.Common.Connection +{ + public class MachineDisconnectedEventArgs : EventArgs + { + public IExternalBridgeClient MachineOperator { get; set; } + public Exception Exception { get; set; } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj index 80e1dde40..664643f95 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj @@ -83,6 +83,8 @@ + + ConnectedMachineIcon.xaml diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/App.config b/Software/Visual_Studio/FSE/Tango.FSE.UI/App.config index 22e3d6062..27bce5f20 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/App.config +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/App.config @@ -80,6 +80,10 @@ + + + + diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs index 10ba9d957..9027d6a01 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs @@ -57,6 +57,16 @@ namespace Tango.FSE.UI.Connection } } + /// + /// Occurs when machine operator has connected. + /// + public event EventHandler MachineConnected; + + /// + /// Occurs when the machine operator has disconnected. + /// + public event EventHandler MachineDisconnected; + [TangoInject] private INotificationProvider NotificationProvider { get; set; } @@ -192,6 +202,7 @@ namespace Tango.FSE.UI.Connection await MachineOperator.Connect(); IsConnected = true; + OnMachineConnected(MachineOperator); return true; } } @@ -234,6 +245,7 @@ namespace Tango.FSE.UI.Connection { IsConnected = false; IsBusy = false; + OnMachineDisconnected(MachineOperator, null); } } } @@ -247,6 +259,8 @@ namespace Tango.FSE.UI.Connection { IsConnected = false; + OnMachineDisconnected(MachineOperator, MachineOperator.FailedStateException); + InvokeUI(async () => { var vm = await NotificationProvider.ShowDialog(new MachineConnectionLostViewVM(MachineOperator, MachineOperator.FailedStateException.FlattenMessage(), 10)); @@ -280,6 +294,8 @@ namespace Tango.FSE.UI.Connection { IsConnected = false; + OnMachineDisconnected(MachineOperator, new Exception("The connection has been terminated by the remote machine.")); + InvokeUI(() => { NotificationProvider.ShowError("The connection has been terminated by the remote machine."); @@ -301,6 +317,23 @@ namespace Tango.FSE.UI.Connection MachineOperator.ContinuousRequestTimeout = TimeSpan.FromSeconds(5); } + protected virtual void OnMachineConnected(IExternalBridgeClient machineOperator) + { + MachineConnected?.Invoke(this, new MachineConnectedEventArgs() + { + MachineOperator = machineOperator, + }); + } + + protected virtual void OnMachineDisconnected(IExternalBridgeClient machineOperator, Exception exception) + { + MachineDisconnected?.Invoke(this, new MachineDisconnectedEventArgs() + { + MachineOperator = machineOperator, + Exception = exception + }); + } + /// /// Reassigns the event handlers from the previous connected machine to a new one. /// diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/LayoutView.xaml b/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/LayoutView.xaml index 5d84b6b46..2a4db030b 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/LayoutView.xaml @@ -36,9 +36,9 @@ - + - +