From f16453f95d38c89936b96e627250c93117d0b4b6 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 28 Apr 2019 13:26:51 +0300 Subject: Added exception throwing when transporter is disconnected. Added dispensers controllers to technician mode on PPC. --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes Software/DB/TCC/TCC.mdf | Bin 8388608 -> 8388608 bytes Software/DB/TCC/TCC_log.ldf | Bin 8388608 -> 8388608 bytes Software/Graphics/Mobile/Technician/dispensers.png | Bin 0 -> 5943 bytes .../Controls/DispenserController.xaml | 94 ++++++++++ .../Controls/DispenserController.xaml.cs | 202 +++++++++++++++++++++ .../Tango.PPC.Technician/Images/dispensers.png | Bin 0 -> 5943 bytes .../Models/DispenserController.cs | 73 ++++++++ .../Tango.PPC.Technician.csproj | 37 ++++ .../Tango.PPC.Technician/ViewModelLocator.cs | 12 ++ .../ViewModels/DispensersViewVM.cs | 17 ++ .../Tango.PPC.Technician/Views/CatalogView.xaml | 6 +- .../Tango.PPC.Technician/Views/DispensersView.xaml | 41 +++++ .../Views/DispensersView.xaml.cs | 28 +++ .../Tango.PPC.Technician/Views/MainView.xaml | 1 + .../PPC/Modules/Tango.PPC.Technician/app.config | 14 +- .../Modules/Tango.PPC.Technician/packages.config | 3 + Software/Visual_Studio/PPC/Tango.PPC.UI/App.config | 80 ++++++++ .../Visual_Studio/PPC/Tango.PPC.UI/app.manifest | 2 +- .../Tango.Touch/Controls/TouchIconButton.xaml | 7 + .../Tango.Touch/Controls/TouchNumericTextBox.xaml | 4 +- .../Tango.Transport/TransporterBase.cs | 40 ++++ 23 files changed, 648 insertions(+), 13 deletions(-) create mode 100644 Software/Graphics/Mobile/Technician/dispensers.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Controls/DispenserController.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Controls/DispenserController.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/dispensers.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Models/DispenserController.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/DispensersViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/DispensersView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/DispensersView.xaml.cs (limited to 'Software') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index 2e33873fa..c7be9fdc6 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index f32930dff..099506086 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/DB/TCC/TCC.mdf b/Software/DB/TCC/TCC.mdf index 9a07550ca..032683b9d 100644 Binary files a/Software/DB/TCC/TCC.mdf and b/Software/DB/TCC/TCC.mdf differ diff --git a/Software/DB/TCC/TCC_log.ldf b/Software/DB/TCC/TCC_log.ldf index 6463bbdf7..c016fe931 100644 Binary files a/Software/DB/TCC/TCC_log.ldf and b/Software/DB/TCC/TCC_log.ldf differ diff --git a/Software/Graphics/Mobile/Technician/dispensers.png b/Software/Graphics/Mobile/Technician/dispensers.png new file mode 100644 index 000000000..65d59b082 Binary files /dev/null and b/Software/Graphics/Mobile/Technician/dispensers.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Controls/DispenserController.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Controls/DispenserController.xaml new file mode 100644 index 000000000..3fc7c607e --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Controls/DispenserController.xaml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Controls/DispenserController.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Controls/DispenserController.xaml.cs new file mode 100644 index 000000000..98b857fba --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Controls/DispenserController.xaml.cs @@ -0,0 +1,202 @@ +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.BL.Entities; +using Tango.Core.EventArguments; +using Tango.Integration.Operation; +using Tango.PMR.Diagnostics; +using System.Reactive.Concurrency; +using System.Reactive; + +namespace Tango.PPC.Technician.Controls +{ + /// + /// Interaction logic for DispenserController.xaml + /// + public partial class DispenserController : UserControl + { + public IdsPack IdsPack + { + get { return (IdsPack)GetValue(IdsPackProperty); } + set { SetValue(IdsPackProperty, value); } + } + public static readonly DependencyProperty IdsPackProperty = + DependencyProperty.Register("IdsPack", typeof(IdsPack), typeof(DispenserController), new PropertyMetadata(null)); + + public IMachineOperator MachineOperator + { + get { return (IMachineOperator)GetValue(MachineOperatorProperty); } + set { SetValue(MachineOperatorProperty, value); } + } + public static readonly DependencyProperty MachineOperatorProperty = + DependencyProperty.Register("MachineOperator", typeof(IMachineOperator), typeof(DispenserController), new PropertyMetadata(null)); + + public bool IsHoming + { + get { return (bool)GetValue(IsHomingProperty); } + set { SetValue(IsHomingProperty, value); } + } + public static readonly DependencyProperty IsHomingProperty = + DependencyProperty.Register("IsHoming", typeof(bool), typeof(DispenserController), new PropertyMetadata(false)); + + public bool IsJogging + { + get { return (bool)GetValue(IsJoggingProperty); } + set { SetValue(IsJoggingProperty, value); } + } + public static readonly DependencyProperty IsJoggingProperty = + DependencyProperty.Register("IsJogging", typeof(bool), typeof(DispenserController), new PropertyMetadata(false)); + + public DispenserController() + { + InitializeComponent(); + + btnHome.Click += BtnHome_Click; + btnUp.RegisterForPreviewMouseOrTouchDown(OnUpButtonPressed); + btnUp.RegisterForPreviewMouseOrTouchUp(OnUpButtonReleased); + btnDown.RegisterForPreviewMouseOrTouchDown(OnDownButtonPressed); + btnDown.RegisterForPreviewMouseOrTouchUp(OnDownButtonReleased); + } + + #region Home + + private async void BtnHome_Click(object sender, RoutedEventArgs e) + { + if (!IsHoming) + { + try + { + IsHoming = true; + + MachineOperator.StartDispenserHoming(new DispenserHomingRequest() + { + Index = IdsPack.PackIndex, + Speed = numSpeed.Value, + Direction = MotorDirection.Forward + }) + .Subscribe((response) => + { + + + + }, (ex) => + { + + InvokeUI(() => IsHoming = false); + + + }, () => + { + + InvokeUI(() => IsHoming = false); + + }); + } + catch + { + IsHoming = false; + } + } + else + { + IsHoming = false; + + try + { + await MachineOperator.StopDispenserHoming(new DispenserAbortHomingRequest() + { + Index = IdsPack.PackIndex, + }); + } + catch { } + } + } + + #endregion + + #region Up + + private async void OnUpButtonPressed(object sender, MouseOrTouchEventArgs e) + { + IsJogging = true; + + + try + { + await MachineOperator.StartDispenserJogging(new DispenserJoggingRequest() + { + Index = IdsPack.PackIndex, + Direction = MotorDirection.Forward, + Speed = numSpeed.Value, + }); + } + catch { } + } + + private async void OnUpButtonReleased(object sender, MouseOrTouchEventArgs e) + { + IsJogging = false; + + try + { + await MachineOperator.StopDispenserJogging(new DispenserAbortJoggingRequest() + { + Index = IdsPack.PackIndex, + }); + } + catch { } + } + + #endregion + + #region Down + + private async void OnDownButtonPressed(object sender, MouseOrTouchEventArgs e) + { + IsJogging = true; + + try + { + await MachineOperator.StartDispenserJogging(new DispenserJoggingRequest() + { + Index = IdsPack.PackIndex, + Direction = MotorDirection.Backward, + Speed = numSpeed.Value, + }); + } + catch { } + } + + private async void OnDownButtonReleased(object sender, MouseOrTouchEventArgs e) + { + IsJogging = false; + + try + { + await MachineOperator.StopDispenserJogging(new DispenserAbortJoggingRequest() + { + Index = IdsPack.PackIndex, + }); + } + catch { } + } + + #endregion + + private void InvokeUI(Action action) + { + Dispatcher.BeginInvoke(action); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/dispensers.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/dispensers.png new file mode 100644 index 000000000..65d59b082 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/dispensers.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Models/DispenserController.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Models/DispenserController.cs new file mode 100644 index 000000000..a3ee9a613 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Models/DispenserController.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Core.Commands; +using Tango.Integration.Operation; +using Tango.PMR.Diagnostics; + +namespace Tango.PPC.Technician.Models +{ + public class DispenserController : ExtendedObject + { + private IMachineOperator _operator; + + public String Name { get; set; } + public int Index { get; set; } + + private bool _isMovingUp; + public bool IsMovingUp + { + get { return _isMovingUp; } + set { _isMovingUp = value; RaisePropertyChangedAuto(); } + } + + private bool _isMovingDown; + public bool IsMovingDown + { + get { return _isMovingDown; } + set { _isMovingDown = value; RaisePropertyChangedAuto(); } + } + + + private bool _isHoming; + public bool IsHoming + { + get { return _isHoming; } + set { _isHoming = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand MoveUpCommand { get; set; } + public RelayCommand MoveDownCommand { get; set; } + public RelayCommand HomeCommand { get; set; } + + public DispenserController(IMachineOperator machineOperator) + { + _operator = machineOperator; + } + + public DispenserController() + { + MoveUpCommand = new RelayCommand(MoveUp, () => !IsHoming && !IsMovingDown); + MoveDownCommand = new RelayCommand(MoveDown, () => !IsHoming && !IsMovingUp); + HomeCommand = new RelayCommand(Home, () => !IsMovingUp && !IsMovingDown); + } + + private void Home() + { + + } + + private void MoveDown() + { + + } + + private async void MoveUp() + { + await _operator.StartDispenserJogging(new DispenserJoggingRequest()); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj index 5b34c38a1..212ab6f16 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj @@ -37,9 +37,15 @@ ..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + ..\..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll + + + ..\..\..\packages\System.Reactive.Core.3.1.1\lib\net46\System.Reactive.Core.dll + @@ -57,6 +63,10 @@ GlobalVersionInfo.cs + + DispenserController.xaml + + Code @@ -73,11 +83,15 @@ + CatalogView.xaml + + DispensersView.xaml + LoggingView.xaml @@ -104,10 +118,18 @@ {A34EE0F0-649D-41C8-8489-B6F1CC6924EE} Tango.Core + + {4206ac58-3b57-4699-8835-90bf6db01a61} + Tango.Integration + {BC932DBD-7CDB-488C-99E4-F02CF441F55E} Tango.Logging + + {e4927038-348d-4295-aaf4-861c58cb3943} + Tango.PMR + {8491D07B-C1F6-4B62-A412-41B9FD2D6538} Tango.SharedUI @@ -116,6 +138,10 @@ {fd86424c-6e84-491b-8df9-3d0f5c236a2a} Tango.Touch + + {74e700b0-1156-4126-be40-ee450d3c3026} + Tango.Transport + {0BE74EEE-22CB-4DBA-B896-793B9E1A3AC0} Tango.PPC.Common @@ -126,10 +152,18 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -148,5 +182,8 @@ + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs index 3c6f874e0..9460578c8 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs @@ -18,6 +18,7 @@ namespace Tango.PPC.Technician TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); + TangoIOC.Default.Register(); } /// @@ -52,5 +53,16 @@ namespace Tango.PPC.Technician return TangoIOC.Default.GetInstance(); } } + + /// + /// Gets the dispensers view VM. + /// + public static DispensersViewVM DispensersViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/DispensersViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/DispensersViewVM.cs new file mode 100644 index 000000000..e72c74009 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/DispensersViewVM.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Common; + +namespace Tango.PPC.Technician.ViewModels +{ + public class DispensersViewVM : PPCViewModel + { + public override void OnApplicationStarted() + { + + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml index 79d753474..4571f99de 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml @@ -39,10 +39,10 @@ - + - Coming soon... - + Dispensers + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/DispensersView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/DispensersView.xaml new file mode 100644 index 000000000..c8fc038f1 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/DispensersView.xaml @@ -0,0 +1,41 @@ + + + + + + + + + + + + Dispensers + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/DispensersView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/DispensersView.xaml.cs new file mode 100644 index 000000000..bf5b64e8b --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/DispensersView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Technician.Views +{ + /// + /// Interaction logic for DispensersView.xaml + /// + public partial class DispensersView : UserControl + { + public DispensersView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml index 66e16588b..e697696c2 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml @@ -15,6 +15,7 @@ + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/app.config b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/app.config index 154562d23..806bfe66d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/app.config +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/app.config @@ -16,7 +16,7 @@ - + @@ -24,27 +24,27 @@ - + - + - + - + - + - + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/packages.config b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/packages.config index b3daf0d6c..865851bd7 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/packages.config +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/packages.config @@ -1,4 +1,7 @@  + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config index ea49af905..15a7107bd 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config @@ -11,6 +11,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest index d72e75011..efc5f8179 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - + diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchIconButton.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchIconButton.xaml index 36aad386b..5875b26d0 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchIconButton.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchIconButton.xaml @@ -23,6 +23,13 @@ + + + + + + + diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.xaml index 29be2dd00..b00273cf0 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.xaml @@ -88,7 +88,7 @@ - + - + diff --git a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs index 008c0759a..534d3d05d 100644 --- a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs +++ b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs @@ -333,6 +333,11 @@ namespace Tango.Transport LogManager.Log("Queuing request message: " + requestName + " Token: " + container.Token, LogCategory.Debug); LogManager.Log("Expected response: " + responseName, LogCategory.Debug); + if (State != TransportComponentState.Connected) + { + throw LogManager.Log(new InvalidOperationException($"Could not send the request while transporter state is {State}.")); + } + TaskCompletionSource source = new TaskCompletionSource(); TransportMessage message = new TransportMessage(container.Token, request, TransportMessageDirection.Request, () => container.ToByteArray(), source); @@ -407,6 +412,11 @@ namespace Tango.Transport LogManager.Log("Queuing request message: " + container.Type + " Token: " + container.Token, LogCategory.Debug); LogManager.Log("Expected response: " + responseName, LogCategory.Debug); + if (State != TransportComponentState.Connected) + { + throw LogManager.Log(new InvalidOperationException($"Could not send the request while transporter state is {State}.")); + } + TaskCompletionSource source = new TaskCompletionSource(); TransportMessage message = new TransportMessage(container.Token, container, TransportMessageDirection.Request, () => container.ToByteArray(), source); @@ -446,6 +456,11 @@ namespace Tango.Transport PendingResponse pendingResponse = null; + if (State != TransportComponentState.Connected) + { + throw LogManager.Log(new InvalidOperationException($"Could not send the response while transporter state is {State}.")); + } + LogManager.Log("Searching for matching request token: " + token, LogCategory.Debug); if (_pendingResponses.TryGetValue(token, out pendingResponse)) @@ -495,6 +510,11 @@ namespace Tango.Transport LogManager.Log("Queuing continuous request message: " + requestName + " Token: " + container.Token, LogCategory.Debug); + if (State != TransportComponentState.Connected) + { + throw LogManager.Log(new InvalidOperationException($"Could not send the request while transporter state is {State}.")); + } + Subject subject = new Subject(); LogManager.Log("Expected response: " + responseName, LogCategory.Debug); @@ -541,6 +561,11 @@ namespace Tango.Transport LogManager.Log("Queuing request message: " + typeof(Request).Name + " Token: " + request.Container.Token, LogCategory.Debug); LogManager.Log("Expected response: " + typeof(Response).Name, LogCategory.Debug); + if (State != TransportComponentState.Connected) + { + throw LogManager.Log(new InvalidOperationException($"Could not send the request while transporter state is {State}.")); + } + request.Container.Timeout = timeout.HasValue ? (UInt32)timeout.Value.TotalMilliseconds : (UInt32)RequestTimeout.TotalMilliseconds; TaskCompletionSource> source = new TaskCompletionSource>(); @@ -583,6 +608,11 @@ namespace Tango.Transport LogManager.Log("Expected response: " + typeof(Response).Name, LogCategory.Debug); + if (State != TransportComponentState.Connected) + { + throw LogManager.Log(new InvalidOperationException($"Could not send the request while transporter state is {State}.")); + } + request.Container.Continuous = true; request.Container.Completed = false; @@ -655,6 +685,11 @@ namespace Tango.Transport LogManager.Log("Queuing continuous request message: " + requestName + " Token: " + container.Token, LogCategory.Debug); + if (State != TransportComponentState.Connected) + { + throw LogManager.Log(new InvalidOperationException($"Could not send the request while transporter state is {State}.")); + } + Subject subject = new Subject(); LogManager.Log("Expected response: " + responseName, LogCategory.Debug); @@ -758,6 +793,11 @@ namespace Tango.Transport LogManager.Log("Queuing response message: " + typeof(Response).Name, LogCategory.Debug); + if (State != TransportComponentState.Connected) + { + throw LogManager.Log(new InvalidOperationException($"Could not send the response while transporter state is {State}.")); + } + PendingResponse pendingResponse = null; LogManager.Log("Searching for matching request token: " + token, LogCategory.Debug); -- cgit v1.3.1