From d9b0b7617864600f690a8202d06b2fb2a64306db Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 19 Dec 2017 18:52:45 +0200 Subject: Started working on 'Synchronization' - Machine Studio module. --- .../Tango.MachineStudio.Synchronization.csproj | 184 +++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj new file mode 100644 index 000000000..53a0476e5 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj @@ -0,0 +1,184 @@ + + + + + Debug + AnyCPU + {12D0C43C-391F-4C74-92AB-82E9A9BEEB9B} + library + Tango.MachineStudio.Synchronization + Tango.MachineStudio.Synchronization + v4.6 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + true + full + false + ..\..\..\Build\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll + + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.dll + + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Extras.dll + + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll + + + ..\..\..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll + + + ..\..\..\packages\MaterialDesignColors.1.1.2\lib\net45\MaterialDesignColors.dll + + + ..\..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll + + + ..\..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll + + + + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll + + + + + + + + + 4.0 + + + + + + + + + + + + + RemoteSynchronizationView.xaml + + + LocalSynchronizationView.xaml + + + MainView.xaml + + + MenuView.xaml + + + MSBuild:Compile + Designer + + + GlobalVersionInfo.cs + + + + UserControl1.xaml + Code + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {0ecd6da8-7aa6-48d9-8b65-279d176ad9af} + Tango.DAL.Observables + + + {8491d07b-c1f6-4b62-a412-41b9fd2d6538} + Tango.SharedUI + + + {7ada4e86-cad7-4968-a210-3a8a9e5153ab} + Tango.Synchronization + + + {cb0b0aa2-bb24-4bca-a720-45e397684e12} + Tango.MachineStudio.Common + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.3.1 From de514b47f502ace13335e2a432b896f16af55039 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 20 Dec 2017 10:17:08 +0200 Subject: MERGE. --- Software/DB/Tango.mdf | Bin 8388608 -> 8388608 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes .../Tango.MachineStudio.Synchronization.csproj | 9 + .../ViewModelLocator.cs | 9 + .../ViewModels/LocalSynchronizationViewVM.cs | 302 +++++++++++++++++++++ .../ViewModels/MainViewVM.cs | 48 ++++ .../Views/LocalSynchronizationView.xaml | 46 +++- .../Views/MainView.xaml | 6 +- .../Views/MainView.xaml.cs | 15 + .../ViewModels/LoadingViewVM.cs | 2 +- .../ViewModels/MainViewVM.cs | 20 +- .../Tango.MachineStudio.UI/Views/MainView.xaml | 14 +- .../Visual_Studio/Tango.Settings/MachineStudio.cs | 18 -- .../MachineStudioSettings/MachineStudio.cs | 25 ++ .../MachineStudioSettings/SynchronizationModule.cs | 15 + .../Tango.Settings/SettingsCollection.cs | 1 + .../Tango.Settings/Tango.Settings.csproj | 3 +- .../Web/Tango.MachineService/App_Data/Tango.db | Bin 557056 -> 557056 bytes 18 files changed, 492 insertions(+), 41 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/LocalSynchronizationViewVM.cs delete mode 100644 Software/Visual_Studio/Tango.Settings/MachineStudio.cs create mode 100644 Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs create mode 100644 Software/Visual_Studio/Tango.Settings/MachineStudioSettings/SynchronizationModule.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 11a540748..4b61dad5b 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 5687558f7..9fc49b058 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj index 53a0476e5..8b2f0ae82 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj @@ -77,6 +77,7 @@ + @@ -153,6 +154,14 @@ {0ecd6da8-7aa6-48d9-8b65-279d176ad9af} Tango.DAL.Observables + + {bc932dbd-7cdb-488c-99e4-f02cf441f55e} + Tango.Logging + + + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} + Tango.Settings + {8491d07b-c1f6-4b62-a412-41b9fd2d6538} Tango.SharedUI diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModelLocator.cs index 30162e824..8eac609c2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModelLocator.cs @@ -20,6 +20,7 @@ namespace Tango.MachineStudio.Synchronization ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); SimpleIoc.Default.Unregister(); @@ -41,5 +42,13 @@ namespace Tango.MachineStudio.Synchronization return ServiceLocator.Current.GetInstance(); } } + + public static LocalSynchronizationViewVM LocalSynchronizationViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } } } \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/LocalSynchronizationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/LocalSynchronizationViewVM.cs new file mode 100644 index 000000000..773080813 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/LocalSynchronizationViewVM.cs @@ -0,0 +1,302 @@ +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.Logging; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.Synchronization.Navigation; +using Tango.MachineStudio.Synchronization.Properties; +using Tango.Settings; +using Tango.SharedUI; +using Tango.Synchronization; +using Tango.Synchronization.Local; + +namespace Tango.MachineStudio.Synchronization.ViewModels +{ + public class LocalSynchronizationViewVM : ViewModel + { + private SyncNavigationManager _navigation; + private String _masterDBFile; + private String _slaveDBFile; + private LocalDBComparer _comparer; + private INotificationProvider _notification; + private bool _isWorking; + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The navigation. + /// The notification. + public LocalSynchronizationViewVM(SyncNavigationManager navigation, INotificationProvider notification) + { + _navigation = navigation; + _notification = notification; + + BackCommand = new RelayCommand(() => _navigation.NavigateTo(NavigationView.MenuView)); + + Differences = new ObservableCollection(); + + BrowseMasterDBCommand = new RelayCommand(BrowseMasterDB, (x) => !_isWorking); + BrowseSlaveDBCommand = new RelayCommand(BrowseSlaveDB, (x) => !_isWorking); + CompareCommand = new RelayCommand(Compare, (x) => _masterDBFile != null && _slaveDBFile != null && !_isWorking); + CommitCommand = new RelayCommand(Commit, (x) => SelectedDifference != null && !_isWorking); + CommitAllCommand = new RelayCommand(CommitAll, (x) => Differences.Count > 0 && !_isWorking); + + if (File.Exists(SettingsManager.Default.MachineStudio.SynchronizationModule.LocalMasterDBFile)) + { + _masterDBFile = SettingsManager.Default.MachineStudio.SynchronizationModule.LocalMasterDBFile; + MasterDBName = Path.GetFileName(_masterDBFile); + } + + if (File.Exists(SettingsManager.Default.MachineStudio.SynchronizationModule.LocalSlaveDBFile)) + { + _slaveDBFile = SettingsManager.Default.MachineStudio.SynchronizationModule.LocalSlaveDBFile; + SlaveDBName = Path.GetFileName(_slaveDBFile); + } + } + + #endregion + + #region Commands + + /// + /// Gets or sets the back command. + /// + public RelayCommand BackCommand { get; set; } + + /// + /// Gets or sets the browse master database command. + /// + public RelayCommand BrowseMasterDBCommand { get; set; } + + /// + /// Gets or sets the browse slave database command. + /// + public RelayCommand BrowseSlaveDBCommand { get; set; } + + /// + /// Gets or sets the compare command. + /// + public RelayCommand CompareCommand { get; set; } + + /// + /// Gets or sets the commit command. + /// + public RelayCommand CommitCommand { get; set; } + + /// + /// Gets or sets the commit all command. + /// + public RelayCommand CommitAllCommand { get; set; } + #endregion + + #region Properties + + private ObservableCollection _differences; + /// + /// Gets or sets the differences. + /// + public ObservableCollection Differences + { + get { return _differences; } + set { _differences = value; RaisePropertyChanged(nameof(Differences)); } + } + + private Diff _selectedDifference; + /// + /// Gets or sets the selected difference. + /// + public Diff SelectedDifference + { + get { return _selectedDifference; } + set { _selectedDifference = value; RaisePropertyChanged(nameof(SelectedDifference)); InvalidateRelayCommands(); } + } + + private String _masterDBName; + /// + /// Gets or sets the name of the master database. + /// + public String MasterDBName + { + get { return _masterDBName; } + set { _masterDBName = value; RaisePropertyChanged(nameof(MasterDBName)); } + } + + private String _slaveDBName; + /// + /// Gets or sets the name of the slave database. + /// + public String SlaveDBName + { + get { return _slaveDBName; } + set { _slaveDBName = value; RaisePropertyChanged(nameof(SlaveDBName)); } + } + + #endregion + + #region Private Methods + + private void Compare() + { + _comparer = new LocalDBComparer(new SQLiteDataBase(_masterDBFile), new SQLiteDataBase(_slaveDBFile)); + + Task.Factory.StartNew(() => + { + using (_notification.PushTaskItem("Comparing Databases...")) + { + try + { + _isWorking = true; + InvalidateRelayCommands(); + Thread.Sleep(1500); + var diffs = _comparer.Compare(); + Differences = new ObservableCollection(diffs); + + if (diffs.Where(x => x.Action != DiffAction.ReplaceTableDataInSlave).Count() > 0) + { + ShowInfo("Found " + Differences.Where(x => x.Action != DiffAction.ReplaceTableDataInSlave).Count() + " differences."); + } + else + { + ShowInfo("The master and slave databases are synchronized."); + } + } + catch (Exception ex) + { + ShowError(ex.Message); + } + finally + { + _isWorking = false; + SelectedDifference = null; + InvalidateRelayCommands(); + + SettingsManager.Default.MachineStudio.SynchronizationModule.LocalMasterDBFile = _masterDBFile; + SettingsManager.Default.MachineStudio.SynchronizationModule.LocalSlaveDBFile = _slaveDBFile; + SettingsManager.SaveDefaultSettings(); + } + } + }); + } + + private void Commit() + { + Task.Factory.StartNew(() => + { + using (_notification.PushTaskItem("Committing difference...")) + { + try + { + _isWorking = true; + InvalidateRelayCommands(); + Thread.Sleep(1500); + SelectedDifference.Commit(); + + InvokeUINow(() => Differences.Remove(SelectedDifference)); + } + catch (Exception ex) + { + ShowError(ex.Message); + } + finally + { + _isWorking = false; + SelectedDifference = null; + InvalidateRelayCommands(); + } + } + }); + } + + private void CommitAll() + { + Task.Factory.StartNew(() => + { + using (_notification.PushTaskItem("Committing all differences...")) + { + try + { + _isWorking = true; + InvalidateRelayCommands(); + Thread.Sleep(1500); + + for (int i = 0; i < Differences.Count; i++) + { + var diff = Differences[i]; + using (_notification.PushTaskItem("Committing difference " + (Differences.IndexOf(diff) + 1) + "...")) + { + diff.Commit(); + InvokeUINow(() => Differences.Remove(diff)); + i--; + } + } + } + catch (Exception ex) + { + ShowError(ex.Message); + } + finally + { + _isWorking = false; + SelectedDifference = null; + InvalidateRelayCommands(); + } + } + }); + } + + private void BrowseSlaveDB() + { + String file = BrowseForFilePath(); + if (file != null) + { + _slaveDBFile = file; + SlaveDBName = Path.GetFileName(file); + InvalidateRelayCommands(); + } + } + + private void BrowseMasterDB() + { + String file = BrowseForFilePath(); + if (file != null) + { + _masterDBFile = file; + MasterDBName = Path.GetFileName(file); + InvalidateRelayCommands(); + } + } + + private String BrowseForFilePath() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Select SQLite Database File"; + dlg.Filter = "SQLite Database|*.db"; + if (dlg.ShowDialog().Value) + { + return dlg.FileName; + } + return null; + } + + private void ShowError(String message) + { + InvokeUINow(() => _notification.ShowError(message)); + } + + private void ShowInfo(String message) + { + InvokeUINow(() => _notification.ShowInfo(message)); + } + + #endregion + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/MainViewVM.cs index 61bf6e20c..c392aee1a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/MainViewVM.cs @@ -3,11 +3,59 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Logging; using Tango.SharedUI; namespace Tango.MachineStudio.Synchronization.ViewModels { public class MainViewVM : ViewModel { + public MainViewVM() + { + MainViewLogger logger = new MainViewLogger(); + logger.NewLog += (output) => + { + Log += output + Environment.NewLine; + }; + + LogManager.RegisterLogger(logger); + } + + private String _log; + /// + /// Gets or sets the current application log text. + /// + public String Log + { + get { return _log; } + set { _log = value; RaisePropertyChanged(nameof(Log)); } + } + + #region Custom Logger + + public class MainViewLogger : ILogger + { + public bool Enabled { get; set; } + public bool Immediate { get; set; } + public event Action NewLog; + + public MainViewLogger() + { + Enabled = true; + Immediate = true; + } + + public void OnError(LogItemBase output) + { + NewLog?.Invoke(output.TimeStamp.ToTimeString() + ": " + output.GetMessage()); + } + + public void OnTrace(LogItemBase output) + { + NewLog?.Invoke(output.TimeStamp.ToTimeString() + ": " + output.GetMessage()); + } + } + + #endregion } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/LocalSynchronizationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/LocalSynchronizationView.xaml index ded60fbb7..e52a8bfc1 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/LocalSynchronizationView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/LocalSynchronizationView.xaml @@ -4,10 +4,13 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:synchronization="clr-namespace:Tango.Synchronization;assembly=Tango.Synchronization" + xmlns:global="clr-namespace:Tango.MachineStudio.Synchronization" xmlns:local="clr-namespace:Tango.MachineStudio.Synchronization.Views" xmlns:fa="http://schemas.fontawesome.io/icons/" mc:Ignorable="d" - d:DesignHeight="720" d:DesignWidth="1280"> + d:DesignHeight="720" d:DesignWidth="1280" DataContext="{x:Static global:ViewModelLocator.LocalSynchronizationViewVM}"> @@ -31,11 +34,23 @@ - + + + + + + + + Local Database Synchronization + + + - + @@ -58,10 +73,10 @@ - Master DataBase + Master Database - @@ -69,10 +84,10 @@ - Slave DataBase + Slave Database - @@ -91,14 +106,25 @@ - Differences + Differences - + + + + + @@ -123,7 +149,7 @@ SQL Command - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/MainView.xaml index 53bcfdb1e..bac530777 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/MainView.xaml @@ -5,7 +5,7 @@ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Tango.MachineStudio.Synchronization.Views" - xmlns:global="clr-namespace:Tango.MachineStudio.Synchronization" + xmlns:global="clr-namespace:Tango.MachineStudio.Synchronization" xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" mc:Ignorable="d" d:DesignHeight="720" d:DesignWidth="1280" Background="White" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> @@ -32,8 +32,8 @@ - - 11:35:10.34> Synchronization Engine Started... + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/MainView.xaml.cs index 65e50905d..31d50dedb 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/MainView.xaml.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; @@ -27,5 +28,19 @@ namespace Tango.MachineStudio.Synchronization.Views InitializeComponent(); Instance = this; } + + private void txtLog_TextChanged(object sender, TextChangedEventArgs e) + { + Task.Factory.StartNew(() => + { + Thread.Sleep(50); + + this.Dispatcher.Invoke(() => + { + txtLog.SelectionStart = txtLog.Text.Length; + txtLog.ScrollToEnd(); + }); + }); + } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs index f50b734f4..6505bcf88 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -31,7 +31,7 @@ namespace Tango.MachineStudio.UI.ViewModels { StaThreadHelper.StartStaThread(() => { - Thread.Sleep(3000); + Thread.Sleep(1000); try { ObservablesEntitiesAdapter.Instance.Initialize(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index 7ef47fabd..a12156d60 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -26,6 +26,15 @@ namespace Tango.MachineStudio.UI.ViewModels set { _currentModule = value; RaisePropertyChangedAuto(); } } + private bool _isModuleLoaded; + + public bool IsModuleLoaded + { + get { return _isModuleLoaded; } + set { _isModuleLoaded = value; RaisePropertyChangedAuto(); } + } + + private bool _isMenuOpened; public bool IsMenuOpened @@ -85,7 +94,16 @@ namespace Tango.MachineStudio.UI.ViewModels private void StartModule(IStudioModule module) { IsMenuOpened = false; - CurrentModule = module; + + if (module != null) + { + CurrentModule = module; + IsModuleLoaded = true; + } + else + { + IsModuleLoaded = false; + } } protected override void OnViewAttached() diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml index cb7378666..aad1189b8 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml @@ -166,22 +166,22 @@ - + - - - + + + - - - + + + diff --git a/Software/Visual_Studio/Tango.Settings/MachineStudio.cs b/Software/Visual_Studio/Tango.Settings/MachineStudio.cs deleted file mode 100644 index bc486b6c3..000000000 --- a/Software/Visual_Studio/Tango.Settings/MachineStudio.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core.Cryptography; - -namespace Tango.Settings -{ - public class MachineStudio - { - public String LastLoginEmail { get; set; } - - public String LastLoginPassword { get; set; } - - public bool RememberMe { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs b/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs new file mode 100644 index 000000000..723d85c5d --- /dev/null +++ b/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Cryptography; + +namespace Tango.Settings.MachineStudioSettings +{ + public class MachineStudio + { + public String LastLoginEmail { get; set; } + + public String LastLoginPassword { get; set; } + + public bool RememberMe { get; set; } + + public SynchronizationModule SynchronizationModule { get; set; } + + public MachineStudio() + { + SynchronizationModule = new SynchronizationModule(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/SynchronizationModule.cs b/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/SynchronizationModule.cs new file mode 100644 index 000000000..18e50da90 --- /dev/null +++ b/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/SynchronizationModule.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Settings.MachineStudioSettings +{ + public class SynchronizationModule + { + public String LocalMasterDBFile { get; set; } + + public String LocalSlaveDBFile { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.Settings/SettingsCollection.cs b/Software/Visual_Studio/Tango.Settings/SettingsCollection.cs index 1e0fbd522..aae228b49 100644 --- a/Software/Visual_Studio/Tango.Settings/SettingsCollection.cs +++ b/Software/Visual_Studio/Tango.Settings/SettingsCollection.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Serialization; +using Tango.Settings.MachineStudioSettings; namespace Tango.Settings { diff --git a/Software/Visual_Studio/Tango.Settings/Tango.Settings.csproj b/Software/Visual_Studio/Tango.Settings/Tango.Settings.csproj index 895079449..e85a5f1bd 100644 --- a/Software/Visual_Studio/Tango.Settings/Tango.Settings.csproj +++ b/Software/Visual_Studio/Tango.Settings/Tango.Settings.csproj @@ -44,7 +44,8 @@ GlobalVersionInfo.cs - + + diff --git a/Software/Visual_Studio/Web/Tango.MachineService/App_Data/Tango.db b/Software/Visual_Studio/Web/Tango.MachineService/App_Data/Tango.db index 2a238547c..a0d317b86 100644 Binary files a/Software/Visual_Studio/Web/Tango.MachineService/App_Data/Tango.db and b/Software/Visual_Studio/Web/Tango.MachineService/App_Data/Tango.db differ -- cgit v1.3.1 From 6091da506db1083f6ca707c24e509ca3470f6a73 Mon Sep 17 00:00:00 2001 From: Roy Date: Fri, 22 Dec 2017 13:28:53 +0200 Subject: Implemented Remote To Local File Synchronization. --- Software/DB/Tango.db | Bin 557056 -> 557056 bytes Software/DB/Tango.mdf | Bin 8388608 -> 8388608 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes .../Tango.MachineStudio.Synchronization/App.config | 15 + .../AutoComplete/MachinesProvider.cs | 19 + .../Tango.MachineStudio.Synchronization.csproj | 32 +- .../UserControl1.xaml | 12 - .../UserControl1.xaml.cs | 28 -- .../ViewModelLocator.cs | 9 + .../ViewModels/LocalSynchronizationViewVM.cs | 81 ++- .../ViewModels/RemoteSynchronizationViewVM.cs | 372 ++++++++++++++ .../Views/LocalSynchronizationView.xaml | 13 +- .../Views/RemoteSynchronizationView.xaml | 164 ++++++- .../packages.config | 1 + .../Resources/MaterialDesign.xaml | 113 +++++ .../StudioApplication/IStudioApplicationManager.cs | 1 + .../Tango.MachineStudio.Common.csproj | 4 + .../Tango.MachineStudio.UI/App.config | 10 +- .../MachineStudio/Tango.MachineStudio.UI/App.xaml | 59 +-- .../Navigation/DefaultNavigationManager.cs | 5 +- .../DefaultStudioApplicationManager.cs | 12 +- .../Tango.AutoComplete/BindingEvaluator.cs | 56 +++ .../Editors/AutoCompleteTextBox.cs | 545 +++++++++++++++++++++ .../Editors/ISuggestionProvider.cs | 17 + .../Tango.AutoComplete/Editors/SelectionAdapter.cs | 131 +++++ .../Editors/SuggestionProvider.cs | 39 ++ .../Tango.AutoComplete/Editors/Themes/Generic.xaml | 157 ++++++ .../SideChains/Tango.AutoComplete/Enumerations.cs | 5 + .../Tango.AutoComplete/Properties/AssemblyInfo.cs | 53 ++ .../Properties/Resources.Designer.cs | 63 +++ .../Tango.AutoComplete/Properties/Resources.resx | 117 +++++ .../Properties/Settings.Designer.cs | 26 + .../Properties/Settings.settings | 7 + .../Tango.AutoComplete/Tango.AutoComplete.csproj | 100 ++++ .../Tango.AutoComplete/Themes/Generic.xaml | 7 + .../Tango.DAL.Remote/Partials/RemoteDB.cs | 6 +- .../MachineStudioSettings/SynchronizationModule.cs | 2 + .../Tango.Synchronization/Local/SqliteDataBase.cs | 4 +- .../Remote/RemoteDBComparer.cs | 2 +- Software/Visual_Studio/Tango.sln | 25 +- 40 files changed, 2181 insertions(+), 131 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/App.config create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/AutoComplete/MachinesProvider.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/UserControl1.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/UserControl1.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/RemoteSynchronizationViewVM.cs create mode 100644 Software/Visual_Studio/SideChains/Tango.AutoComplete/BindingEvaluator.cs create mode 100644 Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/AutoCompleteTextBox.cs create mode 100644 Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/ISuggestionProvider.cs create mode 100644 Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/SelectionAdapter.cs create mode 100644 Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/SuggestionProvider.cs create mode 100644 Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/Themes/Generic.xaml create mode 100644 Software/Visual_Studio/SideChains/Tango.AutoComplete/Enumerations.cs create mode 100644 Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/Resources.Designer.cs create mode 100644 Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/Resources.resx create mode 100644 Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/Settings.Designer.cs create mode 100644 Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/Settings.settings create mode 100644 Software/Visual_Studio/SideChains/Tango.AutoComplete/Tango.AutoComplete.csproj create mode 100644 Software/Visual_Studio/SideChains/Tango.AutoComplete/Themes/Generic.xaml (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj') diff --git a/Software/DB/Tango.db b/Software/DB/Tango.db index 00c79da9c..0419b065c 100644 Binary files a/Software/DB/Tango.db and b/Software/DB/Tango.db differ diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index fb25f3c28..2123553a2 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 6deb366c2..74ecadd2d 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/App.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/App.config new file mode 100644 index 000000000..00d1c3941 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/App.config @@ -0,0 +1,15 @@ + + + + +
+ + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/AutoComplete/MachinesProvider.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/AutoComplete/MachinesProvider.cs new file mode 100644 index 000000000..887cb842d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/AutoComplete/MachinesProvider.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.AutoComplete.Editors; +using Tango.DAL.Observables; + +namespace Tango.MachineStudio.Synchronization.AutoComplete +{ + public class MachinesProvider : ISuggestionProvider + { + public IEnumerable GetSuggestions(string filter) + { + return ObservablesEntitiesAdapter.Instance.Machines.Where(x => x.SerialNumber.StartsWith(filter, StringComparison.CurrentCultureIgnoreCase)).ToList(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj index 8b2f0ae82..12323ff91 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj @@ -12,6 +12,8 @@ 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 + + true @@ -31,6 +33,12 @@ 4 + + ..\..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll + + + ..\..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll + ..\..\..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll @@ -56,6 +64,7 @@ ..\..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll @@ -74,12 +83,14 @@ + + RemoteSynchronizationView.xaml @@ -92,18 +103,10 @@ MenuView.xaml - - MSBuild:Compile - Designer - GlobalVersionInfo.cs - - UserControl1.xaml - Code - MSBuild:Compile Designer @@ -139,6 +142,7 @@ ResXFileCodeGenerator Resources.Designer.cs + SettingsSingleFileGenerator @@ -146,14 +150,26 @@ + + {bb2abb74-ba58-4812-83aa-ec8171f42df4} + Tango.AutoComplete + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core + + {0e0eef3e-8f4e-4f23-9d19-479fd8d76c12} + Tango.DAL.Local + {0ecd6da8-7aa6-48d9-8b65-279d176ad9af} Tango.DAL.Observables + + {38197109-8610-4d3f-92b9-16d48df94d7c} + Tango.DAL.Remote + {bc932dbd-7cdb-488c-99e4-f02cf441f55e} Tango.Logging diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/UserControl1.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/UserControl1.xaml deleted file mode 100644 index 50afe7e4e..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/UserControl1.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/UserControl1.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/UserControl1.xaml.cs deleted file mode 100644 index 16186b6bd..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/UserControl1.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -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.MachineStudio.Synchronization -{ - /// - /// Interaction logic for UserControl1.xaml - /// - public partial class UserControl1 : UserControl - { - public UserControl1() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModelLocator.cs index 8eac609c2..a58ffe64b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModelLocator.cs @@ -21,6 +21,7 @@ namespace Tango.MachineStudio.Synchronization SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); SimpleIoc.Default.Unregister(); @@ -50,5 +51,13 @@ namespace Tango.MachineStudio.Synchronization return ServiceLocator.Current.GetInstance(); } } + + public static RemoteSynchronizationViewVM RemoteSynchronizationViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } } } \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/LocalSynchronizationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/LocalSynchronizationViewVM.cs index 773080813..9c805cca4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/LocalSynchronizationViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/LocalSynchronizationViewVM.cs @@ -46,20 +46,21 @@ namespace Tango.MachineStudio.Synchronization.ViewModels BrowseMasterDBCommand = new RelayCommand(BrowseMasterDB, (x) => !_isWorking); BrowseSlaveDBCommand = new RelayCommand(BrowseSlaveDB, (x) => !_isWorking); - CompareCommand = new RelayCommand(Compare, (x) => _masterDBFile != null && _slaveDBFile != null && !_isWorking); + CompareCommand = new RelayCommand(Compare, (x) => MasterDBFile != null && SlaveDBFile != null && !_isWorking); CommitCommand = new RelayCommand(Commit, (x) => SelectedDifference != null && !_isWorking); CommitAllCommand = new RelayCommand(CommitAll, (x) => Differences.Count > 0 && !_isWorking); + CleanCommand = new RelayCommand(CleanSlave, (x) => !_isWorking && SlaveDBFile != null); if (File.Exists(SettingsManager.Default.MachineStudio.SynchronizationModule.LocalMasterDBFile)) { - _masterDBFile = SettingsManager.Default.MachineStudio.SynchronizationModule.LocalMasterDBFile; - MasterDBName = Path.GetFileName(_masterDBFile); + MasterDBFile = SettingsManager.Default.MachineStudio.SynchronizationModule.LocalMasterDBFile; + MasterDBName = Path.GetFileName(MasterDBFile); } if (File.Exists(SettingsManager.Default.MachineStudio.SynchronizationModule.LocalSlaveDBFile)) { - _slaveDBFile = SettingsManager.Default.MachineStudio.SynchronizationModule.LocalSlaveDBFile; - SlaveDBName = Path.GetFileName(_slaveDBFile); + SlaveDBFile = SettingsManager.Default.MachineStudio.SynchronizationModule.LocalSlaveDBFile; + SlaveDBName = Path.GetFileName(SlaveDBFile); } } @@ -96,6 +97,11 @@ namespace Tango.MachineStudio.Synchronization.ViewModels /// Gets or sets the commit all command. /// public RelayCommand CommitAllCommand { get; set; } + + /// + /// Gets or sets the clean command. + /// + public RelayCommand CleanCommand { get; set; } #endregion #region Properties @@ -140,13 +146,68 @@ namespace Tango.MachineStudio.Synchronization.ViewModels set { _slaveDBName = value; RaisePropertyChanged(nameof(SlaveDBName)); } } + /// + /// Gets or sets the slave database file. + /// + public String SlaveDBFile + { + get { return _slaveDBFile; } + set { _slaveDBFile = value; RaisePropertyChangedAuto(); } + } + + /// + /// Gets or sets the master database file. + /// + public String MasterDBFile + { + get { return _masterDBFile; } + set { _masterDBFile = value; RaisePropertyChangedAuto(); } + } + #endregion #region Private Methods + private async void CleanSlave() + { + if (_notification.ShowQuestion("Are you sure you want to erase all data on slave database?")) + { + using (_notification.PushTaskItem("Clearing database...")) + { + try + { + _isWorking = true; + await Task.Factory.StartNew(() => + { + SQLiteDataBase localDB = new SQLiteDataBase(SlaveDBFile); + localDB.LoadTables(); + localDB.ClearDataBase(); + try + { + localDB.Dispose(); + } + catch { } + }); + + Differences.Clear(); + } + catch (Exception ex) + { + ShowError(LogManager.Log(ex).Message); + } + finally + { + _isWorking = false; + InvalidateRelayCommands(); + SelectedDifference = null; + } + } + } + } + private void Compare() { - _comparer = new LocalDBComparer(new SQLiteDataBase(_masterDBFile), new SQLiteDataBase(_slaveDBFile)); + _comparer = new LocalDBComparer(new SQLiteDataBase(MasterDBFile), new SQLiteDataBase(SlaveDBFile)); Task.Factory.StartNew(() => { @@ -179,8 +240,8 @@ namespace Tango.MachineStudio.Synchronization.ViewModels SelectedDifference = null; InvalidateRelayCommands(); - SettingsManager.Default.MachineStudio.SynchronizationModule.LocalMasterDBFile = _masterDBFile; - SettingsManager.Default.MachineStudio.SynchronizationModule.LocalSlaveDBFile = _slaveDBFile; + SettingsManager.Default.MachineStudio.SynchronizationModule.LocalMasterDBFile = MasterDBFile; + SettingsManager.Default.MachineStudio.SynchronizationModule.LocalSlaveDBFile = SlaveDBFile; SettingsManager.SaveDefaultSettings(); } } @@ -258,7 +319,7 @@ namespace Tango.MachineStudio.Synchronization.ViewModels String file = BrowseForFilePath(); if (file != null) { - _slaveDBFile = file; + SlaveDBFile = file; SlaveDBName = Path.GetFileName(file); InvalidateRelayCommands(); } @@ -269,7 +330,7 @@ namespace Tango.MachineStudio.Synchronization.ViewModels String file = BrowseForFilePath(); if (file != null) { - _masterDBFile = file; + MasterDBFile = file; MasterDBName = Path.GetFileName(file); InvalidateRelayCommands(); } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/RemoteSynchronizationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/RemoteSynchronizationViewVM.cs new file mode 100644 index 000000000..e14b0ffb9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/RemoteSynchronizationViewVM.cs @@ -0,0 +1,372 @@ +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Data.Entity.Validation; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.DAL.Local.DB; +using Tango.DAL.Observables; +using Tango.DAL.Remote.DB; +using Tango.Logging; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.Common.StudioApplication; +using Tango.MachineStudio.Synchronization.Navigation; +using Tango.Settings; +using Tango.SharedUI; +using Tango.Synchronization; +using Tango.Synchronization.Local; +using Tango.Synchronization.Remote; + +namespace Tango.MachineStudio.Synchronization.ViewModels +{ + public class RemoteSynchronizationViewVM : ViewModel, IShutdownRequestBlocker + { + private SyncNavigationManager _navigation; + private String _slaveDBFile; + private INotificationProvider _notification; + private bool _isWorking; + private RemoteDBComparer _comparer; + private RemoteDB _remoteDB; + private LocalDB _localDB; + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The navigation. + /// The notification. + public RemoteSynchronizationViewVM(SyncNavigationManager navigation, INotificationProvider notification) + { + _navigation = navigation; + _notification = notification; + + BackCommand = new RelayCommand(() => _navigation.NavigateTo(NavigationView.MenuView)); + + Differences = new ObservableCollection(); + + BrowseSlaveDBCommand = new RelayCommand(BrowseSlaveDB, (x) => !_isWorking); + CompareCommand = new RelayCommand(Compare, (x) => SlaveDBFile != null && !_isWorking && SelectedMachine != null); + CommitCommand = new RelayCommand(Commit, (x) => SelectedDifference != null && !_isWorking && SelectedMachine != null); + CommitAllCommand = new RelayCommand(CommitAll, (x) => Differences.Count > 0 && !_isWorking && SelectedMachine != null); + CleanCommand = new RelayCommand(CleanSlave, (x) => !_isWorking && SlaveDBFile != null); + + if (File.Exists(SettingsManager.Default.MachineStudio.SynchronizationModule.RemoteSQLiteFile)) + { + SlaveDBFile = SettingsManager.Default.MachineStudio.SynchronizationModule.RemoteSQLiteFile; + SlaveDBName = Path.GetFileName(SlaveDBFile); + } + } + + #endregion + + #region Commands + + /// + /// Gets or sets the back command. + /// + public RelayCommand BackCommand { get; set; } + + /// + /// Gets or sets the browse master database command. + /// + public RelayCommand BrowseMasterDBCommand { get; set; } + + /// + /// Gets or sets the browse slave database command. + /// + public RelayCommand BrowseSlaveDBCommand { get; set; } + + /// + /// Gets or sets the compare command. + /// + public RelayCommand CompareCommand { get; set; } + + /// + /// Gets or sets the commit command. + /// + public RelayCommand CommitCommand { get; set; } + + /// + /// Gets or sets the commit all command. + /// + public RelayCommand CommitAllCommand { get; set; } + + /// + /// Gets or sets the clean command. + /// + public RelayCommand CleanCommand { get; set; } + + #endregion + + #region Properties + + private ObservableCollection _differences; + /// + /// Gets or sets the differences. + /// + public ObservableCollection Differences + { + get { return _differences; } + set { _differences = value; RaisePropertyChanged(nameof(Differences)); } + } + + private Diff _selectedDifference; + /// + /// Gets or sets the selected difference. + /// + public Diff SelectedDifference + { + get { return _selectedDifference; } + set { _selectedDifference = value; RaisePropertyChanged(nameof(SelectedDifference)); InvalidateRelayCommands(); } + } + + private String _slaveDBName; + /// + /// Gets or sets the name of the slave database. + /// + public String SlaveDBName + { + get { return _slaveDBName; } + set { _slaveDBName = value; RaisePropertyChanged(nameof(SlaveDBName)); } + } + + private Machine _selectedMachine; + /// + /// Gets or sets the selected machine. + /// + public Machine SelectedMachine + { + get { return _selectedMachine; } + set { _selectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + /// + /// Gets or sets the slave database file. + /// + public String SlaveDBFile + { + get { return _slaveDBFile; } + set { _slaveDBFile = value; RaisePropertyChangedAuto(); } + } + #endregion + + #region Private Methods + + private async void CleanSlave() + { + if (_notification.ShowQuestion("Are you sure you want to erase all data on slave database?")) + { + using (_notification.PushTaskItem("Clearing database...")) + { + try + { + _isWorking = true; + await Task.Factory.StartNew(() => + { + SQLiteDataBase localDB = new SQLiteDataBase(SlaveDBFile); + localDB.LoadTables(); + localDB.ClearDataBase(); + try + { + localDB.Dispose(); + } + catch{ } + }); + + Differences.Clear(); + } + catch (Exception ex) + { + ShowError(LogManager.Log(ex).Message); + } + finally + { + _isWorking = false; + InvalidateRelayCommands(); + SelectedDifference = null; + } + } + } + } + + private void Compare() + { + Task.Factory.StartNew(() => + { + using (_notification.PushTaskItem("Comparing Databases...")) + { + try + { + if (_comparer != null) + { + _comparer.Dispose(); + } + + _remoteDB = RemoteDB.CreateDefault(); + _localDB = new LocalDB(SlaveDBFile); + _comparer = new RemoteDBComparer(_remoteDB, _localDB, SelectedMachine.SerialNumber); + _isWorking = true; + InvalidateRelayCommands(); + Thread.Sleep(1500); + var diffs = _comparer.Compare(); + Differences = new ObservableCollection(diffs); + + if (diffs.Where(x => x.Action != DiffAction.ReplaceTableDataInSlave).Count() > 0) + { + ShowInfo("Found " + Differences.Where(x => x.Action != DiffAction.ReplaceTableDataInSlave).Count() + " differences."); + } + else + { + ShowInfo("The master and slave databases are synchronized."); + } + } + catch (Exception ex) + { + ShowError(ex.Message); + } + finally + { + _isWorking = false; + SelectedDifference = null; + InvalidateRelayCommands(); + + SettingsManager.Default.MachineStudio.SynchronizationModule.RemoteSQLiteFile = SlaveDBFile; + SettingsManager.SaveDefaultSettings(); + } + } + }); + } + + private void Commit() + { + Task.Factory.StartNew(() => + { + using (_notification.PushTaskItem("Committing difference...")) + { + try + { + _isWorking = true; + InvalidateRelayCommands(); + Thread.Sleep(1500); + SelectedDifference.Commit(); + _remoteDB.SaveChanges(); + _localDB.SaveChanges(); + + InvokeUINow(() => Differences.Remove(SelectedDifference)); + } + catch (Exception ex) + { + ShowError(ex.Message); + } + finally + { + _isWorking = false; + SelectedDifference = null; + InvalidateRelayCommands(); + } + } + }); + } + + private void CommitAll() + { + Task.Factory.StartNew(() => + { + using (_notification.PushTaskItem("Committing all differences...")) + { + try + { + _isWorking = true; + InvalidateRelayCommands(); + Thread.Sleep(1500); + + for (int i = 0; i < Differences.Count; i++) + { + var diff = Differences[i]; + using (_notification.PushTaskItem("Committing difference " + (Differences.IndexOf(diff) + 1) + "...")) + { + diff.Commit(); + InvokeUINow(() => Differences.Remove(diff)); + i--; + } + } + + _remoteDB.SaveChanges(); + _localDB.SaveChanges(); + } + catch (DbEntityValidationException ex) + { + String message = "The following validation errors occurred while trying to update the database." + Environment.NewLine + Environment.NewLine; + + foreach (var error in ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).ToList()) + { + message += error.ErrorMessage + Environment.NewLine; + } + + ShowError(message); + } + catch (Exception ex) + { + ShowError(ex.Message); + } + finally + { + _isWorking = false; + SelectedDifference = null; + InvalidateRelayCommands(); + } + } + }); + } + + private void BrowseSlaveDB() + { + String file = BrowseForFilePath(); + if (file != null) + { + SlaveDBFile = file; + SlaveDBName = Path.GetFileName(file); + InvalidateRelayCommands(); + } + } + + private String BrowseForFilePath() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Select SQLite Database File"; + dlg.Filter = "SQLite Database|*.db"; + if (dlg.ShowDialog().Value) + { + return dlg.FileName; + } + return null; + } + + private void ShowError(String message) + { + InvokeUINow(() => _notification.ShowError(message)); + } + + private void ShowInfo(String message) + { + InvokeUINow(() => _notification.ShowInfo(message)); + } + + public Task OnShutdownRequest() + { + if (_comparer != null) + { + _comparer.Dispose(); + } + return Task.FromResult(true); + } + + #endregion + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/LocalSynchronizationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/LocalSynchronizationView.xaml index e52a8bfc1..72297e2cb 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/LocalSynchronizationView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/LocalSynchronizationView.xaml @@ -75,7 +75,7 @@ Master Database - + @@ -86,7 +86,7 @@ Slave Database - + @@ -101,7 +101,7 @@ - + @@ -131,6 +131,13 @@ + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/RemoteSynchronizationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/RemoteSynchronizationView.xaml index 92c8fa674..2487aab64 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/RemoteSynchronizationView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/RemoteSynchronizationView.xaml @@ -3,10 +3,170 @@ 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:providers="clr-namespace:Tango.MachineStudio.Synchronization.AutoComplete" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:synchronization="clr-namespace:Tango.Synchronization;assembly=Tango.Synchronization" + xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete" + xmlns:global="clr-namespace:Tango.MachineStudio.Synchronization" + xmlns:local="clr-namespace:Tango.MachineStudio.Synchronization.Views" + xmlns:fa="http://schemas.fontawesome.io/icons/" mc:Ignorable="d" - d:DesignHeight="720" d:DesignWidth="1280" Background="White"> + d:DesignHeight="720" d:DesignWidth="1280" Background="White" DataContext="{x:Static global:ViewModelLocator.RemoteSynchronizationViewVM}"> + + + + + + + + + + + + + + + + + + + + + + + + + + - Remote Sync + + + + + + + + Local Database Synchronization + + + + + + + + + + + + + + + + + + + + + + + + Remote Database + + + + + + + + + + + + + + + + + + SQLite Database + + + + + + + + + + + + + + + Differences + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/packages.config index 42945b407..8d8f972d1 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/packages.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/packages.config @@ -1,6 +1,7 @@  + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml index 482e852d6..58bb9ef34 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml @@ -1,5 +1,7 @@  @@ -61,5 +63,116 @@ + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs index 0ee27fbf6..740c257b9 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs @@ -8,6 +8,7 @@ namespace Tango.MachineStudio.Common.StudioApplication { public interface IStudioApplicationManager { + bool IsShuttingDown { get;} void ShutDown(); } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index 70962a2f7..32466e45a 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -126,6 +126,10 @@ + + {bb2abb74-ba58-4812-83aa-ec8171f42df4} + Tango.AutoComplete + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config index 250f57a4d..b31d56717 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config @@ -1,7 +1,6 @@  -
@@ -11,6 +10,15 @@ + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml index 6974f54be..8e5876e79 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml @@ -9,64 +9,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Navigation/DefaultNavigationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Navigation/DefaultNavigationManager.cs index 10314ae62..15f2fe422 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Navigation/DefaultNavigationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Navigation/DefaultNavigationManager.cs @@ -11,7 +11,10 @@ namespace Tango.MachineStudio.UI.Navigation { public void NavigateTo(NavigationView view) { - MainWindow.Instance.TransitionControl.AutoNavigate(view.ToString()); + MainWindow.Instance.Dispatcher.Invoke(() => + { + MainWindow.Instance.TransitionControl.AutoNavigate(view.ToString()); + }); } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs index b95a74a3e..ea4234fd8 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -23,9 +23,13 @@ namespace Tango.MachineStudio.UI.StudioApplication _navigationManager = navigationManager; } + public bool IsShuttingDown { get; private set; } + public async void ShutDown() { - _navigationManager.NavigateTo(NavigationView.ShutdownView); + if (IsShuttingDown) return; + + IsShuttingDown = true; await Task.Factory.StartNew(async () => { @@ -36,14 +40,12 @@ namespace Tango.MachineStudio.UI.StudioApplication var result = await vm.OnShutdownRequest(); if (!result) { - ThreadsHelper.InvokeUI(() => - { - _navigationManager.NavigateTo(NavigationView.MainView); - }); + IsShuttingDown = false; return; } } + _navigationManager.NavigateTo(NavigationView.ShutdownView); Thread.Sleep(3000); Environment.Exit(0); diff --git a/Software/Visual_Studio/SideChains/Tango.AutoComplete/BindingEvaluator.cs b/Software/Visual_Studio/SideChains/Tango.AutoComplete/BindingEvaluator.cs new file mode 100644 index 000000000..a577db660 --- /dev/null +++ b/Software/Visual_Studio/SideChains/Tango.AutoComplete/BindingEvaluator.cs @@ -0,0 +1,56 @@ +namespace Tango.AutoComplete +{ + + using System.Windows; + using System.Windows.Data; + public class BindingEvaluator : FrameworkElement + { + + #region "Fields" + + + public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(string), typeof(BindingEvaluator), new FrameworkPropertyMetadata(string.Empty)); + + private Binding _valueBinding; + #endregion + + #region "Constructors" + + public BindingEvaluator(Binding binding) + { + ValueBinding = binding; + } + + #endregion + + #region "Properties" + + public string Value + { + get { return (string)GetValue(ValueProperty); } + + set { SetValue(ValueProperty, value); } + } + + public Binding ValueBinding + { + get { return _valueBinding; } + set { _valueBinding = value; } + } + + #endregion + + #region "Methods" + + public string Evaluate(object dataItem) + { + this.DataContext = dataItem; + SetBinding(ValueProperty, ValueBinding); + return Value; + } + + #endregion + + } + +} diff --git a/Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/AutoCompleteTextBox.cs b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/AutoCompleteTextBox.cs new file mode 100644 index 000000000..f350c0b9b --- /dev/null +++ b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/AutoCompleteTextBox.cs @@ -0,0 +1,545 @@ +namespace Tango.AutoComplete.Editors +{ + + using System; + using System.Collections; + using System.Threading; + using System.Windows; + using System.Windows.Controls; + using System.Windows.Controls.Primitives; + using System.Windows.Data; + using System.Windows.Input; + using System.Windows.Media; + using System.Windows.Threading; + + [TemplatePart(Name = AutoCompleteTextBox.PartEditor, Type = typeof(TextBox))] + [TemplatePart(Name = AutoCompleteTextBox.PartPopup, Type = typeof(Popup))] + [TemplatePart(Name = AutoCompleteTextBox.PartSelector, Type = typeof(Selector))] + public class AutoCompleteTextBox : Control + { + + #region "Fields" + + public const string PartEditor = "PART_Editor"; + public const string PartPopup = "PART_Popup"; + + public const string PartSelector = "PART_Selector"; + public static readonly DependencyProperty DelayProperty = DependencyProperty.Register("Delay", typeof(int), typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(200)); + public static readonly DependencyProperty DisplayMemberProperty = DependencyProperty.Register("DisplayMember", typeof(string), typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(string.Empty)); + public static readonly DependencyProperty IconPlacementProperty = DependencyProperty.Register("IconPlacement", typeof(IconPlacement), typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(IconPlacement.Left)); + public static readonly DependencyProperty IconProperty = DependencyProperty.Register("Icon", typeof(object), typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(null)); + public static readonly DependencyProperty IconVisibilityProperty = DependencyProperty.Register("IconVisibility", typeof(Visibility), typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(Visibility.Visible)); + public static readonly DependencyProperty IsDropDownOpenProperty = DependencyProperty.Register("IsDropDownOpen", typeof(bool), typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(false)); + public static readonly DependencyProperty IsLoadingProperty = DependencyProperty.Register("IsLoading", typeof(bool), typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(false)); + public static readonly DependencyProperty IsReadOnlyProperty = DependencyProperty.Register("IsReadOnly", typeof(bool), typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(false)); + public static readonly DependencyProperty ItemTemplateProperty = DependencyProperty.Register("ItemTemplate", typeof(DataTemplate), typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(null)); + public static readonly DependencyProperty ItemTemplateSelectorProperty = DependencyProperty.Register("ItemTemplateSelector", typeof(DataTemplateSelector), typeof(AutoCompleteTextBox)); + public static readonly DependencyProperty LoadingContentProperty = DependencyProperty.Register("LoadingContent", typeof(object), typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(null)); + public static readonly DependencyProperty ProviderProperty = DependencyProperty.Register("Provider", typeof(ISuggestionProvider), typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(null)); + public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register("SelectedItem", typeof(object), typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(null, OnSelectedItemChanged)); + public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(string.Empty)); + public static readonly DependencyProperty MaxLengthProperty = DependencyProperty.Register("MaxLength", typeof(int), typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(0)); + public static readonly DependencyProperty CharacterCasingProperty = DependencyProperty.Register("CharacterCasing", typeof(CharacterCasing), typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(CharacterCasing.Normal)); + public static readonly DependencyProperty MaxPopUpHeightProperty = DependencyProperty.Register("MaxPopUpHeight", typeof(int), typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(600)); + + public static readonly DependencyProperty WatermarkProperty = DependencyProperty.Register("Watermark", typeof(string), typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(string.Empty)); + + public static readonly DependencyProperty SuggestionBackgroundProperty = DependencyProperty.Register("SuggestionBackground", typeof(Brush), typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(Brushes.White)); + private BindingEvaluator _bindingEvaluator; + + private TextBox _editor; + + private DispatcherTimer _fetchTimer; + + private string _filter; + + private bool _isUpdatingText; + + private Selector _itemsSelector; + + private Popup _popup; + + private SelectionAdapter _selectionAdapter; + + private bool _selectionCancelled; + + private SuggestionsAdapter _suggestionsAdapter; + + + #endregion + + #region "Constructors" + + static AutoCompleteTextBox() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(typeof(AutoCompleteTextBox))); + } + + #endregion + + #region "Properties" + + + public int MaxPopupHeight + { + get { return (int) GetValue(MaxPopUpHeightProperty); } + set { SetValue(MaxPopUpHeightProperty, value);} + } + + + public BindingEvaluator BindingEvaluator + { + get { return _bindingEvaluator; } + set { _bindingEvaluator = value; } + } + + public CharacterCasing CharacterCasing + { + get { return (System.Windows.Controls.CharacterCasing) GetValue(CharacterCasingProperty); } + set { SetValue(CharacterCasingProperty, value);} + } + + public int MaxLength + { + get { return (int) GetValue(DelayProperty); } + set { SetValue(MaxLengthProperty, value); } + } + + public int Delay + { + get { return (int)GetValue(DelayProperty); } + + set { SetValue(DelayProperty, value); } + } + + public string DisplayMember + { + get { return (string)GetValue(DisplayMemberProperty); } + + set { SetValue(DisplayMemberProperty, value); } + } + + public TextBox Editor + { + get { return _editor; } + set { _editor = value; } + } + + public DispatcherTimer FetchTimer + { + get { return _fetchTimer; } + set { _fetchTimer = value; } + } + + public string Filter + { + get { return _filter; } + set { _filter = value; } + } + + public object Icon + { + get { return GetValue(IconProperty); } + + set { SetValue(IconProperty, value); } + } + + public IconPlacement IconPlacement + { + get { return (IconPlacement)GetValue(IconPlacementProperty); } + + set { SetValue(IconPlacementProperty, value); } + } + + public Visibility IconVisibility + { + get { return (Visibility)GetValue(IconVisibilityProperty); } + + set { SetValue(IconVisibilityProperty, value); } + } + + public bool IsDropDownOpen + { + get { return (bool)GetValue(IsDropDownOpenProperty); } + + set { SetValue(IsDropDownOpenProperty, value); } + } + + public bool IsLoading + { + get { return (bool)GetValue(IsLoadingProperty); } + + set { SetValue(IsLoadingProperty, value); } + } + + public bool IsReadOnly + { + get { return (bool)GetValue(IsReadOnlyProperty); } + + set { SetValue(IsReadOnlyProperty, value); } + } + + public Selector ItemsSelector + { + get { return _itemsSelector; } + set { _itemsSelector = value; } + } + + public DataTemplate ItemTemplate + { + get { return (DataTemplate)GetValue(ItemTemplateProperty); } + + set { SetValue(ItemTemplateProperty, value); } + } + + public DataTemplateSelector ItemTemplateSelector + { + get { return ((DataTemplateSelector)(GetValue(AutoCompleteTextBox.ItemTemplateSelectorProperty))); } + set { SetValue(AutoCompleteTextBox.ItemTemplateSelectorProperty, value); } + } + + public object LoadingContent + { + get { return GetValue(LoadingContentProperty); } + + set { SetValue(LoadingContentProperty, value); } + } + + public Popup Popup + { + get { return _popup; } + set { _popup = value; } + } + + public ISuggestionProvider Provider + { + get { return (ISuggestionProvider)GetValue(ProviderProperty); } + + set { SetValue(ProviderProperty, value); } + } + + public object SelectedItem + { + get { return GetValue(SelectedItemProperty); } + + set { SetValue(SelectedItemProperty, value); } + } + + public SelectionAdapter SelectionAdapter + { + get { return _selectionAdapter; } + set { _selectionAdapter = value; } + } + + public string Text + { + get { return (string)GetValue(TextProperty); } + + set { SetValue(TextProperty, value); } + } + + public string Watermark + { + get { return (string)GetValue(WatermarkProperty); } + + set { SetValue(WatermarkProperty, value); } + } + public Brush SuggestionBackground { + get { return (Brush)GetValue(SuggestionBackgroundProperty); } + + set { SetValue(SuggestionBackgroundProperty, value); } + } + + #endregion + + #region "Methods" + + public static void OnSelectedItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + AutoCompleteTextBox act = null; + act = d as AutoCompleteTextBox; + if (act != null) + { + if (act.Editor != null & !act._isUpdatingText) + { + act._isUpdatingText = true; + act.Editor.Text = act.BindingEvaluator.Evaluate(e.NewValue); + act._isUpdatingText = false; + } + } + } + + private void ScrollToSelectedItem() + { + ListBox listBox = ItemsSelector as ListBox; + if (listBox != null && listBox.SelectedItem != null) + listBox.ScrollIntoView(listBox.SelectedItem); + } + + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + Editor = Template.FindName(PartEditor, this) as TextBox; + Popup = Template.FindName(PartPopup, this) as Popup; + ItemsSelector = Template.FindName(PartSelector, this) as Selector; + BindingEvaluator = new BindingEvaluator(new Binding(DisplayMember)); + + if (Editor != null) + { + Editor.TextChanged += OnEditorTextChanged; + Editor.PreviewKeyDown += OnEditorKeyDown; + Editor.LostFocus += OnEditorLostFocus; + + if (SelectedItem != null) + { + Editor.Text = BindingEvaluator.Evaluate(SelectedItem); + } + + } + + this.GotFocus += AutoCompleteTextBox_GotFocus; + + if (Popup != null) + { + Popup.StaysOpen = false; + Popup.Opened += OnPopupOpened; + Popup.Closed += OnPopupClosed; + } + if (ItemsSelector != null) + { + SelectionAdapter = new SelectionAdapter(ItemsSelector); + SelectionAdapter.Commit += OnSelectionAdapterCommit; + SelectionAdapter.Cancel += OnSelectionAdapterCancel; + SelectionAdapter.SelectionChanged += OnSelectionAdapterSelectionChanged; + ItemsSelector.PreviewMouseDown += ItemsSelector_PreviewMouseDown; + } + } + private void ItemsSelector_PreviewMouseDown(object sender, MouseButtonEventArgs e) + { + var pos_item = (e.OriginalSource as FrameworkElement)?.DataContext; + if (pos_item == null) + return; + if (!ItemsSelector.Items.Contains(pos_item)) + return; + ItemsSelector.SelectedItem = pos_item; + OnSelectionAdapterCommit(); + } + private void AutoCompleteTextBox_GotFocus(object sender, RoutedEventArgs e) + { + Editor?.Focus(); + } + + private string GetDisplayText(object dataItem) + { + if (BindingEvaluator == null) + { + BindingEvaluator = new BindingEvaluator(new Binding(DisplayMember)); + } + if (dataItem == null) + { + return string.Empty; + } + if (string.IsNullOrEmpty(DisplayMember)) + { + return dataItem.ToString(); + } + return BindingEvaluator.Evaluate(dataItem); + } + + private void OnEditorKeyDown(object sender, KeyEventArgs e) + { + if (SelectionAdapter != null) + { + if (IsDropDownOpen) + SelectionAdapter.HandleKeyDown(e); + else + IsDropDownOpen = e.Key == Key.Down || e.Key == Key.Up; + } + } + + private void OnEditorLostFocus(object sender, RoutedEventArgs e) + { + if (!IsKeyboardFocusWithin) + { + IsDropDownOpen = false; + } + } + + private void OnEditorTextChanged(object sender, TextChangedEventArgs e) + { + if (_isUpdatingText) + return; + if (FetchTimer == null) + { + FetchTimer = new DispatcherTimer(); + FetchTimer.Interval = TimeSpan.FromMilliseconds(Delay); + FetchTimer.Tick += OnFetchTimerTick; + } + FetchTimer.IsEnabled = false; + FetchTimer.Stop(); + SetSelectedItem(null); + if (Editor.Text.Length > 0) + { + IsLoading = true; + IsDropDownOpen = true; + ItemsSelector.ItemsSource = null; + FetchTimer.IsEnabled = true; + FetchTimer.Start(); + } + else + { + IsDropDownOpen = false; + } + } + + private void OnFetchTimerTick(object sender, EventArgs e) + { + FetchTimer.IsEnabled = false; + FetchTimer.Stop(); + if (Provider != null && ItemsSelector != null) + { + Filter = Editor.Text; + if (_suggestionsAdapter == null) + { + _suggestionsAdapter = new SuggestionsAdapter(this); + } + _suggestionsAdapter.GetSuggestions(Filter); + } + } + + private void OnPopupClosed(object sender, EventArgs e) + { + if (!_selectionCancelled) + { + OnSelectionAdapterCommit(); + } + } + + private void OnPopupOpened(object sender, EventArgs e) + { + _selectionCancelled = false; + ItemsSelector.SelectedItem = SelectedItem; + } + + private void OnSelectionAdapterCancel() + { + _isUpdatingText = true; + Editor.Text = SelectedItem == null ? Filter : GetDisplayText(SelectedItem); + Editor.SelectionStart = Editor.Text.Length; + Editor.SelectionLength = 0; + _isUpdatingText = false; + IsDropDownOpen = false; + _selectionCancelled = true; + } + + private void OnSelectionAdapterCommit() + { + if (ItemsSelector.SelectedItem != null) + { + SelectedItem = ItemsSelector.SelectedItem; + _isUpdatingText = true; + Editor.Text = GetDisplayText(ItemsSelector.SelectedItem); + SetSelectedItem(ItemsSelector.SelectedItem); + _isUpdatingText = false; + IsDropDownOpen = false; + } + } + + private void OnSelectionAdapterSelectionChanged() + { + _isUpdatingText = true; + if (ItemsSelector.SelectedItem == null) + { + Editor.Text = Filter; + } + else + { + Editor.Text = GetDisplayText(ItemsSelector.SelectedItem); + } + Editor.SelectionStart = Editor.Text.Length; + Editor.SelectionLength = 0; + ScrollToSelectedItem(); + _isUpdatingText = false; + } + + private void SetSelectedItem(object item) + { + _isUpdatingText = true; + SelectedItem = item; + _isUpdatingText = false; + } + #endregion + + #region "Nested Types" + + private class SuggestionsAdapter + { + + #region "Fields" + + private AutoCompleteTextBox _actb; + + private string _filter; + #endregion + + #region "Constructors" + + public SuggestionsAdapter(AutoCompleteTextBox actb) + { + _actb = actb; + } + + #endregion + + #region "Methods" + + public void GetSuggestions(string searchText) + { + _filter = searchText; + _actb.IsLoading = true; + ParameterizedThreadStart thInfo = new ParameterizedThreadStart(GetSuggestionsAsync); + Thread th = new Thread(thInfo); + th.Start(new object[] { + searchText, + _actb.Provider + }); + } + + private void DisplaySuggestions(IEnumerable suggestions, string filter) + { + if (_filter != filter) + { + return; + } + if (_actb.IsDropDownOpen) + { + _actb.IsLoading = false; + _actb.ItemsSelector.ItemsSource = suggestions; + _actb.IsDropDownOpen = _actb.ItemsSelector.HasItems; + } + + } + + private void GetSuggestionsAsync(object param) + { + object[] args = param as object[]; + string searchText = Convert.ToString(args[0]); + ISuggestionProvider provider = args[1] as ISuggestionProvider; + IEnumerable list = provider.GetSuggestions(searchText); + _actb.Dispatcher.BeginInvoke(new Action(DisplaySuggestions), DispatcherPriority.Background, new object[] { + list, + searchText + }); + } + + #endregion + + } + + #endregion + + } + +} diff --git a/Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/ISuggestionProvider.cs b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/ISuggestionProvider.cs new file mode 100644 index 000000000..eca96a456 --- /dev/null +++ b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/ISuggestionProvider.cs @@ -0,0 +1,17 @@ + + +namespace Tango.AutoComplete.Editors +{ + using System.Collections; + + public interface ISuggestionProvider + { + + #region Public Methods + + IEnumerable GetSuggestions(string filter); + + #endregion Public Methods + + } +} diff --git a/Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/SelectionAdapter.cs b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/SelectionAdapter.cs new file mode 100644 index 000000000..3fcc8fd12 --- /dev/null +++ b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/SelectionAdapter.cs @@ -0,0 +1,131 @@ +namespace Tango.AutoComplete.Editors +{ + + using System.Diagnostics; + using System.Windows.Controls.Primitives; + using System.Windows.Input; + + public class SelectionAdapter + { + + #region "Fields" + + + private Selector _selectorControl; + #endregion + + #region "Constructors" + + public SelectionAdapter(Selector selector) + { + SelectorControl = selector; + SelectorControl.PreviewMouseUp += OnSelectorMouseDown; + } + + #endregion + + #region "Events" + + public delegate void CancelEventHandler(); + + public delegate void CommitEventHandler(); + + public delegate void SelectionChangedEventHandler(); + + public event CancelEventHandler Cancel; + public event CommitEventHandler Commit; + public event SelectionChangedEventHandler SelectionChanged; + #endregion + + #region "Properties" + + public Selector SelectorControl + { + get { return _selectorControl; } + set { _selectorControl = value; } + } + + #endregion + + #region "Methods" + + public void HandleKeyDown(KeyEventArgs key) + { + Debug.WriteLine(key.Key); + switch (key.Key) + { + case Key.Down: + IncrementSelection(); + break; + case Key.Up: + DecrementSelection(); + break; + case Key.Enter: + if (Commit != null) + { + Commit(); + } + + break; + case Key.Escape: + if (Cancel != null) + { + Cancel(); + } + + break; + case Key.Tab: + if (Commit != null) + { + Commit(); + } + + break; + } + } + + private void DecrementSelection() + { + if (SelectorControl.SelectedIndex == -1) + { + SelectorControl.SelectedIndex = SelectorControl.Items.Count - 1; + } + else + { + SelectorControl.SelectedIndex -= 1; + } + if (SelectionChanged != null) + { + SelectionChanged(); + } + } + + private void IncrementSelection() + { + if (SelectorControl.SelectedIndex == SelectorControl.Items.Count - 1) + { + SelectorControl.SelectedIndex = -1; + } + else + { + SelectorControl.SelectedIndex += 1; + } + if (SelectionChanged != null) + { + SelectionChanged(); + } + } + + private void OnSelectorMouseDown(object sender, MouseButtonEventArgs e) + { + if (Commit != null) + { + Commit(); + } + } + + #endregion + + } + +} diff --git a/Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/SuggestionProvider.cs b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/SuggestionProvider.cs new file mode 100644 index 000000000..8efb56f94 --- /dev/null +++ b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/SuggestionProvider.cs @@ -0,0 +1,39 @@ +namespace Tango.AutoComplete.Editors +{ + + using System; + using System.Collections; + public class SuggestionProvider : ISuggestionProvider + { + + + #region Private Fields + + private Func _method; + + #endregion Private Fields + + #region Public Constructors + + public SuggestionProvider(Func method) + { + if (method == null) + { + throw new ArgumentNullException("method"); + } + _method = method; + } + + #endregion Public Constructors + + #region Public Methods + + public System.Collections.IEnumerable GetSuggestions(string filter) + { + return _method(filter); + } + + #endregion Public Methods + + } +} diff --git a/Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/Themes/Generic.xaml b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/Themes/Generic.xaml new file mode 100644 index 000000000..a3c124841 --- /dev/null +++ b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Editors/Themes/Generic.xaml @@ -0,0 +1,157 @@ + + + + + + + + + + diff --git a/Software/Visual_Studio/SideChains/Tango.AutoComplete/Enumerations.cs b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Enumerations.cs new file mode 100644 index 000000000..fdc6cbea1 --- /dev/null +++ b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Enumerations.cs @@ -0,0 +1,5 @@ +public enum IconPlacement +{ + Left, + Right +} \ No newline at end of file diff --git a/Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/AssemblyInfo.cs b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..ef723816b --- /dev/null +++ b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/AssemblyInfo.cs @@ -0,0 +1,53 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; +using System.Windows.Markup; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango.AutoComplete")] +[assembly: AssemblyDescription("A collection of WPF controls.")] +[assembly: AssemblyCompany("Deepak Bhardwaj")] +[assembly: AssemblyProduct("Tango.AutoComplete")] +[assembly: AssemblyCopyright("Copyright © Deepak Bhardwaj 2015")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly:ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.8")] +[assembly: AssemblyFileVersion("1.0.0.8")] diff --git a/Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/Resources.Designer.cs b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/Resources.Designer.cs new file mode 100644 index 000000000..e649fff60 --- /dev/null +++ b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.AutoComplete.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.AutoComplete.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/Resources.resx b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/Settings.Designer.cs b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/Settings.Designer.cs new file mode 100644 index 000000000..46036a464 --- /dev/null +++ b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.AutoComplete.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/Settings.settings b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/SideChains/Tango.AutoComplete/Tango.AutoComplete.csproj b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Tango.AutoComplete.csproj new file mode 100644 index 000000000..130da019d --- /dev/null +++ b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Tango.AutoComplete.csproj @@ -0,0 +1,100 @@ + + + + + Debug + AnyCPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4} + library + Properties + Tango.AutoComplete + Tango.AutoComplete + v4.6 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + + + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/SideChains/Tango.AutoComplete/Themes/Generic.xaml b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Themes/Generic.xaml new file mode 100644 index 000000000..a766db735 --- /dev/null +++ b/Software/Visual_Studio/SideChains/Tango.AutoComplete/Themes/Generic.xaml @@ -0,0 +1,7 @@ + + + + + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/Partials/RemoteDB.cs b/Software/Visual_Studio/Tango.DAL.Remote/Partials/RemoteDB.cs index 6fdd35983..f6fcbcf3f 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/Partials/RemoteDB.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/Partials/RemoteDB.cs @@ -4,6 +4,7 @@ using System.Data.Entity; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Settings; namespace Tango.DAL.Remote.DB { @@ -26,6 +27,9 @@ namespace Tango.DAL.Remote.DB } } - + public static RemoteDB CreateDefault() + { + return new RemoteDB(SettingsManager.Default.DataBase.SQLServerAddress, false); + } } } diff --git a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/SynchronizationModule.cs b/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/SynchronizationModule.cs index 18e50da90..e5e82f581 100644 --- a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/SynchronizationModule.cs +++ b/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/SynchronizationModule.cs @@ -11,5 +11,7 @@ namespace Tango.Settings.MachineStudioSettings public String LocalMasterDBFile { get; set; } public String LocalSlaveDBFile { get; set; } + + public String RemoteSQLiteFile { get; set; } } } diff --git a/Software/Visual_Studio/Tango.Synchronization/Local/SqliteDataBase.cs b/Software/Visual_Studio/Tango.Synchronization/Local/SqliteDataBase.cs index add791b19..6068d5b6c 100644 --- a/Software/Visual_Studio/Tango.Synchronization/Local/SqliteDataBase.cs +++ b/Software/Visual_Studio/Tango.Synchronization/Local/SqliteDataBase.cs @@ -501,7 +501,9 @@ namespace Tango.Synchronization.Local _connection.Dispose(); GC.Collect(); - while (true) + DateTime startTime = DateTime.Now; + + while (startTime.AddSeconds(2) > DateTime.Now) { try { diff --git a/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBComparer.cs b/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBComparer.cs index 82bc53c1f..514948d57 100644 --- a/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBComparer.cs +++ b/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBComparer.cs @@ -218,7 +218,7 @@ namespace Tango.Synchronization.Remote var master = _remoteDB.GetType().GetProperty(config.TABLE_NAME).GetValue(_remoteDB) as IEnumerable; var slave = _localDB.GetType().GetProperty(config.TABLE_NAME).GetValue(_localDB) as IEnumerable; - _diffs.Add(new Diff(DiffAction.ReplaceTableDataInSlave, "Override all rows on table " + config.TABLE_NAME, () => + _diffs.Add(new Diff(DiffAction.ReplaceTableDataInSlave, "Override all rows on slave table " + config.TABLE_NAME, () => { LogManager.Log("Overwriting slave table " + config.TABLE_NAME + "..."); diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 99f26f42d..52f716bf8 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26430.16 +VisualStudioVersion = 15.0.26430.14 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Protobuf", "Tango.Protobuf\Tango.Protobuf.csproj", "{40073806-914E-4E78-97AB-FA9639308EBE}" EndProject @@ -99,6 +99,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.MachineStudio.Synchro EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tango.ColorLib", "Native\Tango.ColorLib\Tango.ColorLib.vcxproj", "{625B2A26-97A9-45C9-8BCF-6BD30F593E17}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.AutoComplete", "SideChains\Tango.AutoComplete\Tango.AutoComplete.csproj", "{BB2ABB74-BA58-4812-83AA-EC8171F42DF4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -839,6 +841,26 @@ Global {625B2A26-97A9-45C9-8BCF-6BD30F593E17}.Release|x64.Build.0 = Release|x64 {625B2A26-97A9-45C9-8BCF-6BD30F593E17}.Release|x86.ActiveCfg = Release|Win32 {625B2A26-97A9-45C9-8BCF-6BD30F593E17}.Release|x86.Build.0 = Release|Win32 + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Debug|ARM.ActiveCfg = Debug|Any CPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Debug|ARM.Build.0 = Debug|Any CPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Debug|ARM64.Build.0 = Debug|Any CPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Debug|x64.ActiveCfg = Debug|Any CPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Debug|x64.Build.0 = Debug|Any CPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Debug|x86.ActiveCfg = Debug|Any CPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Debug|x86.Build.0 = Debug|Any CPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Release|Any CPU.Build.0 = Release|Any CPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Release|ARM.ActiveCfg = Release|Any CPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Release|ARM.Build.0 = Release|Any CPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Release|ARM64.ActiveCfg = Release|Any CPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Release|ARM64.Build.0 = Release|Any CPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Release|x64.ActiveCfg = Release|Any CPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Release|x64.Build.0 = Release|Any CPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Release|x86.ActiveCfg = Release|Any CPU + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -864,5 +886,6 @@ Global {CE4A0D11-08A2-4CD6-9908-D6C62E80D805} = {B2AF4F3F-2828-47C3-8F3E-A0EA0BD66FF8} {12D0C43C-391F-4C74-92AB-82E9A9BEEB9B} = {B2AF4F3F-2828-47C3-8F3E-A0EA0BD66FF8} {625B2A26-97A9-45C9-8BCF-6BD30F593E17} = {4443B71C-216E-4D4C-8D19-868F50803813} + {BB2ABB74-BA58-4812-83AA-EC8171F42DF4} = {EC62BC9C-F2FE-4333-B7E4-110E38D43958} EndGlobalSection EndGlobal -- cgit v1.3.1 From 53db041e636bb3802dbe3cb911de6ef6ef41446c Mon Sep 17 00:00:00 2001 From: Roy Date: Sun, 24 Dec 2017 02:27:16 +0200 Subject: Continue for last commit. --- .../Tango.DAL/src/main/res/raw/tangodb | Bin 557056 -> 557056 bytes .../Android_Studio/Tango.Integration/build.gradle | 4 + .../Tango.Integration/src/main/AndroidManifest.xml | 1 + .../integration/operators/IMachineOperator.java | 5 +- .../integration/operators/MachineOperator.java | 13 +- .../providers/IMachineIdentityProvider.java | 2 +- .../providers/MachineIdentityProvider.java | 2 +- .../services/ExternalBridgeService.java | 173 +++++- .../services/IExternalBridgeService.java | 2 +- .../services/SynchronizationService.java | 3 +- .../Android_Studio/Tango.NativeBridge/build.gradle | 7 - .../java/com/twine/tango/pmr/MessageFactory.java | 45 +- .../tango/pmr/common/MessageTypeOuterClass.java | 36 +- ...ExternalBridgeUdpDiscoveryPacketOuterClass.java | 580 +++++++++++++++++++ .../ExternalClientLoginRequestOuterClass.java | 579 ++++++++++++++++++ .../ExternalClientLoginResponseOuterClass.java | 644 +++++++++++++++++++++ .../Tango.PMR/src/main/res/raw/packages.txt | 1 + .../Android_Studio/Tango.SharedUI/build.gradle | 4 + .../Android_Studio/Tango.Stubs.UI/build.gradle | 2 +- .../main/java/com/twine/tango/stubs/ui/App.java | 4 - .../stubs/ui/dagger/ApplicationComponent.java | 2 +- .../tango/stubs/ui/dagger/ApplicationModule.java | 30 + .../tango/stubs/ui/dagger/EventBusModule.java | 24 + .../tango/stubs/ui/dagger/IntegrationModule.java | 50 ++ .../tango/stubs/ui/dagger/NavigationModule.java | 20 + .../tango/stubs/ui/dagger/NotificationModule.java | 27 + .../tango/stubs/ui/dagger/ViewModelsModule.java | 11 +- .../tango/stubs/ui/views/main/MainActivityVM.java | 36 +- .../tango/stubs/ui/views/stub/StubFragmentVM.java | 9 +- .../com/twine/tango/stubs/stubs/Calculate.java | 2 +- .../java/com/twine/tango/stubs/stubs/Progress.java | 2 +- .../Tango.Synchronization/build.gradle | 2 +- .../twine/tango/transport/ITransportAdapter.java | 26 +- .../com/twine/tango/transport/ITransporter.java | 8 +- .../tango/transport/TransportAdapterBase.java | 84 ++- .../com/twine/tango/transport/TransporterBase.java | 52 +- .../Android_Studio/Tango.UnitTesting/build.gradle | 1 - .../tango/unittesting/Synchronization_TST.java | 10 +- Software/Android_Studio/settings.gradle | 2 +- Software/DB/Tango.mdf | Bin 8388608 -> 8388608 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes Software/PMR/Messages/Common/MessageType.proto | 3 + .../ExternalBridgeUdpDiscoveryPacket.proto | 9 + .../Integration/ExternalClientLoginRequest.proto | 9 + .../Integration/ExternalClientLoginResponse.proto | 10 + .../INotificationProviderExtensions.cs | 30 - .../Tango.MachineStudio.DB.csproj | 1 - .../ViewModels/DbTableViewModel.cs | 1 - .../Images/machine-trans.png | Bin 0 -> 45618 bytes .../Navigation/NavigationView.cs | 1 + .../Tango.MachineStudio.Synchronization.csproj | 15 + .../ViewModelLocator.cs | 9 + .../ViewModels/DirectSynchronizationViewVM.cs | 20 + .../ViewModels/MenuViewVM.cs | 3 + .../Views/DirectSynchronizationView.xaml | 33 ++ .../Views/DirectSynchronizationView.xaml.cs | 28 + .../Views/MainView.xaml | 3 + .../Views/MenuView.xaml | 56 +- .../Notifications/DialogViewVM.cs | 47 ++ .../Notifications/INotificationProvider.cs | 6 +- .../StudioApplication/IStudioApplicationManager.cs | 3 + .../Tango.MachineStudio.Common.csproj | 5 + .../Tango.MachineStudio.UI/App.config | 8 + .../Tango.MachineStudio.UI/MainWindow.xaml.cs | 2 + .../Notifications/DefaultNotificationProvider.cs | 118 +++- .../Notifications/DialogWindow.xaml | 32 +- .../Notifications/DialogWindow.xaml.cs | 42 +- .../DefaultStudioApplicationManager.cs | 29 +- .../Tango.MachineStudio.UI.csproj | 23 + .../Tango.MachineStudio.UI/ViewModelLocator.cs | 15 + .../ViewModels/MachineConnectionViewVM.cs | 55 ++ .../ViewModels/MainViewVM.cs | 73 ++- .../Views/MachineConnectionView.xaml | 85 +++ .../Views/MachineConnectionView.xaml.cs | 34 ++ .../Tango.MachineStudio.UI/Views/MainView.xaml | 58 +- .../Tango.MachineStudio.UI/Views/MainView.xaml.cs | 6 +- .../Tango.MachineStudio.UI/packages.config | 1 + .../Tango.Core/Helpers/ThreadsHelper.cs | 12 +- .../Tango.Integration/Properties/AssemblyInfo.cs | 6 + .../Services/ExternalBridgeClient.cs | 68 +++ .../Services/ExternalBridgeScanner.cs | 112 ++++ .../Services/IExternalBridgeClient.cs | 22 + .../Tango.Integration/Tango.Integration.csproj | 85 +++ .../Visual_Studio/Tango.Integration/app.config | 11 + .../Tango.Integration/packages.config | 4 + .../Visual_Studio/Tango.PMR/Common/MessageType.cs | 11 +- .../ExternalBridgeUdpDiscoveryPacket.cs | 160 +++++ .../Integration/ExternalClientLoginRequest.cs | 160 +++++ .../Integration/ExternalClientLoginResponse.cs | 188 ++++++ Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj | 3 + .../Visual_Studio/Tango.Settings/Integration.cs | 18 + .../Tango.Settings/SettingsCollection.cs | 3 + .../Tango.Settings/Tango.Settings.csproj | 1 + .../Tango.Transport/TransporterBase.cs | 6 +- Software/Visual_Studio/Tango.sln | 22 + 95 files changed, 3990 insertions(+), 280 deletions(-) create mode 100644 Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/ExternalBridgeUdpDiscoveryPacketOuterClass.java create mode 100644 Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/ExternalClientLoginRequestOuterClass.java create mode 100644 Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/ExternalClientLoginResponseOuterClass.java create mode 100644 Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/ApplicationModule.java create mode 100644 Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/EventBusModule.java create mode 100644 Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/IntegrationModule.java create mode 100644 Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/NavigationModule.java create mode 100644 Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/NotificationModule.java create mode 100644 Software/PMR/Messages/Integration/ExternalBridgeUdpDiscoveryPacket.proto create mode 100644 Software/PMR/Messages/Integration/ExternalClientLoginRequest.proto create mode 100644 Software/PMR/Messages/Integration/ExternalClientLoginResponse.proto delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ExtensionMethods/INotificationProviderExtensions.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Images/machine-trans.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/DirectSynchronizationViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/DirectSynchronizationView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/DirectSynchronizationView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/DialogViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml.cs create mode 100644 Software/Visual_Studio/Tango.Integration/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/Tango.Integration/Services/ExternalBridgeClient.cs create mode 100644 Software/Visual_Studio/Tango.Integration/Services/ExternalBridgeScanner.cs create mode 100644 Software/Visual_Studio/Tango.Integration/Services/IExternalBridgeClient.cs create mode 100644 Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj create mode 100644 Software/Visual_Studio/Tango.Integration/app.config create mode 100644 Software/Visual_Studio/Tango.Integration/packages.config create mode 100644 Software/Visual_Studio/Tango.PMR/Integration/ExternalBridgeUdpDiscoveryPacket.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Integration/ExternalClientLoginRequest.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Integration/ExternalClientLoginResponse.cs create mode 100644 Software/Visual_Studio/Tango.Settings/Integration.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj') diff --git a/Software/Android_Studio/Tango.DAL/src/main/res/raw/tangodb b/Software/Android_Studio/Tango.DAL/src/main/res/raw/tangodb index 00c79da9c..0419b065c 100644 Binary files a/Software/Android_Studio/Tango.DAL/src/main/res/raw/tangodb and b/Software/Android_Studio/Tango.DAL/src/main/res/raw/tangodb differ diff --git a/Software/Android_Studio/Tango.Integration/build.gradle b/Software/Android_Studio/Tango.Integration/build.gradle index dc482d641..255fce0f6 100644 --- a/Software/Android_Studio/Tango.Integration/build.gradle +++ b/Software/Android_Studio/Tango.Integration/build.gradle @@ -43,4 +43,8 @@ dependencies { compile globalDependencies.dagger compile globalDependencies.daggerAndroid implementation project(':Tango.PMR') + implementation project(':Tango.Transport') + implementation project(':Tango.Core') + implementation project(':Tango.DAL') + implementation project(':Tango.Web') } diff --git a/Software/Android_Studio/Tango.Integration/src/main/AndroidManifest.xml b/Software/Android_Studio/Tango.Integration/src/main/AndroidManifest.xml index b57dcb665..81958ad3d 100644 --- a/Software/Android_Studio/Tango.Integration/src/main/AndroidManifest.xml +++ b/Software/Android_Studio/Tango.Integration/src/main/AndroidManifest.xml @@ -2,5 +2,6 @@ package="com.twine.tango.integration"> + diff --git a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/operators/IMachineOperator.java b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/operators/IMachineOperator.java index 7d69ce8ad..9963f295b 100644 --- a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/operators/IMachineOperator.java +++ b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/operators/IMachineOperator.java @@ -1,9 +1,12 @@ package com.twine.tango.integration.operators; +import com.twine.tango.transport.ITransporter; + /** * Created by Roy on 12/23/2017. */ -public interface IMachineOperator +public interface IMachineOperator extends ITransporter { + } diff --git a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/operators/MachineOperator.java b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/operators/MachineOperator.java index 0eb73cab3..f23c8c705 100644 --- a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/operators/MachineOperator.java +++ b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/operators/MachineOperator.java @@ -1,9 +1,20 @@ package com.twine.tango.integration.operators; +import com.twine.tango.transport.ITransportAdapter; +import com.twine.tango.transport.transporters.ProtoTransporter; + /** * Created by Roy on 12/23/2017. */ -public class MachineOperator +public class MachineOperator extends ProtoTransporter implements IMachineOperator { + public MachineOperator() + { + } + + public MachineOperator(ITransportAdapter adapter) + { + super(adapter); + } } diff --git a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/providers/IMachineIdentityProvider.java b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/providers/IMachineIdentityProvider.java index 3e35be9d0..547a17e50 100644 --- a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/providers/IMachineIdentityProvider.java +++ b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/providers/IMachineIdentityProvider.java @@ -1,4 +1,4 @@ -package com.twine.tango.integration; +package com.twine.tango.integration.providers; /** diff --git a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/providers/MachineIdentityProvider.java b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/providers/MachineIdentityProvider.java index 29cb0c30c..b4f2d3c4d 100644 --- a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/providers/MachineIdentityProvider.java +++ b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/providers/MachineIdentityProvider.java @@ -1,4 +1,4 @@ -package com.twine.tango.integration; +package com.twine.tango.integration.providers; /** diff --git a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/ExternalBridgeService.java b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/ExternalBridgeService.java index f1702ee9e..709d5a271 100644 --- a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/ExternalBridgeService.java +++ b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/ExternalBridgeService.java @@ -1,35 +1,60 @@ package com.twine.tango.integration.services; +import android.content.Context; +import android.net.DhcpInfo; +import android.net.wifi.WifiManager; +import android.os.StrictMode; import android.os.SystemClock; +import android.provider.SyncStateContract.Constants; +import android.util.Log; import com.elvishew.xlog.XLog; +import com.google.protobuf.GeneratedMessageV3; +import com.twine.tango.core.ContextHelper; import com.twine.tango.core.IEventHandler; +import com.twine.tango.integration.operators.IMachineOperator; +import com.twine.tango.integration.providers.IMachineIdentityProvider; import com.twine.tango.pmr.MessageFactory; +import com.twine.tango.pmr.TangoMessage; import com.twine.tango.pmr.common.MessageContainerOuterClass.MessageContainer; import com.twine.tango.pmr.common.MessageTypeOuterClass.MessageType; +import com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket; +import com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest; +import com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse; +import com.twine.tango.transport.ITransportAdapter; import com.twine.tango.transport.adapters.TcpTransportAdapter; import com.twine.tango.transport.transporters.ProtoTransporter; import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.util.ArrayList; import java.util.List; +import javax.inject.Inject; + import static br.com.zbra.androidlinq.Linq.stream; /** * Created by Roy on 12/22/2017. */ -public class TangoBridgeService extends ProtoTransporter implements ITangoBridgeService +public class ExternalBridgeService extends ProtoTransporter implements IExternalBridgeService { private ServerSocket listener; private boolean isStarted; private List handlers; + private IMachineIdentityProvider identityProvider; + private IMachineOperator machineOperator; - public TangoBridgeService() + @Inject + public ExternalBridgeService(IMachineIdentityProvider identityProvider, IMachineOperator machineOperator) { + this.identityProvider = identityProvider; + this.machineOperator = machineOperator; handlers = new ArrayList<>(); } @@ -43,8 +68,63 @@ public class TangoBridgeService extends ProtoTransporter implements ITangoBridge public void start() throws IOException { listener = new ServerSocket(1984); + isStarted = true; Thread listenerThread = new Thread(this::listenerThreadMethod); + Thread discoveryThread = new Thread(this::discoveryThreadMethod); listenerThread.start(); + discoveryThread.start(); + } + + private void discoveryThreadMethod() + { + // Hack Prevent crash (sending should be done using an async task) + StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); + StrictMode.setThreadPolicy(policy); + + byte[] packet = ExternalBridgeUdpDiscoveryPacket.newBuilder().setSerialNumber(identityProvider.getSerialNumber()).build().toByteArray(); + + while (isStarted) + { + try + { + DatagramSocket socket = new DatagramSocket(); + socket.setBroadcast(true); + + //First try to send to emulator host... + DatagramPacket sendPacket = new DatagramPacket(packet, packet.length, InetAddress.getByName("10.0.2.2"), 8888); + socket.send(sendPacket); + + //This will not work on the emulator as far as I know. + //TODO: This needs to be tested on a real device! + sendPacket = new DatagramPacket(packet, packet.length, InetAddress.getByName("255.255.255.255"), 8888); + socket.send(sendPacket); + + } catch (IOException e) + { + XLog.e(e); + } + + SystemClock.sleep(5000); + } + } + + private InetAddress getBroadcastAddress() throws IOException + { + WifiManager wifi = (WifiManager) ContextHelper.getApplicationContext().getSystemService(Context.WIFI_SERVICE); + assert wifi != null; + DhcpInfo dhcp = wifi.getDhcpInfo(); + + if (dhcp != null) + { + int broadcast = (dhcp.ipAddress & dhcp.netmask) | ~dhcp.netmask; + byte[] quads = new byte[4]; + for (int k = 0; k < 4; k++) + quads[k] = (byte) ((broadcast >> k * 8) & 0xFF); + return InetAddress.getByAddress(quads); + } else + { + return null; + } } @Override @@ -86,37 +166,98 @@ public class TangoBridgeService extends ProtoTransporter implements ITangoBridge if (newSocket != null) { + for (ITransportAdapter adapter : getAdapters()) + { + adapter.disconnect().blockingAwait(); + } getAdapters().clear(); - getAdapters().add(new TcpTransportAdapter(newSocket)); - connect(); + TcpTransportAdapter adapter = new TcpTransportAdapter(newSocket); + adapter.setAuthenticated(false); + getAdapters().add(adapter); + connect().blockingAwait(); } } catch (IOException e) { - + XLog.e(e); } SystemClock.sleep(100); } + + disconnect().blockingAwait(); } @Override - protected void onRequestReceived(MessageContainer request) + protected void onRequestReceived(MessageContainer container) { - super.onRequestReceived(request); - + super.onRequestReceived(container); + try { - Object message = MessageFactory.parseMessageFromContainerAgnostic(request); - - List receivers = stream(handlers).where((x) -> x.messageType == request.getType()).toList(); - - for (HandlerAndType receiver : receivers) + if (container.getType() == MessageType.ExternalClientLoginRequest) { - //noinspection unchecked - receiver.handler.invoke(this, message); + ExternalClientLoginRequest request = MessageFactory.parseMessageFromContainer(container); + if (request.getKey().equals("1234")) + { + getAdapters().get(0).setAuthenticated(true); + sendResponse(MessageFactory.createTangoMessage( + ExternalClientLoginResponse.class, + ExternalClientLoginResponse.newBuilder().setAuthenticated(true).build(), + container.getToken())); + } else + { + getAdapters().get(0).setAuthenticated(false); + sendResponse(MessageFactory.createTangoMessage( + ExternalClientLoginResponse.class, + ExternalClientLoginResponse.newBuilder().setAuthenticated(false).build(), + container.getToken())); + } + + return; } - + + if (getAdapters().get(0).isAuthenticated()) + { + GeneratedMessageV3 message = MessageFactory.parseMessageFromContainerAgnostic(container); + + List receivers = stream(handlers).where((x) -> x.messageType == container.getType()).toList(); + + if (receivers.size() > 0) + { + for (HandlerAndType receiver : receivers) + { + //noinspection unchecked + receiver.handler.invoke(this, new MessageReceivedArgs(container, message)); + } + } else + { + //Route to machine... + if (container.getContinuous()) + { + machineOperator.sendContinuousRequest(MessageFactory.createTangoMessage(container, message)).subscribe((response) -> + { + sendResponse((TangoMessage) response); + }, (ex) -> + { + + }); + } else + { + machineOperator.sendRequest(MessageFactory.createTangoMessage(container, message)).subscribe((response) -> + { + sendResponse((TangoMessage) response); + }, (ex) -> + { + + }); + } + } + } else + { + XLog.w("Message received from an unauthorized adapter!"); + } + } catch (Exception e) { XLog.e(e); diff --git a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/IExternalBridgeService.java b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/IExternalBridgeService.java index 32abe3365..5a2aed9aa 100644 --- a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/IExternalBridgeService.java +++ b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/IExternalBridgeService.java @@ -11,7 +11,7 @@ import java.io.IOException; * Created by Roy on 12/22/2017. */ -public interface ITangoBridgeService extends ITransporter +public interface IExternalBridgeService extends ITransporter { boolean isStarted(); void start() throws IOException; diff --git a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/SynchronizationService.java b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/SynchronizationService.java index ed15c9b7b..0f3d98982 100644 --- a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/SynchronizationService.java +++ b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/SynchronizationService.java @@ -29,7 +29,6 @@ public class SynchronizationService implements ISynchronizationService private IMachineIdentityProvider machineIdentityProvider; private IExternalBridgeService bridgeService; - /** * Instantiates a new Tango synchronizer. * @@ -40,7 +39,7 @@ public class SynchronizationService implements ISynchronizationService { this.machineIdentityProvider = machineIdentityProvider; this.bridgeService = bridgeService; - this.bridgeService.registerMessageHandler(this::handleCalculateRequest, MessageType.CalculateRequest); + //this.bridgeService.registerMessageHandler(this::handleCalculateRequest, MessageType.CalculateRequest); } private void handleCalculateRequest(Object o, MessageReceivedArgs e) diff --git a/Software/Android_Studio/Tango.NativeBridge/build.gradle b/Software/Android_Studio/Tango.NativeBridge/build.gradle index 1454dd7ec..eaa5f5c3f 100644 --- a/Software/Android_Studio/Tango.NativeBridge/build.gradle +++ b/Software/Android_Studio/Tango.NativeBridge/build.gradle @@ -15,7 +15,6 @@ android { externalNativeBuild { cmake { cppFlags "-std=c++11 -frtti -fexceptions" - abiFilters "x86", "armeabi-v7a", "x86_64" } } } @@ -27,12 +26,6 @@ android { } } - sourceSets { - main { - jniLibs.srcDirs = ['libs'] - } - } - externalNativeBuild { cmake { path "CMakeLists.txt" diff --git a/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/MessageFactory.java b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/MessageFactory.java index 55a0de4dd..413824e8d 100644 --- a/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/MessageFactory.java +++ b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/MessageFactory.java @@ -1,6 +1,7 @@ package com.twine.tango.pmr; import com.elvishew.xlog.XLog; +import com.google.protobuf.GeneratedMessageV3; import com.google.protobuf.InvalidProtocolBufferException; import com.google.protobuf.Parser; import com.twine.tango.core.ReflectionsHelper; @@ -79,7 +80,7 @@ public class MessageFactory * @param typeName The inner message class. * @return New instance of {@link TangoMessage}. */ - public static TangoMessage createTangoMessage(Class typeName) + public static TangoMessage createTangoMessage(Class typeName) { try { @@ -108,7 +109,7 @@ public class MessageFactory * @param message the message * @return the tango message */ - public static TangoMessage createTangoMessage(Class typeName, T message) + public static TangoMessage createTangoMessage(Class typeName, T message) { TangoMessage tangoMessage = createTangoMessage(typeName); tangoMessage.setMessage(message); @@ -123,7 +124,39 @@ public class MessageFactory * @param token the token * @return the tango message */ - public static TangoMessage createTangoMessage(Class typeName, String token) + public static TangoMessage createTangoMessage(Class typeName, T message, String token) + { + TangoMessage tangoMessage = createTangoMessage(typeName); + tangoMessage.setMessage(message); + tangoMessage.getContainer().setToken(token); + return tangoMessage; + } + + /** + * Creates a new tango message with the specified message token. + * + * @param the type parameter + * @param typeName the type name + * @param token the token + * @return the tango message + */ + public static TangoMessage createTangoMessage(MessageContainer container, GeneratedMessageV3 message) + { + TangoMessage tangoMessage = new TangoMessage(message,container.getType()); + tangoMessage.setMessage(message); + tangoMessage.getContainer().setToken(container.getToken()); + return tangoMessage; + } + + /** + * Creates a new tango message with the specified message token. + * + * @param the type parameter + * @param typeName the type name + * @param token the token + * @return the tango message + */ + public static TangoMessage createTangoMessage(Class typeName, String token) { TangoMessage tangoMessage = createTangoMessage(typeName); tangoMessage.getContainer().setToken(token); @@ -138,7 +171,7 @@ public class MessageFactory * @return New instance of {@link TangoMessage}. */ @SuppressWarnings("unchecked") - public static TangoMessage parseTangoMessage(byte[] data) + public static TangoMessage parseTangoMessage(byte[] data) { try { @@ -167,7 +200,7 @@ public class MessageFactory * @throws IllegalAccessException the illegal access exception * @throws InvalidProtocolBufferException the invalid protocol buffer exception */ - public static T parseMessageFromContainer(MessageContainer container) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, InvalidProtocolBufferException + public static T parseMessageFromContainer(MessageContainer container) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, InvalidProtocolBufferException { Class type = getClassForName(container.getType().toString()); @@ -185,7 +218,7 @@ public class MessageFactory * @throws IllegalAccessException the illegal access exception * @throws InvalidProtocolBufferException the invalid protocol buffer exception */ - public static com.google.protobuf.GeneratedMessageV3 parseMessageFromContainerAgnostic(MessageContainer container) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, InvalidProtocolBufferException + public static GeneratedMessageV3 parseMessageFromContainerAgnostic(MessageContainer container) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, InvalidProtocolBufferException { Class type = getClassForName(container.getType().toString()); Parser parser = (Parser) type.getMethod("parser").invoke(null); diff --git a/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/common/MessageTypeOuterClass.java b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/common/MessageTypeOuterClass.java index eeced1c83..27d581c93 100644 --- a/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/common/MessageTypeOuterClass.java +++ b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/common/MessageTypeOuterClass.java @@ -151,6 +151,18 @@ public final class MessageTypeOuterClass { * StubValveResponse = 32; */ StubValveResponse(32), + /** + * ExternalBridgeUdpDiscoveryPacket = 33; + */ + ExternalBridgeUdpDiscoveryPacket(33), + /** + * ExternalClientLoginRequest = 34; + */ + ExternalClientLoginRequest(34), + /** + * ExternalClientLoginResponse = 35; + */ + ExternalClientLoginResponse(35), UNRECOGNIZED(-1), ; @@ -286,6 +298,18 @@ public final class MessageTypeOuterClass { * StubValveResponse = 32; */ public static final int StubValveResponse_VALUE = 32; + /** + * ExternalBridgeUdpDiscoveryPacket = 33; + */ + public static final int ExternalBridgeUdpDiscoveryPacket_VALUE = 33; + /** + * ExternalClientLoginRequest = 34; + */ + public static final int ExternalClientLoginRequest_VALUE = 34; + /** + * ExternalClientLoginResponse = 35; + */ + public static final int ExternalClientLoginResponse_VALUE = 35; public final int getNumber() { @@ -339,6 +363,9 @@ public final class MessageTypeOuterClass { case 30: return StubSteperMotorResponse; case 31: return StubValveRequest; case 32: return StubValveResponse; + case 33: return ExternalBridgeUdpDiscoveryPacket; + case 34: return ExternalClientLoginRequest; + case 35: return ExternalClientLoginResponse; default: return null; } } @@ -400,7 +427,7 @@ public final class MessageTypeOuterClass { descriptor; static { java.lang.String[] descriptorData = { - "\n\021MessageType.proto\022\020Tango.PMR.Common*\357\006" + + "\n\021MessageType.proto\022\020Tango.PMR.Common*\326\007" + "\n\013MessageType\022\007\n\003RGB\020\000\022\007\n\003Job\020\001\022\013\n\007Segme" + "nt\020\002\022\024\n\020CalculateRequest\020\003\022\025\n\021CalculateR" + "esponse\020\004\022\023\n\017ProgressRequest\020\005\022\024\n\020Progre" + @@ -422,8 +449,11 @@ public final class MessageTypeOuterClass { "ubOptLimitSwitchRequest\020\033\022\036\n\032StubOptLimi", "tSwitchResponse\020\034\022\032\n\026StubSteperMotorRequ" + "est\020\035\022\033\n\027StubSteperMotorResponse\020\036\022\024\n\020St" + - "ubValveRequest\020\037\022\025\n\021StubValveResponse\020 B" + - "\034\n\032com.twine.tango.pmr.commonb\006proto3" + "ubValveRequest\020\037\022\025\n\021StubValveResponse\020 \022" + + "$\n ExternalBridgeUdpDiscoveryPacket\020!\022\036\n" + + "\032ExternalClientLoginRequest\020\"\022\037\n\033Externa" + + "lClientLoginResponse\020#B\034\n\032com.twine.tang" + + "o.pmr.commonb\006proto3" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { diff --git a/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/ExternalBridgeUdpDiscoveryPacketOuterClass.java b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/ExternalBridgeUdpDiscoveryPacketOuterClass.java new file mode 100644 index 000000000..5b83561c0 --- /dev/null +++ b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/ExternalBridgeUdpDiscoveryPacketOuterClass.java @@ -0,0 +1,580 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ExternalBridgeUdpDiscoveryPacket.proto + +package com.twine.tango.pmr.integration; + +public final class ExternalBridgeUdpDiscoveryPacketOuterClass { + private ExternalBridgeUdpDiscoveryPacketOuterClass() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface ExternalBridgeUdpDiscoveryPacketOrBuilder extends + // @@protoc_insertion_point(interface_extends:Tango.PMR.Integration.ExternalBridgeUdpDiscoveryPacket) + com.google.protobuf.MessageOrBuilder { + + /** + * string SerialNumber = 2; + */ + java.lang.String getSerialNumber(); + /** + * string SerialNumber = 2; + */ + com.google.protobuf.ByteString + getSerialNumberBytes(); + } + /** + * Protobuf type {@code Tango.PMR.Integration.ExternalBridgeUdpDiscoveryPacket} + */ + public static final class ExternalBridgeUdpDiscoveryPacket extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:Tango.PMR.Integration.ExternalBridgeUdpDiscoveryPacket) + ExternalBridgeUdpDiscoveryPacketOrBuilder { + private static final long serialVersionUID = 0L; + // Use ExternalBridgeUdpDiscoveryPacket.newBuilder() to construct. + private ExternalBridgeUdpDiscoveryPacket(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ExternalBridgeUdpDiscoveryPacket() { + serialNumber_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ExternalBridgeUdpDiscoveryPacket( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + serialNumber_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.internal_static_Tango_PMR_Integration_ExternalBridgeUdpDiscoveryPacket_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.internal_static_Tango_PMR_Integration_ExternalBridgeUdpDiscoveryPacket_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket.class, com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket.Builder.class); + } + + public static final int SERIALNUMBER_FIELD_NUMBER = 2; + private volatile java.lang.Object serialNumber_; + /** + * string SerialNumber = 2; + */ + public java.lang.String getSerialNumber() { + java.lang.Object ref = serialNumber_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + serialNumber_ = s; + return s; + } + } + /** + * string SerialNumber = 2; + */ + public com.google.protobuf.ByteString + getSerialNumberBytes() { + java.lang.Object ref = serialNumber_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + serialNumber_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getSerialNumberBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, serialNumber_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getSerialNumberBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, serialNumber_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket)) { + return super.equals(obj); + } + com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket other = (com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket) obj; + + boolean result = true; + result = result && getSerialNumber() + .equals(other.getSerialNumber()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SERIALNUMBER_FIELD_NUMBER; + hash = (53 * hash) + getSerialNumber().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code Tango.PMR.Integration.ExternalBridgeUdpDiscoveryPacket} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:Tango.PMR.Integration.ExternalBridgeUdpDiscoveryPacket) + com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacketOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.internal_static_Tango_PMR_Integration_ExternalBridgeUdpDiscoveryPacket_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.internal_static_Tango_PMR_Integration_ExternalBridgeUdpDiscoveryPacket_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket.class, com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket.Builder.class); + } + + // Construct using com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + serialNumber_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.internal_static_Tango_PMR_Integration_ExternalBridgeUdpDiscoveryPacket_descriptor; + } + + public com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket getDefaultInstanceForType() { + return com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket.getDefaultInstance(); + } + + public com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket build() { + com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket buildPartial() { + com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket result = new com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket(this); + result.serialNumber_ = serialNumber_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket) { + return mergeFrom((com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket other) { + if (other == com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket.getDefaultInstance()) return this; + if (!other.getSerialNumber().isEmpty()) { + serialNumber_ = other.serialNumber_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object serialNumber_ = ""; + /** + * string SerialNumber = 2; + */ + public java.lang.String getSerialNumber() { + java.lang.Object ref = serialNumber_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + serialNumber_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string SerialNumber = 2; + */ + public com.google.protobuf.ByteString + getSerialNumberBytes() { + java.lang.Object ref = serialNumber_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + serialNumber_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string SerialNumber = 2; + */ + public Builder setSerialNumber( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + serialNumber_ = value; + onChanged(); + return this; + } + /** + * string SerialNumber = 2; + */ + public Builder clearSerialNumber() { + + serialNumber_ = getDefaultInstance().getSerialNumber(); + onChanged(); + return this; + } + /** + * string SerialNumber = 2; + */ + public Builder setSerialNumberBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + serialNumber_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:Tango.PMR.Integration.ExternalBridgeUdpDiscoveryPacket) + } + + // @@protoc_insertion_point(class_scope:Tango.PMR.Integration.ExternalBridgeUdpDiscoveryPacket) + private static final com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket(); + } + + public static com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ExternalBridgeUdpDiscoveryPacket parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ExternalBridgeUdpDiscoveryPacket(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClass.ExternalBridgeUdpDiscoveryPacket getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_Tango_PMR_Integration_ExternalBridgeUdpDiscoveryPacket_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_Tango_PMR_Integration_ExternalBridgeUdpDiscoveryPacket_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n&ExternalBridgeUdpDiscoveryPacket.proto" + + "\022\025Tango.PMR.Integration\"8\n ExternalBridg" + + "eUdpDiscoveryPacket\022\024\n\014SerialNumber\030\002 \001(" + + "\tB!\n\037com.twine.tango.pmr.integrationb\006pr" + + "oto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_Tango_PMR_Integration_ExternalBridgeUdpDiscoveryPacket_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_Tango_PMR_Integration_ExternalBridgeUdpDiscoveryPacket_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_Tango_PMR_Integration_ExternalBridgeUdpDiscoveryPacket_descriptor, + new java.lang.String[] { "SerialNumber", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/ExternalClientLoginRequestOuterClass.java b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/ExternalClientLoginRequestOuterClass.java new file mode 100644 index 000000000..9717c3d11 --- /dev/null +++ b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/ExternalClientLoginRequestOuterClass.java @@ -0,0 +1,579 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ExternalClientLoginRequest.proto + +package com.twine.tango.pmr.integration; + +public final class ExternalClientLoginRequestOuterClass { + private ExternalClientLoginRequestOuterClass() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface ExternalClientLoginRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:Tango.PMR.Integration.ExternalClientLoginRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * string key = 1; + */ + java.lang.String getKey(); + /** + * string key = 1; + */ + com.google.protobuf.ByteString + getKeyBytes(); + } + /** + * Protobuf type {@code Tango.PMR.Integration.ExternalClientLoginRequest} + */ + public static final class ExternalClientLoginRequest extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:Tango.PMR.Integration.ExternalClientLoginRequest) + ExternalClientLoginRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use ExternalClientLoginRequest.newBuilder() to construct. + private ExternalClientLoginRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ExternalClientLoginRequest() { + key_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ExternalClientLoginRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + key_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.internal_static_Tango_PMR_Integration_ExternalClientLoginRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.internal_static_Tango_PMR_Integration_ExternalClientLoginRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest.class, com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest.Builder.class); + } + + public static final int KEY_FIELD_NUMBER = 1; + private volatile java.lang.Object key_; + /** + * string key = 1; + */ + public java.lang.String getKey() { + java.lang.Object ref = key_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + key_ = s; + return s; + } + } + /** + * string key = 1; + */ + public com.google.protobuf.ByteString + getKeyBytes() { + java.lang.Object ref = key_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + key_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getKeyBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, key_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getKeyBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, key_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest)) { + return super.equals(obj); + } + com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest other = (com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest) obj; + + boolean result = true; + result = result && getKey() + .equals(other.getKey()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + KEY_FIELD_NUMBER; + hash = (53 * hash) + getKey().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code Tango.PMR.Integration.ExternalClientLoginRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:Tango.PMR.Integration.ExternalClientLoginRequest) + com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.internal_static_Tango_PMR_Integration_ExternalClientLoginRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.internal_static_Tango_PMR_Integration_ExternalClientLoginRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest.class, com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest.Builder.class); + } + + // Construct using com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + key_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.internal_static_Tango_PMR_Integration_ExternalClientLoginRequest_descriptor; + } + + public com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest getDefaultInstanceForType() { + return com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest.getDefaultInstance(); + } + + public com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest build() { + com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest buildPartial() { + com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest result = new com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest(this); + result.key_ = key_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest) { + return mergeFrom((com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest other) { + if (other == com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest.getDefaultInstance()) return this; + if (!other.getKey().isEmpty()) { + key_ = other.key_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object key_ = ""; + /** + * string key = 1; + */ + public java.lang.String getKey() { + java.lang.Object ref = key_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + key_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string key = 1; + */ + public com.google.protobuf.ByteString + getKeyBytes() { + java.lang.Object ref = key_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + key_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string key = 1; + */ + public Builder setKey( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + key_ = value; + onChanged(); + return this; + } + /** + * string key = 1; + */ + public Builder clearKey() { + + key_ = getDefaultInstance().getKey(); + onChanged(); + return this; + } + /** + * string key = 1; + */ + public Builder setKeyBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + key_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:Tango.PMR.Integration.ExternalClientLoginRequest) + } + + // @@protoc_insertion_point(class_scope:Tango.PMR.Integration.ExternalClientLoginRequest) + private static final com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest(); + } + + public static com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ExternalClientLoginRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ExternalClientLoginRequest(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_Tango_PMR_Integration_ExternalClientLoginRequest_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_Tango_PMR_Integration_ExternalClientLoginRequest_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n ExternalClientLoginRequest.proto\022\025Tang" + + "o.PMR.Integration\")\n\032ExternalClientLogin" + + "Request\022\013\n\003key\030\001 \001(\tB!\n\037com.twine.tango." + + "pmr.integrationb\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_Tango_PMR_Integration_ExternalClientLoginRequest_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_Tango_PMR_Integration_ExternalClientLoginRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_Tango_PMR_Integration_ExternalClientLoginRequest_descriptor, + new java.lang.String[] { "Key", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/ExternalClientLoginResponseOuterClass.java b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/ExternalClientLoginResponseOuterClass.java new file mode 100644 index 000000000..57600bbc2 --- /dev/null +++ b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/ExternalClientLoginResponseOuterClass.java @@ -0,0 +1,644 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ExternalClientLoginResponse.proto + +package com.twine.tango.pmr.integration; + +public final class ExternalClientLoginResponseOuterClass { + private ExternalClientLoginResponseOuterClass() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface ExternalClientLoginResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:Tango.PMR.Integration.ExternalClientLoginResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * bool Authenticated = 1; + */ + boolean getAuthenticated(); + + /** + * string SerialNumber = 2; + */ + java.lang.String getSerialNumber(); + /** + * string SerialNumber = 2; + */ + com.google.protobuf.ByteString + getSerialNumberBytes(); + } + /** + * Protobuf type {@code Tango.PMR.Integration.ExternalClientLoginResponse} + */ + public static final class ExternalClientLoginResponse extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:Tango.PMR.Integration.ExternalClientLoginResponse) + ExternalClientLoginResponseOrBuilder { + private static final long serialVersionUID = 0L; + // Use ExternalClientLoginResponse.newBuilder() to construct. + private ExternalClientLoginResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ExternalClientLoginResponse() { + authenticated_ = false; + serialNumber_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ExternalClientLoginResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + authenticated_ = input.readBool(); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + serialNumber_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.internal_static_Tango_PMR_Integration_ExternalClientLoginResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.internal_static_Tango_PMR_Integration_ExternalClientLoginResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse.class, com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse.Builder.class); + } + + public static final int AUTHENTICATED_FIELD_NUMBER = 1; + private boolean authenticated_; + /** + * bool Authenticated = 1; + */ + public boolean getAuthenticated() { + return authenticated_; + } + + public static final int SERIALNUMBER_FIELD_NUMBER = 2; + private volatile java.lang.Object serialNumber_; + /** + * string SerialNumber = 2; + */ + public java.lang.String getSerialNumber() { + java.lang.Object ref = serialNumber_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + serialNumber_ = s; + return s; + } + } + /** + * string SerialNumber = 2; + */ + public com.google.protobuf.ByteString + getSerialNumberBytes() { + java.lang.Object ref = serialNumber_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + serialNumber_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (authenticated_ != false) { + output.writeBool(1, authenticated_); + } + if (!getSerialNumberBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, serialNumber_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (authenticated_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(1, authenticated_); + } + if (!getSerialNumberBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, serialNumber_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse)) { + return super.equals(obj); + } + com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse other = (com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse) obj; + + boolean result = true; + result = result && (getAuthenticated() + == other.getAuthenticated()); + result = result && getSerialNumber() + .equals(other.getSerialNumber()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + AUTHENTICATED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getAuthenticated()); + hash = (37 * hash) + SERIALNUMBER_FIELD_NUMBER; + hash = (53 * hash) + getSerialNumber().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code Tango.PMR.Integration.ExternalClientLoginResponse} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:Tango.PMR.Integration.ExternalClientLoginResponse) + com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.internal_static_Tango_PMR_Integration_ExternalClientLoginResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.internal_static_Tango_PMR_Integration_ExternalClientLoginResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse.class, com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse.Builder.class); + } + + // Construct using com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + authenticated_ = false; + + serialNumber_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.internal_static_Tango_PMR_Integration_ExternalClientLoginResponse_descriptor; + } + + public com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse getDefaultInstanceForType() { + return com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse.getDefaultInstance(); + } + + public com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse build() { + com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse buildPartial() { + com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse result = new com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse(this); + result.authenticated_ = authenticated_; + result.serialNumber_ = serialNumber_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse) { + return mergeFrom((com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse other) { + if (other == com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse.getDefaultInstance()) return this; + if (other.getAuthenticated() != false) { + setAuthenticated(other.getAuthenticated()); + } + if (!other.getSerialNumber().isEmpty()) { + serialNumber_ = other.serialNumber_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private boolean authenticated_ ; + /** + * bool Authenticated = 1; + */ + public boolean getAuthenticated() { + return authenticated_; + } + /** + * bool Authenticated = 1; + */ + public Builder setAuthenticated(boolean value) { + + authenticated_ = value; + onChanged(); + return this; + } + /** + * bool Authenticated = 1; + */ + public Builder clearAuthenticated() { + + authenticated_ = false; + onChanged(); + return this; + } + + private java.lang.Object serialNumber_ = ""; + /** + * string SerialNumber = 2; + */ + public java.lang.String getSerialNumber() { + java.lang.Object ref = serialNumber_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + serialNumber_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string SerialNumber = 2; + */ + public com.google.protobuf.ByteString + getSerialNumberBytes() { + java.lang.Object ref = serialNumber_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + serialNumber_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string SerialNumber = 2; + */ + public Builder setSerialNumber( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + serialNumber_ = value; + onChanged(); + return this; + } + /** + * string SerialNumber = 2; + */ + public Builder clearSerialNumber() { + + serialNumber_ = getDefaultInstance().getSerialNumber(); + onChanged(); + return this; + } + /** + * string SerialNumber = 2; + */ + public Builder setSerialNumberBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + serialNumber_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:Tango.PMR.Integration.ExternalClientLoginResponse) + } + + // @@protoc_insertion_point(class_scope:Tango.PMR.Integration.ExternalClientLoginResponse) + private static final com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse(); + } + + public static com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ExternalClientLoginResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ExternalClientLoginResponse(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_Tango_PMR_Integration_ExternalClientLoginResponse_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_Tango_PMR_Integration_ExternalClientLoginResponse_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n!ExternalClientLoginResponse.proto\022\025Tan" + + "go.PMR.Integration\"J\n\033ExternalClientLogi" + + "nResponse\022\025\n\rAuthenticated\030\001 \001(\010\022\024\n\014Seri" + + "alNumber\030\002 \001(\tB!\n\037com.twine.tango.pmr.in" + + "tegrationb\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_Tango_PMR_Integration_ExternalClientLoginResponse_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_Tango_PMR_Integration_ExternalClientLoginResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_Tango_PMR_Integration_ExternalClientLoginResponse_descriptor, + new java.lang.String[] { "Authenticated", "SerialNumber", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/Software/Android_Studio/Tango.PMR/src/main/res/raw/packages.txt b/Software/Android_Studio/Tango.PMR/src/main/res/raw/packages.txt index 803095d92..7dcb7e0f1 100644 --- a/Software/Android_Studio/Tango.PMR/src/main/res/raw/packages.txt +++ b/Software/Android_Studio/Tango.PMR/src/main/res/raw/packages.txt @@ -1,4 +1,5 @@ common +integration jobs stubs synchronization diff --git a/Software/Android_Studio/Tango.SharedUI/build.gradle b/Software/Android_Studio/Tango.SharedUI/build.gradle index 00bf0b351..832a8eb22 100644 --- a/Software/Android_Studio/Tango.SharedUI/build.gradle +++ b/Software/Android_Studio/Tango.SharedUI/build.gradle @@ -59,4 +59,8 @@ dependencies { compile globalDependencies.protobuf implementation project(':Tango.PMR') implementation project(':Tango.Web') + compile 'com.google.dagger:dagger:2.11' + implementation project(':Tango.Transport') + implementation project(':Tango.Integration') + compile 'com.squareup:otto:1.3.8' } diff --git a/Software/Android_Studio/Tango.Stubs.UI/build.gradle b/Software/Android_Studio/Tango.Stubs.UI/build.gradle index 42109f2a8..41853210a 100644 --- a/Software/Android_Studio/Tango.Stubs.UI/build.gradle +++ b/Software/Android_Studio/Tango.Stubs.UI/build.gradle @@ -12,7 +12,7 @@ android { versionCode 1 versionName "1.0" vectorDrawables.useSupportLibrary = true - + multiDexEnabled true testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } diff --git a/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/App.java b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/App.java index d0437aaa1..96b5b490d 100644 --- a/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/App.java +++ b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/App.java @@ -1,9 +1,5 @@ package com.twine.tango.stubs.ui; -import android.app.Application; -import android.content.Context; - -import com.elvishew.xlog.XLog; import com.twine.tango.sharedui.TangoApplication; import com.twine.tango.stubs.ui.dagger.ApplicationComponent; import com.twine.tango.stubs.ui.dagger.ApplicationModule; diff --git a/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/ApplicationComponent.java b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/ApplicationComponent.java index ab0b84c25..cbd61f9ee 100644 --- a/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/ApplicationComponent.java +++ b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/ApplicationComponent.java @@ -16,7 +16,7 @@ import dagger.Component; */ @Singleton -@Component(modules = {ApplicationModule.class, ViewModelsModule.class, EventBusModule.class, NotificationModule.class, TransportModule.class, NavigationModule.class}) +@Component(modules = {ApplicationModule.class, ViewModelsModule.class, EventBusModule.class, NotificationModule.class, NavigationModule.class, IntegrationModule.class}) public interface ApplicationComponent { diff --git a/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/ApplicationModule.java b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/ApplicationModule.java new file mode 100644 index 000000000..ce664f835 --- /dev/null +++ b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/ApplicationModule.java @@ -0,0 +1,30 @@ +package com.twine.tango.stubs.ui.dagger; + +import android.app.Application; +import android.content.Context; + +import javax.inject.Singleton; + +import dagger.Module; +import dagger.Provides; + +/** + * Created by Roy on 11/6/2017. + */ + +@Module +public class ApplicationModule { + + private Application application; + + public ApplicationModule(Application application) { + this.application = application; + } + + @Provides + @Singleton + public Context provideContext() + { + return application; + } +} diff --git a/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/EventBusModule.java b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/EventBusModule.java new file mode 100644 index 000000000..3aeb461f7 --- /dev/null +++ b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/EventBusModule.java @@ -0,0 +1,24 @@ +package com.twine.tango.stubs.ui.dagger; + +import com.squareup.otto.Bus; +import com.squareup.otto.ThreadEnforcer; + +import javax.inject.Singleton; + +import dagger.Module; +import dagger.Provides; + +/** + * Created by Roy on 11/6/2017. + */ + +@Module +public class EventBusModule { + + @Provides + @Singleton + public Bus provideEventBus() + { + return new Bus(ThreadEnforcer.MAIN); + } +} diff --git a/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/IntegrationModule.java b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/IntegrationModule.java new file mode 100644 index 000000000..b06d9aa67 --- /dev/null +++ b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/IntegrationModule.java @@ -0,0 +1,50 @@ +package com.twine.tango.stubs.ui.dagger; + +import com.twine.tango.integration.operators.IMachineOperator; +import com.twine.tango.integration.operators.MachineOperator; +import com.twine.tango.integration.providers.IMachineIdentityProvider; +import com.twine.tango.integration.providers.MachineIdentityProvider; +import com.twine.tango.integration.services.IExternalBridgeService; +import com.twine.tango.integration.services.ISynchronizationService; +import com.twine.tango.integration.services.ExternalBridgeService; +import com.twine.tango.integration.services.SynchronizationService; +import com.twine.tango.transport.adapters.TcpTransportAdapter; + +import javax.inject.Singleton; +import dagger.Module; +import dagger.Provides; + +/** + * Created by Roy on 11/6/2017. + */ +@Module +public class IntegrationModule +{ + @Provides + @Singleton + public IExternalBridgeService provideBridgeService(IMachineIdentityProvider machineIdentityProvider,IMachineOperator machineOperator) + { + return new ExternalBridgeService(machineIdentityProvider,machineOperator); + } + + @Provides + @Singleton + public ISynchronizationService provideSynchronizationService(IMachineIdentityProvider machineIdentityProvider, IExternalBridgeService bridgeService) + { + return new SynchronizationService(machineIdentityProvider, bridgeService); + } + + @Provides + @Singleton + public IMachineIdentityProvider provideMachineIdentityProvider() + { + return new MachineIdentityProvider(); + } + + @Provides + @Singleton + public IMachineOperator providerMachineOperator() + { + return new MachineOperator(new TcpTransportAdapter("10.0.2.2", 9999)); + } +} diff --git a/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/NavigationModule.java b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/NavigationModule.java new file mode 100644 index 000000000..674157858 --- /dev/null +++ b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/NavigationModule.java @@ -0,0 +1,20 @@ +package com.twine.tango.stubs.ui.dagger; + +import android.content.Context; +import com.twine.tango.sharedui.navigation.AndroidNavigationProvider; +import com.twine.tango.sharedui.navigation.INavigationProvider; +import javax.inject.Singleton; + +import dagger.Module; +import dagger.Provides; + +@Module +public class NavigationModule +{ + @Provides + @Singleton + public INavigationProvider provideNavigation() + { + return new AndroidNavigationProvider(); + } +} diff --git a/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/NotificationModule.java b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/NotificationModule.java new file mode 100644 index 000000000..69d6d8f62 --- /dev/null +++ b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/NotificationModule.java @@ -0,0 +1,27 @@ +package com.twine.tango.stubs.ui.dagger; + +import android.content.Context; + +import com.twine.tango.sharedui.notifications.AndroidNotificationProvider; +import com.twine.tango.sharedui.notifications.INotificationProvider; + +import javax.inject.Singleton; + +import dagger.Module; +import dagger.Provides; + +/** + * Created by Roy on 11/6/2017. + */ + +@Module +public class NotificationModule { + + @Provides + @Singleton + public INotificationProvider provideNotificationProvider(Context context) + { + return new AndroidNotificationProvider(context); + } + +} diff --git a/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/ViewModelsModule.java b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/ViewModelsModule.java index 927511efc..b7e494ecf 100644 --- a/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/ViewModelsModule.java +++ b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/dagger/ViewModelsModule.java @@ -1,6 +1,9 @@ package com.twine.tango.stubs.ui.dagger; import com.squareup.otto.Bus; +import com.twine.tango.integration.operators.IMachineOperator; +import com.twine.tango.integration.services.IExternalBridgeService; +import com.twine.tango.integration.services.ISynchronizationService; import com.twine.tango.sharedui.navigation.INavigationProvider; import com.twine.tango.sharedui.notifications.INotificationProvider; import com.twine.tango.stubs.ui.views.login.LoginFragmentVM; @@ -26,9 +29,9 @@ public class ViewModelsModule @Provides @Singleton - public MainActivityVM provideMainActivityVM(Bus eventBus, INotificationProvider notificationProvider, INavigationProvider navigationProvider, ITransporter transporter) + public MainActivityVM provideMainActivityVM(Bus eventBus, INotificationProvider notificationProvider, INavigationProvider navigationProvider, IMachineOperator machineOperator, ISynchronizationService synchronizationService, IExternalBridgeService externalBridgeService) { - return new MainActivityVM(eventBus, notificationProvider, navigationProvider, transporter); + return new MainActivityVM(eventBus, notificationProvider, navigationProvider, machineOperator, externalBridgeService, synchronizationService); } @Provides @@ -54,8 +57,8 @@ public class ViewModelsModule @Provides @Singleton - public StubFragmentVM provideStubFragmentVM(Bus eventBus, INotificationProvider notificationProvider, ITransporter transporter) + public StubFragmentVM provideStubFragmentVM(Bus eventBus, INotificationProvider notificationProvider, IMachineOperator machineOperator) { - return new StubFragmentVM(eventBus, notificationProvider, transporter); + return new StubFragmentVM(eventBus, notificationProvider, machineOperator); } } diff --git a/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/views/main/MainActivityVM.java b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/views/main/MainActivityVM.java index e77cc0810..64d69b0e6 100644 --- a/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/views/main/MainActivityVM.java +++ b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/views/main/MainActivityVM.java @@ -2,6 +2,9 @@ package com.twine.tango.stubs.ui.views.main; import com.squareup.otto.Bus; import com.squareup.otto.Subscribe; +import com.twine.tango.integration.operators.IMachineOperator; +import com.twine.tango.integration.services.IExternalBridgeService; +import com.twine.tango.integration.services.ISynchronizationService; import com.twine.tango.models.User; import com.twine.tango.sharedui.mvvm.DependencyProperty; import com.twine.tango.sharedui.mvvm.RelayCommand; @@ -10,9 +13,10 @@ import com.twine.tango.sharedui.navigation.INavigationProvider; import com.twine.tango.sharedui.notifications.INotificationProvider; import com.twine.tango.stubs.ui.Events.LoginEvent; import com.twine.tango.stubs.ui.views.main.IMainActivity.Navigation; -import com.twine.tango.transport.ITransporter; import com.twine.tango.transport.TransportComponentState; +import java.io.IOException; + import javax.inject.Inject; import io.reactivex.android.schedulers.AndroidSchedulers; @@ -24,7 +28,9 @@ public class MainActivityVM extends ViewModelBase private User currentUser; private INotificationProvider notificationProvider; private INavigationProvider navigationProvider; - private ITransporter transporter; + private IMachineOperator machineOperator; + private ISynchronizationService synchronizationService; + private IExternalBridgeService externalBridgeService; public DependencyProperty isConnected; @@ -34,33 +40,43 @@ public class MainActivityVM extends ViewModelBase @Inject - public MainActivityVM(Bus eventBus, INotificationProvider notificationProvider, INavigationProvider navigationProvider,ITransporter transporter) + public MainActivityVM(Bus eventBus, INotificationProvider notificationProvider, INavigationProvider navigationProvider, IMachineOperator machineOperator, IExternalBridgeService externalBridgeService, ISynchronizationService synchronizationService) { this.eventBus = eventBus; this.notificationProvider = notificationProvider; this.navigationProvider = navigationProvider; - this.transporter = transporter; + this.machineOperator = machineOperator; + this.synchronizationService = synchronizationService; + this.externalBridgeService = externalBridgeService; this.eventBus.register(this); isConnected = new DependencyProperty<>(false); - connectCommand = new RelayCommand(this::connect,() -> this.transporter.getState() != TransportComponentState.Connected); - disconnectCommand = new RelayCommand(this::disconnect,() -> this.transporter.getState() == TransportComponentState.Connected); + connectCommand = new RelayCommand(this::connect,() -> this.machineOperator.getState() != TransportComponentState.Connected); + disconnectCommand = new RelayCommand(this::disconnect,() -> this.machineOperator.getState() == TransportComponentState.Connected); - this.transporter.addStateChangedListener((sender,e) -> - isConnected.set(this.transporter.getState() == TransportComponentState.Connected)); + this.machineOperator.addStateChangedListener((sender, e) -> + isConnected.set(this.machineOperator.getState() == TransportComponentState.Connected)); + + try + { + externalBridgeService.start(); + } catch (IOException e) + { + e.printStackTrace(); + } } private void connect() { - transporter.connect().observeOn(AndroidSchedulers.mainThread()).subscribe(() -> + machineOperator.connect().observeOn(AndroidSchedulers.mainThread()).subscribe(() -> invalidateCommands(),(ex) -> notificationProvider.showMessage(view,"Could not connect the Transporter.")); } private void disconnect() { - transporter.disconnect().observeOn(AndroidSchedulers.mainThread()).subscribe(() -> + machineOperator.disconnect().observeOn(AndroidSchedulers.mainThread()).subscribe(() -> invalidateCommands(),(ex) -> notificationProvider.showMessage(view,"Could not disconnect the Transporter.")); } diff --git a/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/views/stub/StubFragmentVM.java b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/views/stub/StubFragmentVM.java index 8a052b38c..fe237bcd8 100644 --- a/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/views/stub/StubFragmentVM.java +++ b/Software/Android_Studio/Tango.Stubs.UI/src/main/java/com/twine/tango/stubs/ui/views/stub/StubFragmentVM.java @@ -3,6 +3,7 @@ package com.twine.tango.stubs.ui.views.stub; import com.elvishew.xlog.XLog; import com.squareup.otto.Bus; import com.squareup.otto.Subscribe; +import com.twine.tango.integration.operators.IMachineOperator; import com.twine.tango.sharedui.mvvm.RelayCommand; import com.twine.tango.sharedui.notifications.INotificationProvider; import com.twine.tango.stubs.AvailableStub; @@ -24,21 +25,21 @@ public class StubFragmentVM extends ViewModelBase { private Bus eventBus; private INotificationProvider notificationProvider; - private ITransporter transporter; + private IMachineOperator machineOperator; public DependencyProperty availableStub; public DependencyProperty stub; public DependencyProperty response; public RelayCommand runCommand; @Inject - public StubFragmentVM(Bus eventBus, INotificationProvider notificationProvider, ITransporter transporter) + public StubFragmentVM(Bus eventBus, INotificationProvider notificationProvider, IMachineOperator machineOperator) { availableStub = new DependencyProperty<>(); stub = new DependencyProperty<>(); response = new DependencyProperty<>(""); this.eventBus = eventBus; - this.transporter = transporter; + this.machineOperator = machineOperator; this.notificationProvider = notificationProvider; this.eventBus.register(this); @@ -49,7 +50,7 @@ public class StubFragmentVM extends ViewModelBase public void handleStubSelectedEvent(StubSelectedEvent e) { availableStub.set(e.getStub()); - stub.set(availableStub.get().createInstance(transporter)); + stub.set(availableStub.get().createInstance(machineOperator)); } private void runSelectedStub() diff --git a/Software/Android_Studio/Tango.Stubs/src/main/java/com/twine/tango/stubs/stubs/Calculate.java b/Software/Android_Studio/Tango.Stubs/src/main/java/com/twine/tango/stubs/stubs/Calculate.java index 68c697b67..1e0d6f199 100644 --- a/Software/Android_Studio/Tango.Stubs/src/main/java/com/twine/tango/stubs/stubs/Calculate.java +++ b/Software/Android_Studio/Tango.Stubs/src/main/java/com/twine/tango/stubs/stubs/Calculate.java @@ -56,7 +56,7 @@ public class Calculate extends StubBase MessageFactory.createTangoMessage( CalculateRequest.class, CalculateRequest.newBuilder().setA(num1).setB(num2).build())).subscribe((response) -> - subject.onNext(String.valueOf(response.getSum())), subject::onError); + subject.onNext(String.valueOf(response.getMessage().getSum())), subject::onError); return subject; } diff --git a/Software/Android_Studio/Tango.Stubs/src/main/java/com/twine/tango/stubs/stubs/Progress.java b/Software/Android_Studio/Tango.Stubs/src/main/java/com/twine/tango/stubs/stubs/Progress.java index 0b4d656f9..e1838a34f 100644 --- a/Software/Android_Studio/Tango.Stubs/src/main/java/com/twine/tango/stubs/stubs/Progress.java +++ b/Software/Android_Studio/Tango.Stubs/src/main/java/com/twine/tango/stubs/stubs/Progress.java @@ -51,7 +51,7 @@ public class Progress extends StubBase MessageFactory.createTangoMessage( ProgressRequest.class, ProgressRequest.newBuilder().setAmount(amount.get().intValue()).setDelay(delay.get().intValue()).build())).subscribe((response) -> - subject.onNext(String.valueOf(response.getProgress()))); + subject.onNext(String.valueOf(response.getMessage().getProgress()))); return subject; } diff --git a/Software/Android_Studio/Tango.Synchronization/build.gradle b/Software/Android_Studio/Tango.Synchronization/build.gradle index 7134933aa..a8a33e319 100644 --- a/Software/Android_Studio/Tango.Synchronization/build.gradle +++ b/Software/Android_Studio/Tango.Synchronization/build.gradle @@ -43,7 +43,7 @@ dependencies { compile globalDependencies.daggerAndroid implementation project(':Tango.DAL') implementation project(':Tango.Integration') - compile globalDependencies.rxJava compile globalDependencies.rxJavaAndroid + implementation project(':Tango.Transport') } diff --git a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ITransportAdapter.java b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ITransportAdapter.java index 083ab60fd..abd12e0f0 100644 --- a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ITransportAdapter.java +++ b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ITransportAdapter.java @@ -9,33 +9,49 @@ import java.io.IOException; * Represents a transport adapter capable of connecting, writing and receiving data from a serial stream. */ public interface ITransportAdapter extends ITransportComponent { - + /** * Writes the specified data to the stream. * * @param data the data + * @throws ObjectDisposedException the object disposed exception + * @throws IOException the io exception */ void write(byte[] data) throws ObjectDisposedException, IOException; - + /** * Add data available listener. * * @param handler event handler */ void setDataAvailableListener(IEventHandler handler); - + /** * Gets the adapter address. * * @return the address */ String getAddress(); - + /** * Sets the adapter address. * * @param address the address */ void setAddress(String address); - + + + /** + * Gets whether this adapter is authenticated. + * + * @return the authenticated + */ + boolean isAuthenticated(); + + /** + * Sets whether this adapter is authenticated. + * + * @param authenticated the authenticated + */ + void setAuthenticated(boolean authenticated); } diff --git a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ITransporter.java b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ITransporter.java index ae5f6b5dc..9d2bce329 100644 --- a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ITransporter.java +++ b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ITransporter.java @@ -32,7 +32,7 @@ public interface ITransporter extends ITransportComponent { * @param request the request * @return the single */ - Single sendRequest(TangoMessage request); + Single> sendRequest(TangoMessage request); /** * Sends a request on the specified adapter. @@ -43,7 +43,7 @@ public interface ITransporter extends ITransportComponent { * @param adapter the adapter * @return the single */ - Single sendRequest(TangoMessage request,ITransportAdapter adapter); + Single> sendRequest(TangoMessage request,ITransportAdapter adapter); /** * Sends a continuous request on all adapters. @@ -53,7 +53,7 @@ public interface ITransporter extends ITransportComponent { * @param request the request * @return the observable */ - Observable sendContinuousRequest(TangoMessage request); + Observable> sendContinuousRequest(TangoMessage request); /** * Sends a continuous request on the specified adapter. @@ -64,7 +64,7 @@ public interface ITransporter extends ITransportComponent { * @param adapter the adapter * @return the observable */ - Observable sendContinuousRequest(TangoMessage request, ITransportAdapter adapter); + Observable> sendContinuousRequest(TangoMessage request, ITransportAdapter adapter); /** * Sends a response. diff --git a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransportAdapterBase.java b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransportAdapterBase.java index d5301296b..b9221ea27 100644 --- a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransportAdapterBase.java +++ b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransportAdapterBase.java @@ -13,8 +13,10 @@ import io.reactivex.Completable; /** * Represents an {@link ITransportAdapter} base class. */ -public abstract class TransportAdapterBase implements ITransportAdapter { - +public abstract class TransportAdapterBase implements ITransportAdapter +{ + + private boolean isAuthenticated; private String address; private Event stateChangedEvent; private IEventHandler dataAvailableListener; @@ -26,31 +28,48 @@ public abstract class TransportAdapterBase implements ITransportAdapter { public TransportAdapterBase() { stateChangedEvent = new Event<>(); + setAuthenticated(true); } public abstract void write(byte[] data) throws ObjectDisposedException, IOException; - + public abstract Completable connect(); - + public abstract Completable disconnect(); - + @Override - public void setDataAvailableListener(IEventHandler handler) { + public void setDataAvailableListener(IEventHandler handler) + { dataAvailableListener = handler; } - + @Override - public String getAddress() { + public String getAddress() + { return this.address; } - + @Override - public void setAddress(String address) { + public void setAddress(String address) + { this.address = address; } - + @Override - public void addStateChangedListener(IEventHandler listener) { + public boolean isAuthenticated() + { + return isAuthenticated; + } + + @Override + public void setAuthenticated(boolean authenticated) + { + isAuthenticated = authenticated; + } + + @Override + public void addStateChangedListener(IEventHandler listener) + { stateChangedEvent.addListener(listener); } @@ -61,7 +80,8 @@ public abstract class TransportAdapterBase implements ITransportAdapter { } @Override - public TransportComponentState getState() { + public TransportComponentState getState() + { return state; } @@ -70,19 +90,24 @@ public abstract class TransportAdapterBase implements ITransportAdapter { * * @param state the state */ - protected void setState(TransportComponentState state) { + protected void setState(TransportComponentState state) + { this.state = state; - if (stateChangedEvent != null) { - try { + if (stateChangedEvent != null) + { + try + { stateChangedEvent.invoke(this, this.state); - } catch (Exception e) { + } catch (Exception e) + { e.printStackTrace(); } } } - + @Override - public void dispose() { + public void dispose() + { disconnect().blockingAwait(); setState(TransportComponentState.Disposed); } @@ -92,8 +117,10 @@ public abstract class TransportAdapterBase implements ITransportAdapter { * * @throws ObjectDisposedException the object disposed exception */ - protected void throwIfDisposed() throws ObjectDisposedException { - if (state == TransportComponentState.Disposed) { + protected void throwIfDisposed() throws ObjectDisposedException + { + if (state == TransportComponentState.Disposed) + { throw new ObjectDisposedException("The adapter is in a " + state + " state."); } } @@ -103,11 +130,15 @@ public abstract class TransportAdapterBase implements ITransportAdapter { * * @param data the data */ - protected void onDataAvailable(byte[] data) { - if (dataAvailableListener != null) { - try { + protected void onDataAvailable(byte[] data) + { + if (dataAvailableListener != null) + { + try + { dataAvailableListener.invoke(this, data); - } catch (Exception e) { + } catch (Exception e) + { e.printStackTrace(); } } @@ -118,7 +149,8 @@ public abstract class TransportAdapterBase implements ITransportAdapter { * * @param ex the ex */ - protected void onFailed(Exception ex) { + protected void onFailed(Exception ex) + { disconnect().blockingAwait(); setState(TransportComponentState.Failed); XLog.e(ex); diff --git a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransporterBase.java b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransporterBase.java index ca7f6ed92..51c4eedf8 100644 --- a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransporterBase.java +++ b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransporterBase.java @@ -240,6 +240,13 @@ public abstract class TransporterBase implements ITransporter return MessageFactory.parseMessageFromContainerAgnostic(container); } + protected TangoMessage onParseTangoMessage(byte[] data) throws InvalidProtocolBufferException, NoSuchMethodException, IllegalAccessException, InvocationTargetException + { + MessageContainer container = onParseContainer(data); + GeneratedMessageV3 message = onParseMessage(container); + return MessageFactory.createTangoMessage(container,message); + } + //endregion //region Constructors @@ -336,9 +343,9 @@ public abstract class TransporterBase implements ITransporter { adapter.disconnect().blockingAwait(); } - + setState(TransportComponentState.Disconnected); - + XLog.i("Transporter disconnected..."); x.onComplete(); @@ -351,19 +358,19 @@ public abstract class TransporterBase implements ITransporter } @Override - public Single sendRequest(TangoMessage request) + public Single> sendRequest(TangoMessage request) { return sendRequest(request, null); } @Override - public Single sendRequest(TangoMessage request, ITransportAdapter adapter) + public Single> sendRequest(TangoMessage request, ITransportAdapter adapter) { XLog.i("Queuing request message: " + request.getClass().getSimpleName() + " Token: " + request.getContainer().getToken() + " on adapter: " + (adapter != null ? adapter.getAddress() : "ALL")); XLog.i("Expected response: " + Response.Builder.class.getSimpleName()); - PublishSubject subject = PublishSubject.create(); - TransportMessage message = new TransportMessage<>(adapter, request.getContainer().getToken(), request, TransportMessageDirection.Request, onSerializingMessage(request), subject); + PublishSubject> subject = PublishSubject.create(); + TransportMessage> message = new TransportMessage<>(adapter, request.getContainer().getToken(), request, TransportMessageDirection.Request, onSerializingMessage(request), subject); sendingQueue.add(message); Completable.timer(getRequestTimeout().getSeconds(), TimeUnit.SECONDS) @@ -382,13 +389,13 @@ public abstract class TransporterBase implements ITransporter } @Override - public Observable sendContinuousRequest(TangoMessage request) + public Observable> sendContinuousRequest(TangoMessage request) { return sendContinuousRequest(request, null); } @Override - public Observable sendContinuousRequest(TangoMessage request, ITransportAdapter adapter) + public Observable> sendContinuousRequest(TangoMessage request, ITransportAdapter adapter) { XLog.i("Queuing continuous response request message: " + request.getClass().getSimpleName() + " Token: " + request.getContainer().getToken() + " on adapter: " + (adapter != null ? adapter.getAddress() : "ALL")); XLog.i("Expected response: " + Response.Builder.class.getSimpleName()); @@ -396,8 +403,8 @@ public abstract class TransporterBase implements ITransporter request.getContainer().setContinuous(true); request.getContainer().setCompleted(false); - PublishSubject subject = PublishSubject.create(); - TransportMessage message = new TransportMessage<>(adapter, request.getContainer().getToken(), request, TransportMessageDirection.Request, onSerializingMessage(request), subject); + PublishSubject> subject = PublishSubject.create(); + TransportMessage> message = new TransportMessage<>(adapter, request.getContainer().getToken(), request, TransportMessageDirection.Request, onSerializingMessage(request), subject); message.setContinuous(true); sendingQueue.add(message); @@ -473,8 +480,10 @@ public abstract class TransporterBase implements ITransporter * * @throws ObjectDisposedException the object disposed exception */ - protected void throwIfDisposed() throws ObjectDisposedException { - if (state == TransportComponentState.Disposed) { + protected void throwIfDisposed() throws ObjectDisposedException + { + if (state == TransportComponentState.Disposed) + { throw new ObjectDisposedException("The transporter is in a " + state + " state."); } } @@ -568,13 +577,24 @@ public abstract class TransporterBase implements ITransporter { XLog.i("Message received on adapter: " + data.first.getAddress()); XLog.i("Parsing message container..."); - MessageContainer container = onParseContainer(data.second); + + MessageContainer container; + + try + { + container = onParseContainer(data.second); + } catch (Exception e) + { + XLog.e("Invalid message container received!", e); + continue; + } + XLog.i("Searching for pending request token: " + container.getToken()); TransportMessageBase request = stream(pendingRequests).singleOrDefault(x -> x.getToken().equals(container.getToken()), null); if (request != null) { - XLog.i("Found pending request: " + request.getMessage().getClass().getSimpleName()); + XLog.i("Found pending request: " + ((TangoMessage)request.getMessage()).getContainer().getType()); if (!request.isContinuous()) { @@ -585,7 +605,7 @@ public abstract class TransporterBase implements ITransporter try { XLog.i("Parsing inner response message and setting pending request task result..."); - request.setResult(onParseMessage(container), true); + request.setResult(onParseTangoMessage(data.second), true); } catch (Exception ex) { XLog.e("Error parsing inner message", ex); @@ -602,7 +622,7 @@ public abstract class TransporterBase implements ITransporter { XLog.i("Continuous sequence completed."); } - request.setResult(onParseMessage(container), container.getCompleted()); + request.setResult(onParseTangoMessage(data.second), container.getCompleted()); } catch (Exception ex) { XLog.e("Error parsing inner message", ex); diff --git a/Software/Android_Studio/Tango.UnitTesting/build.gradle b/Software/Android_Studio/Tango.UnitTesting/build.gradle index 3b9a730c8..3f58e3803 100644 --- a/Software/Android_Studio/Tango.UnitTesting/build.gradle +++ b/Software/Android_Studio/Tango.UnitTesting/build.gradle @@ -42,7 +42,6 @@ dependencies { implementation project(':Tango.Integration') implementation project(':Tango.SharedUI') implementation project(':Tango.Stubs') - implementation project(':Tango.Synchronization') implementation project(':Tango.Transport') implementation project(':Tango.Web') implementation project(':Tango.NativeBridge') diff --git a/Software/Android_Studio/Tango.UnitTesting/src/androidTest/java/com/twine/tango/unittesting/Synchronization_TST.java b/Software/Android_Studio/Tango.UnitTesting/src/androidTest/java/com/twine/tango/unittesting/Synchronization_TST.java index b162c2215..4713fb6cc 100644 --- a/Software/Android_Studio/Tango.UnitTesting/src/androidTest/java/com/twine/tango/unittesting/Synchronization_TST.java +++ b/Software/Android_Studio/Tango.UnitTesting/src/androidTest/java/com/twine/tango/unittesting/Synchronization_TST.java @@ -5,13 +5,11 @@ import android.support.test.InstrumentationRegistry; import android.support.test.runner.AndroidJUnit4; import com.elvishew.xlog.XLog; -import com.twine.tango.dal.TangoDB; import com.twine.tango.dal.dao.TangoDAO; import com.twine.tango.dal.entities.Organization; -import com.twine.tango.integration.MachineIdentityProvider; -import com.twine.tango.synchronization.ITangoSynchronizer; -import com.twine.tango.synchronization.TangoSynchronizer; -import com.twine.tango.web.WebApiFactory; +import com.twine.tango.integration.providers.MachineIdentityProvider; +import com.twine.tango.integration.services.ISynchronizationService; +import com.twine.tango.integration.services.SynchronizationService; import org.junit.Test; import org.junit.runner.RunWith; @@ -38,7 +36,7 @@ public class Synchronization_TST XLog.i(org.getName()); } - ITangoSynchronizer synchronizer = new TangoSynchronizer(new MachineIdentityProvider()); + ISynchronizationService synchronizer = new SynchronizationService(new MachineIdentityProvider()); synchronizer.synchronizeDB().subscribe(() -> { diff --git a/Software/Android_Studio/settings.gradle b/Software/Android_Studio/settings.gradle index 7a7daf836..15bb94e3b 100644 --- a/Software/Android_Studio/settings.gradle +++ b/Software/Android_Studio/settings.gradle @@ -1 +1 @@ -include ':Tango.BL', ':Tango.Stubs.UI', ':Tango.SharedUI', ':Tango.Models', ':Tango.Stubs', ':Tango.Integration', ':Tango.Transport', ':Tango.Core', ':Tango.PMR', ':Tango.DAL', ':Tango.Web', ':Tango.Synchronization', ':Tango.UnitTesting', ':Tango.NativeBridge' +include ':Tango.Stubs.UI', ':Tango.SharedUI', ':Tango.Models', ':Tango.Stubs', ':Tango.Integration', ':Tango.Transport', ':Tango.Core', ':Tango.PMR', ':Tango.DAL', ':Tango.Web', ':Tango.UnitTesting', ':Tango.NativeBridge' diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 2123553a2..e1171e9f0 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 74ecadd2d..61c3049d0 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/PMR/Messages/Common/MessageType.proto b/Software/PMR/Messages/Common/MessageType.proto index 8a593b394..e77095809 100644 --- a/Software/PMR/Messages/Common/MessageType.proto +++ b/Software/PMR/Messages/Common/MessageType.proto @@ -38,4 +38,7 @@ enum MessageType StubSteperMotorResponse = 30; StubValveRequest = 31; StubValveResponse = 32; + ExternalBridgeUdpDiscoveryPacket = 33; + ExternalClientLoginRequest = 34; + ExternalClientLoginResponse = 35; } diff --git a/Software/PMR/Messages/Integration/ExternalBridgeUdpDiscoveryPacket.proto b/Software/PMR/Messages/Integration/ExternalBridgeUdpDiscoveryPacket.proto new file mode 100644 index 000000000..33c565bae --- /dev/null +++ b/Software/PMR/Messages/Integration/ExternalBridgeUdpDiscoveryPacket.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Integration; +option java_package = "com.twine.tango.pmr.integration"; + +message ExternalBridgeUdpDiscoveryPacket +{ + string SerialNumber = 2; +} \ No newline at end of file diff --git a/Software/PMR/Messages/Integration/ExternalClientLoginRequest.proto b/Software/PMR/Messages/Integration/ExternalClientLoginRequest.proto new file mode 100644 index 000000000..3c7d701b5 --- /dev/null +++ b/Software/PMR/Messages/Integration/ExternalClientLoginRequest.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Integration; +option java_package = "com.twine.tango.pmr.integration"; + +message ExternalClientLoginRequest +{ + string key = 1; +} \ No newline at end of file diff --git a/Software/PMR/Messages/Integration/ExternalClientLoginResponse.proto b/Software/PMR/Messages/Integration/ExternalClientLoginResponse.proto new file mode 100644 index 000000000..7d0ef89b5 --- /dev/null +++ b/Software/PMR/Messages/Integration/ExternalClientLoginResponse.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package Tango.PMR.Integration; +option java_package = "com.twine.tango.pmr.integration"; + +message ExternalClientLoginResponse +{ + bool Authenticated = 1; + string SerialNumber = 2; +} \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ExtensionMethods/INotificationProviderExtensions.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ExtensionMethods/INotificationProviderExtensions.cs deleted file mode 100644 index 8d95bb38e..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ExtensionMethods/INotificationProviderExtensions.cs +++ /dev/null @@ -1,30 +0,0 @@ -using MaterialDesignThemes.Wpf; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using Tango.DAL.Observables; -using Tango.MachineStudio.Common.Notifications; -using Tango.MachineStudio.DB.ViewModels; -using Tango.MachineStudio.DB.Views.DBViews; -using Tango.MachineStudio.DB.Windows; - -namespace Tango.MachineStudio.DB.ExtensionMethods -{ - public static class INotificationProviderExtensions - { - public static bool ShowDialog(this INotificationProvider provider, DialogOpenMode mode, DbTableViewModel context) where T : class, IObservableEntity - { - Type viewType = typeof(INotificationProviderExtensions).Assembly.GetType(typeof(OrganizationView).Namespace + "." + typeof(T).Name + "View"); - - DBDialogWindow window = new DBDialogWindow(Activator.CreateInstance(viewType) as FrameworkElement); - window.IconKind = (mode == DialogOpenMode.Editing ? PackIconKind.TableEdit : PackIconKind.Plus); - window.InnerTitle = (mode == DialogOpenMode.Editing ? "Edit " : "Add New ") + typeof(T).Name; - window.DataContext = context; - - return provider.ShowModalWindow(window).Value; - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj index b77d0daf9..bd6166b4f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj @@ -90,7 +90,6 @@ - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs index 89759309b..e472e312a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs @@ -8,7 +8,6 @@ using Tango.DAL.Observables; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.DB.Managers; using Tango.SharedUI; -using Tango.MachineStudio.DB.ExtensionMethods; using System.Data.Entity.Infrastructure; using GalaSoft.MvvmLight.Messaging; using Tango.MachineStudio.DB.Messages; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Images/machine-trans.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Images/machine-trans.png new file mode 100644 index 000000000..a7cf65852 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Images/machine-trans.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Navigation/NavigationView.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Navigation/NavigationView.cs index 8d38acb7c..d4212475c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Navigation/NavigationView.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Navigation/NavigationView.cs @@ -11,5 +11,6 @@ namespace Tango.MachineStudio.Synchronization.Navigation MenuView, LocalSynchronizationView, RemoteSynchronizationView, + DirectSynchronizationView, } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj index 12323ff91..19eecc2e1 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj @@ -87,10 +87,14 @@ + + + DirectSynchronizationView.xaml + RemoteSynchronizationView.xaml @@ -107,6 +111,10 @@ GlobalVersionInfo.cs + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -170,6 +178,10 @@ {38197109-8610-4d3f-92b9-16d48df94d7c} Tango.DAL.Remote + + {4206ac58-3b57-4699-8835-90bf6db01a61} + Tango.Integration + {bc932dbd-7cdb-488c-99e4-f02cf441f55e} Tango.Logging @@ -205,5 +217,8 @@ + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModelLocator.cs index a58ffe64b..090a323a2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModelLocator.cs @@ -22,6 +22,7 @@ namespace Tango.MachineStudio.Synchronization SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); SimpleIoc.Default.Unregister(); @@ -59,5 +60,13 @@ namespace Tango.MachineStudio.Synchronization return ServiceLocator.Current.GetInstance(); } } + + public static DirectSynchronizationViewVM DirectSynchronizationViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } } } \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/DirectSynchronizationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/DirectSynchronizationViewVM.cs new file mode 100644 index 000000000..ba3521009 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/DirectSynchronizationViewVM.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Integration.Services; +using Tango.SharedUI; + +namespace Tango.MachineStudio.Synchronization.ViewModels +{ + public class DirectSynchronizationViewVM : ViewModel + { + public ExternalBridgeScanner Scanner { get; set; } + + public DirectSynchronizationViewVM(ExternalBridgeScanner scanner) + { + Scanner = scanner; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/MenuViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/MenuViewVM.cs index 8eb68a383..0fe510f36 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/MenuViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/MenuViewVM.cs @@ -19,10 +19,13 @@ namespace Tango.MachineStudio.Synchronization.ViewModels StartLocalSyncCommand = new RelayCommand(() => { _navigation.NavigateTo(NavigationView.LocalSynchronizationView); }); StartRemoteSyncCommand = new RelayCommand(() => { _navigation.NavigateTo(NavigationView.RemoteSynchronizationView); }); + StartDirectRemoteSyncCommand = new RelayCommand(() => { _navigation.NavigateTo(NavigationView.DirectSynchronizationView); }); } public RelayCommand StartLocalSyncCommand { get; set; } public RelayCommand StartRemoteSyncCommand { get; set; } + + public RelayCommand StartDirectRemoteSyncCommand { get; set; } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/DirectSynchronizationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/DirectSynchronizationView.xaml new file mode 100644 index 000000000..7dc0cdacc --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/DirectSynchronizationView.xaml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/DirectSynchronizationView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/DirectSynchronizationView.xaml.cs new file mode 100644 index 000000000..5a7c12646 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/DirectSynchronizationView.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.MachineStudio.Synchronization.Views +{ + /// + /// Interaction logic for DirectSynchronizationView.xaml + /// + public partial class DirectSynchronizationView : UserControl + { + public DirectSynchronizationView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/MainView.xaml index bac530777..664dac229 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/MainView.xaml @@ -28,6 +28,9 @@ + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/MenuView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/MenuView.xaml index 6210ca94c..67501743b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/MenuView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/MenuView.xaml @@ -10,17 +10,34 @@ d:DesignHeight="720" d:DesignWidth="1280" DataContext="{x:Static global:ViewModelLocator.MenuViewVM}"> - - - - - + + + + + Local Synchronization + Synchronize two SQLite local database files. + + + + + + + + + + + + + + + + - Remote Synchronization - Synchronize local SQLite database file with the remote Twine database. + Direct Remote Synchronization + Connect and synchronized a Tango machine over the network. @@ -28,42 +45,39 @@ - + - + - + - Local Synchronization - Synchronize two SQLite local database files. + Semi Remote Synchronization + Synchronize local SQLite database file with the remote Twine database. - - - - - - - + + + - + - + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/DialogViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/DialogViewVM.cs new file mode 100644 index 000000000..e5e4cac78 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/DialogViewVM.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.SharedUI; + +namespace Tango.MachineStudio.Common.Notifications +{ + public abstract class DialogViewVM : ViewModel + { + public event Action Accepted; + public event Action Canceled; + + public DialogViewVM() + { + CanClose = true; + CloseCommand = new RelayCommand(Cancel, (x) => CanClose); + } + + private bool _canClose; + + public bool CanClose + { + get { return _canClose; } + set { _canClose = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + public RelayCommand CloseCommand { get; set; } + + public virtual void OnShow() + { + + } + + protected virtual void Accept() + { + Accepted?.Invoke(); + } + + protected virtual void Cancel() + { + Canceled?.Invoke(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs index a45f9a847..937a39ec2 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs @@ -24,11 +24,11 @@ namespace Tango.MachineStudio.Common.Notifications void PopTaskItem(TaskItem taskItem); - bool? ShowModalWindow(Window window); + void ShowModalDialog(Action onAccept, Action onCancel) where View : FrameworkElement where VM : DialogViewVM; - bool ShowModalWindow(PackIconKind icon, String title, object context) where T : FrameworkElement; + void ShowModalDialog(Action onAccept, Action onCancel) where VM : DialogViewVM; - bool ShowModalWindow(PackIconKind icon, String title, FrameworkElement content, object context); + void ShowModalDialog(Action onAccept) where VM : DialogViewVM; bool? ShowDialog(PackIconKind icon, Brush iconColor, String message, bool hasCancel); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs index 740c257b9..3297f9374 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Integration.Services; namespace Tango.MachineStudio.Common.StudioApplication { @@ -10,5 +11,7 @@ namespace Tango.MachineStudio.Common.StudioApplication { bool IsShuttingDown { get;} void ShutDown(); + IExternalBridgeClient ConnectedMachine { get; set; } + bool IsMachineConnected { get; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index 32466e45a..5cf171090 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -71,6 +71,7 @@ + @@ -142,6 +143,10 @@ {38197109-8610-4d3f-92b9-16d48df94d7c} Tango.DAL.Remote + + {4206ac58-3b57-4699-8835-90bf6db01a61} + Tango.Integration + {8491d07b-c1f6-4b62-a412-41b9fd2d6538} Tango.SharedUI diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config index b31d56717..692b77528 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config @@ -21,4 +21,12 @@ + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml.cs index 9193cfd3e..dfbc0eb77 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml.cs @@ -14,6 +14,7 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.Core.Helpers; using Tango.MachineStudio.Common.StudioApplication; namespace Tango.MachineStudio.UI @@ -29,6 +30,7 @@ namespace Tango.MachineStudio.UI { InitializeComponent(); Instance = this; + ThreadsHelper.SetDisptacher(Dispatcher); this.Closing += MainWindow_Closing; } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs index b1ba03109..3c245510b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs @@ -35,32 +35,6 @@ namespace Tango.MachineStudio.UI.Notifications TaskItems = new ObservableCollection(); } - public bool ShowModalWindow(PackIconKind icon, string title, object context) where T : FrameworkElement - { - return ShowModalWindow(icon, title, Activator.CreateInstance(), context); - } - - public bool? ShowModalWindow(Window window) - { - window.Owner = Application.Current.MainWindow; - MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; - bool result = window.ShowDialog().Value; - MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; - return result; - } - - public bool ShowModalWindow(PackIconKind icon, string title, FrameworkElement content, object context) - { - DialogWindow dialog = new DialogWindow(content); - dialog.DataContext = context; - dialog.InnerTitle = title; - dialog.Owner = Application.Current.MainWindow; - MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; - bool result = dialog.ShowDialog().Value; - MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; - return result; - } - public bool? ShowDialog(PackIconKind icon, Brush iconColor, string message, bool hasCancel) { MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; @@ -79,6 +53,98 @@ namespace Tango.MachineStudio.UI.Notifications return result; } + public void ShowModalDialog(Action onAccept, Action onCancel) where View : FrameworkElement where VM : DialogViewVM + { + var view = Activator.CreateInstance(); + DialogWindow dialog = new DialogWindow(); + dialog.Owner = Application.Current.MainWindow; + dialog.InnerContent = view; + MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; + view.Loaded += (x, y) => + { + VM context = view.DataContext as VM; + dialog.DataContext = context; + + Action onAcceptAction = null; + onAcceptAction = new Action(() => + { + dialog.Close(); + onAccept(context); + context.Accepted -= onAcceptAction; + }); + + Action onCancelAction = null; + onCancelAction = new Action(() => + { + dialog.Close(); + + if (onCancel != null) + { + onCancel(); + } + + context.Canceled -= onCancelAction; + }); + + context.Accepted += onAcceptAction; + context.Canceled += onCancelAction; + + context.OnShow(); + }; + dialog.ShowDialog(); + MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; + } + + public void ShowModalDialog(Action onAccept, Action onCancel) where VM : DialogViewVM + { + String viewName = typeof(VM).Name.Replace("VM", ""); + + var view = Activator.CreateInstance(AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes()).Single(x => x.Name == viewName)) as FrameworkElement; + DialogWindow dialog = new DialogWindow(); + dialog.Owner = Application.Current.MainWindow; + dialog.InnerContent = view; + MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; + view.Loaded += (x, y) => + { + VM context = view.DataContext as VM; + dialog.DataContext = context; + + Action onAcceptAction = null; + onAcceptAction = new Action(() => + { + dialog.Close(); + onAccept(context); + context.Accepted -= onAcceptAction; + }); + + Action onCancelAction = null; + onCancelAction = new Action(() => + { + dialog.Close(); + + if (onCancel != null) + { + onCancel(); + } + + context.Canceled -= onCancelAction; + }); + + context.Accepted += onAcceptAction; + context.Canceled += onCancelAction; + + context.OnShow(); + }; + + dialog.ShowDialog(); + MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; + } + + public void ShowModalDialog(Action onAccept) where VM : DialogViewVM + { + ShowModalDialog(onAccept, null); + } + public void ShowError(string message) { ShowDialog(PackIconKind.Exclamation, Brushes.Red, message, false); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml index 2a8dd9f28..c11e2e11b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml @@ -1,4 +1,4 @@ - + Title="Machine Studio" MinHeight="220" SizeToContent="WidthAndHeight" MinWidth="600" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterOwner" Background="Transparent"> - - - - - - - - - - - + + + + + + + + + + + + + - + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml.cs index 31dd3d644..d1bc0564b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml.cs @@ -20,51 +20,23 @@ namespace Tango.MachineStudio.UI.Windows /// /// Interaction logic for DialogWindow.xaml /// - public partial class DialogWindow : MetroWindow + public partial class DialogWindow : Window { public DialogWindow() { InitializeComponent(); } - - - public String InnerTitle - { - get { return (String)GetValue(InnerTitleProperty); } - set { SetValue(InnerTitleProperty, value); } - } - public static readonly DependencyProperty InnerTitleProperty = - DependencyProperty.Register("InnerTitle", typeof(String), typeof(DialogWindow), new PropertyMetadata(null)); - - - - public PackIconKind IconKind + public FrameworkElement InnerContent { - get { return (PackIconKind)GetValue(IconKindProperty); } - set { SetValue(IconKindProperty, value); } + get { return (FrameworkElement)GetValue(InnerContentProperty); } + set { SetValue(InnerContentProperty, value); } } - public static readonly DependencyProperty IconKindProperty = - DependencyProperty.Register("IconKind", typeof(PackIconKind), typeof(DialogWindow), new PropertyMetadata(PackIconKind.Information)); - + // Using a DependencyProperty as the backing store for InnerContent. This enables animation, styling, binding, etc... + public static readonly DependencyProperty InnerContentProperty = + DependencyProperty.Register("InnerContent", typeof(FrameworkElement), typeof(DialogWindow), new PropertyMetadata(null)); - public DialogWindow(FrameworkElement content) : this() - { - presenter.Content = content; - } - - private void OnOKClicked(object sender, RoutedEventArgs e) - { - DialogResult = true; - Close(); - } - - private void OnCancelClicked(object sender, RoutedEventArgs e) - { - DialogResult = false; - Close(); - } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs index ea4234fd8..b0315e633 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -11,10 +11,13 @@ using Tango.MachineStudio.Common.Navigation; using GalaSoft.MvvmLight.Ioc; using System.Reflection; using System.Collections; +using Tango.Integration.Services; +using Tango.Core; +using Tango.Logging; namespace Tango.MachineStudio.UI.StudioApplication { - public class DefaultStudioApplicationManager : IStudioApplicationManager + public class DefaultStudioApplicationManager : ExtendedObject, IStudioApplicationManager { private INavigationManager _navigationManager; @@ -25,6 +28,19 @@ namespace Tango.MachineStudio.UI.StudioApplication public bool IsShuttingDown { get; private set; } + private IExternalBridgeClient _connectedMachine; + + public IExternalBridgeClient ConnectedMachine + { + get { return _connectedMachine; } + set { _connectedMachine = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(IsMachineConnected)); } + } + + public bool IsMachineConnected + { + get { return ConnectedMachine != null; } + } + public async void ShutDown() { if (IsShuttingDown) return; @@ -33,6 +49,17 @@ namespace Tango.MachineStudio.UI.StudioApplication await Task.Factory.StartNew(async () => { + try + { + if (ConnectedMachine != null) + { + ConnectedMachine.Disconnect().Wait(); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error disconnecting from machine."); + } //Do Shutdown Procedures... foreach (var vm in ServiceLocator.Current.GetAllInstancesByBase()) diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index fa04a1068..3becf0252 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -58,6 +58,9 @@ ..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll + + ..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll + ..\..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll @@ -110,6 +113,7 @@ + @@ -119,6 +123,9 @@ LoginView.xaml + + MachineConnectionView.xaml + MainView.xaml @@ -159,6 +166,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -216,10 +227,18 @@ {38197109-8610-4d3f-92b9-16d48df94d7c} Tango.DAL.Remote + + {4206ac58-3b57-4699-8835-90bf6db01a61} + Tango.Integration + {bc932dbd-7cdb-488c-99e4-f02cf441f55e} Tango.Logging + + {e4927038-348d-4295-aaf4-861c58cb3943} + Tango.PMR + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} Tango.Settings @@ -228,6 +247,10 @@ {8491d07b-c1f6-4b62-a412-41b9fd2d6538} Tango.SharedUI + + {74e700b0-1156-4126-be40-ee450d3c3026} + Tango.Transport + {94f7acf8-55e1-4a02-b9bc-a818413fdbbf} Tango.MachineStudio.DB diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs index f4a7a7502..e40f589af 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs @@ -2,6 +2,7 @@ using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Ioc; using Microsoft.Practices.ServiceLocation; using System; +using Tango.Integration.Services; using Tango.Logging; using Tango.MachineStudio.Common.Authentication; using Tango.MachineStudio.Common.Modules; @@ -48,17 +49,23 @@ namespace Tango.MachineStudio.UI SimpleIoc.Default.Unregister(); SimpleIoc.Default.Unregister(); SimpleIoc.Default.Unregister(); + SimpleIoc.Default.Unregister(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + + LogManager.RegisterLogger(new VSOutputLogger()); + LogManager.RegisterLogger(new FileLogger()); //Register View (Supervising Controller Pattern). if (!ViewModelBase.IsInDesignModeStatic) @@ -99,5 +106,13 @@ namespace Tango.MachineStudio.UI return ServiceLocator.Current.GetInstance(); } } + + public MachineConnectionViewVM MachineConnectionViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } } } \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs new file mode 100644 index 000000000..b8b888e86 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.Integration.Services; +using Tango.MachineStudio.Common.Notifications; +using Tango.SharedUI; + +namespace Tango.MachineStudio.UI.ViewModels +{ + public class MachineConnectionViewVM : DialogViewVM + { + private ExternalBridgeScanner _scanner; + + public ExternalBridgeScanner Scanner + { + get { return _scanner; } + set { _scanner = value; RaisePropertyChangedAuto(); } + } + + private IExternalBridgeClient _selectedMachine; + + public IExternalBridgeClient SelectedMachine + { + get { return _selectedMachine; } + set { _selectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + public RelayCommand ConnectCommand { get; set; } + + public MachineConnectionViewVM(ExternalBridgeScanner scanner) + { + Scanner = scanner; + ConnectCommand = new RelayCommand(Connect,(x) => SelectedMachine != null); + Scanner.Start(); + } + + private void Connect() + { + if (SelectedMachine != null) + { + Accept(); + } + } + + public override void OnShow() + { + base.OnShow(); + + Scanner.AvailableMachines.Clear(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index a12156d60..6c44c8480 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -7,18 +7,24 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; using Tango.Core.Commands; +using Tango.Logging; using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Authentication; using Tango.MachineStudio.Common.Modules; using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.Common.StudioApplication; using Tango.MachineStudio.UI.SupervisingController; +using Tango.MachineStudio.UI.Views; +using Tango.PMR.Stubs; using Tango.SharedUI; +using Tango.Transport.Adapters; namespace Tango.MachineStudio.UI.ViewModels { public class MainViewVM : ViewModel { private IStudioModule _currentModule; + private bool _isDisconnecting; public IStudioModule CurrentModule { @@ -47,6 +53,10 @@ namespace Tango.MachineStudio.UI.ViewModels public RelayCommand HomeCommand { get; set; } + public RelayCommand ConnectCommand { get; set; } + + public RelayCommand DisconnectCommand { get; set; } + private IAuthenticationProvider _authenticationProvider; public IAuthenticationProvider AuthenticationProvider { @@ -70,20 +80,81 @@ namespace Tango.MachineStudio.UI.ViewModels set { _notificationProvider = value; RaisePropertyChangedAuto(); } } + private IStudioApplicationManager _applicationManager; + + public IStudioApplicationManager ApplicationManager + { + get { return _applicationManager; } + set { _applicationManager = value; RaisePropertyChangedAuto(); } + } + + public MainViewVM( IMainView view, IAuthenticationProvider authenticationProvider, IStudioModuleLoader studioModuleLoader, - INotificationProvider notificationProvider) : base(view) + INotificationProvider notificationProvider, + IStudioApplicationManager applicationManager) : base(view) { AuthenticationProvider = authenticationProvider; StudioModuleLoader = studioModuleLoader; NotificationProvider = notificationProvider; + ApplicationManager = applicationManager; StartModuleCommand = new RelayCommand(StartModule); HomeCommand = new RelayCommand(Home); + ConnectCommand = new RelayCommand(ConnectToMachine); + DisconnectCommand = new RelayCommand(DisconnectFromMachine,(x) => ApplicationManager.IsMachineConnected && !_isDisconnecting); + } + + private async void DisconnectFromMachine() + { + using (_notificationProvider.PushTaskItem("Disconnecting from machine...")) + { + _isDisconnecting = true; + InvalidateRelayCommands(); + await ApplicationManager.ConnectedMachine.Disconnect(); + ApplicationManager.ConnectedMachine = null; + _isDisconnecting = false; + InvalidateRelayCommands(); + } + } + + private void ConnectToMachine() + { + _notificationProvider.ShowModalDialog(async (x) => + { + if (x.SelectedMachine != null) + { + using (NotificationProvider.PushTaskItem("Connecting to machine " + x.SelectedMachine.SerialNumber + "...")) + { + try + { + await x.SelectedMachine.Connect(); + var authenticated = await x.SelectedMachine.Authenticate(); + if (!authenticated) + { + _notificationProvider.ShowError("It seems like you are not authorized to access the selected machine."); + } + else + { + ApplicationManager.ConnectedMachine = x.SelectedMachine; + var response = await x.SelectedMachine.SendRequest(new CalculateRequest() { A = 10, B = 5 }); + _notificationProvider.ShowInfo(response.ToString()); + } + } + catch (Exception ex) + { + LogManager.Log(ex); + _notificationProvider.ShowError(ex.Message); + } + } + } + + InvalidateRelayCommands(); + }); } private void Home() diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml new file mode 100644 index 000000000..2d172837a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + S/N: + + + IP Address: + + + Organization: + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml.cs new file mode 100644 index 000000000..58cec1987 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.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.MachineStudio.UI.Views +{ + /// + /// Interaction logic for MachineConnectionView.xaml + /// + public partial class MachineConnectionView : UserControl + { + public MachineConnectionView() + { + InitializeComponent(); + } + + private void OnConnectClicked(object sender, RoutedEventArgs e) + { + Window.GetWindow(this).DialogResult = true; + Window.GetWindow(this).Close(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml index aad1189b8..fc9db8adc 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml @@ -26,7 +26,7 @@ - + @@ -84,17 +84,49 @@ x:Name="MenuToggleButton"/> - + + + @@ -189,7 +221,7 @@ - + @@ -204,16 +236,16 @@ - + - + - + - + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml.cs index 520b69741..f52393e1c 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml.cs @@ -1,4 +1,5 @@ -using System; +using Microsoft.Practices.ServiceLocation; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,9 +10,12 @@ using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; +using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.UI.Notifications; using Tango.MachineStudio.UI.SupervisingController; using Tango.SharedUI; using Tango.SharedUI.Controls; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/packages.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/packages.config index 3a7265a72..25ad810bd 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/packages.config +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/packages.config @@ -4,6 +4,7 @@ + diff --git a/Software/Visual_Studio/Tango.Core/Helpers/ThreadsHelper.cs b/Software/Visual_Studio/Tango.Core/Helpers/ThreadsHelper.cs index 5f140d344..bd934747d 100644 --- a/Software/Visual_Studio/Tango.Core/Helpers/ThreadsHelper.cs +++ b/Software/Visual_Studio/Tango.Core/Helpers/ThreadsHelper.cs @@ -3,20 +3,28 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows; using System.Windows.Threading; namespace Tango.Core.Helpers { public static class ThreadsHelper { + private static Dispatcher _dispatcher; + + public static void SetDisptacher(Dispatcher dispatcher) + { + _dispatcher = dispatcher; + } + public static void InvokeUI(Action action) { - Dispatcher.CurrentDispatcher.BeginInvoke(action); + _dispatcher.BeginInvoke(action); } public static void InvokeUINow(Action action) { - Dispatcher.CurrentDispatcher.Invoke(action); + _dispatcher.Invoke(action); } } } diff --git a/Software/Visual_Studio/Tango.Integration/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.Integration/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..161c5a04e --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Properties/AssemblyInfo.cs @@ -0,0 +1,6 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Tango - Logging Library")] +[assembly: ComVisible(false)] \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Integration/Services/ExternalBridgeClient.cs b/Software/Visual_Studio/Tango.Integration/Services/ExternalBridgeClient.cs new file mode 100644 index 000000000..1cbb6982a --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Services/ExternalBridgeClient.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.PMR.Integration; +using Tango.Settings; +using Tango.Transport; +using Tango.Transport.Adapters; +using Tango.Transport.Transporters; + +namespace Tango.Integration.Services +{ + public class ExternalBridgeClient : ProtoTransporter, IExternalBridgeClient + { + private String _serialNumber; + + public String SerialNumber + { + get { return _serialNumber; } + internal set + { + _serialNumber = value; + RaisePropertyChangedAuto(); + + var org = ObservablesEntitiesAdapter.Instance.Organizations.SingleOrDefault(x => x.Machines.ToList().Exists(y => y.SerialNumber == SerialNumber)); + Organization = org != null ? org.Name : "Unknown"; + } + } + + private String _ipAddress; + + public String IPAddress + { + get { return _ipAddress; } + set { _ipAddress = value; RaisePropertyChangedAuto(); } + } + + private String _organization; + + public String Organization + { + get { return _organization; } + private set { _organization = value; RaisePropertyChangedAuto(); } + } + + public override async Task Connect() + { + await Disconnect(); + Adapters.Clear(); + Adapters.Add(new TcpTransportAdapter(IPAddress, SettingsManager.Default.Integration.ExternalBridgeServicePort)); + await base.Connect(); + } + + public async Task Authenticate() + { + var response = await SendRequest(new ExternalClientLoginRequest() { Key = "1234" }); + return response.Authenticated; + } + + public ExternalBridgeClient(String serialNumber,String ipAddress) + { + SerialNumber = serialNumber; + IPAddress = ipAddress; + } + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Services/ExternalBridgeScanner.cs b/Software/Visual_Studio/Tango.Integration/Services/ExternalBridgeScanner.cs new file mode 100644 index 000000000..fe7260a02 --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Services/ExternalBridgeScanner.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Net; +using System.Net.NetworkInformation; +using System.Net.Sockets; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Core.Helpers; +using Tango.Logging; +using Tango.PMR; +using Tango.PMR.Common; +using Tango.PMR.Integration; +using Tango.Settings; +using Tango.Transport.Adapters; + +namespace Tango.Integration.Services +{ + public class ExternalBridgeScanner : ExtendedObject + { + private Thread _discoveryThread; + + private ObservableCollection _availableMachines; + /// + /// Gets or sets the available services. + /// + public ObservableCollection AvailableMachines + { + get { return _availableMachines; } + private set { _availableMachines = value; RaisePropertyChangedAuto(); } + } + + private bool _isStarted; + /// + /// Gets or sets a value indicating whether this instance is started. + /// + public bool IsStarted + { + get { return _isStarted; } + private set { _isStarted = value; RaisePropertyChangedAuto(); } + } + + /// + /// Initializes a new instance of the class. + /// + public ExternalBridgeScanner() + { + AvailableMachines = new ObservableCollection(); + } + + /// + /// Starts this instance. + /// + public void Start() + { + if (!IsStarted) + { + _discoveryThread = new Thread(DiscoveryThreadMethod); + _discoveryThread.IsBackground = true; + _discoveryThread.Start(); + } + } + + private void DiscoveryThreadMethod() + { + var Server = new UdpClient(8888); + + while (!IsStarted) + { + var ClientEp = new IPEndPoint(IPAddress.Any, 0); + var ClientRequestData = Server.Receive(ref ClientEp); + + ExternalBridgeUdpDiscoveryPacket packet = ExternalBridgeUdpDiscoveryPacket.Parser.ParseFrom(ClientRequestData); + + ExternalBridgeClient newMachine = new ExternalBridgeClient(packet.SerialNumber, ClientEp.Address.ToString()); + if (!AvailableMachines.ToList().Exists(x => x.SerialNumber == packet.SerialNumber)) + { + ThreadsHelper.InvokeUINow(() => + { + AvailableMachines.Add(newMachine); + }); + } + + Thread.Sleep(1000); + } + + Server.Close(); + } + + /// + /// Stops this instance. + /// + public void Stop() + { + if (IsStarted) + { + IsStarted = false; + } + } + + private void Client_StateChanged(object sender, Transport.TransportComponentState e) + { + if (e == Transport.TransportComponentState.Failed || e == Transport.TransportComponentState.Disposed) + { + AvailableMachines.Remove(sender as IExternalBridgeClient); + } + } + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Services/IExternalBridgeClient.cs b/Software/Visual_Studio/Tango.Integration/Services/IExternalBridgeClient.cs new file mode 100644 index 000000000..6eb0ac5f9 --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Services/IExternalBridgeClient.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Sockets; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport; +using Tango.Transport.Transporters; + +namespace Tango.Integration.Services +{ + public interface IExternalBridgeClient : ITransporter + { + String SerialNumber { get; } + + String Organization { get; } + + String IPAddress { get; set; } + + Task Authenticate(); + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj new file mode 100644 index 000000000..e07c5a90d --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj @@ -0,0 +1,85 @@ + + + + + Debug + AnyCPU + {4206AC58-3B57-4699-8835-90BF6DB01A61} + Library + Properties + Tango.Integration + Tango.Integration + v4.6 + 512 + + + true + full + false + ..\Build\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll + + + + + + + + + + + + + GlobalVersionInfo.cs + + + + + + + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {0ecd6da8-7aa6-48d9-8b65-279d176ad9af} + Tango.DAL.Observables + + + {bc932dbd-7cdb-488c-99e4-f02cf441f55e} + Tango.Logging + + + {E4927038-348D-4295-AAF4-861C58CB3943} + Tango.PMR + + + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} + Tango.Settings + + + {74e700b0-1156-4126-be40-ee450d3c3026} + Tango.Transport + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Integration/app.config b/Software/Visual_Studio/Tango.Integration/app.config new file mode 100644 index 000000000..cacd4cd77 --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Integration/packages.config b/Software/Visual_Studio/Tango.Integration/packages.config new file mode 100644 index 000000000..6d9929c06 --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs b/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs index 51f9e0f52..07079271b 100644 --- a/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs +++ b/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs @@ -22,7 +22,7 @@ namespace Tango.PMR.Common { static MessageTypeReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "ChFNZXNzYWdlVHlwZS5wcm90bxIQVGFuZ28uUE1SLkNvbW1vbirvBgoLTWVz", + "ChFNZXNzYWdlVHlwZS5wcm90bxIQVGFuZ28uUE1SLkNvbW1vbirWBwoLTWVz", "c2FnZVR5cGUSBwoDUkdCEAASBwoDSm9iEAESCwoHU2VnbWVudBACEhQKEENh", "bGN1bGF0ZVJlcXVlc3QQAxIVChFDYWxjdWxhdGVSZXNwb25zZRAEEhMKD1By", "b2dyZXNzUmVxdWVzdBAFEhQKEFByb2dyZXNzUmVzcG9uc2UQBhIcChhTdHVi", @@ -42,8 +42,10 @@ namespace Tango.PMR.Common { "TGltaXRTd2l0Y2hSZXF1ZXN0EBsSHgoaU3R1Yk9wdExpbWl0U3dpdGNoUmVz", "cG9uc2UQHBIaChZTdHViU3RlcGVyTW90b3JSZXF1ZXN0EB0SGwoXU3R1YlN0", "ZXBlck1vdG9yUmVzcG9uc2UQHhIUChBTdHViVmFsdmVSZXF1ZXN0EB8SFQoR", - "U3R1YlZhbHZlUmVzcG9uc2UQIEIcChpjb20udHdpbmUudGFuZ28ucG1yLmNv", - "bW1vbmIGcHJvdG8z")); + "U3R1YlZhbHZlUmVzcG9uc2UQIBIkCiBFeHRlcm5hbEJyaWRnZVVkcERpc2Nv", + "dmVyeVBhY2tldBAhEh4KGkV4dGVybmFsQ2xpZW50TG9naW5SZXF1ZXN0ECIS", + "HwobRXh0ZXJuYWxDbGllbnRMb2dpblJlc3BvbnNlECNCHAoaY29tLnR3aW5l", + "LnRhbmdvLnBtci5jb21tb25iBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tango.PMR.Common.MessageType), }, null)); @@ -86,6 +88,9 @@ namespace Tango.PMR.Common { [pbr::OriginalName("StubSteperMotorResponse")] StubSteperMotorResponse = 30, [pbr::OriginalName("StubValveRequest")] StubValveRequest = 31, [pbr::OriginalName("StubValveResponse")] StubValveResponse = 32, + [pbr::OriginalName("ExternalBridgeUdpDiscoveryPacket")] ExternalBridgeUdpDiscoveryPacket = 33, + [pbr::OriginalName("ExternalClientLoginRequest")] ExternalClientLoginRequest = 34, + [pbr::OriginalName("ExternalClientLoginResponse")] ExternalClientLoginResponse = 35, } #endregion diff --git a/Software/Visual_Studio/Tango.PMR/Integration/ExternalBridgeUdpDiscoveryPacket.cs b/Software/Visual_Studio/Tango.PMR/Integration/ExternalBridgeUdpDiscoveryPacket.cs new file mode 100644 index 000000000..163a753b7 --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Integration/ExternalBridgeUdpDiscoveryPacket.cs @@ -0,0 +1,160 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ExternalBridgeUdpDiscoveryPacket.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Integration { + + /// Holder for reflection information generated from ExternalBridgeUdpDiscoveryPacket.proto + public static partial class ExternalBridgeUdpDiscoveryPacketReflection { + + #region Descriptor + /// File descriptor for ExternalBridgeUdpDiscoveryPacket.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static ExternalBridgeUdpDiscoveryPacketReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CiZFeHRlcm5hbEJyaWRnZVVkcERpc2NvdmVyeVBhY2tldC5wcm90bxIVVGFu", + "Z28uUE1SLkludGVncmF0aW9uIjgKIEV4dGVybmFsQnJpZGdlVWRwRGlzY292", + "ZXJ5UGFja2V0EhQKDFNlcmlhbE51bWJlchgCIAEoCUIhCh9jb20udHdpbmUu", + "dGFuZ28ucG1yLmludGVncmF0aW9uYgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Integration.ExternalBridgeUdpDiscoveryPacket), global::Tango.PMR.Integration.ExternalBridgeUdpDiscoveryPacket.Parser, new[]{ "SerialNumber" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class ExternalBridgeUdpDiscoveryPacket : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ExternalBridgeUdpDiscoveryPacket()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Integration.ExternalBridgeUdpDiscoveryPacketReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExternalBridgeUdpDiscoveryPacket() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExternalBridgeUdpDiscoveryPacket(ExternalBridgeUdpDiscoveryPacket other) : this() { + serialNumber_ = other.serialNumber_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExternalBridgeUdpDiscoveryPacket Clone() { + return new ExternalBridgeUdpDiscoveryPacket(this); + } + + /// Field number for the "SerialNumber" field. + public const int SerialNumberFieldNumber = 2; + private string serialNumber_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string SerialNumber { + get { return serialNumber_; } + set { + serialNumber_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ExternalBridgeUdpDiscoveryPacket); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ExternalBridgeUdpDiscoveryPacket other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (SerialNumber != other.SerialNumber) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (SerialNumber.Length != 0) hash ^= SerialNumber.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (SerialNumber.Length != 0) { + output.WriteRawTag(18); + output.WriteString(SerialNumber); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (SerialNumber.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(SerialNumber); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ExternalBridgeUdpDiscoveryPacket other) { + if (other == null) { + return; + } + if (other.SerialNumber.Length != 0) { + SerialNumber = other.SerialNumber; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 18: { + SerialNumber = input.ReadString(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Integration/ExternalClientLoginRequest.cs b/Software/Visual_Studio/Tango.PMR/Integration/ExternalClientLoginRequest.cs new file mode 100644 index 000000000..2b614b2ed --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Integration/ExternalClientLoginRequest.cs @@ -0,0 +1,160 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ExternalClientLoginRequest.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Integration { + + /// Holder for reflection information generated from ExternalClientLoginRequest.proto + public static partial class ExternalClientLoginRequestReflection { + + #region Descriptor + /// File descriptor for ExternalClientLoginRequest.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static ExternalClientLoginRequestReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CiBFeHRlcm5hbENsaWVudExvZ2luUmVxdWVzdC5wcm90bxIVVGFuZ28uUE1S", + "LkludGVncmF0aW9uIikKGkV4dGVybmFsQ2xpZW50TG9naW5SZXF1ZXN0EgsK", + "A2tleRgBIAEoCUIhCh9jb20udHdpbmUudGFuZ28ucG1yLmludGVncmF0aW9u", + "YgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Integration.ExternalClientLoginRequest), global::Tango.PMR.Integration.ExternalClientLoginRequest.Parser, new[]{ "Key" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class ExternalClientLoginRequest : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ExternalClientLoginRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Integration.ExternalClientLoginRequestReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExternalClientLoginRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExternalClientLoginRequest(ExternalClientLoginRequest other) : this() { + key_ = other.key_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExternalClientLoginRequest Clone() { + return new ExternalClientLoginRequest(this); + } + + /// Field number for the "key" field. + public const int KeyFieldNumber = 1; + private string key_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Key { + get { return key_; } + set { + key_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ExternalClientLoginRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ExternalClientLoginRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Key != other.Key) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Key.Length != 0) hash ^= Key.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Key.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Key); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Key.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Key); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ExternalClientLoginRequest other) { + if (other == null) { + return; + } + if (other.Key.Length != 0) { + Key = other.Key; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Key = input.ReadString(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Integration/ExternalClientLoginResponse.cs b/Software/Visual_Studio/Tango.PMR/Integration/ExternalClientLoginResponse.cs new file mode 100644 index 000000000..3d374024c --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Integration/ExternalClientLoginResponse.cs @@ -0,0 +1,188 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ExternalClientLoginResponse.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Integration { + + /// Holder for reflection information generated from ExternalClientLoginResponse.proto + public static partial class ExternalClientLoginResponseReflection { + + #region Descriptor + /// File descriptor for ExternalClientLoginResponse.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static ExternalClientLoginResponseReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CiFFeHRlcm5hbENsaWVudExvZ2luUmVzcG9uc2UucHJvdG8SFVRhbmdvLlBN", + "Ui5JbnRlZ3JhdGlvbiJKChtFeHRlcm5hbENsaWVudExvZ2luUmVzcG9uc2US", + "FQoNQXV0aGVudGljYXRlZBgBIAEoCBIUCgxTZXJpYWxOdW1iZXIYAiABKAlC", + "IQofY29tLnR3aW5lLnRhbmdvLnBtci5pbnRlZ3JhdGlvbmIGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Integration.ExternalClientLoginResponse), global::Tango.PMR.Integration.ExternalClientLoginResponse.Parser, new[]{ "Authenticated", "SerialNumber" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class ExternalClientLoginResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ExternalClientLoginResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Integration.ExternalClientLoginResponseReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExternalClientLoginResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExternalClientLoginResponse(ExternalClientLoginResponse other) : this() { + authenticated_ = other.authenticated_; + serialNumber_ = other.serialNumber_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExternalClientLoginResponse Clone() { + return new ExternalClientLoginResponse(this); + } + + /// Field number for the "Authenticated" field. + public const int AuthenticatedFieldNumber = 1; + private bool authenticated_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Authenticated { + get { return authenticated_; } + set { + authenticated_ = value; + } + } + + /// Field number for the "SerialNumber" field. + public const int SerialNumberFieldNumber = 2; + private string serialNumber_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string SerialNumber { + get { return serialNumber_; } + set { + serialNumber_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ExternalClientLoginResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ExternalClientLoginResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Authenticated != other.Authenticated) return false; + if (SerialNumber != other.SerialNumber) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Authenticated != false) hash ^= Authenticated.GetHashCode(); + if (SerialNumber.Length != 0) hash ^= SerialNumber.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Authenticated != false) { + output.WriteRawTag(8); + output.WriteBool(Authenticated); + } + if (SerialNumber.Length != 0) { + output.WriteRawTag(18); + output.WriteString(SerialNumber); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Authenticated != false) { + size += 1 + 1; + } + if (SerialNumber.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(SerialNumber); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ExternalClientLoginResponse other) { + if (other == null) { + return; + } + if (other.Authenticated != false) { + Authenticated = other.Authenticated; + } + if (other.SerialNumber.Length != 0) { + SerialNumber = other.SerialNumber; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + Authenticated = input.ReadBool(); + break; + } + case 18: { + SerialNumber = input.ReadString(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj index 08a809060..a720373ae 100644 --- a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj +++ b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj @@ -48,6 +48,9 @@ GlobalVersionInfo.cs + + + diff --git a/Software/Visual_Studio/Tango.Settings/Integration.cs b/Software/Visual_Studio/Tango.Settings/Integration.cs new file mode 100644 index 000000000..8ca80176b --- /dev/null +++ b/Software/Visual_Studio/Tango.Settings/Integration.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Settings +{ + public class Integration + { + public int ExternalBridgeServicePort { get; set; } + + public Integration() + { + ExternalBridgeServicePort = 1984; + } + } +} diff --git a/Software/Visual_Studio/Tango.Settings/SettingsCollection.cs b/Software/Visual_Studio/Tango.Settings/SettingsCollection.cs index aae228b49..1deeac638 100644 --- a/Software/Visual_Studio/Tango.Settings/SettingsCollection.cs +++ b/Software/Visual_Studio/Tango.Settings/SettingsCollection.cs @@ -18,6 +18,8 @@ namespace Tango.Settings public StubsUI StubsUI { get; set; } + public Integration Integration { get; set; } + /// /// Initializes a new instance of the class. /// @@ -26,6 +28,7 @@ namespace Tango.Settings DataBase = new DataBase(); MachineStudio = new MachineStudio(); StubsUI = new StubsUI(); + Integration = new Integration(); } } } diff --git a/Software/Visual_Studio/Tango.Settings/Tango.Settings.csproj b/Software/Visual_Studio/Tango.Settings/Tango.Settings.csproj index e85a5f1bd..edd0b1c25 100644 --- a/Software/Visual_Studio/Tango.Settings/Tango.Settings.csproj +++ b/Software/Visual_Studio/Tango.Settings/Tango.Settings.csproj @@ -44,6 +44,7 @@ GlobalVersionInfo.cs + diff --git a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs index bb3a95cbc..aeda918fa 100644 --- a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs +++ b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs @@ -18,7 +18,7 @@ namespace Tango.Transport /// Represents an base class. /// /// - public abstract class TransporterBase : ITransporter + public abstract class TransporterBase : ExtendedObject, ITransporter { private ConcurrentQueue _sendingQueue; private List _pendingRequests; @@ -237,7 +237,7 @@ namespace Tango.Transport /// Connects the transport component. /// /// - public async Task Connect() + public virtual async Task Connect() { State = TransportComponentState.Connected; StartThreads(); @@ -249,7 +249,7 @@ namespace Tango.Transport /// Disconnects the transport component. /// /// - public async Task Disconnect() + public virtual async Task Disconnect() { State = TransportComponentState.Disconnected; await Task.WhenAll(Adapters.Select(x => x.Disconnect())); diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 52f716bf8..f64a4cf59 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -101,6 +101,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tango.ColorLib", "Native\Ta EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.AutoComplete", "SideChains\Tango.AutoComplete\Tango.AutoComplete.csproj", "{BB2ABB74-BA58-4812-83AA-EC8171F42DF4}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Integration", "Tango.Integration\Tango.Integration.csproj", "{4206AC58-3B57-4699-8835-90BF6DB01A61}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -861,6 +863,26 @@ Global {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Release|x64.Build.0 = Release|Any CPU {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Release|x86.ActiveCfg = Release|Any CPU {BB2ABB74-BA58-4812-83AA-EC8171F42DF4}.Release|x86.Build.0 = Release|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Debug|ARM.ActiveCfg = Debug|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Debug|ARM.Build.0 = Debug|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Debug|ARM64.Build.0 = Debug|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Debug|x64.ActiveCfg = Debug|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Debug|x64.Build.0 = Debug|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Debug|x86.ActiveCfg = Debug|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Debug|x86.Build.0 = Debug|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Release|Any CPU.Build.0 = Release|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Release|ARM.ActiveCfg = Release|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Release|ARM.Build.0 = Release|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Release|ARM64.ActiveCfg = Release|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Release|ARM64.Build.0 = Release|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Release|x64.ActiveCfg = Release|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Release|x64.Build.0 = Release|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Release|x86.ActiveCfg = Release|Any CPU + {4206AC58-3B57-4699-8835-90BF6DB01A61}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE -- cgit v1.3.1 From 2ea2bb5bcd96045f1bd6cb4c3d8b8416dbaa05dc Mon Sep 17 00:00:00 2001 From: Roy Date: Tue, 26 Dec 2017 21:16:15 +0200 Subject: MERGE --- .../java/com/twine/tango/dal/DateConverter.java | 4 +- .../src/main/java/com/twine/tango/dal/TangoDB.java | 2 +- .../Tango.DAL/src/main/res/raw/tangodb | Bin 557056 -> 557056 bytes .../providers/MachineIdentityProvider.java | 8 +- .../services/ExternalBridgeService.java | 9 +- .../services/SynchronizationService.java | 100 +++- .../tango/pmr/common/MessageTypeOuterClass.java | 45 +- .../DirectSynchronizationRequestOuterClass.java | 441 +++++++++++++++++ .../DirectSynchronizationResponseOuterClass.java | 508 ++++++++++++++++++++ .../ExternalClientLoginRequestOuterClass.java | 100 ++-- .../OverrideDataBaseRequestOuterClass.java | 508 ++++++++++++++++++++ .../OverrideDataBaseResponseOuterClass.java | 506 ++++++++++++++++++++ .../twine/tango/transport/ITransportAdapter.java | 14 + .../com/twine/tango/transport/ITransporter.java | 5 +- .../tango/transport/ResponseErrorException.java | 57 +++ .../tango/transport/TransportAdapterBase.java | 51 +- .../tango/transport/TransportAdapterMode.java | 17 + .../com/twine/tango/transport/TransporterBase.java | 14 +- .../transport/adapters/TcpTransportAdapter.java | 96 ++-- .../transport/adapters/UsbTransportAdapter.java | 57 ++- .../transporters/ResponseErrorException.java | 43 -- Software/DB/Tango.mdf | Bin 8388608 -> 8388608 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes Software/Graphics/Machine Studio Modules/stubs.jpg | Bin 0 -> 96798 bytes Software/PMR/Messages/Common/MessageType.proto | 4 + .../Integration/DirectSynchronizationRequest.proto | 9 + .../DirectSynchronizationResponse.proto | 9 + .../Integration/ExternalClientLoginRequest.proto | 2 +- .../Integration/OverrideDataBaseRequest.proto | 9 + .../Integration/OverrideDataBaseResponse.proto | 9 + .../Converters/LiquidTypeRmlsToStringConverter.cs | 36 ++ .../Tango.MachineStudio.DB.csproj | 136 ++++++ .../Tango.MachineStudio.DB/ViewModelLocator.cs | 83 ++++ .../ViewModels/ContactsViewVM.cs | 28 ++ .../ViewModels/FiberShapesViewVM.cs | 17 + .../ViewModels/FiberSynthsViewVM.cs | 17 + .../ViewModels/LinearMassDensityUnitsViewVM.cs | 17 + .../ViewModels/LiquidTypesViewVM.cs | 59 +++ .../ViewModels/MediaColorsViewVM.cs | 17 + .../ViewModels/MediaConditionsViewVM.cs | 17 + .../ViewModels/MediaMaterialsViewVM.cs | 17 + .../ViewModels/MediaPurposesViewVM.cs | 17 + .../ViewModels/RmlsViewVM.cs | 17 + .../ViewModels/UsersViewVM.cs | 7 +- .../Views/DBViews/ContactView.xaml | 30 ++ .../Views/DBViews/ContactView.xaml.cs | 28 ++ .../Views/DBViews/ContactsView.xaml | 27 ++ .../Views/DBViews/ContactsView.xaml.cs | 31 ++ .../Views/DBViews/FiberShapeView.xaml | 25 + .../Views/DBViews/FiberShapeView.xaml.cs | 28 ++ .../Views/DBViews/FiberShapesView.xaml | 24 + .../Views/DBViews/FiberShapesView.xaml.cs | 32 ++ .../Views/DBViews/FiberSynthView.xaml | 25 + .../Views/DBViews/FiberSynthView.xaml.cs | 28 ++ .../Views/DBViews/FiberSynthsView.xaml | 24 + .../Views/DBViews/FiberSynthsView.xaml.cs | 32 ++ .../Views/DBViews/LinearMassDensityUnitView.xaml | 25 + .../DBViews/LinearMassDensityUnitView.xaml.cs | 28 ++ .../Views/DBViews/LinearMassDensityUnitsView.xaml | 24 + .../DBViews/LinearMassDensityUnitsView.xaml.cs | 32 ++ .../Views/DBViews/LiquidTypeView.xaml | 17 +- .../Views/DBViews/LiquidTypeView.xaml.cs | 6 + .../Views/DBViews/LiquidTypesView.xaml | 3 + .../Views/DBViews/MediaColorView.xaml | 34 ++ .../Views/DBViews/MediaColorView.xaml.cs | 28 ++ .../Views/DBViews/MediaColorsView.xaml | 38 ++ .../Views/DBViews/MediaColorsView.xaml.cs | 32 ++ .../Views/DBViews/MediaConditionView.xaml | 25 + .../Views/DBViews/MediaConditionView.xaml.cs | 28 ++ .../Views/DBViews/MediaConditionsView.xaml | 24 + .../Views/DBViews/MediaConditionsView.xaml.cs | 32 ++ .../Views/DBViews/MediaMaterialView.xaml | 25 + .../Views/DBViews/MediaMaterialView.xaml.cs | 28 ++ .../Views/DBViews/MediaMaterialsView.xaml | 24 + .../Views/DBViews/MediaMaterialsView.xaml.cs | 32 ++ .../Views/DBViews/MediaPurposView.xaml | 25 + .../Views/DBViews/MediaPurposView.xaml.cs | 28 ++ .../Views/DBViews/MediaPurposesView.xaml | 24 + .../Views/DBViews/MediaPurposesView.xaml.cs | 32 ++ .../Views/DBViews/RmlView.xaml | 98 ++++ .../Views/DBViews/RmlView.xaml.cs | 28 ++ .../Views/DBViews/RmlsView.xaml | 57 +++ .../Views/DBViews/RmlsView.xaml.cs | 31 ++ .../Tango.MachineStudio.Stubs/Images/stubs.jpg | Bin 0 -> 96798 bytes .../Properties/AssemblyInfo.cs | 18 + .../Properties/Resources.Designer.cs | 92 ++++ .../Properties/Resources.resx | 124 +++++ .../Properties/Settings.Designer.cs | 30 ++ .../Properties/Settings.settings | 7 + .../Resources/CodeTabTemplate.cs | 20 + .../Tango.MachineStudio.Stubs/StubManager.cs | 181 +++++++ .../StubOnExecuteParameters.cs | 30 ++ .../Tango.MachineStudio.Stubs/StubsModule.cs | 39 ++ .../Tango.MachineStudio.Stubs.csproj | 183 +++++++ .../Tango.MachineStudio.Stubs/ViewModelLocator.cs | 33 ++ .../ViewModels/CodeTabVM.cs | 100 ++++ .../ViewModels/MainViewVM.cs | 525 +++++++++++++++++++++ .../ViewModels/StubSnippetVM.cs | 47 ++ .../Tango.MachineStudio.Stubs/Views/MainView.xaml | 319 +++++++++++++ .../Views/MainView.xaml.cs | 53 +++ .../Modules/Tango.MachineStudio.Stubs/app.config | 51 ++ .../Tango.MachineStudio.Stubs/packages.config | 11 + .../Tango.MachineStudio.Synchronization/App.config | 15 + .../Tango.MachineStudio.Synchronization.csproj | 31 ++ .../ViewModels/DirectSynchronizationViewVM.cs | 274 ++++++++++- .../Views/DirectSynchronizationView.xaml | 202 +++++++- .../Views/LocalSynchronizationView.xaml | 77 ++- .../Views/RemoteSynchronizationView.xaml | 2 +- .../packages.config | 7 + .../Tango.MachineStudio.UI/App.config | 40 ++ .../Modules/DefaultStudioModuleLoader.cs | 12 +- .../Notifications/DefaultNotificationProvider.cs | 16 +- .../Notifications/MessageBoxWindow.xaml | 2 +- .../Tango.MachineStudio.UI.csproj | 23 + .../Tango.MachineStudio.UI/ViewModelLocator.cs | 9 + .../ViewModels/LoadingViewVM.cs | 1 - .../ViewModels/MachineLoginViewVM.cs | 31 ++ .../ViewModels/MainViewVM.cs | 39 +- .../Views/MachineConnectionView.xaml | 2 +- .../Views/MachineConnectionView.xaml.cs | 6 - .../Views/MachineLoginView.xaml | 31 +- .../Views/MachineLoginView.xaml.cs | 23 + .../Tango.MachineStudio.UI/Views/MainView.xaml | 3 +- .../Tango.MachineStudio.UI/packages.config | 6 + .../Visual_Studio/Tango.Core/Helpers/PathHelper.cs | 5 + .../Visual_Studio/Tango.DAL.Local/DB/LocalADO.edmx | 3 + Software/Visual_Studio/Tango.DAL.Local/DB/RML.cs | 1 + .../Tango.DAL.Observables/Entities/Rml.cs | 19 + .../Enumerations/FiberShapes.cs | 7 + .../Enumerations/FiberSynths.cs | 7 + .../Enumerations/LinearMassDensityUnits.cs | 7 + .../Enumerations/MediaConditions.cs | 7 + .../Enumerations/MediaMaterials.cs | 7 + .../Enumerations/MediaPurposes.cs | 7 + .../ObservablesEntitiesAdapter.cs | 16 + Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs | 1 + .../Tango.DAL.Remote/DB/RemoteADO.edmx | 3 + .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 78 +-- .../Services/ExternalBridgeClient.cs | 4 +- .../Services/IExternalBridgeClient.cs | 2 +- .../Visual_Studio/Tango.PMR/Common/MessageType.cs | 13 +- .../Integration/DirectSynchronizationRequest.cs | 131 +++++ .../Integration/DirectSynchronizationResponse.cs | 160 +++++++ .../Integration/ExternalClientLoginRequest.cs | 40 +- .../Integration/OverrideDataBaseRequest.cs | 160 +++++++ .../Integration/OverrideDataBaseResponse.cs | 160 +++++++ Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj | 4 + .../Visual_Studio/Tango.Scripting/FodyWeavers.xml | 4 + .../Tango.Scripting/Tango.Scripting.csproj | 24 + .../Visual_Studio/Tango.Scripting/packages.config | 2 + .../MachineStudioSettings/MachineStudio.cs | 3 + .../MachineStudioSettings/StubsModule.cs | 20 + .../Tango.Settings/Tango.Settings.csproj | 1 + .../Converters/BooleanToYesNoConverter.cs | 23 + .../Tango.SharedUI/Tango.SharedUI.csproj | 1 + .../Visual_Studio/Tango.Stubs/Stubs/Calculate.cs | 23 +- .../Adapters/TcpTransportAdapter.cs | 51 +- .../Adapters/UsbTransportAdapter.cs | 37 +- .../Tango.Transport/ITransportAdapter.cs | 5 + .../Tango.Transport/Tango.Transport.csproj | 1 + .../Tango.Transport/TransportAdapterBase.cs | 24 + .../Tango.Transport/TransportAdapterMode.cs | 23 + .../Tango.Transport/TransporterBase.cs | 2 +- Software/Visual_Studio/Tango.sln | 23 + .../Web/Tango.MachineService/App_Data/Tango.db | Bin 557056 -> 557056 bytes .../Controllers/SynchronizationController.cs | 2 +- 166 files changed, 7742 insertions(+), 338 deletions(-) create mode 100644 Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/DirectSynchronizationRequestOuterClass.java create mode 100644 Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/DirectSynchronizationResponseOuterClass.java create mode 100644 Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/OverrideDataBaseRequestOuterClass.java create mode 100644 Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/OverrideDataBaseResponseOuterClass.java create mode 100644 Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ResponseErrorException.java create mode 100644 Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransportAdapterMode.java delete mode 100644 Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/transporters/ResponseErrorException.java create mode 100644 Software/Graphics/Machine Studio Modules/stubs.jpg create mode 100644 Software/PMR/Messages/Integration/DirectSynchronizationRequest.proto create mode 100644 Software/PMR/Messages/Integration/DirectSynchronizationResponse.proto create mode 100644 Software/PMR/Messages/Integration/OverrideDataBaseRequest.proto create mode 100644 Software/PMR/Messages/Integration/OverrideDataBaseResponse.proto create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/LiquidTypeRmlsToStringConverter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ContactsViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/FiberShapesViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/FiberSynthsViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/LinearMassDensityUnitsViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MediaColorsViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MediaConditionsViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MediaMaterialsViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MediaPurposesViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/RmlsViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ContactView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ContactView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ContactsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ContactsView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberShapeView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberShapeView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberShapesView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberShapesView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberSynthView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberSynthView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberSynthsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberSynthsView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LinearMassDensityUnitView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LinearMassDensityUnitView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LinearMassDensityUnitsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LinearMassDensityUnitsView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaColorView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaColorView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaColorsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaColorsView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaConditionView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaConditionView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaConditionsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaConditionsView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaMaterialView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaMaterialView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaMaterialsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaMaterialsView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaPurposView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaPurposView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaPurposesView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaPurposesView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Images/stubs.jpg create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/Resources.Designer.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/Resources.resx create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/Settings.Designer.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/Settings.settings create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Resources/CodeTabTemplate.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubManager.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubOnExecuteParameters.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Tango.MachineStudio.Stubs.csproj create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModelLocator.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/CodeTabVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/StubSnippetVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Views/MainView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Views/MainView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/app.config create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/packages.config create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Integration/DirectSynchronizationRequest.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Integration/DirectSynchronizationResponse.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Integration/OverrideDataBaseRequest.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Integration/OverrideDataBaseResponse.cs create mode 100644 Software/Visual_Studio/Tango.Scripting/FodyWeavers.xml create mode 100644 Software/Visual_Studio/Tango.Settings/MachineStudioSettings/StubsModule.cs create mode 100644 Software/Visual_Studio/Tango.SharedUI/Converters/BooleanToYesNoConverter.cs create mode 100644 Software/Visual_Studio/Tango.Transport/TransportAdapterMode.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj') diff --git a/Software/Android_Studio/Tango.DAL/src/main/java/com/twine/tango/dal/DateConverter.java b/Software/Android_Studio/Tango.DAL/src/main/java/com/twine/tango/dal/DateConverter.java index 165d0f161..548b1dd09 100644 --- a/Software/Android_Studio/Tango.DAL/src/main/java/com/twine/tango/dal/DateConverter.java +++ b/Software/Android_Studio/Tango.DAL/src/main/java/com/twine/tango/dal/DateConverter.java @@ -21,14 +21,14 @@ public class DateConverter extends TypeConverter @Override public String getDBValue(DateTime model) { - DateTimeFormatter dtfOut = DateTimeFormat.forPattern("yyyy-MM-dd hh:mm:ss"); + DateTimeFormatter dtfOut = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS"); return dtfOut.print(model); } @Override public DateTime getModelValue(String data) { - DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy-MM-dd hh:mm:ss"); + DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS"); DateTime jodatime = dtf.parseDateTime(data); return jodatime; } diff --git a/Software/Android_Studio/Tango.DAL/src/main/java/com/twine/tango/dal/TangoDB.java b/Software/Android_Studio/Tango.DAL/src/main/java/com/twine/tango/dal/TangoDB.java index 367cbc088..53bb6a8e2 100644 --- a/Software/Android_Studio/Tango.DAL/src/main/java/com/twine/tango/dal/TangoDB.java +++ b/Software/Android_Studio/Tango.DAL/src/main/java/com/twine/tango/dal/TangoDB.java @@ -37,7 +37,7 @@ public class TangoDB { database_name = "Tango.db"; database_path = ContextHelper.getApplicationContext().getDatabasePath(database_name).getPath(); - database_backup_path = Environment.getExternalStorageDirectory() + "/BACKUP/" + "backup.db"; + database_backup_path = ContextHelper.getApplicationContext().getDatabasePath("backup").getPath(); try { diff --git a/Software/Android_Studio/Tango.DAL/src/main/res/raw/tangodb b/Software/Android_Studio/Tango.DAL/src/main/res/raw/tangodb index 0419b065c..f7af9b52f 100644 Binary files a/Software/Android_Studio/Tango.DAL/src/main/res/raw/tangodb and b/Software/Android_Studio/Tango.DAL/src/main/res/raw/tangodb differ diff --git a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/providers/MachineIdentityProvider.java b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/providers/MachineIdentityProvider.java index b4f2d3c4d..c72b9cea4 100644 --- a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/providers/MachineIdentityProvider.java +++ b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/providers/MachineIdentityProvider.java @@ -1,4 +1,8 @@ package com.twine.tango.integration.providers; +import com.twine.tango.dal.dao.TangoDAO; +import com.twine.tango.dal.entities.Machine; + +import static br.com.zbra.androidlinq.Linq.stream; /** @@ -6,10 +10,10 @@ package com.twine.tango.integration.providers; */ public class MachineIdentityProvider implements IMachineIdentityProvider { - @Override public String getSerialNumber() { - return "1234"; + Machine machine = stream(TangoDAO.getAllMachines()).firstOrNull(); + return machine != null ? machine.getSerialNumber() : "0000"; } } diff --git a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/ExternalBridgeService.java b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/ExternalBridgeService.java index 709d5a271..24ae72eba 100644 --- a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/ExternalBridgeService.java +++ b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/ExternalBridgeService.java @@ -22,6 +22,7 @@ import com.twine.tango.pmr.integration.ExternalBridgeUdpDiscoveryPacketOuterClas import com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest; import com.twine.tango.pmr.integration.ExternalClientLoginResponseOuterClass.ExternalClientLoginResponse; import com.twine.tango.transport.ITransportAdapter; +import com.twine.tango.transport.ResponseErrorException; import com.twine.tango.transport.adapters.TcpTransportAdapter; import com.twine.tango.transport.transporters.ProtoTransporter; @@ -198,7 +199,7 @@ public class ExternalBridgeService extends ProtoTransporter implements IExternal if (container.getType() == MessageType.ExternalClientLoginRequest) { ExternalClientLoginRequest request = MessageFactory.parseMessageFromContainer(container); - if (request.getKey().equals("1234")) + if (request.getPassword().equals("Aa123456")) //TODO: Compare with global machine settings password... { getAdapters().get(0).setAuthenticated(true); sendResponse(MessageFactory.createTangoMessage( @@ -235,21 +236,23 @@ public class ExternalBridgeService extends ProtoTransporter implements IExternal //Route to machine... if (container.getContinuous()) { + //noinspection unchecked machineOperator.sendContinuousRequest(MessageFactory.createTangoMessage(container, message)).subscribe((response) -> { sendResponse((TangoMessage) response); }, (ex) -> { - + sendResponse((TangoMessage) ((ResponseErrorException)ex).getResponse()); }); } else { + //noinspection unchecked machineOperator.sendRequest(MessageFactory.createTangoMessage(container, message)).subscribe((response) -> { sendResponse((TangoMessage) response); }, (ex) -> { - + sendResponse((TangoMessage) ((ResponseErrorException)ex).getResponse()); }); } } diff --git a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/SynchronizationService.java b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/SynchronizationService.java index 0f3d98982..53b4c8194 100644 --- a/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/SynchronizationService.java +++ b/Software/Android_Studio/Tango.Integration/src/main/java/com/twine/tango/integration/services/SynchronizationService.java @@ -1,5 +1,7 @@ package com.twine.tango.integration.services; +import android.os.AsyncTask; + import com.elvishew.xlog.XLog; import com.google.protobuf.ByteString; import com.snatik.storage.Storage; @@ -10,12 +12,18 @@ import com.twine.tango.integration.services.IExternalBridgeService.MessageReceiv import com.twine.tango.pmr.MessageFactory; import com.twine.tango.pmr.TangoMessage; import com.twine.tango.pmr.common.MessageTypeOuterClass.MessageType; +import com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest; +import com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse; +import com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest; +import com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse; import com.twine.tango.pmr.stubs.CalculateRequestOuterClass.CalculateRequest; import com.twine.tango.pmr.stubs.CalculateResponseOuterClass.CalculateResponse; import com.twine.tango.pmr.synchronization.SynchronizeDBRequestOuterClass.SynchronizeDBRequest; import com.twine.tango.web.WebApiFactory; import com.twine.tango.web.ISynchronizationAPI; +import java.io.IOException; + import javax.inject.Inject; import io.reactivex.Completable; @@ -39,14 +47,96 @@ public class SynchronizationService implements ISynchronizationService { this.machineIdentityProvider = machineIdentityProvider; this.bridgeService = bridgeService; - //this.bridgeService.registerMessageHandler(this::handleCalculateRequest, MessageType.CalculateRequest); + this.bridgeService.registerMessageHandler(this::handleDirectSynchronizationRequest, MessageType.DirectSynchronizationRequest); + this.bridgeService.registerMessageHandler(this::handleOverrideDataBaseRequest, MessageType.OverrideDataBaseRequest); + } - private void handleCalculateRequest(Object o, MessageReceivedArgs e) + private void handleOverrideDataBaseRequest(Object o, MessageReceivedArgs request) { - CalculateResponse response = CalculateResponse.newBuilder().setSum(e.getMessage().getA() + e.getMessage().getB()).build(); - TangoMessage tangoMessage = MessageFactory.createTangoMessage(CalculateResponse.class, response, e.getContainer().getToken()); - bridgeService.sendResponse(tangoMessage); + AsyncTask.execute(() -> + { + try + { + //Backup DataBase. + TangoDB.backup(); + + //Replace Database. + TangoDB.replace(request.getMessage().getRemoteDB().toByteArray()); + + //Create response. + OverrideDataBaseResponse response = OverrideDataBaseResponse.newBuilder() + .setSuccessful(true) + .build(); + + TangoMessage message = MessageFactory.createTangoMessage( + OverrideDataBaseResponse.class, + response); + + bridgeService.sendResponse(message, request.getContainer().getToken()).subscribe(() -> + { + + },(ex) -> + { + XLog.e(ex); + }); + + } catch (Exception e) + { + XLog.e(e); + //Create response. + OverrideDataBaseResponse response = OverrideDataBaseResponse.newBuilder() + .setSuccessful(false) + .build(); + + TangoMessage message = MessageFactory.createTangoMessage( + OverrideDataBaseResponse.class, + response); + + bridgeService.sendResponse(message, request.getContainer().getToken()).subscribe(() -> + { + + },(ex) -> + { + XLog.e(ex); + }); + } + }); + } + + private void handleDirectSynchronizationRequest(Object o, MessageReceivedArgs request) + { + AsyncTask.execute(() -> + { + try + { + Storage storage = new Storage(ContextHelper.getApplicationContext()); + + //Read current DB file bytes. + byte[] data = storage.readFile(TangoDB.getDataBasePath()); + + //Create synchronization response. + DirectSynchronizationResponse response = DirectSynchronizationResponse.newBuilder() + .setLocalDB(ByteString.copyFrom(data)) + .build(); + + TangoMessage message = MessageFactory.createTangoMessage( + DirectSynchronizationResponse.class, + response); + + bridgeService.sendResponse(message, request.getContainer().getToken()).subscribe(() -> + { + + },(ex) -> + { + XLog.e(ex); + }); + + } catch (Exception e) + { + XLog.e(e); + } + }); } @Override diff --git a/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/common/MessageTypeOuterClass.java b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/common/MessageTypeOuterClass.java index 27d581c93..c6aaf8d17 100644 --- a/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/common/MessageTypeOuterClass.java +++ b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/common/MessageTypeOuterClass.java @@ -163,6 +163,22 @@ public final class MessageTypeOuterClass { * ExternalClientLoginResponse = 35; */ ExternalClientLoginResponse(35), + /** + * DirectSynchronizationRequest = 36; + */ + DirectSynchronizationRequest(36), + /** + * DirectSynchronizationResponse = 37; + */ + DirectSynchronizationResponse(37), + /** + * OverrideDataBaseRequest = 38; + */ + OverrideDataBaseRequest(38), + /** + * OverrideDataBaseResponse = 39; + */ + OverrideDataBaseResponse(39), UNRECOGNIZED(-1), ; @@ -310,6 +326,22 @@ public final class MessageTypeOuterClass { * ExternalClientLoginResponse = 35; */ public static final int ExternalClientLoginResponse_VALUE = 35; + /** + * DirectSynchronizationRequest = 36; + */ + public static final int DirectSynchronizationRequest_VALUE = 36; + /** + * DirectSynchronizationResponse = 37; + */ + public static final int DirectSynchronizationResponse_VALUE = 37; + /** + * OverrideDataBaseRequest = 38; + */ + public static final int OverrideDataBaseRequest_VALUE = 38; + /** + * OverrideDataBaseResponse = 39; + */ + public static final int OverrideDataBaseResponse_VALUE = 39; public final int getNumber() { @@ -366,6 +398,10 @@ public final class MessageTypeOuterClass { case 33: return ExternalBridgeUdpDiscoveryPacket; case 34: return ExternalClientLoginRequest; case 35: return ExternalClientLoginResponse; + case 36: return DirectSynchronizationRequest; + case 37: return DirectSynchronizationResponse; + case 38: return OverrideDataBaseRequest; + case 39: return OverrideDataBaseResponse; default: return null; } } @@ -427,7 +463,7 @@ public final class MessageTypeOuterClass { descriptor; static { java.lang.String[] descriptorData = { - "\n\021MessageType.proto\022\020Tango.PMR.Common*\326\007" + + "\n\021MessageType.proto\022\020Tango.PMR.Common*\326\010" + "\n\013MessageType\022\007\n\003RGB\020\000\022\007\n\003Job\020\001\022\013\n\007Segme" + "nt\020\002\022\024\n\020CalculateRequest\020\003\022\025\n\021CalculateR" + "esponse\020\004\022\023\n\017ProgressRequest\020\005\022\024\n\020Progre" + @@ -452,8 +488,11 @@ public final class MessageTypeOuterClass { "ubValveRequest\020\037\022\025\n\021StubValveResponse\020 \022" + "$\n ExternalBridgeUdpDiscoveryPacket\020!\022\036\n" + "\032ExternalClientLoginRequest\020\"\022\037\n\033Externa" + - "lClientLoginResponse\020#B\034\n\032com.twine.tang" + - "o.pmr.commonb\006proto3" + "lClientLoginResponse\020#\022 \n\034DirectSynchron" + + "izationRequest\020$\022!\n\035DirectSynchronizatio" + + "nResponse\020%\022\033\n\027OverrideDataBaseRequest\020&" + + "\022\034\n\030OverrideDataBaseResponse\020\'B\034\n\032com.tw" + + "ine.tango.pmr.commonb\006proto3" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { diff --git a/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/DirectSynchronizationRequestOuterClass.java b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/DirectSynchronizationRequestOuterClass.java new file mode 100644 index 000000000..b2d324b39 --- /dev/null +++ b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/DirectSynchronizationRequestOuterClass.java @@ -0,0 +1,441 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DirectSynchronizationRequest.proto + +package com.twine.tango.pmr.integration; + +public final class DirectSynchronizationRequestOuterClass { + private DirectSynchronizationRequestOuterClass() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface DirectSynchronizationRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:Tango.PMR.Integration.DirectSynchronizationRequest) + com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code Tango.PMR.Integration.DirectSynchronizationRequest} + */ + public static final class DirectSynchronizationRequest extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:Tango.PMR.Integration.DirectSynchronizationRequest) + DirectSynchronizationRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use DirectSynchronizationRequest.newBuilder() to construct. + private DirectSynchronizationRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private DirectSynchronizationRequest() { + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private DirectSynchronizationRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.internal_static_Tango_PMR_Integration_DirectSynchronizationRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.internal_static_Tango_PMR_Integration_DirectSynchronizationRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest.class, com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest.Builder.class); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest)) { + return super.equals(obj); + } + com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest other = (com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest) obj; + + boolean result = true; + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code Tango.PMR.Integration.DirectSynchronizationRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:Tango.PMR.Integration.DirectSynchronizationRequest) + com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.internal_static_Tango_PMR_Integration_DirectSynchronizationRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.internal_static_Tango_PMR_Integration_DirectSynchronizationRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest.class, com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest.Builder.class); + } + + // Construct using com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.internal_static_Tango_PMR_Integration_DirectSynchronizationRequest_descriptor; + } + + public com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest getDefaultInstanceForType() { + return com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest.getDefaultInstance(); + } + + public com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest build() { + com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest buildPartial() { + com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest result = new com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest(this); + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest) { + return mergeFrom((com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest other) { + if (other == com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest.getDefaultInstance()) return this; + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:Tango.PMR.Integration.DirectSynchronizationRequest) + } + + // @@protoc_insertion_point(class_scope:Tango.PMR.Integration.DirectSynchronizationRequest) + private static final com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest(); + } + + public static com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public DirectSynchronizationRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DirectSynchronizationRequest(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.twine.tango.pmr.integration.DirectSynchronizationRequestOuterClass.DirectSynchronizationRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_Tango_PMR_Integration_DirectSynchronizationRequest_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_Tango_PMR_Integration_DirectSynchronizationRequest_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\"DirectSynchronizationRequest.proto\022\025Ta" + + "ngo.PMR.Integration\"\036\n\034DirectSynchroniza" + + "tionRequestB!\n\037com.twine.tango.pmr.integ" + + "rationb\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_Tango_PMR_Integration_DirectSynchronizationRequest_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_Tango_PMR_Integration_DirectSynchronizationRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_Tango_PMR_Integration_DirectSynchronizationRequest_descriptor, + new java.lang.String[] { }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/DirectSynchronizationResponseOuterClass.java b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/DirectSynchronizationResponseOuterClass.java new file mode 100644 index 000000000..e1187ec4b --- /dev/null +++ b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/DirectSynchronizationResponseOuterClass.java @@ -0,0 +1,508 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DirectSynchronizationResponse.proto + +package com.twine.tango.pmr.integration; + +public final class DirectSynchronizationResponseOuterClass { + private DirectSynchronizationResponseOuterClass() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface DirectSynchronizationResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:Tango.PMR.Integration.DirectSynchronizationResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes LocalDB = 1; + */ + com.google.protobuf.ByteString getLocalDB(); + } + /** + * Protobuf type {@code Tango.PMR.Integration.DirectSynchronizationResponse} + */ + public static final class DirectSynchronizationResponse extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:Tango.PMR.Integration.DirectSynchronizationResponse) + DirectSynchronizationResponseOrBuilder { + private static final long serialVersionUID = 0L; + // Use DirectSynchronizationResponse.newBuilder() to construct. + private DirectSynchronizationResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private DirectSynchronizationResponse() { + localDB_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private DirectSynchronizationResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + localDB_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.internal_static_Tango_PMR_Integration_DirectSynchronizationResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.internal_static_Tango_PMR_Integration_DirectSynchronizationResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse.class, com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse.Builder.class); + } + + public static final int LOCALDB_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString localDB_; + /** + * bytes LocalDB = 1; + */ + public com.google.protobuf.ByteString getLocalDB() { + return localDB_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!localDB_.isEmpty()) { + output.writeBytes(1, localDB_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!localDB_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, localDB_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse)) { + return super.equals(obj); + } + com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse other = (com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse) obj; + + boolean result = true; + result = result && getLocalDB() + .equals(other.getLocalDB()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + LOCALDB_FIELD_NUMBER; + hash = (53 * hash) + getLocalDB().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code Tango.PMR.Integration.DirectSynchronizationResponse} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:Tango.PMR.Integration.DirectSynchronizationResponse) + com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.internal_static_Tango_PMR_Integration_DirectSynchronizationResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.internal_static_Tango_PMR_Integration_DirectSynchronizationResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse.class, com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse.Builder.class); + } + + // Construct using com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + localDB_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.internal_static_Tango_PMR_Integration_DirectSynchronizationResponse_descriptor; + } + + public com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse getDefaultInstanceForType() { + return com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse.getDefaultInstance(); + } + + public com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse build() { + com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse buildPartial() { + com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse result = new com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse(this); + result.localDB_ = localDB_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse) { + return mergeFrom((com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse other) { + if (other == com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse.getDefaultInstance()) return this; + if (other.getLocalDB() != com.google.protobuf.ByteString.EMPTY) { + setLocalDB(other.getLocalDB()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString localDB_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes LocalDB = 1; + */ + public com.google.protobuf.ByteString getLocalDB() { + return localDB_; + } + /** + * bytes LocalDB = 1; + */ + public Builder setLocalDB(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + localDB_ = value; + onChanged(); + return this; + } + /** + * bytes LocalDB = 1; + */ + public Builder clearLocalDB() { + + localDB_ = getDefaultInstance().getLocalDB(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:Tango.PMR.Integration.DirectSynchronizationResponse) + } + + // @@protoc_insertion_point(class_scope:Tango.PMR.Integration.DirectSynchronizationResponse) + private static final com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse(); + } + + public static com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public DirectSynchronizationResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DirectSynchronizationResponse(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.twine.tango.pmr.integration.DirectSynchronizationResponseOuterClass.DirectSynchronizationResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_Tango_PMR_Integration_DirectSynchronizationResponse_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_Tango_PMR_Integration_DirectSynchronizationResponse_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n#DirectSynchronizationResponse.proto\022\025T" + + "ango.PMR.Integration\"0\n\035DirectSynchroniz" + + "ationResponse\022\017\n\007LocalDB\030\001 \001(\014B!\n\037com.tw" + + "ine.tango.pmr.integrationb\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_Tango_PMR_Integration_DirectSynchronizationResponse_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_Tango_PMR_Integration_DirectSynchronizationResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_Tango_PMR_Integration_DirectSynchronizationResponse_descriptor, + new java.lang.String[] { "LocalDB", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/ExternalClientLoginRequestOuterClass.java b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/ExternalClientLoginRequestOuterClass.java index 9717c3d11..4709d4992 100644 --- a/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/ExternalClientLoginRequestOuterClass.java +++ b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/ExternalClientLoginRequestOuterClass.java @@ -19,14 +19,14 @@ public final class ExternalClientLoginRequestOuterClass { com.google.protobuf.MessageOrBuilder { /** - * string key = 1; + * string Password = 1; */ - java.lang.String getKey(); + java.lang.String getPassword(); /** - * string key = 1; + * string Password = 1; */ com.google.protobuf.ByteString - getKeyBytes(); + getPasswordBytes(); } /** * Protobuf type {@code Tango.PMR.Integration.ExternalClientLoginRequest} @@ -41,7 +41,7 @@ public final class ExternalClientLoginRequestOuterClass { super(builder); } private ExternalClientLoginRequest() { - key_ = ""; + password_ = ""; } @java.lang.Override @@ -75,7 +75,7 @@ public final class ExternalClientLoginRequestOuterClass { case 10: { java.lang.String s = input.readStringRequireUtf8(); - key_ = s; + password_ = s; break; } } @@ -102,34 +102,34 @@ public final class ExternalClientLoginRequestOuterClass { com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest.class, com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest.Builder.class); } - public static final int KEY_FIELD_NUMBER = 1; - private volatile java.lang.Object key_; + public static final int PASSWORD_FIELD_NUMBER = 1; + private volatile java.lang.Object password_; /** - * string key = 1; + * string Password = 1; */ - public java.lang.String getKey() { - java.lang.Object ref = key_; + public java.lang.String getPassword() { + java.lang.Object ref = password_; if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); - key_ = s; + password_ = s; return s; } } /** - * string key = 1; + * string Password = 1; */ public com.google.protobuf.ByteString - getKeyBytes() { - java.lang.Object ref = key_; + getPasswordBytes() { + java.lang.Object ref = password_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - key_ = b; + password_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; @@ -148,8 +148,8 @@ public final class ExternalClientLoginRequestOuterClass { public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!getKeyBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, key_); + if (!getPasswordBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, password_); } unknownFields.writeTo(output); } @@ -159,8 +159,8 @@ public final class ExternalClientLoginRequestOuterClass { if (size != -1) return size; size = 0; - if (!getKeyBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, key_); + if (!getPasswordBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, password_); } size += unknownFields.getSerializedSize(); memoizedSize = size; @@ -178,8 +178,8 @@ public final class ExternalClientLoginRequestOuterClass { com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest other = (com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest) obj; boolean result = true; - result = result && getKey() - .equals(other.getKey()); + result = result && getPassword() + .equals(other.getPassword()); result = result && unknownFields.equals(other.unknownFields); return result; } @@ -191,8 +191,8 @@ public final class ExternalClientLoginRequestOuterClass { } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + KEY_FIELD_NUMBER; - hash = (53 * hash) + getKey().hashCode(); + hash = (37 * hash) + PASSWORD_FIELD_NUMBER; + hash = (53 * hash) + getPassword().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -322,7 +322,7 @@ public final class ExternalClientLoginRequestOuterClass { } public Builder clear() { super.clear(); - key_ = ""; + password_ = ""; return this; } @@ -346,7 +346,7 @@ public final class ExternalClientLoginRequestOuterClass { public com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest buildPartial() { com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest result = new com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest(this); - result.key_ = key_; + result.password_ = password_; onBuilt(); return result; } @@ -388,8 +388,8 @@ public final class ExternalClientLoginRequestOuterClass { public Builder mergeFrom(com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest other) { if (other == com.twine.tango.pmr.integration.ExternalClientLoginRequestOuterClass.ExternalClientLoginRequest.getDefaultInstance()) return this; - if (!other.getKey().isEmpty()) { - key_ = other.key_; + if (!other.getPassword().isEmpty()) { + password_ = other.password_; onChanged(); } this.mergeUnknownFields(other.unknownFields); @@ -419,71 +419,71 @@ public final class ExternalClientLoginRequestOuterClass { return this; } - private java.lang.Object key_ = ""; + private java.lang.Object password_ = ""; /** - * string key = 1; + * string Password = 1; */ - public java.lang.String getKey() { - java.lang.Object ref = key_; + public java.lang.String getPassword() { + java.lang.Object ref = password_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); - key_ = s; + password_ = s; return s; } else { return (java.lang.String) ref; } } /** - * string key = 1; + * string Password = 1; */ public com.google.protobuf.ByteString - getKeyBytes() { - java.lang.Object ref = key_; + getPasswordBytes() { + java.lang.Object ref = password_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - key_ = b; + password_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** - * string key = 1; + * string Password = 1; */ - public Builder setKey( + public Builder setPassword( java.lang.String value) { if (value == null) { throw new NullPointerException(); } - key_ = value; + password_ = value; onChanged(); return this; } /** - * string key = 1; + * string Password = 1; */ - public Builder clearKey() { + public Builder clearPassword() { - key_ = getDefaultInstance().getKey(); + password_ = getDefaultInstance().getPassword(); onChanged(); return this; } /** - * string key = 1; + * string Password = 1; */ - public Builder setKeyBytes( + public Builder setPasswordBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); - key_ = value; + password_ = value; onChanged(); return this; } @@ -551,9 +551,9 @@ public final class ExternalClientLoginRequestOuterClass { static { java.lang.String[] descriptorData = { "\n ExternalClientLoginRequest.proto\022\025Tang" + - "o.PMR.Integration\")\n\032ExternalClientLogin" + - "Request\022\013\n\003key\030\001 \001(\tB!\n\037com.twine.tango." + - "pmr.integrationb\006proto3" + "o.PMR.Integration\".\n\032ExternalClientLogin" + + "Request\022\020\n\010Password\030\001 \001(\tB!\n\037com.twine.t" + + "ango.pmr.integrationb\006proto3" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { @@ -572,7 +572,7 @@ public final class ExternalClientLoginRequestOuterClass { internal_static_Tango_PMR_Integration_ExternalClientLoginRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_Tango_PMR_Integration_ExternalClientLoginRequest_descriptor, - new java.lang.String[] { "Key", }); + new java.lang.String[] { "Password", }); } // @@protoc_insertion_point(outer_class_scope) diff --git a/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/OverrideDataBaseRequestOuterClass.java b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/OverrideDataBaseRequestOuterClass.java new file mode 100644 index 000000000..b02fae384 --- /dev/null +++ b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/OverrideDataBaseRequestOuterClass.java @@ -0,0 +1,508 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: OverrideDataBaseRequest.proto + +package com.twine.tango.pmr.integration; + +public final class OverrideDataBaseRequestOuterClass { + private OverrideDataBaseRequestOuterClass() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface OverrideDataBaseRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:Tango.PMR.Integration.OverrideDataBaseRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes RemoteDB = 1; + */ + com.google.protobuf.ByteString getRemoteDB(); + } + /** + * Protobuf type {@code Tango.PMR.Integration.OverrideDataBaseRequest} + */ + public static final class OverrideDataBaseRequest extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:Tango.PMR.Integration.OverrideDataBaseRequest) + OverrideDataBaseRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use OverrideDataBaseRequest.newBuilder() to construct. + private OverrideDataBaseRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private OverrideDataBaseRequest() { + remoteDB_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private OverrideDataBaseRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + remoteDB_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.internal_static_Tango_PMR_Integration_OverrideDataBaseRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.internal_static_Tango_PMR_Integration_OverrideDataBaseRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest.class, com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest.Builder.class); + } + + public static final int REMOTEDB_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString remoteDB_; + /** + * bytes RemoteDB = 1; + */ + public com.google.protobuf.ByteString getRemoteDB() { + return remoteDB_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!remoteDB_.isEmpty()) { + output.writeBytes(1, remoteDB_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!remoteDB_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, remoteDB_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest)) { + return super.equals(obj); + } + com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest other = (com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest) obj; + + boolean result = true; + result = result && getRemoteDB() + .equals(other.getRemoteDB()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + REMOTEDB_FIELD_NUMBER; + hash = (53 * hash) + getRemoteDB().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code Tango.PMR.Integration.OverrideDataBaseRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:Tango.PMR.Integration.OverrideDataBaseRequest) + com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.internal_static_Tango_PMR_Integration_OverrideDataBaseRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.internal_static_Tango_PMR_Integration_OverrideDataBaseRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest.class, com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest.Builder.class); + } + + // Construct using com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + remoteDB_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.internal_static_Tango_PMR_Integration_OverrideDataBaseRequest_descriptor; + } + + public com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest getDefaultInstanceForType() { + return com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest.getDefaultInstance(); + } + + public com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest build() { + com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest buildPartial() { + com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest result = new com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest(this); + result.remoteDB_ = remoteDB_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest) { + return mergeFrom((com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest other) { + if (other == com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest.getDefaultInstance()) return this; + if (other.getRemoteDB() != com.google.protobuf.ByteString.EMPTY) { + setRemoteDB(other.getRemoteDB()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString remoteDB_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes RemoteDB = 1; + */ + public com.google.protobuf.ByteString getRemoteDB() { + return remoteDB_; + } + /** + * bytes RemoteDB = 1; + */ + public Builder setRemoteDB(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + remoteDB_ = value; + onChanged(); + return this; + } + /** + * bytes RemoteDB = 1; + */ + public Builder clearRemoteDB() { + + remoteDB_ = getDefaultInstance().getRemoteDB(); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:Tango.PMR.Integration.OverrideDataBaseRequest) + } + + // @@protoc_insertion_point(class_scope:Tango.PMR.Integration.OverrideDataBaseRequest) + private static final com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest(); + } + + public static com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public OverrideDataBaseRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new OverrideDataBaseRequest(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.twine.tango.pmr.integration.OverrideDataBaseRequestOuterClass.OverrideDataBaseRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_Tango_PMR_Integration_OverrideDataBaseRequest_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_Tango_PMR_Integration_OverrideDataBaseRequest_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\035OverrideDataBaseRequest.proto\022\025Tango.P" + + "MR.Integration\"+\n\027OverrideDataBaseReques" + + "t\022\020\n\010RemoteDB\030\001 \001(\014B!\n\037com.twine.tango.p" + + "mr.integrationb\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_Tango_PMR_Integration_OverrideDataBaseRequest_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_Tango_PMR_Integration_OverrideDataBaseRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_Tango_PMR_Integration_OverrideDataBaseRequest_descriptor, + new java.lang.String[] { "RemoteDB", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/OverrideDataBaseResponseOuterClass.java b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/OverrideDataBaseResponseOuterClass.java new file mode 100644 index 000000000..562f4259c --- /dev/null +++ b/Software/Android_Studio/Tango.PMR/src/main/java/com/twine/tango/pmr/integration/OverrideDataBaseResponseOuterClass.java @@ -0,0 +1,506 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: OverrideDataBaseResponse.proto + +package com.twine.tango.pmr.integration; + +public final class OverrideDataBaseResponseOuterClass { + private OverrideDataBaseResponseOuterClass() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface OverrideDataBaseResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:Tango.PMR.Integration.OverrideDataBaseResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * bool Successful = 1; + */ + boolean getSuccessful(); + } + /** + * Protobuf type {@code Tango.PMR.Integration.OverrideDataBaseResponse} + */ + public static final class OverrideDataBaseResponse extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:Tango.PMR.Integration.OverrideDataBaseResponse) + OverrideDataBaseResponseOrBuilder { + private static final long serialVersionUID = 0L; + // Use OverrideDataBaseResponse.newBuilder() to construct. + private OverrideDataBaseResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private OverrideDataBaseResponse() { + successful_ = false; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private OverrideDataBaseResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + successful_ = input.readBool(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.internal_static_Tango_PMR_Integration_OverrideDataBaseResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.internal_static_Tango_PMR_Integration_OverrideDataBaseResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse.class, com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse.Builder.class); + } + + public static final int SUCCESSFUL_FIELD_NUMBER = 1; + private boolean successful_; + /** + * bool Successful = 1; + */ + public boolean getSuccessful() { + return successful_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (successful_ != false) { + output.writeBool(1, successful_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (successful_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(1, successful_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse)) { + return super.equals(obj); + } + com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse other = (com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse) obj; + + boolean result = true; + result = result && (getSuccessful() + == other.getSuccessful()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SUCCESSFUL_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getSuccessful()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code Tango.PMR.Integration.OverrideDataBaseResponse} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:Tango.PMR.Integration.OverrideDataBaseResponse) + com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.internal_static_Tango_PMR_Integration_OverrideDataBaseResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.internal_static_Tango_PMR_Integration_OverrideDataBaseResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse.class, com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse.Builder.class); + } + + // Construct using com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + successful_ = false; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.internal_static_Tango_PMR_Integration_OverrideDataBaseResponse_descriptor; + } + + public com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse getDefaultInstanceForType() { + return com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse.getDefaultInstance(); + } + + public com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse build() { + com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse buildPartial() { + com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse result = new com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse(this); + result.successful_ = successful_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse) { + return mergeFrom((com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse other) { + if (other == com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse.getDefaultInstance()) return this; + if (other.getSuccessful() != false) { + setSuccessful(other.getSuccessful()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private boolean successful_ ; + /** + * bool Successful = 1; + */ + public boolean getSuccessful() { + return successful_; + } + /** + * bool Successful = 1; + */ + public Builder setSuccessful(boolean value) { + + successful_ = value; + onChanged(); + return this; + } + /** + * bool Successful = 1; + */ + public Builder clearSuccessful() { + + successful_ = false; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:Tango.PMR.Integration.OverrideDataBaseResponse) + } + + // @@protoc_insertion_point(class_scope:Tango.PMR.Integration.OverrideDataBaseResponse) + private static final com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse(); + } + + public static com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public OverrideDataBaseResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new OverrideDataBaseResponse(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.twine.tango.pmr.integration.OverrideDataBaseResponseOuterClass.OverrideDataBaseResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_Tango_PMR_Integration_OverrideDataBaseResponse_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_Tango_PMR_Integration_OverrideDataBaseResponse_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\036OverrideDataBaseResponse.proto\022\025Tango." + + "PMR.Integration\".\n\030OverrideDataBaseRespo" + + "nse\022\022\n\nSuccessful\030\001 \001(\010B!\n\037com.twine.tan" + + "go.pmr.integrationb\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_Tango_PMR_Integration_OverrideDataBaseResponse_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_Tango_PMR_Integration_OverrideDataBaseResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_Tango_PMR_Integration_OverrideDataBaseResponse_descriptor, + new java.lang.String[] { "Successful", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ITransportAdapter.java b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ITransportAdapter.java index abd12e0f0..2e076b1c8 100644 --- a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ITransportAdapter.java +++ b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ITransportAdapter.java @@ -40,6 +40,20 @@ public interface ITransportAdapter extends ITransportComponent { */ void setAddress(String address); + /** + * Sets the adapter mode. + * + * @param mode the mode + */ + void setAdapterMode(TransportAdapterMode mode); + + /** + * Gets the adapter mode. + * + * @return the adapter mode + */ + TransportAdapterMode getAdapterMode(); + /** * Gets whether this adapter is authenticated. diff --git a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ITransporter.java b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ITransporter.java index 9d2bce329..1ad704829 100644 --- a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ITransporter.java +++ b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ITransporter.java @@ -8,6 +8,7 @@ import com.twine.tango.pmr.common.MessageContainerOuterClass.MessageContainer; import org.joda.time.Period; +import io.reactivex.Completable; import io.reactivex.Observable; import io.reactivex.Single; @@ -73,7 +74,7 @@ public interface ITransporter extends ITransportComponent { * @param response the response * @return the single */ - Single sendResponse(TangoMessage response); + Completable sendResponse(TangoMessage response); /** * Sends a response with the specified request token. @@ -83,7 +84,7 @@ public interface ITransporter extends ITransportComponent { * @param token the token * @return the single */ - Single sendResponse(TangoMessage response,String token); + Completable sendResponse(TangoMessage response,String token); /** * Sets request received listener. diff --git a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ResponseErrorException.java b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ResponseErrorException.java new file mode 100644 index 000000000..896e92b38 --- /dev/null +++ b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/ResponseErrorException.java @@ -0,0 +1,57 @@ +package com.twine.tango.transport; + +import com.twine.tango.pmr.TangoMessage; +import com.twine.tango.pmr.common.ErrorCodeOuterClass.ErrorCode; + + +/** + * Represents a tango message response exception which indicates a response container with {@link ErrorCode} different from None. + */ +public class ResponseErrorException extends Exception +{ + private ErrorCode error; + + private TangoMessage response; + + public TangoMessage getResponse() + { + return response; + } + + public void setResponse(TangoMessage response) + { + this.response = response; + } + + /** + * Gets the error. + * + * @return the error + */ + public ErrorCode getError() + { + return error; + } + + /** + * Sets the error. + * + * @param error the error + */ + public void setError(ErrorCode error) + { + this.error = error; + } + + /** + * Instantiates a new Response error exception. + * + * @param error the error + */ + public ResponseErrorException(ErrorCode error,TangoMessage response) + { + super("Response received with error " + error.toString()); + setError(error); + setResponse(response); + } +} diff --git a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransportAdapterBase.java b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransportAdapterBase.java index b9221ea27..6d5667ada 100644 --- a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransportAdapterBase.java +++ b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransportAdapterBase.java @@ -6,6 +6,9 @@ import com.twine.tango.core.IEventHandler; import com.twine.tango.core.ObjectDisposedException; import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Arrays; import io.reactivex.Completable; @@ -15,18 +18,20 @@ import io.reactivex.Completable; */ public abstract class TransportAdapterBase implements ITransportAdapter { - + protected static final int MAX_BUFFER_SIZE = 1024 * 1024 * 10; //10 MB. private boolean isAuthenticated; private String address; private Event stateChangedEvent; private IEventHandler dataAvailableListener; private TransportComponentState state; + private TransportAdapterMode adapterMode; /** * Instantiates a new Transport adapter base. */ public TransportAdapterBase() { + setAdapterMode(TransportAdapterMode.NO_HEADER); stateChangedEvent = new Event<>(); setAuthenticated(true); } @@ -55,6 +60,18 @@ public abstract class TransportAdapterBase implements ITransportAdapter this.address = address; } + @Override + public void setAdapterMode(TransportAdapterMode mode) + { + adapterMode = mode; + } + + @Override + public TransportAdapterMode getAdapterMode() + { + return adapterMode; + } + @Override public boolean isAuthenticated() { @@ -155,4 +172,36 @@ public abstract class TransportAdapterBase implements ITransportAdapter setState(TransportComponentState.Failed); XLog.e(ex); } + + /** + * Applies any additional headers if required. + * + * @param data the data + * @return the byte [ ] + */ + protected byte[] postProcessBuffer(byte[] data) + { + if (adapterMode == TransportAdapterMode.NO_HEADER) + { + return data; + } else + { + byte[] size = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(data.length).array(); + return concatByteArrays(size, data); + } + } + + /** + * Concat byte arrays byte [ ]. + * + * @param first the first + * @param second the second + * @return the byte [ ] + */ + protected byte[] concatByteArrays(byte[] first, byte[] second) + { + byte[] result = Arrays.copyOf(first, first.length + second.length); + System.arraycopy(second, 0, result, first.length, second.length); + return result; + } } diff --git a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransportAdapterMode.java b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransportAdapterMode.java new file mode 100644 index 000000000..699be758d --- /dev/null +++ b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransportAdapterMode.java @@ -0,0 +1,17 @@ +package com.twine.tango.transport; + + +/** + * Represents an {@link com.twine.tango.transport.ITransportAdapter} read/write mode. + */ +public enum TransportAdapterMode +{ + /** + * Pure protobuf message with no message size. + */ + NO_HEADER, + /** + * Prepends and truncates the message size before writing and reading. + */ + PREPEND_HEADER +} diff --git a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransporterBase.java b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransporterBase.java index 3c09d547f..ff192bc3b 100644 --- a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransporterBase.java +++ b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/TransporterBase.java @@ -16,7 +16,6 @@ import com.twine.tango.pmr.MessageFactory; import com.twine.tango.pmr.TangoMessage; import com.twine.tango.pmr.common.ErrorCodeOuterClass.ErrorCode; import com.twine.tango.pmr.common.MessageContainerOuterClass.MessageContainer; -import com.twine.tango.transport.transporters.ResponseErrorException; import org.joda.time.Period; @@ -414,13 +413,13 @@ public abstract class TransporterBase implements ITransporter } @Override - public Single sendResponse(TangoMessage response) + public Completable sendResponse(TangoMessage response) { return sendResponse(response, response.getContainer().getToken()); } @Override - public Single sendResponse(TangoMessage response, String token) + public Completable sendResponse(TangoMessage response, String token) { response.getContainer().setToken(token); @@ -459,7 +458,7 @@ public abstract class TransporterBase implements ITransporter TransportMessage message = new TransportMessage<>(adapter, token, response, TransportMessageDirection.Response, onSerializingMessage(response), subject); sendingQueue.add(message); - return subject.singleOrError(); + return subject.singleOrError().toCompletable(); } //endregion @@ -537,7 +536,7 @@ public abstract class TransporterBase implements ITransporter pendingRequests.add(message); } else { - message.setResult(true, true); + message.setResult(new Object(), true); } } catch (Exception ex) { @@ -613,8 +612,7 @@ public abstract class TransporterBase implements ITransporter } else { XLog.i("Parsing inner response message and setting pending request task result..."); - request.setException(new ResponseErrorException(container.getError())); - + request.setException(new ResponseErrorException(container.getError(), onParseTangoMessage(data.second))); } } catch (Exception ex) { @@ -638,7 +636,7 @@ public abstract class TransporterBase implements ITransporter } else { XLog.i("Response has returned with error: " + container.getError().toString()); - request.setException(new ResponseErrorException(container.getError())); + request.setException(new ResponseErrorException(container.getError(), onParseTangoMessage(data.second))); } } catch (Exception ex) { diff --git a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/adapters/TcpTransportAdapter.java b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/adapters/TcpTransportAdapter.java index b72d1669b..f2e7a83a8 100644 --- a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/adapters/TcpTransportAdapter.java +++ b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/adapters/TcpTransportAdapter.java @@ -5,6 +5,7 @@ import android.os.SystemClock; import com.elvishew.xlog.XLog; import com.twine.tango.core.ObjectDisposedException; import com.twine.tango.transport.TransportAdapterBase; +import com.twine.tango.transport.TransportAdapterMode; import com.twine.tango.transport.TransportComponentState; import java.io.IOException; @@ -12,6 +13,8 @@ import java.io.InputStream; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.nio.channels.Selector; import io.reactivex.Completable; @@ -36,6 +39,7 @@ public class TcpTransportAdapter extends TransportAdapterBase super(); setAddress("127.0.0.1"); setPort(9999); + setAdapterMode(TransportAdapterMode.PREPEND_HEADER); } public TcpTransportAdapter(String address, int port) @@ -144,7 +148,7 @@ public class TcpTransportAdapter extends TransportAdapterBase try { - socket.getOutputStream().write(data); + socket.getOutputStream().write(postProcessBuffer(data)); } catch (IOException e) { onFailed(e); @@ -167,39 +171,59 @@ public class TcpTransportAdapter extends TransportAdapterBase { InputStream stream = socket.getInputStream(); - if (stream.available() > 0) + if (getAdapterMode() == TransportAdapterMode.NO_HEADER) { - byte[] data = new byte[stream.available()]; - int read = stream.read(data); - - if (read == -1) + if (stream.available() > 0) { - throw new SocketException("Error reading from TCP adapter."); + byte[] data = new byte[stream.available()]; + int read = stream.read(data); + + if (read == -1) + { + throw new SocketException("Error reading from TCP adapter."); + } + + onDataAvailable(data); + } + } + else + { + if (stream.available() > 4) + { + byte[] size = new byte[4]; + + int read = stream.read(size, 0, size.length); + + if (read == -1) + { + throw new SocketException("Error reading from TCP adapter."); + } + + int expectedSize = ByteBuffer.wrap(size).order(ByteOrder.LITTLE_ENDIAN).getInt(); + + while (stream.available() < expectedSize) + { + SystemClock.sleep(10); + + if (getState() != TransportComponentState.Connected) + { + break; + } + } + + byte[] data = new byte[expectedSize]; + read = stream.read(data); + + if (read == -1) + { + throw new SocketException("Error reading from TCP adapter."); + } + + onDataAvailable(data); } - - onDataAvailable(data); } SystemClock.sleep(10); -// counter++; - -// if (counter > 200) -// { -// try -// { -// if (socket.getChannel().keyFor(selector).isWritable() && socket.getChannel().keyFor(selector).isReadable()) -// { -// onFailed(new SocketTimeoutException("Client disconnected.")); -// return; -// } -// } catch (Exception e) -// { -// onFailed(e); -// return; -// } -// -// counter = 0; -// } } } catch (Exception e) @@ -210,4 +234,20 @@ public class TcpTransportAdapter extends TransportAdapterBase } //endregion + + //region Private Methods + + private void setSocketProperties() + { + try + { + socket.setReceiveBufferSize(MAX_BUFFER_SIZE); + socket.setSendBufferSize(MAX_BUFFER_SIZE); + } catch (SocketException e) + { + e.printStackTrace(); + } + } + + //endregion } diff --git a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/adapters/UsbTransportAdapter.java b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/adapters/UsbTransportAdapter.java index 8ad55708c..60efe976a 100644 --- a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/adapters/UsbTransportAdapter.java +++ b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/adapters/UsbTransportAdapter.java @@ -15,9 +15,13 @@ import com.felhr.usbserial.UsbSerialInterface; import com.twine.tango.core.ContextHelper; import com.twine.tango.core.ObjectDisposedException; import com.twine.tango.transport.TransportAdapterBase; +import com.twine.tango.transport.TransportAdapterMode; import com.twine.tango.transport.TransportComponentState; import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Arrays; import java.util.Map; import io.reactivex.Completable; @@ -37,6 +41,8 @@ public class UsbTransportAdapter extends TransportAdapterBase private UsbManager usbManager; private boolean hasPermission; private PublishSubject connectionSubject; + private byte[] current_buffer; + private int current_buffer_bar; public UsbTransportAdapter() { @@ -51,7 +57,7 @@ public class UsbTransportAdapter extends TransportAdapterBase @Override public void write(byte[] data) throws ObjectDisposedException, IOException { - serial.write(data); + serial.write(postProcessBuffer(data)); } @Override @@ -126,7 +132,54 @@ public class UsbTransportAdapter extends TransportAdapterBase private void onUsbReceiveData(byte[] data) { - onDataAvailable(data); + if (getAdapterMode() == TransportAdapterMode.NO_HEADER) + { + onDataAvailable(data); + } else + { + if (current_buffer == null) + { + byte[] size = Arrays.copyOfRange(data, 0, 4); + int expectedSize = ByteBuffer.wrap(size).order(ByteOrder.LITTLE_ENDIAN).getInt(); + current_buffer = new byte[expectedSize]; + byte[] rest = Arrays.copyOfRange(data, 4, data.length); + if (rest.length == expectedSize) + { + current_buffer = null; + onDataAvailable(rest); + } else + { + current_buffer_bar = rest.length; + ByteBuffer.wrap(current_buffer).put(rest); + } + } else + { + int remaining = current_buffer.length - current_buffer_bar; + + if (data.length < remaining) + { + current_buffer_bar += data.length; + ByteBuffer.wrap(current_buffer).put(data); + } else if (data.length > remaining) + { + byte[] end = Arrays.copyOfRange(data, 0, remaining); + ByteBuffer.wrap(current_buffer).put(end); + onDataAvailable(current_buffer); + current_buffer = null; + current_buffer_bar = 0; + byte[] rest = Arrays.copyOfRange(data, remaining, data.length); + onUsbReceiveData(rest); + } + else //Equals + { + byte[] end = Arrays.copyOfRange(data, 0, remaining); + ByteBuffer.wrap(current_buffer).put(end); + onDataAvailable(current_buffer); + current_buffer = null; + current_buffer_bar = 0; + } + } + } } @Override diff --git a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/transporters/ResponseErrorException.java b/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/transporters/ResponseErrorException.java deleted file mode 100644 index 465412f68..000000000 --- a/Software/Android_Studio/Tango.Transport/src/main/java/com/twine/tango/transport/transporters/ResponseErrorException.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.twine.tango.transport.transporters; - -import com.twine.tango.pmr.common.ErrorCodeOuterClass.ErrorCode; - - -/** - * Represents a tango message response exception which indicates a response container with {@link ErrorCode} different from None. - */ -public class ResponseErrorException extends Exception -{ - private ErrorCode error; - - /** - * Gets the error. - * - * @return the error - */ - public ErrorCode getError() - { - return error; - } - - /** - * Sets the error. - * - * @param error the error - */ - public void setError(ErrorCode error) - { - this.error = error; - } - - /** - * Instantiates a new Response error exception. - * - * @param error the error - */ - public ResponseErrorException(ErrorCode error) - { - super("Response received with error " + error.toString()); - setError(error); - } -} diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index f3d6c1aa6..8c68d77f1 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 0a80c5341..d80e67e97 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Graphics/Machine Studio Modules/stubs.jpg b/Software/Graphics/Machine Studio Modules/stubs.jpg new file mode 100644 index 000000000..f9dd9b246 Binary files /dev/null and b/Software/Graphics/Machine Studio Modules/stubs.jpg differ diff --git a/Software/PMR/Messages/Common/MessageType.proto b/Software/PMR/Messages/Common/MessageType.proto index e77095809..aed740ad1 100644 --- a/Software/PMR/Messages/Common/MessageType.proto +++ b/Software/PMR/Messages/Common/MessageType.proto @@ -41,4 +41,8 @@ enum MessageType ExternalBridgeUdpDiscoveryPacket = 33; ExternalClientLoginRequest = 34; ExternalClientLoginResponse = 35; + DirectSynchronizationRequest = 36; + DirectSynchronizationResponse = 37; + OverrideDataBaseRequest = 38; + OverrideDataBaseResponse = 39; } diff --git a/Software/PMR/Messages/Integration/DirectSynchronizationRequest.proto b/Software/PMR/Messages/Integration/DirectSynchronizationRequest.proto new file mode 100644 index 000000000..9a50d2b27 --- /dev/null +++ b/Software/PMR/Messages/Integration/DirectSynchronizationRequest.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Integration; +option java_package = "com.twine.tango.pmr.integration"; + +message DirectSynchronizationRequest +{ + +} \ No newline at end of file diff --git a/Software/PMR/Messages/Integration/DirectSynchronizationResponse.proto b/Software/PMR/Messages/Integration/DirectSynchronizationResponse.proto new file mode 100644 index 000000000..19343b60f --- /dev/null +++ b/Software/PMR/Messages/Integration/DirectSynchronizationResponse.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Integration; +option java_package = "com.twine.tango.pmr.integration"; + +message DirectSynchronizationResponse +{ + bytes LocalDB = 1; +} \ No newline at end of file diff --git a/Software/PMR/Messages/Integration/ExternalClientLoginRequest.proto b/Software/PMR/Messages/Integration/ExternalClientLoginRequest.proto index 3c7d701b5..624532823 100644 --- a/Software/PMR/Messages/Integration/ExternalClientLoginRequest.proto +++ b/Software/PMR/Messages/Integration/ExternalClientLoginRequest.proto @@ -5,5 +5,5 @@ option java_package = "com.twine.tango.pmr.integration"; message ExternalClientLoginRequest { - string key = 1; + string Password = 1; } \ No newline at end of file diff --git a/Software/PMR/Messages/Integration/OverrideDataBaseRequest.proto b/Software/PMR/Messages/Integration/OverrideDataBaseRequest.proto new file mode 100644 index 000000000..9c46f4349 --- /dev/null +++ b/Software/PMR/Messages/Integration/OverrideDataBaseRequest.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Integration; +option java_package = "com.twine.tango.pmr.integration"; + +message OverrideDataBaseRequest +{ + bytes RemoteDB = 1; +} \ No newline at end of file diff --git a/Software/PMR/Messages/Integration/OverrideDataBaseResponse.proto b/Software/PMR/Messages/Integration/OverrideDataBaseResponse.proto new file mode 100644 index 000000000..715831419 --- /dev/null +++ b/Software/PMR/Messages/Integration/OverrideDataBaseResponse.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Integration; +option java_package = "com.twine.tango.pmr.integration"; + +message OverrideDataBaseResponse +{ + bool Successful = 1; +} \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/LiquidTypeRmlsToStringConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/LiquidTypeRmlsToStringConverter.cs new file mode 100644 index 000000000..0bbcd68a3 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/LiquidTypeRmlsToStringConverter.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.DAL.Observables; +using Tango.MachineStudio.DB.ViewModels; + +namespace Tango.MachineStudio.DB.Converters +{ + public class LiquidTypeRmlsToStringConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) return ""; + + if (value is IEnumerable) + { + IEnumerable liquidRmls = value as IEnumerable; + return String.Join(", ", liquidRmls.Where(x => !x.Deleted).Select(x => x.Rml.Name)); + } + else + { + IEnumerable> rmls = value as IEnumerable>; + return String.Join(", ", rmls.Where(x => x.IsSelected).Select(x => x.Entity.Name)); + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj index bd6166b4f..12af196bc 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj @@ -88,6 +88,7 @@ + @@ -101,6 +102,7 @@ + @@ -108,14 +110,22 @@ + + + + + + + + @@ -127,6 +137,60 @@ ActionTypeView.xaml + + RmlView.xaml + + + RmlsView.xaml + + + ContactView.xaml + + + ContactsView.xaml + + + MediaConditionsView.xaml + + + MediaConditionView.xaml + + + LinearMassDensityUnitsView.xaml + + + LinearMassDensityUnitView.xaml + + + FiberShapesView.xaml + + + FiberShapeView.xaml + + + FiberSynthsView.xaml + + + FiberSynthView.xaml + + + MediaPurposesView.xaml + + + MediaMaterialsView.xaml + + + MediaColorView.xaml + + + MediaPurposView.xaml + + + MediaMaterialView.xaml + + + MediaColorsView.xaml + IdsPacksView.xaml @@ -288,6 +352,78 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + MSBuild:Compile Designer diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs index 8bc6ff1c0..fa4139389 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs @@ -44,6 +44,17 @@ namespace Tango.MachineStudio.DB SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); + + SimpleIoc.Default.Register(); + + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); } public static MainViewVM MainViewVM @@ -237,5 +248,77 @@ namespace Tango.MachineStudio.DB return ServiceLocator.Current.GetInstance(); } } + + public static ContactsViewVM ContactsViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + + public static MediaMaterialsViewVM MediaMaterialsViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + + public static MediaColorsViewVM MediaColorsViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + + public static MediaPurposesViewVM MediaPurposesViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + + public static MediaConditionsViewVM MediaConditionsViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + + public static LinearMassDensityUnitsViewVM LinearMassDensityUnitsViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + + public static FiberShapesViewVM FiberShapesViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + + public static FiberSynthsViewVM FiberSynthsViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + + public static RmlsViewVM RmlsViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } } } \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ContactsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ContactsViewVM.cs new file mode 100644 index 000000000..6f44d51f0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ContactsViewVM.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; +using SimpleValidator.Extensions; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class ContactsViewVM : DbTableViewModel + { + public ContactsViewVM(INotificationProvider notification) : base(notification) + { + } + + protected override void OnValidating() + { + base.OnValidating(); + + if (!EditEntity.Email.IsEmail()) + { + ValidationErrors.Add("Email address is invalid"); + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/FiberShapesViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/FiberShapesViewVM.cs new file mode 100644 index 000000000..c4954f9b3 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/FiberShapesViewVM.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class FiberShapesViewVM : DbTableViewModel + { + public FiberShapesViewVM(INotificationProvider notification) : base(notification) + { + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/FiberSynthsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/FiberSynthsViewVM.cs new file mode 100644 index 000000000..6b157fc0d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/FiberSynthsViewVM.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class FiberSynthsViewVM : DbTableViewModel + { + public FiberSynthsViewVM(INotificationProvider notification) : base(notification) + { + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/LinearMassDensityUnitsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/LinearMassDensityUnitsViewVM.cs new file mode 100644 index 000000000..9ac38a7c4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/LinearMassDensityUnitsViewVM.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class LinearMassDensityUnitsViewVM : DbTableViewModel + { + public LinearMassDensityUnitsViewVM(INotificationProvider notification) : base(notification) + { + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/LiquidTypesViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/LiquidTypesViewVM.cs index 2ec2d59bb..eaa482a41 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/LiquidTypesViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/LiquidTypesViewVM.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -12,6 +13,64 @@ namespace Tango.MachineStudio.DB.ViewModels { public LiquidTypesViewVM(INotificationProvider notification) : base(notification) { + SelectedRmls = new ObservableCollection>(); + } + + private ObservableCollection> _selectedRmls; + public ObservableCollection> SelectedRmls + { + get { return _selectedRmls; } + set { _selectedRmls = value; RaisePropertyChangedAuto(); } + } + + protected override void OnEdit() + { + SelectedRmls = Adapter.Rmls.Select(x => new MultiComboVM(x, () => RaisePropertyChanged(nameof(SelectedRmls)))).ToObservableCollection(); + + foreach (var rml in SelectedRmls) + { + if (SelectedEntity.LiquidTypesRmls.ToList().Exists(x => x.Rml == rml.Entity && !x.Deleted)) + { + rml.IsSelected = true; + } + } + + base.OnEdit(); + } + + protected override void OnAdd() + { + SelectedRmls = Adapter.Rmls.Select(x => new MultiComboVM(x, () => RaisePropertyChanged(nameof(SelectedRmls)))).ToObservableCollection(); + + base.OnAdd(); + } + + protected override void OnBeforeEntitySave(DialogOpenMode mode, LiquidType liquid) + { + base.OnBeforeEntitySave(mode, liquid); + + foreach (var rml in SelectedRmls) + { + var liquidRml = liquid.LiquidTypesRmls.SingleOrDefault(x => x.Rml == rml.Entity); + + if (liquidRml != null) + { + liquidRml.Deleted = !rml.IsSelected; + } + else + { + if (rml.IsSelected) + { + liquid.LiquidTypesRmls.Add(new LiquidTypesRml() + { + Rml = rml.Entity, + LiquidTypes = liquid, + RmlGuid = rml.Entity.Guid, + LiquidTypeGuid = liquid.Guid + }); + } + } + } } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MediaColorsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MediaColorsViewVM.cs new file mode 100644 index 000000000..4227cc27a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MediaColorsViewVM.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class MediaColorsViewVM : DbTableViewModel + { + public MediaColorsViewVM(INotificationProvider notification) : base(notification) + { + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MediaConditionsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MediaConditionsViewVM.cs new file mode 100644 index 000000000..451e20ff0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MediaConditionsViewVM.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class MediaConditionsViewVM : DbTableViewModel + { + public MediaConditionsViewVM(INotificationProvider notification) : base(notification) + { + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MediaMaterialsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MediaMaterialsViewVM.cs new file mode 100644 index 000000000..534ebc0d8 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MediaMaterialsViewVM.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class MediaMaterialsViewVM : DbTableViewModel + { + public MediaMaterialsViewVM(INotificationProvider notification) : base(notification) + { + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MediaPurposesViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MediaPurposesViewVM.cs new file mode 100644 index 000000000..4850f6316 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MediaPurposesViewVM.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class MediaPurposesViewVM : DbTableViewModel + { + public MediaPurposesViewVM(INotificationProvider notification) : base(notification) + { + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/RmlsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/RmlsViewVM.cs new file mode 100644 index 000000000..740a4969b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/RmlsViewVM.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class RmlsViewVM : DbTableViewModel + { + public RmlsViewVM(INotificationProvider notification) : base(notification) + { + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/UsersViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/UsersViewVM.cs index 6af1184aa..044b8a88a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/UsersViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/UsersViewVM.cs @@ -80,12 +80,17 @@ namespace Tango.MachineStudio.DB.ViewModels if (EditEntity.Email != null) { - if (Adapter.Users.ToList().Exists(x => x.Email.ToLower() == EditEntity.Email.ToLower())) + if (Adapter.Users.ToList().Exists(x => x != EditEntity && x.Email.ToLower() == EditEntity.Email.ToLower())) { ValidationErrors.Add("Email already exist"); } } + if (!EditEntity.Email.IsEmail()) + { + ValidationErrors.Add("Email address is invalid"); + } + if (!EditEntity.Password.IsMinLength(4)) { ValidationErrors.Add("Password must have at least 4 characters"); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ContactView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ContactView.xaml new file mode 100644 index 000000000..999ad9e71 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ContactView.xaml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ContactView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ContactView.xaml.cs new file mode 100644 index 000000000..88397c92a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ContactView.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.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for AddressView.xaml + /// + public partial class ContactView : UserControl + { + public ContactView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ContactsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ContactsView.xaml new file mode 100644 index 000000000..e05808d83 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ContactsView.xaml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ContactsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ContactsView.xaml.cs new file mode 100644 index 000000000..a8c6eb814 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ContactsView.xaml.cs @@ -0,0 +1,31 @@ +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; +using Tango.MachineStudio.DB.CustomAttributes; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachinesView.xaml + /// + [DBView] + public partial class ContactsView : UserControl + { + public ContactsView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberShapeView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberShapeView.xaml new file mode 100644 index 000000000..dfca47372 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberShapeView.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberShapeView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberShapeView.xaml.cs new file mode 100644 index 000000000..477a2445d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberShapeView.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.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachineView.xaml + /// + public partial class FiberShapeView : UserControl + { + public FiberShapeView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberShapesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberShapesView.xaml new file mode 100644 index 000000000..f46b5894e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberShapesView.xaml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberShapesView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberShapesView.xaml.cs new file mode 100644 index 000000000..66190eee9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberShapesView.xaml.cs @@ -0,0 +1,32 @@ +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; +using Tango.MachineStudio.DB.CustomAttributes; +using Tango.MachineStudio.DB.Managers; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachinesView.xaml + /// + [DBView] + public partial class FiberShapesView : UserControl + { + public FiberShapesView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberSynthView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberSynthView.xaml new file mode 100644 index 000000000..b200f9efc --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberSynthView.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberSynthView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberSynthView.xaml.cs new file mode 100644 index 000000000..55ac39620 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberSynthView.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.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachineView.xaml + /// + public partial class FiberSynthView : UserControl + { + public FiberSynthView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberSynthsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberSynthsView.xaml new file mode 100644 index 000000000..bec19add1 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberSynthsView.xaml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberSynthsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberSynthsView.xaml.cs new file mode 100644 index 000000000..d6e652cf9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/FiberSynthsView.xaml.cs @@ -0,0 +1,32 @@ +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; +using Tango.MachineStudio.DB.CustomAttributes; +using Tango.MachineStudio.DB.Managers; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachinesView.xaml + /// + [DBView] + public partial class FiberSynthsView : UserControl + { + public FiberSynthsView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LinearMassDensityUnitView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LinearMassDensityUnitView.xaml new file mode 100644 index 000000000..e845249b4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LinearMassDensityUnitView.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LinearMassDensityUnitView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LinearMassDensityUnitView.xaml.cs new file mode 100644 index 000000000..bf37d1a5b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LinearMassDensityUnitView.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.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachineView.xaml + /// + public partial class LinearMassDensityUnitView : UserControl + { + public LinearMassDensityUnitView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LinearMassDensityUnitsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LinearMassDensityUnitsView.xaml new file mode 100644 index 000000000..41d719dad --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LinearMassDensityUnitsView.xaml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LinearMassDensityUnitsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LinearMassDensityUnitsView.xaml.cs new file mode 100644 index 000000000..f419bc926 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LinearMassDensityUnitsView.xaml.cs @@ -0,0 +1,32 @@ +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; +using Tango.MachineStudio.DB.CustomAttributes; +using Tango.MachineStudio.DB.Managers; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachinesView.xaml + /// + [DBView] + public partial class LinearMassDensityUnitsView : UserControl + { + public LinearMassDensityUnitsView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LiquidTypeView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LiquidTypeView.xaml index 3a14b27df..3f934de0a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LiquidTypeView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/LiquidTypeView.xaml @@ -6,7 +6,9 @@ xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:controls="clr-namespace:Tango.MachineStudio.DB.Controls" xmlns:colorPicker="clr-namespace:Tango;assembly=Tango.ColorPicker" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:localConverters="clr-namespace:Tango.MachineStudio.DB.Converters" xmlns:vm="clr-namespace:Tango.MachineStudio.DB.ViewModels" xmlns:local="clr-namespace:Tango.MachineStudio.DB.Views.DBViews" mc:Ignorable="d" @@ -14,7 +16,8 @@ - + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaColorView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaColorView.xaml.cs new file mode 100644 index 000000000..de09b9aaf --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaColorView.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.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachineView.xaml + /// + public partial class MediaColorView : UserControl + { + public MediaColorView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaColorsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaColorsView.xaml new file mode 100644 index 000000000..644c865da --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaColorsView.xaml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaColorsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaColorsView.xaml.cs new file mode 100644 index 000000000..ceae18ec8 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaColorsView.xaml.cs @@ -0,0 +1,32 @@ +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; +using Tango.MachineStudio.DB.CustomAttributes; +using Tango.MachineStudio.DB.Managers; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachinesView.xaml + /// + [DBView] + public partial class MediaColorsView : UserControl + { + public MediaColorsView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaConditionView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaConditionView.xaml new file mode 100644 index 000000000..cbee759b1 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaConditionView.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaConditionView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaConditionView.xaml.cs new file mode 100644 index 000000000..64238c2fc --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaConditionView.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.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachineView.xaml + /// + public partial class MediaConditionView : UserControl + { + public MediaConditionView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaConditionsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaConditionsView.xaml new file mode 100644 index 000000000..08f144710 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaConditionsView.xaml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaConditionsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaConditionsView.xaml.cs new file mode 100644 index 000000000..74ab29af0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaConditionsView.xaml.cs @@ -0,0 +1,32 @@ +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; +using Tango.MachineStudio.DB.CustomAttributes; +using Tango.MachineStudio.DB.Managers; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachinesView.xaml + /// + [DBView] + public partial class MediaConditionsView : UserControl + { + public MediaConditionsView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaMaterialView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaMaterialView.xaml new file mode 100644 index 000000000..b7e0a88fe --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaMaterialView.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaMaterialView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaMaterialView.xaml.cs new file mode 100644 index 000000000..4ddcca14e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaMaterialView.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.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachineView.xaml + /// + public partial class MediaMaterialView : UserControl + { + public MediaMaterialView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaMaterialsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaMaterialsView.xaml new file mode 100644 index 000000000..7530cf9df --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaMaterialsView.xaml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaMaterialsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaMaterialsView.xaml.cs new file mode 100644 index 000000000..26fbfb73a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaMaterialsView.xaml.cs @@ -0,0 +1,32 @@ +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; +using Tango.MachineStudio.DB.CustomAttributes; +using Tango.MachineStudio.DB.Managers; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachinesView.xaml + /// + [DBView] + public partial class MediaMaterialsView : UserControl + { + public MediaMaterialsView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaPurposView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaPurposView.xaml new file mode 100644 index 000000000..9b352cc59 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaPurposView.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaPurposView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaPurposView.xaml.cs new file mode 100644 index 000000000..08bc7f6a6 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaPurposView.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.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachineView.xaml + /// + public partial class MediaPurposView : UserControl + { + public MediaPurposView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaPurposesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaPurposesView.xaml new file mode 100644 index 000000000..ee4903f69 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaPurposesView.xaml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaPurposesView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaPurposesView.xaml.cs new file mode 100644 index 000000000..f780e5009 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MediaPurposesView.xaml.cs @@ -0,0 +1,32 @@ +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; +using Tango.MachineStudio.DB.CustomAttributes; +using Tango.MachineStudio.DB.Managers; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachinesView.xaml + /// + [DBView] + public partial class MediaPurposesView : UserControl + { + public MediaPurposesView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlView.xaml new file mode 100644 index 000000000..adf5310ee --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlView.xaml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlView.xaml.cs new file mode 100644 index 000000000..124f007ae --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlView.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.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachineView.xaml + /// + public partial class RmlView : UserControl + { + public RmlView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsView.xaml new file mode 100644 index 000000000..0a02c6821 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsView.xaml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsView.xaml.cs new file mode 100644 index 000000000..2909bdb6f --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/RmlsView.xaml.cs @@ -0,0 +1,31 @@ +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; +using Tango.MachineStudio.DB.CustomAttributes; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachinesView.xaml + /// + [DBView] + public partial class RmlsView : UserControl + { + public RmlsView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Images/stubs.jpg b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Images/stubs.jpg new file mode 100644 index 000000000..f9dd9b246 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Images/stubs.jpg differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..45c89075b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/AssemblyInfo.cs @@ -0,0 +1,18 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +[assembly: AssemblyTitle("Tango - Machine Studio Stubs Module")] + +[assembly: ComVisible(false)] + +[assembly:ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/Resources.Designer.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/Resources.Designer.cs new file mode 100644 index 000000000..e712344b4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/Resources.Designer.cs @@ -0,0 +1,92 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.MachineStudio.Stubs.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.MachineStudio.Stubs.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to using System; + ///using System.Text; + ///using System.Linq; + ///using System.Drawing; + ///using System.Diagnostics; + ///using System.Windows.Forms; + ///using System.Threading; + ///using System.Threading.Tasks; + ///using System.Collections.Generic; + ///using Tango.Stubs.UI; + /// + ///public void OnExecute(StubManager stubManager) + ///{ + /// for (int i = 0; i < 10; i++) + /// { + /// stubManager.Run("calculate", 10, 5); + /// Thread.Sleep(10); + /// } + ///} + /// + ///. + /// + internal static string CodeTabTemplate { + get { + return ResourceManager.GetString("CodeTabTemplate", resourceCulture); + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/Resources.resx b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/Resources.resx new file mode 100644 index 000000000..7693cadac --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/Resources.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\CodeTabTemplate.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/Settings.Designer.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/Settings.Designer.cs new file mode 100644 index 000000000..465246f32 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.MachineStudio.Stubs.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/Settings.settings b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Resources/CodeTabTemplate.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Resources/CodeTabTemplate.cs new file mode 100644 index 000000000..b21e6e758 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Resources/CodeTabTemplate.cs @@ -0,0 +1,20 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.MachineStudio.Stubs; + +public void OnExecute(StubManager stubManager) +{ + for (int i = 0; i < 10; i++) + { + stubManager.Run("calculate", 10, 5); + Thread.Sleep(10); + } +} + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubManager.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubManager.cs new file mode 100644 index 000000000..8e0eafa3a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubManager.cs @@ -0,0 +1,181 @@ +using Google.Protobuf; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Tango.PMR; +using Tango.PMR.Common; +using Tango.Stubs; +using Tango.Transport; +using Tango.Transport.Adapters; + +namespace Tango.MachineStudio.Stubs +{ + /// + /// Represents a manager capable of executing stub scripts asynchronously. + /// + public class StubManager + { + private ITransportAdapter _adapter; //Holds the USB transport adapter. + + /// + /// Occurs when the stub has failed to execute. + /// + public event EventHandler Failed; + + /// + /// Occurs when the stub has completed successfully. + /// + public event EventHandler Completed; + + /// + /// Occurs when the stub has been initialized and executed. + /// + public event EventHandler Executed; + + /// + /// Gets a value indicating whether this is aborted. + /// + internal bool Aborted { get; private set; } + + /// + /// Initializes a new instance of the class. + /// + /// The adapter. + public StubManager(ITransportAdapter adapter) + { + _adapter = adapter; + } + + /// + /// Aborts the current script. + /// + internal void Abort() + { + Aborted = true; + } + + /// + /// Runs the specified stub name. + /// + /// Name of the stub. + /// The arguments. + public void Run(String stubName, params Object[] args) + { + if (Aborted) return; + + var stubType = StubBase.GetAvailableRequestStubs().SingleOrDefault(x => x.Name.ToLower() == stubName.ToLower() || x.Name.Replace("Request", "").ToLower() == stubName.ToLower()); + if (stubType == null) + { + OnFailed(new ArgumentException("Invalid stub '" + stubName + "'.")); + return; + } + + var stubProps = stubType.GetProperties(BindingFlags.Public | BindingFlags.Instance); + + if (stubProps.Length > args.Length) + { + OnFailed(new ArgumentOutOfRangeException("Not enough arguments for " + stubType.Name + ".")); + return; + } + + Executed?.Invoke(this, stubType.Name); + + try + { + MessageContainer container = new MessageContainer(); + container.Token = Guid.NewGuid().ToString(); + container.Type = MessageFactory.ParseMessageType(stubType.Name); + + Object request = Activator.CreateInstance(stubType); + + int argIndex = 0; + foreach (var prop in stubProps) + { + String arg = args[argIndex++].ToString(); + + if (prop.PropertyType == typeof(UInt32)) + { + prop.SetValue(request, UInt32.Parse(arg)); + } + else if (prop.PropertyType == typeof(bool)) + { + prop.SetValue(request, bool.Parse(arg)); + } + else + { + object converted = Convert.ChangeType(arg, prop.PropertyType); + prop.SetValue(request, converted); + } + } + + container.Data = typeof(IMessage).GetExtensionMethod(typeof(ByteString).Assembly, "ToByteString").Invoke(request, new object[] { request }) as ByteString; + + byte[] requestData = container.ToByteArray(); + + bool done = false; + + Task.Factory.StartNew(() => + { + _adapter.Write(requestData); + + DateTime startTime = DateTime.Now; + + MessageContainer responseContainer = null; + + _adapter.DataAvailable += (sender, data) => + { + responseContainer = MessageFactory.ParseContainer(data); + }; + + while (responseContainer == null) + { + Thread.Sleep(2); + + if (DateTime.Now > startTime.AddSeconds(2)) + { + done = true; + OnFailed(new TimeoutException("Response has failed to arrive after 2 seconds.")); + return; + } + } + + IMessage message = MessageFactory.ParseMessageFromContainer(responseContainer); + OnCompleted(JsonConvert.SerializeObject(message, Formatting.Indented)); + done = true; + }); + + while (!done) + { + Thread.Sleep(2); + } + } + catch (Exception ex) + { + OnFailed(ex); + } + } + + /// + /// Raises the event. + /// + /// The exception. + protected virtual void OnFailed(Exception ex) + { + Failed?.Invoke(this, ex); + } + + /// + /// Raises the event. + /// + /// The response. + protected virtual void OnCompleted(String response) + { + Completed?.Invoke(this, response); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubOnExecuteParameters.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubOnExecuteParameters.cs new file mode 100644 index 000000000..761375818 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubOnExecuteParameters.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Scripting; + +namespace Tango.MachineStudio.Stubs +{ + /// + /// Represents the global object which will be sent to the scripting engine. + /// + /// + public class StubOnExecuteParameters : OnExecuteParameters + { + /// + /// Provides access to the script stub manager. + /// + public StubManager stubManager; + + /// + /// Initializes a new instance of the class. + /// + /// The manager. + public StubOnExecuteParameters(StubManager manager) + { + stubManager = manager; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs new file mode 100644 index 000000000..2c4b6c76e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Media.Imaging; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common; +using Tango.MachineStudio.Stubs.Views; +using Tango.SharedUI.Helpers; + +namespace Tango.MachineStudio.Stubs +{ + public class StubsModule : IStudioModule + { + public string Name => "Stubs"; + + public string Description => "Execute machine tests using an interactive C# scripting editor"; + + public BitmapSource Image => ResourceHelper.GetImageFromResources("Images/stubs.jpg"); + + public FrameworkElement MainView => new MainView(); + + public Permissions Permission => Permissions.RunSynchronizationModule; + + public bool IsInitialized => true; + + public void Dispose() + { + //throw new NotImplementedException(); + } + + public void Initialize() + { + //throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Tango.MachineStudio.Stubs.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Tango.MachineStudio.Stubs.csproj new file mode 100644 index 000000000..436a8b3ff --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Tango.MachineStudio.Stubs.csproj @@ -0,0 +1,183 @@ + + + + + Debug + AnyCPU + {22C2AA72-9493-4D0D-B421-8EF9789FB192} + library + Tango.MachineStudio.Stubs + Tango.MachineStudio.Stubs + v4.6 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + true + full + false + ..\..\..\Build\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll + + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.dll + + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Extras.dll + + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll + + + ..\..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll + + + ..\..\..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll + + + ..\..\..\packages\MaterialDesignColors.1.1.2\lib\net45\MaterialDesignColors.dll + + + ..\..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll + + + ..\..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll + + + ..\..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + + + + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll + + + + + + + + + 4.0 + + + + + + + + + + + + + + + MainView.xaml + + + + + GlobalVersionInfo.cs + + + + Designer + MSBuild:Compile + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + {6c55b776-26d4-4db3-a6ab-87e783b2f3d1} + ICSharpCode.AvalonEdit + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {0ecd6da8-7aa6-48d9-8b65-279d176ad9af} + Tango.DAL.Observables + + + {4206ac58-3b57-4699-8835-90bf6db01a61} + Tango.Integration + + + {bc932dbd-7cdb-488c-99e4-f02cf441f55e} + Tango.Logging + + + {e4927038-348d-4295-aaf4-861c58cb3943} + Tango.PMR + + + {401989e7-ae1e-4002-b0ee-9a9f63740b97} + Tango.Scripting + + + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} + Tango.Settings + + + {8491d07b-c1f6-4b62-a412-41b9fd2d6538} + Tango.SharedUI + + + {1981b537-39e9-4e7d-8430-27466481aeee} + Tango.Stubs + + + {74e700b0-1156-4126-be40-ee450d3c3026} + Tango.Transport + + + {cb0b0aa2-bb24-4bca-a720-45e397684e12} + Tango.MachineStudio.Common + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModelLocator.cs new file mode 100644 index 000000000..02ac1b8dd --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModelLocator.cs @@ -0,0 +1,33 @@ +using GalaSoft.MvvmLight.Ioc; +using Microsoft.Practices.ServiceLocation; +using Tango.MachineStudio.Stubs.ViewModels; + +namespace Tango.MachineStudio.Stubs +{ + /// + /// This class contains static references to all the view models in the + /// application and provides an entry point for the bindings. + /// + public static class ViewModelLocator + { + /// + /// Initializes a new instance of the ViewModelLocator class. + /// + static ViewModelLocator() + { + ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); + + //SimpleIoc.Default.Unregister(); + + SimpleIoc.Default.Register(); + } + + public static MainViewVM MainViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/CodeTabVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/CodeTabVM.cs new file mode 100644 index 000000000..451e1a1f0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/CodeTabVM.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.SharedUI; + +namespace Tango.MachineStudio.Stubs.ViewModels +{ + /// + /// Represents a single script editor tab view model; + /// + /// + public class CodeTabVM : ViewModel + { + private String _title; + /// + /// Gets or sets the script title/file name. + /// + public String Title + { + get + { + return File != null ? Path.GetFileName(File) : _title; + } + set + { + _title = value; + RaisePropertyChanged(nameof(Title)); + } + } + + private String _file; + /// + /// Gets or sets the full script file path. + /// + public String File + { + get { return _file; } + set + { + _file = value; + RaisePropertyChanged(nameof(File)); + RaisePropertyChanged(nameof(Title)); + } + } + + private String _code; + /// + /// Gets or sets the script code. + /// + public String Code + { + get { return _code; } + set { _code = value; RaisePropertyChanged(nameof(Code)); } + } + + private bool _isRunning; + /// + /// Gets or sets a value indicating whether this instance is running. + /// + public bool IsRunning + { + get { return _isRunning; } + set { _isRunning = value; RaisePropertyChangedAuto(); } + } + + private RelayCommand _insertCodeSnippetCommand; + /// + /// Gets or sets the insert snippet command. (Inserts stub snippet to editor) + /// + public RelayCommand InsertSnippetCommand + { + get { return _insertCodeSnippetCommand; } + set { _insertCodeSnippetCommand = value; RaisePropertyChanged(nameof(InsertSnippetCommand)); } + } + + /// + /// Initializes a new instance of the class. + /// + public CodeTabVM() + { + Title = "untitled"; + Code = Properties.Resources.CodeTabTemplate; + } + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + { + return Title; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs new file mode 100644 index 000000000..d7e641735 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs @@ -0,0 +1,525 @@ +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Tango.Core.Commands; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.Common.StudioApplication; +using Tango.Scripting; +using Tango.Settings; +using Tango.SharedUI; +using Tango.Stubs; +using Tango.Transport; +using Tango.Transport.Adapters; + +namespace Tango.MachineStudio.Stubs.ViewModels +{ + /// + /// Represents the script execution utility main view model. + /// + /// + public class MainViewVM : ViewModel + { + private UsbTransportAdapter _adapter; //Holds the USB transport adapter. + private StubManager _stubManager; + private INotificationProvider _notification; + + #region Properties + + public IStudioApplicationManager ApplicationManager { get; set; } + + private bool _useConnectedMachine; + /// + /// Gets or sets a value indicating whether [use connected machine]. + /// + public bool UseConnectedMachine + { + get { return _useConnectedMachine; } + set { _useConnectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + /// + /// Gets or sets the code tabs. + /// + public ObservableCollection CodeTabs { get; set; } + + /// + /// Gets or sets the additional highlight C# types. + /// + public ObservableCollection> HighlightTypes { get; set; } + + /// + /// Gets or sets the collection of stub snippets. + /// + public ObservableCollection StubSnippets { get; set; } + + private StubSnippetVM _selectedStubSnippet; + /// + /// Gets or sets the selected stub snippet. + /// + public StubSnippetVM SelectedStubSnippet + { + get { return _selectedStubSnippet; } + set { _selectedStubSnippet = value; RaisePropertyChanged(nameof(SelectedStubSnippet)); } + } + + private String _log; + /// + /// Gets or sets the current response log. + /// + public String Log + { + get { return _log; } + set { _log = value; RaisePropertyChanged(nameof(Log)); } + } + + private CodeTabVM _selectedCodeTab; + /// + /// Gets or sets the selected code tab. + /// + public CodeTabVM SelectedCodeTab + { + get { return _selectedCodeTab; } + set { _selectedCodeTab = value; RaisePropertyChanged(nameof(SelectedCodeTab)); InvalidateRelayCommands(); } + } + + private bool _isConnected; + /// + /// Gets or sets a value indicating whether the USB adapter is connected. + /// + public bool IsConnected + { + get { return _isConnected; } + set { _isConnected = value; RaisePropertyChanged(nameof(IsConnected)); InvalidateRelayCommands(); } + } + + private List _ports; + /// + /// Gets or sets the available USB ports. + /// + public List Ports + { + get { return _ports; } + set { _ports = value; RaisePropertyChanged(nameof(Ports)); } + } + + private String _selectedPort; + /// + /// Gets or sets the selected USB port. + /// + public String SelectedPort + { + get { return _selectedPort; } + set { _selectedPort = value; RaisePropertyChanged(nameof(SelectedPort)); InvalidateRelayCommands(); } + } + + private String _status; + /// + /// Gets or sets the current status bar text. + /// + public String Status + { + get { return _status; } + set { _status = value; RaisePropertyChanged(nameof(Status)); } + } + + private bool _isRunning; + /// + /// Gets or sets a value indicating whether a stub is currently running. + /// + public bool IsRunning + { + get { return _isRunning; } + set { _isRunning = value; RaisePropertyChanged(nameof(IsRunning)); InvalidateRelayCommands(); } + } + + #endregion + + #region Commands + + /// + /// Gets or sets the new command. + /// + public RelayCommand NewCommand { get; set; } + + /// + /// Gets or sets the close tab command. + /// + public RelayCommand CloseTabCommand { get; set; } + + /// + /// Gets or sets the run command. + /// + public RelayCommand RunCommand { get; set; } + + /// + /// Gets or sets the stop command. + /// + public RelayCommand StopCommand { get; set; } + + /// + /// Gets or sets the toggle connection command. + /// + public RelayCommand ToggleConnectionCommand { get; set; } + + /// + /// Gets or sets the open command. + /// + public RelayCommand OpenCommand { get; set; } + + /// + /// Gets or sets the save command. + /// + public RelayCommand SaveCommand { get; set; } + + /// + /// Gets or sets the save as command. + /// + public RelayCommand SaveAsCommand { get; set; } + + /// + /// Gets or sets the stub snippet selected command. + /// + public RelayCommand StubSnippetSelectedCommand { get; set; } + + /// + /// Gets or sets the insert snippet command. + /// + public RelayCommand InsertSnippetCommand { get; set; } + + /// + /// Gets or sets the exit command. + /// + public RelayCommand ExitCommand { get; set; } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notification) + { + ApplicationManager = applicationManager; + _notification = notification; + + CodeTabs = new ObservableCollection(); + + NewCommand = new RelayCommand(CreateNewTab); + CloseTabCommand = new RelayCommand(OnTabClosing); + RunCommand = new RelayCommand(RunTab, (x) => (IsConnected || UseConnectedMachine) && !IsRunning && SelectedCodeTab != null); + StopCommand = new RelayCommand(StopTab, (x) => (IsConnected || UseConnectedMachine) && IsRunning && SelectedCodeTab != null); + InsertSnippetCommand = new RelayCommand((x) => { }); + + HighlightTypes = new ObservableCollection>(); + HighlightTypes.Add(new KeyValuePair("stubManager", typeof(StubManager))); + + StubSnippets = new ObservableCollection(); + + foreach (var stubType in StubBase.GetAvailableRequestStubs()) + { + StubSnippetVM snippet = new StubSnippetVM(); + snippet.Name = stubType.Name.Replace("Stub_", ""); + snippet.Code = String.Format("stubManager.Run(\"{0}\" ,{1});", stubType.Name, String.Join(", ", stubType.GetProperties(BindingFlags.Public | BindingFlags.Instance).Select(x => x.PropertyType.Name == "string" ? "\"string\"" : x.PropertyType.Name))); + StubSnippets.Add(snippet); + } + + ToggleConnectionCommand = new RelayCommand(ToggleConnection, (x) => !IsRunning); + OpenCommand = new RelayCommand(OpenFile); + SaveCommand = new RelayCommand(SaveFile); + SaveAsCommand = new RelayCommand(SaveAsFile); + StubSnippetSelectedCommand = new RelayCommand(OnStubSnippetSelected); + ExitCommand = new RelayCommand(() => Application.Current.Shutdown()); + + Ports = new List() + { + "COM1", + "COM2", + "COM3", + "COM4", + "COM5", + "COM6", + "COM7", + "COM8", + "COM9", + }; + + SelectedPort = SettingsManager.Default.StubsUI.SelectedPort != null ? SettingsManager.Default.StubsUI.SelectedPort : Ports.First(); + + Status = "Ready"; + + if (SettingsManager.Default.StubsUI.LastTabs.Count > 0) + { + foreach (var file in SettingsManager.Default.StubsUI.LastTabs) + { + if (File.Exists(file)) + { + OpenFile(file); + } + } + } + else + { + CreateNewTab(); + } + + Application.Current.Exit += Current_Exit; + } + + #endregion + + #region Virtual Methods + + /// + /// Called when a stub snippet is double clicked. + /// + protected virtual void OnStubSnippetSelected() + { + if (SelectedStubSnippet != null) + { + if (InsertSnippetCommand != null) + { + InsertSnippetCommand.Execute(SelectedStubSnippet.Code); + } + } + } + + /// + /// Called when user closes a script tab. + /// + /// The code tab. + protected virtual void OnTabClosing(CodeTabVM codeTab) + { + CodeTabs.Remove(codeTab); + } + + #endregion + + #region Private Methods + + /// + /// Saves the selected script file. + /// + private void SaveFile() + { + if (SelectedCodeTab != null) + { + if (SelectedCodeTab.File == null) + { + SaveAsFile(); + } + else + { + File.WriteAllText(SelectedCodeTab.File, SelectedCodeTab.Code); + } + } + } + + /// + /// Saves the selected script file. + /// + private void SaveAsFile() + { + if (SelectedCodeTab != null) + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "C# Script Files|*.cs"; + dlg.DefaultExt = ".cs"; + if (dlg.ShowDialog().Value) + { + File.WriteAllText(dlg.FileName, SelectedCodeTab.Code); + SelectedCodeTab.File = dlg.FileName; + } + } + } + + /// + /// Opens a script from HD. + /// + private void OpenFile() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "C# Script Files|*.cs"; + dlg.Multiselect = true; + if (dlg.ShowDialog().Value) + { + foreach (var file in dlg.FileNames) + { + OpenFile(file); + } + } + } + + /// + /// Opens the file. + /// + /// The file. + private void OpenFile(String file) + { + var newTab = new CodeTabVM(); + newTab.File = file; + newTab.Code = File.ReadAllText(file); + CodeTabs.Add(newTab); + SelectedCodeTab = newTab; + } + + /// + /// Toggles the USB adapter connection. + /// + private void ToggleConnection() + { + try + { + if (!IsConnected) + { + _adapter = new UsbTransportAdapter(SelectedPort); + _adapter.Connect().Wait(); + IsConnected = true; + } + else + { + _adapter.Disconnect().Wait(); + IsConnected = false; + } + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString(), "Tango"); + } + } + + /// + /// Creates a new script tab. + /// + private void CreateNewTab() + { + var newTab = new CodeTabVM(); + CodeTabs.Add(newTab); + SelectedCodeTab = newTab; + } + + /// + /// Runs the selected script tab. + /// + private async void RunTab() + { + if (UseConnectedMachine && !ApplicationManager.IsMachineConnected) + { + _notification.ShowError("Cannot execute stub while 'Connected Machine' is set but not machine connected."); + return; + } + + IsRunning = true; + SelectedCodeTab.IsRunning = true; + Log = (DateTime.Now.ToTimeString() + ": ") + "Executing script '" + SelectedCodeTab.Title + "'..." + Environment.NewLine; + + await Task.Factory.StartNew(async () => + { + try + { + ITransportAdapter adapter = _adapter; + + if (ApplicationManager.IsMachineConnected && UseConnectedMachine) + { + adapter = ApplicationManager.ConnectedMachine.Adapters.First(); + } + + _stubManager = new StubManager(adapter); + var thisStubManager = _stubManager; + _stubManager.Completed += Manager_Completed; + _stubManager.Failed += Manager_Failed; + _stubManager.Executed += Manager_Executed; + + ScriptEngine engine = new ScriptEngine(new StubOnExecuteParameters(_stubManager)); + + engine.ReferencedAssemblies.Add(this.GetType()); + await engine.Run(SelectedCodeTab.Code); + + if (!thisStubManager.Aborted) + { + IsRunning = false; + SelectedCodeTab.IsRunning = false; + } + } + catch (Exception ex) + { + IsRunning = false; + SelectedCodeTab.IsRunning = false; + MessageBox.Show(ex.Message, "Tango"); + } + }); + } + + /// + /// Stops the currently current script. + /// + private void StopTab() + { + if (_stubManager != null) + { + _stubManager.Abort(); + IsRunning = false; + SelectedCodeTab.IsRunning = false; + Status = "Stopped!"; + Log += (DateTime.Now.ToTimeString() + ": ") + "Stopped!" + Environment.NewLine; + } + } + + #endregion + + #region Event Handlers + + /// + /// Handled the Executed event. + /// + /// The sender. + /// Name of the stub. + private void Manager_Executed(object sender, string stubName) + { + Log += (DateTime.Now.ToTimeString() + ": ") + "Executing '" + stubName + "'..." + Environment.NewLine; + Status = "Executing " + stubName + "..."; + } + + /// + /// Handled the Failed event. + /// + /// The sender. + /// The exception. + private void Manager_Failed(object sender, Exception ex) + { + if (IsRunning) + { + Log += (DateTime.Now.ToTimeString() + ": ") + ex.Message + Environment.NewLine; + Status = "Failed!"; + } + } + + /// + /// Handled the Completed event. + /// + /// The sender. + /// The response. + private void Manager_Completed(object sender, string response) + { + Log += (DateTime.Now.ToTimeString() + ": ") + "Response Received:" + Environment.NewLine; + Log += (DateTime.Now.ToTimeString() + ": ") + response + Environment.NewLine; + Status = "Completed"; + } + + private void Current_Exit(object sender, ExitEventArgs e) + { + SettingsManager.Default.MachineStudio.StubsModule.SelectedPort = SelectedPort; + SettingsManager.Default.MachineStudio.StubsModule.LastTabs = CodeTabs.Select(x => x.File).ToList(); + SettingsManager.SaveDefaultSettings(); + } + + #endregion + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/StubSnippetVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/StubSnippetVM.cs new file mode 100644 index 000000000..d99906f20 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/StubSnippetVM.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; + +namespace Tango.MachineStudio.Stubs.ViewModels +{ + /// + /// Represents a single stub snippet view model. + /// + /// + public class StubSnippetVM : ViewModel + { + private String _name; + /// + /// Gets or sets the stub name. + /// + public String Name + { + get { return _name; } + set { _name = value; RaisePropertyChanged(nameof(Name)); } + } + + private String _code; + /// + /// Gets or sets the snippet code. + /// + public String Code + { + get { return _code; } + set { _code = value; RaisePropertyChanged(nameof(Code)); } + } + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + { + return Name; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Views/MainView.xaml new file mode 100644 index 000000000..5a71b48d1 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Views/MainView.xaml @@ -0,0 +1,319 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Connected Machine + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Views/MainView.xaml.cs new file mode 100644 index 000000000..5eee980de --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Views/MainView.xaml.cs @@ -0,0 +1,53 @@ +using Microsoft.Practices.ServiceLocation; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +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; +using Tango.MachineStudio.Stubs.ViewModels; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.Stubs.Views +{ + /// + /// Interaction logic for MainView.xaml + /// + public partial class MainView : UserControl + { + public MainView() : base() + { + InitializeComponent(); + this.Loaded += MainView_Loaded; + } + + private void MainView_Loaded(object sender, RoutedEventArgs e) + { + ServiceLocator.Current.GetInstance().CodeTabs.RemoveAt(0); + } + + //Auto scroll to bottom of response log each time it is changed. + private void TextBox_TextChanged(object sender, TextChangedEventArgs e) + { + Task.Factory.StartNew(() => + { + Thread.Sleep(50); + + this.Dispatcher.Invoke(() => + { + txtLog.SelectionStart = txtLog.Text.Length; + txtLog.ScrollToEnd(); + }); + }); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/app.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/app.config new file mode 100644 index 000000000..5d794b958 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/app.config @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/packages.config new file mode 100644 index 000000000..a29d1ec82 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/packages.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/App.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/App.config index 00d1c3941..158702ed3 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/App.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/App.config @@ -12,4 +12,19 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj index 19eecc2e1..bc47bbb0b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj @@ -51,6 +51,9 @@ ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll + + ..\..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll + ..\..\..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll @@ -66,6 +69,22 @@ + + ..\..\..\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\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll @@ -150,6 +169,10 @@ ResXFileCodeGenerator Resources.Designer.cs + + Tango.db + PreserveNewest + @@ -186,6 +209,10 @@ {bc932dbd-7cdb-488c-99e4-f02cf441f55e} Tango.Logging + + {e4927038-348d-4295-aaf4-861c58cb3943} + Tango.PMR + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} Tango.Settings @@ -198,6 +225,10 @@ {7ada4e86-cad7-4968-a210-3a8a9e5153ab} Tango.Synchronization + + {74e700b0-1156-4126-be40-ee450d3c3026} + Tango.Transport + {cb0b0aa2-bb24-4bca-a720-45e397684e12} Tango.MachineStudio.Common diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/DirectSynchronizationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/DirectSynchronizationViewVM.cs index ba3521009..f265fafe7 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/DirectSynchronizationViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/DirectSynchronizationViewVM.cs @@ -1,20 +1,286 @@ -using System; +using Google.Protobuf; +using System; using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.Core.Helpers; +using Tango.DAL.Observables; using Tango.Integration.Services; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.Common.StudioApplication; +using Tango.MachineStudio.Synchronization.Navigation; +using Tango.PMR.Integration; using Tango.SharedUI; +using Tango.Synchronization; +using Tango.Synchronization.Local; +using Tango.Synchronization.Remote; namespace Tango.MachineStudio.Synchronization.ViewModels { public class DirectSynchronizationViewVM : ViewModel { - public ExternalBridgeScanner Scanner { get; set; } + private SyncNavigationManager _navigation; + private String _slaveDBFile; + private String _masterDBFile; + private LocalDBComparer _comparer; + private INotificationProvider _notification; + private bool _isWorking; - public DirectSynchronizationViewVM(ExternalBridgeScanner scanner) + public IStudioApplicationManager ApplicationManager { get; set; } + + public DirectSynchronizationViewVM(IStudioApplicationManager applicationManager, SyncNavigationManager navigation, INotificationProvider notification) + { + ApplicationManager = applicationManager; + + _navigation = navigation; + _notification = notification; + + BackCommand = new RelayCommand(() => _navigation.NavigateTo(NavigationView.MenuView)); + + Differences = new ObservableCollection(); + + CompareCommand = new RelayCommand(Compare, (x) => !_isWorking && SelectedMachine != null); + CommitAllCommand = new RelayCommand(Synchronize, (x) => Differences.Count > 0 && !_isWorking && SelectedMachine != null); + } + + #region Commands + + /// + /// Gets or sets the back command. + /// + public RelayCommand BackCommand { get; set; } + + /// + /// Gets or sets the browse master database command. + /// + public RelayCommand BrowseMasterDBCommand { get; set; } + + /// + /// Gets or sets the browse slave database command. + /// + public RelayCommand BrowseSlaveDBCommand { get; set; } + + /// + /// Gets or sets the compare command. + /// + public RelayCommand CompareCommand { get; set; } + + /// + /// Gets or sets the commit command. + /// + public RelayCommand CommitCommand { get; set; } + + /// + /// Gets or sets the commit all command. + /// + public RelayCommand CommitAllCommand { get; set; } + + /// + /// Gets or sets the clean command. + /// + public RelayCommand CleanCommand { get; set; } + + #endregion + + #region Properties + + private bool _isClearMachine; + /// + /// Gets or sets a value indicating whether this instance is clear machine. + /// + public bool IsClearMachine + { + get { return _isClearMachine; } + set + { + _isClearMachine = value; + RaisePropertyChangedAuto(); + } + } + + private ObservableCollection _differences; + /// + /// Gets or sets the differences. + /// + public ObservableCollection Differences + { + get { return _differences; } + set { _differences = value; RaisePropertyChanged(nameof(Differences)); } + } + + private Diff _selectedDifference; + /// + /// Gets or sets the selected difference. + /// + public Diff SelectedDifference + { + get { return _selectedDifference; } + set { _selectedDifference = value; RaisePropertyChanged(nameof(SelectedDifference)); InvalidateRelayCommands(); } + } + + private Machine _selectedMachine; + /// + /// Gets or sets the selected machine. + /// + public Machine SelectedMachine + { + get { return _selectedMachine; } + set { _selectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + #endregion + + private void Compare() + { + if (SelectedMachine.SerialNumber != ApplicationManager.ConnectedMachine.SerialNumber) + { + if (!_notification.ShowQuestion("The selected machine serial number does not match the connected machine. Are you sure you want to continue?")) + { + return; + } + } + + Task.Factory.StartNew(async () => + { + using (_notification.PushTaskItem("Downloading machine database...")) + { + try + { + _isWorking = true; + InvalidateRelayCommands(); + Thread.Sleep(1500); + + ApplicationManager.ConnectedMachine.RequestTimeout = TimeSpan.FromSeconds(10); + var response = await ApplicationManager.ConnectedMachine.SendRequest(new DirectSynchronizationRequest()); + + using (_notification.PushTaskItem("Generating temporary files...")) + { + String tempFolder = PathHelper.GetTempFolderPath(); + + //File path for the reflected remote data base SQLite. + _masterDBFile = Path.Combine(tempFolder, "Remote.db"); + //File path for the received machine SQLite db. + _slaveDBFile = Path.Combine(tempFolder, "Local.db"); + + //Save the machine db to file. + File.WriteAllBytes(_slaveDBFile, response.Message.LocalDB.ToByteArray()); + + //Copy the SQLite db template. + File.Copy(Path.Combine(PathHelper.GetStartupPath(), "Tango.db"), _masterDBFile); + + //Synchronize the SQL Server db with the new SQLite template. (Overwrite basically) + RemoteDBSynchronizer.Synchronize(_masterDBFile, SelectedMachine.SerialNumber, true); + + using (_notification.PushTaskItem("Comparing database...")) + { + _comparer = new LocalDBComparer(new SQLiteDataBase(_masterDBFile), new SQLiteDataBase(_slaveDBFile)); + + var diffs = _comparer.Compare(); + Differences = new ObservableCollection(diffs); + + if (diffs.Where(x => x.Action != DiffAction.ReplaceTableDataInSlave).Count() > 0) + { + ShowInfo("Found " + Differences.Where(x => x.Action != DiffAction.ReplaceTableDataInSlave).Count() + " differences."); + } + else + { + ShowInfo("The machine database is synchronized."); + } + } + } + } + catch (Exception ex) + { + ShowError(ex.Message); + } + finally + { + _isWorking = false; + SelectedDifference = null; + InvalidateRelayCommands(); + } + } + }); + } + + private void Synchronize() + { + if (IsClearMachine) + { + if (!_notification.ShowQuestion("This will erase and override the existing machine database. Do you want to proceed?")) + { + return; + } + } + + Task.Factory.StartNew(async () => + { + using (_notification.PushTaskItem("Synchronizing...")) + { + try + { + _isWorking = true; + InvalidateRelayCommands(); + Thread.Sleep(1500); + + for (int i = 0; i < Differences.Count; i++) + { + var diff = Differences[i]; + + diff.Commit(); + InvokeUINow(() => Differences.Remove(diff)); + i--; + } + + _comparer.Dispose(); + + byte[] remoteDbBytes = IsClearMachine ? File.ReadAllBytes(_masterDBFile) : File.ReadAllBytes(_slaveDBFile); + + var response = await ApplicationManager.ConnectedMachine.SendRequest(new OverrideDataBaseRequest() + { + RemoteDB = ByteString.CopyFrom(remoteDbBytes) + }); + + if (!response.Message.Successful) + { + ShowError("The remote machine has reported some error while trying to override the database."); + } + else + { + PathHelper.TryDeleteFile(_slaveDBFile); + PathHelper.TryDeleteFile(_masterDBFile); + _slaveDBFile = null; + _masterDBFile = null; + InvalidateRelayCommands(); + } + } + catch (Exception ex) + { + ShowError(ex.Message); + } + finally + { + _isWorking = false; + SelectedDifference = null; + InvalidateRelayCommands(); + } + } + }); + } + + private void ShowError(String message) + { + InvokeUINow(() => _notification.ShowError(message)); + } + + private void ShowInfo(String message) { - Scanner = scanner; + InvokeUINow(() => _notification.ShowInfo(message)); } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/DirectSynchronizationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/DirectSynchronizationView.xaml index 7dc0cdacc..4c5a719b5 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/DirectSynchronizationView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/DirectSynchronizationView.xaml @@ -5,29 +5,199 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:fa="http://schemas.fontawesome.io/icons/" xmlns:synchronization="clr-namespace:Tango.Synchronization;assembly=Tango.Synchronization" + xmlns:providers="clr-namespace:Tango.MachineStudio.Synchronization.AutoComplete" + xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete" xmlns:global="clr-namespace:Tango.MachineStudio.Synchronization" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:local="clr-namespace:Tango.MachineStudio.Synchronization.Views" mc:Ignorable="d" - d:DesignHeight="720" d:DesignWidth="1280" Background="White" DataContext="{x:Static global:ViewModelLocator.DirectSynchronizationViewVM}"> + d:DesignHeight="720" d:DesignWidth="1280" DataContext="{x:Static global:ViewModelLocator.DirectSynchronizationViewVM}"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + Direct Database Synchronization + + + + + + + + + + + + + + + + + + + + + + + + Remote Database + + + + + + + + + + + + + + + + + + + IP Address: + + + + Serial Number: + + + + Organization: + + - - - - + + + + + + + + + + + + + + + Differences + + + + + + + + + + + + + + + + + + SQL Command + + + + + + + Clear Machine Before Synchronization + + + + + + + + + + + + + + + + + + + No Machine Connection + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/LocalSynchronizationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/LocalSynchronizationView.xaml index 72297e2cb..e5a4aac5a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/LocalSynchronizationView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/LocalSynchronizationView.xaml @@ -43,18 +43,14 @@ Local Database Synchronization - - - - - + @@ -102,6 +98,10 @@ + + + + @@ -130,51 +130,32 @@ - - - - - - - - - - - - - - - - - - - - SQL Command - + SQL Command + - - - - - - + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/RemoteSynchronizationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/RemoteSynchronizationView.xaml index 2487aab64..9bb995bd8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/RemoteSynchronizationView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Views/RemoteSynchronizationView.xaml @@ -48,7 +48,7 @@ Local Database Synchronization diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/packages.config index 8d8f972d1..1fa8e3268 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/packages.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/packages.config @@ -3,8 +3,15 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config index 692b77528..d38c3ed69 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config @@ -27,6 +27,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs index 689ac7b38..9a8a6bc96 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs @@ -10,6 +10,7 @@ using Tango.Core; using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Authentication; using Tango.MachineStudio.Common.Modules; +using Tango.MachineStudio.Stubs; namespace Tango.MachineStudio.UI.Modules { @@ -49,6 +50,10 @@ namespace Tango.MachineStudio.UI.Modules { if (!_loaded) { + //Preloaded + AllModules.Add(new StubsModule()); + //Preloaded + AllModules.Clear(); string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); @@ -63,8 +68,11 @@ namespace Tango.MachineStudio.UI.Modules { foreach (var moduleType in moduleAssembly.GetTypes().Where(x => !x.IsInterface && typeof(IStudioModule).IsAssignableFrom(x))) { - var module = Activator.CreateInstance(moduleType) as IStudioModule; - AllModules.Add(module); + if (!AllModules.ToList().Exists(x => x.GetType() == moduleType)) + { + var module = Activator.CreateInstance(moduleType) as IStudioModule; + AllModules.Add(module); + } } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs index 3c245510b..ede66dc19 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs @@ -15,6 +15,8 @@ namespace Tango.MachineStudio.UI.Notifications { public class DefaultNotificationProvider : ExtendedObject, INotificationProvider { + private static List viewTypes; + public ObservableCollection TaskItems { get; private set; } public bool HasTaskItems @@ -99,7 +101,19 @@ namespace Tango.MachineStudio.UI.Notifications { String viewName = typeof(VM).Name.Replace("VM", ""); - var view = Activator.CreateInstance(AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes()).Single(x => x.Name == viewName)) as FrameworkElement; + if (viewTypes == null) + { + viewTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes()).ToList(); + } + + var viewType = viewTypes.SingleOrDefault(x => x.Name == viewName); + + if (viewType == null) + { + throw new NullReferenceException("Could not locate view " + viewName); + } + + var view = Activator.CreateInstance(viewType) as FrameworkElement; DialogWindow dialog = new DialogWindow(); dialog.Owner = Application.Current.MainWindow; dialog.InnerContent = view; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml index 4f3b826fe..a89f8eeca 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml @@ -24,7 +24,7 @@ - diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index 355d59083..89823e4f7 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -77,9 +77,27 @@ ..\..\packages\SimpleValidator.0.6.1.0\lib\net40\SimpleValidator.dll + + + + ..\..\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\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll @@ -114,6 +132,7 @@ + @@ -262,6 +281,10 @@ {94f7acf8-55e1-4a02-b9bc-a818413fdbbf} Tango.MachineStudio.DB + + {22c2aa72-9493-4d0d-b421-8ef9789fb192} + Tango.MachineStudio.Stubs + {12d0c43c-391f-4c74-92ab-82e9a9beeb9b} Tango.MachineStudio.Synchronization diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs index e40f589af..70912ba98 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs @@ -63,6 +63,7 @@ namespace Tango.MachineStudio.UI SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); LogManager.RegisterLogger(new VSOutputLogger()); LogManager.RegisterLogger(new FileLogger()); @@ -114,5 +115,13 @@ namespace Tango.MachineStudio.UI return ServiceLocator.Current.GetInstance(); } } + + public MachineLoginViewVM MachineLoginViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } } } \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs index 6505bcf88..f213af0d4 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -31,7 +31,6 @@ namespace Tango.MachineStudio.UI.ViewModels { StaThreadHelper.StartStaThread(() => { - Thread.Sleep(1000); try { ObservablesEntitiesAdapter.Instance.Initialize(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs new file mode 100644 index 000000000..a6ee9ee2a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.UI.ViewModels +{ + public class MachineLoginViewVM : DialogViewVM + { + public String Password { get; set; } + + public RelayCommand LoginCommand { get; set; } + + public RelayCommand CancelCommand { get; set; } + + public MachineLoginViewVM() + { + LoginCommand = new RelayCommand(Login); + CancelCommand = new RelayCommand(Cancel); + } + + private void Login(string password) + { + Password = password; + Accept(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index 6c44c8480..92c0afa21 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -124,33 +124,38 @@ namespace Tango.MachineStudio.UI.ViewModels private void ConnectToMachine() { - _notificationProvider.ShowModalDialog(async (x) => + _notificationProvider.ShowModalDialog((x) => { if (x.SelectedMachine != null) { - using (NotificationProvider.PushTaskItem("Connecting to machine " + x.SelectedMachine.SerialNumber + "...")) + _notificationProvider.ShowModalDialog(async (login) => { - try + using (NotificationProvider.PushTaskItem("Connecting to machine " + x.SelectedMachine.SerialNumber + "...")) { - await x.SelectedMachine.Connect(); - var authenticated = await x.SelectedMachine.Authenticate(); - if (!authenticated) + try { - _notificationProvider.ShowError("It seems like you are not authorized to access the selected machine."); + await x.SelectedMachine.Connect(); + var authenticated = await x.SelectedMachine.Authenticate(login.Password); + if (!authenticated) + { + _notificationProvider.ShowError("It seems like you are not authorized to access the selected machine."); + } + else + { + ApplicationManager.ConnectedMachine = x.SelectedMachine; + } } - else + catch (Exception ex) { - ApplicationManager.ConnectedMachine = x.SelectedMachine; - var response = await x.SelectedMachine.SendRequest(new CalculateRequest() { A = 10, B = 5 }); - _notificationProvider.ShowInfo(response.ToString()); + LogManager.Log(ex); + _notificationProvider.ShowError(ex.Message); } + + InvalidateRelayCommands(); } - catch (Exception ex) - { - LogManager.Log(ex); - _notificationProvider.ShowError(ex.Message); - } - } + }); + + InvalidateRelayCommands(); } InvalidateRelayCommands(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml index 2d172837a..32108c652 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml @@ -77,7 +77,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml.cs index 58cec1987..6c8e305e9 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml.cs @@ -24,11 +24,5 @@ namespace Tango.MachineStudio.UI.Views { InitializeComponent(); } - - private void OnConnectClicked(object sender, RoutedEventArgs e) - { - Window.GetWindow(this).DialogResult = true; - Window.GetWindow(this).Close(); - } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineLoginView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineLoginView.xaml index 83f7cc884..04f787c41 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineLoginView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineLoginView.xaml @@ -3,10 +3,37 @@ 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:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:local="clr-namespace:Tango.MachineStudio.UI.Views" mc:Ignorable="d" - d:DesignHeight="300" d:DesignWidth="300"> + d:DesignHeight="200" d:DesignWidth="550" Background="White" DataContext="{Binding MachineLoginViewVM, Source={StaticResource Locator}}"> - + + + + + + + + + + + + + + + + + Enter machine password + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineLoginView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineLoginView.xaml.cs index c0bfdc25d..c5161b477 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineLoginView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineLoginView.xaml.cs @@ -23,6 +23,29 @@ namespace Tango.MachineStudio.UI.Views public MachineLoginView() { InitializeComponent(); + + this.Loaded += MachineLoginView_Loaded; + } + + private void MachineLoginView_Loaded(object sender, RoutedEventArgs e) + { + txtPass.Focusable = true; + txtPass.Focus(); + txtPass.Password = String.Empty; + Password = String.Empty; + } + + public String Password + { + get { return (String)GetValue(PasswordProperty); } + set { SetValue(PasswordProperty, value); } + } + public static readonly DependencyProperty PasswordProperty = + DependencyProperty.Register("Password", typeof(String), typeof(MachineLoginView), new PropertyMetadata(null)); + + private void txtPass_PasswordChanged(object sender, RoutedEventArgs e) + { + Password = txtPass.Password; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml index fc9db8adc..14858c049 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml @@ -86,9 +86,8 @@