aboutsummaryrefslogtreecommitdiffstats
path: root/Software
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-02-11 16:09:12 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-02-11 16:09:12 +0200
commit29ac4ab17bdc882f0f85666cb82320ca8075ba95 (patch)
tree2879ff2c8c68bd6685a59ca25e91beb4c6f76e8f /Software
parent08686cebb5b2e517cd356bc33d79205d8fcc8d66 (diff)
downloadTango-29ac4ab17bdc882f0f85666cb82320ca8075ba95.tar.gz
Tango-29ac4ab17bdc882f0f85666cb82320ca8075ba95.zip
Implemented TechBoard "New Project" properly.
Changed MS => PPC default intent to Diagnostics. Implemented producer/consumer queue for NavigationControl. Fixed issue with empty points pushed to RealTimerGraphX. Implemented ExternalBridgeService pinging to keep connection. Fixed issue with Firmware upgrade DFU upload failure, now fails all transport components.
Diffstat (limited to 'Software')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs220
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs2
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj2
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml.cs6
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest2
-rw-r--r--Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphController.cs13
-rw-r--r--Software/Visual_Studio/Tango.BL/ObservablesStaticCollections.cs2
-rw-r--r--Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs27
-rw-r--r--Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs20
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs260
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Hubs/ExternalBridgeHub.cs5
11 files changed, 362 insertions, 197 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs
index ac54a714a..36f7940ed 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs
@@ -499,7 +499,11 @@ namespace Tango.MachineStudio.Technician.ViewModels
if (prop != null)
{
var points = GetDataArray(techMonitor, prop.GetValue(data.Monitors));
- sr.PushData(points, delta_base, delta);
+
+ if (points.Count > 0)
+ {
+ sr.PushData(points, delta_base, delta);
+ }
}
}
@@ -512,15 +516,20 @@ namespace Tango.MachineStudio.Technician.ViewModels
if (prop != null)
{
var points = GetDataMatrix(techMonitor, prop.GetValue(data.Monitors));
- mr.PushData(points, delta_base, delta);
+ if (points.Count > 0)
+ {
+ mr.PushData(points, delta_base, delta);
+ }
}
}
lock (_elementsLock)
{
var elements = Tabs.SelectMany(x => x.Elements).ToList();
+ var selectedTabElements = SelectedTab.Elements.ToList();
- foreach (var item in elements.Select(x => x.HostedElement as TechItem))
+ //Can be updated only when visible
+ foreach (var item in selectedTabElements.Select(x => x.HostedElement as TechItem))
{
if (item.GetType() == typeof(MonitorItem))
{
@@ -550,7 +559,79 @@ namespace Tango.MachineStudio.Technician.ViewModels
}
}
}
- else if (item.GetType() == typeof(SingleGraphItem))
+ else if (item.GetType() == typeof(DigitalOutItem))
+ {
+ DigitalOutItem digitalOutItem = item as DigitalOutItem;
+
+ var digitalPin = data.DigitalInterfaceStates.SingleOrDefault(x => x.InterfaceIO == (InterfaceIOs)digitalOutItem.TechIo.Code);
+
+ if (digitalPin != null)
+ {
+ digitalOutItem.EffectiveValue = digitalPin.Value;
+ }
+ }
+ else if (item.GetType() == typeof(DigitalInItem))
+ {
+ DigitalInItem digitalInItem = item as DigitalInItem;
+
+ var digitalPin = data.DigitalInterfaceStates.SingleOrDefault(x => x.InterfaceIO == (InterfaceIOs)digitalInItem.TechIo.Code);
+
+ if (digitalPin != null)
+ {
+ digitalInItem.Value = digitalPin.Value;
+ }
+ }
+ else if (item.GetType() == typeof(HeaterItem))
+ {
+ HeaterItem heaterItem = item as HeaterItem;
+
+ var heaterState = data.HeatersStates.SingleOrDefault(x => x.HeaterType == (HeaterType)heaterItem.TechHeater.Code);
+
+ if (heaterState != null)
+ {
+ heaterItem.HeaterState = heaterState;
+ }
+ }
+ else if (item.GetType() == typeof(ValveItem))
+ {
+ ValveItem valveItem = item as ValveItem;
+
+ var valveState = data.ValvesStates.SingleOrDefault(x => x.ValveType == (ValveType)valveItem.TechValve.Code);
+
+ if (valveState != null)
+ {
+ valveItem.EffectiveState = valveState.State;
+ }
+ }
+ else if (item.GetType() == typeof(BlowerItem))
+ {
+ BlowerItem blowerItem = item as BlowerItem;
+
+ if (data.Monitors.BlowerVoltage.Count > 0)
+ {
+ blowerItem.EffectiveActive = data.Monitors.BlowerVoltage.Last() > 0;
+ }
+ }
+ else if (item.GetType() == typeof(ControllerItem))
+ {
+ ControllerItem controllerItem = item as ControllerItem;
+
+ if (DateTime.Now > controllerItem.LastUpdateTime.AddMilliseconds(controllerItem.UpdateInterval))
+ {
+ var componentState = data.ComponentsStates.SingleOrDefault(x => (int)x.Component == controllerItem.TechController.Code);
+
+ if (componentState != null)
+ {
+ controllerItem.EffectiveValue = componentState.Value;
+ }
+ }
+ }
+ }
+
+ //Must be updated all the time.
+ foreach (var item in elements.Select(x => x.HostedElement as TechItem))
+ {
+ if (item.GetType() == typeof(SingleGraphItem))
{
SingleGraphItem graphItem = item as SingleGraphItem;
@@ -564,20 +645,23 @@ namespace Tango.MachineStudio.Technician.ViewModels
{
var points = GetDataArray(graphItem.TechMonitor, prop.GetValue(data.Monitors));
- List<TimeSpanDataPoint> times = new List<TimeSpanDataPoint>();
- var dPoints = points.Select(x => new DoubleDataPoint(x)).ToList();
-
- for (int i = 0; i < points.Count; i++)
+ if (points.Count > 0)
{
- times.Add(delta_base.Add(TimeSpan.FromMilliseconds((delta_mili / points.Count) * i)));
- }
+ List<TimeSpanDataPoint> times = new List<TimeSpanDataPoint>();
+ var dPoints = points.Select(x => new DoubleDataPoint(x)).ToList();
- controller.PushData(times, dPoints);
+ for (int i = 0; i < points.Count; i++)
+ {
+ times.Add(delta_base.Add(TimeSpan.FromMilliseconds((delta_mili / points.Count) * i)));
+ }
- var _graph_recording = _single_graphs_recordings.SingleOrDefault(x => x.Tag == graphItem);
- if (_graph_recording != null)
- {
- _graph_recording.PushData(points, delta_base, delta);
+ controller.PushData(times, dPoints);
+
+ var _graph_recording = _single_graphs_recordings.SingleOrDefault(x => x.Tag == graphItem);
+ if (_graph_recording != null)
+ {
+ _graph_recording.PushData(points, delta_base, delta);
+ }
}
}
}
@@ -640,73 +724,6 @@ namespace Tango.MachineStudio.Technician.ViewModels
}
}
}
- else if (item.GetType() == typeof(DigitalOutItem))
- {
- DigitalOutItem digitalOutItem = item as DigitalOutItem;
-
- var digitalPin = data.DigitalInterfaceStates.SingleOrDefault(x => x.InterfaceIO == (InterfaceIOs)digitalOutItem.TechIo.Code);
-
- if (digitalPin != null)
- {
- digitalOutItem.EffectiveValue = digitalPin.Value;
- }
- }
- else if (item.GetType() == typeof(DigitalInItem))
- {
- DigitalInItem digitalInItem = item as DigitalInItem;
-
- var digitalPin = data.DigitalInterfaceStates.SingleOrDefault(x => x.InterfaceIO == (InterfaceIOs)digitalInItem.TechIo.Code);
-
- if (digitalPin != null)
- {
- digitalInItem.Value = digitalPin.Value;
- }
- }
- else if (item.GetType() == typeof(HeaterItem))
- {
- HeaterItem heaterItem = item as HeaterItem;
-
- var heaterState = data.HeatersStates.SingleOrDefault(x => x.HeaterType == (HeaterType)heaterItem.TechHeater.Code);
-
- if (heaterState != null)
- {
- heaterItem.HeaterState = heaterState;
- }
- }
- else if (item.GetType() == typeof(ValveItem))
- {
- ValveItem valveItem = item as ValveItem;
-
- var valveState = data.ValvesStates.SingleOrDefault(x => x.ValveType == (ValveType)valveItem.TechValve.Code);
-
- if (valveState != null)
- {
- valveItem.EffectiveState = valveState.State;
- }
- }
- else if (item.GetType() == typeof(BlowerItem))
- {
- BlowerItem blowerItem = item as BlowerItem;
-
- if (data.Monitors.BlowerVoltage.Count > 0)
- {
- blowerItem.EffectiveActive = data.Monitors.BlowerVoltage.Last() > 0;
- }
- }
- else if (item.GetType() == typeof(ControllerItem))
- {
- ControllerItem controllerItem = item as ControllerItem;
-
- if (DateTime.Now > controllerItem.LastUpdateTime.AddMilliseconds(controllerItem.UpdateInterval))
- {
- var componentState = data.ComponentsStates.SingleOrDefault(x => (int)x.Component == controllerItem.TechController.Code);
-
- if (componentState != null)
- {
- controllerItem.EffectiveValue = componentState.Value;
- }
- }
- }
}
}
}
@@ -2117,16 +2134,41 @@ namespace Tango.MachineStudio.Technician.ViewModels
{
var to_remove = Tabs.ToList();
- if (AddNewTab())
+ var name = _notification.ShowTextInput("Enter project name", "Project Name", "untitled");
+
+ if (String.IsNullOrWhiteSpace(name))
{
- _singleControllers.Clear();
- _multiControllers.Clear();
+ return;
+ }
- foreach (var tab in to_remove)
- {
- Tabs.Remove(tab);
- }
+ SaveFileDialog dlg = new SaveFileDialog();
+ dlg.Title = "Select Technician Project Location";
+ dlg.Filter = "Technician Project File|*.tpf";
+ dlg.DefaultExt = ".tpf";
+ dlg.FileName = name;
+
+ if (!dlg.ShowDialog().Value)
+ {
+ return;
+ }
+
+ _singleControllers.Clear();
+ _multiControllers.Clear();
+ _multi_graph_recordings.Clear();
+ _multi_monitors_recordings.Clear();
+ _single_graphs_recordings.Clear();
+ _single_monitors_recordings.Clear();
+
+ foreach (var tab in to_remove)
+ {
+ Tabs.Remove(tab);
}
+
+ AddNewTab(name);
+
+ _lastTechProjectFile = dlg.FileName;
+ File.AppendAllText(_lastTechProjectFile, "");
+ SaveProject();
}
/// <summary>
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs
index 7584617ed..9bee35697 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs
@@ -41,7 +41,7 @@ namespace Tango.MachineStudio.UI.ViewModels
/// </summary>
public MachineLoginViewVM()
{
- Intent = ExternalBridgeLoginIntent.FullControl;
+ Intent = ExternalBridgeLoginIntent.Diagnostics;
LoginCommand = new RelayCommand<string>(Login);
CancelCommand = new RelayCommand(Cancel);
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj
index 6eda39722..7142f461b 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj
@@ -421,7 +421,7 @@
</Target>
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
+ <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml.cs
index f63899932..13a605774 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -37,7 +38,10 @@ namespace Tango.PPC.UI.Views
navigationControl.NavigateTo(view.ToString(), () =>
{
- source.SetResult(new object());
+ if (!source.Task.IsCompleted)
+ {
+ source.SetResult(new object());
+ }
});
return source.Task;
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.
-->
- <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
+ <!--<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />-->
</requestedPrivileges>
</security>
</trustInfo>
diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphController.cs b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphController.cs
index 0331ab3eb..4934a9013 100644
--- a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphController.cs
+++ b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphController.cs
@@ -249,8 +249,16 @@ namespace RealTimeGraphX
GraphDataPoint min_y = _range.MinimumY;
GraphDataPoint max_y = _range.MaximumY;
- min_x = _to_render.First().Value.XX.First();
- max_x = _to_render.First().Value.XX.Last();
+ if (_to_render.Count > 0 && _to_render.First().Value.XX.Count > 0)
+ {
+ min_x = _to_render.First().Value.XX.First();
+ max_x = _to_render.First().Value.XX.Last();
+ }
+ else
+ {
+ Thread.Sleep(RefreshRate);
+ continue;
+ }
if (_range.AutoY)
{
@@ -342,6 +350,7 @@ namespace RealTimeGraphX
catch (Exception ex)
{
Debug.WriteLine($"Error in RealTimeGraphX:\n{ex.ToString()}");
+ Thread.Sleep(RefreshRate);
}
}
else
diff --git a/Software/Visual_Studio/Tango.BL/ObservablesStaticCollections.cs b/Software/Visual_Studio/Tango.BL/ObservablesStaticCollections.cs
index c12b622a4..241e33bd4 100644
--- a/Software/Visual_Studio/Tango.BL/ObservablesStaticCollections.cs
+++ b/Software/Visual_Studio/Tango.BL/ObservablesStaticCollections.cs
@@ -67,7 +67,7 @@ namespace Tango.BL
progressLog?.Invoke("Loading spools...");
SpoolTypes = db.SpoolTypes.ToObservableCollection();
- progressLog?.Invoke("Loading event...");
+ progressLog?.Invoke("Loading events...");
EventTypes = db.EventTypes.ToObservableCollection();
progressLog?.Invoke("Loading blowers...");
diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs
index 312143c57..4395b5f41 100644
--- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs
+++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs
@@ -26,6 +26,7 @@ using Tango.Core;
using Microsoft.AspNet.SignalR.Client;
using Tango.Integration.ExternalBridge.Web;
using Tango.Core.Threading;
+using System.Diagnostics;
namespace Tango.Integration.ExternalBridge
{
@@ -39,6 +40,7 @@ namespace Tango.Integration.ExternalBridge
private HubConnection _connection;
private IHubProxy _proxy;
private bool _isSignalRConnected;
+ private System.Timers.Timer _signalrPingTimer;
#region Events
@@ -447,6 +449,13 @@ namespace Tango.Integration.ExternalBridge
});
_isSignalRConnected = true;
+
+ if (_signalrPingTimer == null)
+ {
+ _signalrPingTimer = new System.Timers.Timer(TimeSpan.FromMinutes(5).TotalMilliseconds);
+ _signalrPingTimer.Elapsed += _signalrPingTimer_Elapsed;
+ _signalrPingTimer.Start();
+ }
}
catch (Exception ex)
{
@@ -478,6 +487,24 @@ namespace Tango.Integration.ExternalBridge
}
}
+ private async void _signalrPingTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
+ {
+ if (Enabled && SignalRConfiguration.Enabled)
+ {
+ if (_proxy != null)
+ {
+ try
+ {
+ var result = await _proxy.Invoke<String>("Ping");
+ }
+ catch
+ {
+ Debug.WriteLine("Error pinging to machine service via SignalR.");
+ }
+ }
+ }
+ }
+
/// <summary>
/// Stops this instance.
/// </summary>
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
index 9db3f17e2..80ba87ce1 100644
--- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
+++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
@@ -1893,7 +1893,7 @@ namespace Tango.Integration.Operation
{
liquidQuantities.Add(pack.PackIndex, 0);
}
-
+
bool stop_calc = false;
for (int segmentIndex = 0; segmentIndex < effectiveSegments.Count && !stop_calc; segmentIndex++)
@@ -1945,7 +1945,8 @@ namespace Tango.Integration.Operation
{
brush_length_centimeters = position_cm - total_length;
stop_calc = true;
- } }
+ }
+ }
prev_offset_cm = brush_offset_cm;
@@ -3424,8 +3425,19 @@ namespace Tango.Integration.Operation
MachineEventsStateProvider.Reset();
}
- LogManager.Log("Upgrading...");
- upgradeManager.PerformUpgrade(data).Wait();
+ try
+ {
+ LogManager.Log("Upgrading...");
+ upgradeManager.PerformUpgrade(data).Wait();
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log("Firmware upgrade failed while doing DFU upload. We need to destroy the whole transport layer.", LogCategory.Error);
+ Status = MachineStatuses.Disconnected;
+ upgradeHandler.RaiseFailed(ex);
+ OnFailed(ex);
+ return;
+ }
LogManager.Log("Waiting for the device...");
upgradeHandler.RaiseProgress(100, FirmwareUpgradeStatus.Upgrading, "Waiting for the device...");
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs
index 89427e1ed..64e2dbf84 100644
--- a/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs
+++ b/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
@@ -12,6 +13,7 @@ using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Threading;
+using Tango.Core;
using Tango.SharedUI.Helpers;
namespace Tango.SharedUI.Controls
@@ -19,7 +21,15 @@ namespace Tango.SharedUI.Controls
[ContentProperty(nameof(Elements))]
public class NavigationControl : UserControl
{
- private Action _onCompleted;
+ private event Action NavigationCompleted;
+ private Thread _navigationThread;
+ private ProducerConsumerQueue<NavigationQueueItem> _navigationQueue;
+
+ private class NavigationQueueItem
+ {
+ public NavigationElement FromElement { get; set; }
+ public NavigationElement ToElement { get; set; }
+ }
#region Transition Types
@@ -296,6 +306,11 @@ namespace Tango.SharedUI.Controls
Content = _grid;
Elements = new ObservableCollection<FrameworkElement>();
Loaded += NavigationControl_Loaded;
+
+ _navigationQueue = new ProducerConsumerQueue<NavigationQueueItem>();
+ _navigationThread = new Thread(NavigationThread);
+ _navigationThread.IsBackground = true;
+ _navigationThread.Start();
}
#endregion
@@ -409,135 +424,174 @@ namespace Tango.SharedUI.Controls
private void Navigate(NavigationElement fromElement, NavigationElement toElement)
{
- if (toElement == null || toElement == fromElement)
+ _navigationQueue.BlockEnqueue(new NavigationQueueItem()
{
- _onCompleted?.Invoke();
- }
+ FromElement = fromElement,
+ ToElement = toElement,
+ });
+ }
- if (fromElement != null)
+ private void NavigationThread()
+ {
+ while (true)
{
- DoubleAnimation toAnimation = new DoubleAnimation();
- toAnimation.Duration = TransitionDuration;
+ var item = _navigationQueue.BlockDequeue();
- DoubleAnimation fromAnimation = new DoubleAnimation();
- fromAnimation.Duration = TransitionDuration;
+ var navigationCompleted = false;
- int fromIndex = Elements.IndexOf(fromElement.Element);
- int toIndex = Elements.IndexOf(toElement.Element);
+ NavigationElement fromElement = item.FromElement;
+ NavigationElement toElement = item.ToElement;
- fromElement.Reset();
- toElement.Reset();
-
- fromAnimation.Completed += (_, __) =>
+ Dispatcher.BeginInvoke(new Action(() =>
{
- fromElement.Deactivate(!KeepElementsAttached);
- };
-
- bool completed = false;
+ if (toElement == null || toElement == fromElement)
+ {
+ //navigationCompleted = true;
+ Debug.WriteLine("NavigationControl: THIS MIGHT CAUSE PROBLEMS !!");
+ }
- toAnimation.Completed += (_, __) =>
- {
- if (!completed)
+ if (fromElement != null)
{
- completed = true;
+ DoubleAnimation toAnimation = new DoubleAnimation();
+ toAnimation.Duration = TransitionDuration;
+
+ DoubleAnimation fromAnimation = new DoubleAnimation();
+ fromAnimation.Duration = TransitionDuration;
+
+ int fromIndex = Elements.IndexOf(fromElement.Element);
+ int toIndex = Elements.IndexOf(toElement.Element);
- INavigationView fromNavigationView = fromElement.Element as INavigationView;
- INavigationView toNavigationView = toElement.Element as INavigationView;
+ fromElement.Reset();
+ toElement.Reset();
- if (fromNavigationView != null)
+ fromAnimation.Completed += (_, __) =>
{
- fromNavigationView.OnNavigatedFrom();
- }
- if (toNavigationView != null)
+ fromElement.Deactivate(!KeepElementsAttached);
+ };
+
+ bool completed = false;
+
+ toAnimation.Completed += (_, __) =>
{
- toNavigationView.OnNavigatedTo();
- }
+ if (!completed)
+ {
+ completed = true;
- INavigationViewModel fromVM = fromElement.Element.DataContext as INavigationViewModel;
- INavigationViewModel toVM = toElement.Element.DataContext as INavigationViewModel;
+ INavigationView fromNavigationView = fromElement.Element as INavigationView;
+ INavigationView toNavigationView = toElement.Element as INavigationView;
- if (fromVM != null && fromVM != toVM) fromVM.OnNavigatedFrom();
- if (toVM != null) toVM.OnNavigatedTo();
+ if (fromNavigationView != null)
+ {
+ fromNavigationView.OnNavigatedFrom();
+ }
+ if (toNavigationView != null)
+ {
+ toNavigationView.OnNavigatedTo();
+ }
- _onCompleted?.Invoke();
- }
- };
+ INavigationViewModel fromVM = fromElement.Element.DataContext as INavigationViewModel;
+ INavigationViewModel toVM = toElement.Element.DataContext as INavigationViewModel;
- switch (TransitionType)
- {
- case TransitionTypes.Fade:
- fromAnimation.From = 1;
- fromAnimation.To = 0;
+ if (fromVM != null && fromVM != toVM) fromVM.OnNavigatedFrom();
+ if (toVM != null) toVM.OnNavigatedTo();
- toAnimation.From = 0;
- toAnimation.To = 1;
+ navigationCompleted = true;
+ }
+ };
- fromElement.AnimateOpacity(fromAnimation);
- toElement.AnimateOpacity(toAnimation);
+ switch (TransitionType)
+ {
+ case TransitionTypes.Fade:
+ fromAnimation.From = 1;
+ fromAnimation.To = 0;
- break;
- case TransitionTypes.Zoom:
- fromAnimation.From = 1;
- fromAnimation.To = 0;
+ toAnimation.From = 0;
+ toAnimation.To = 1;
- toAnimation.From = 0;
- toAnimation.To = 1;
+ fromElement.AnimateOpacity(fromAnimation);
+ toElement.AnimateOpacity(toAnimation);
- fromElement.AnimateScale(fromAnimation);
- toElement.AnimateScale(toAnimation);
+ break;
+ case TransitionTypes.Zoom:
+ fromAnimation.From = 1;
+ fromAnimation.To = 0;
- break;
- case TransitionTypes.Slide:
+ toAnimation.From = 0;
+ toAnimation.To = 1;
- if (toIndex > fromIndex)
- {
- fromAnimation.From = 0;
- fromAnimation.To = -ActualWidth;
+ fromElement.AnimateScale(fromAnimation);
+ toElement.AnimateScale(toAnimation);
+
+ break;
+ case TransitionTypes.Slide:
+
+ if (toIndex > fromIndex)
+ {
+ fromAnimation.From = 0;
+ fromAnimation.To = -ActualWidth;
- toAnimation.From = ActualWidth;
- toAnimation.To = 0;
+ toAnimation.From = ActualWidth;
+ toAnimation.To = 0;
+ }
+ else
+ {
+ fromAnimation.From = 0;
+ fromAnimation.To = ActualWidth;
+
+ toAnimation.From = -ActualWidth;
+ toAnimation.To = 0;
+ }
+
+ fromElement.AnimateTranslateX(fromAnimation);
+ toElement.AnimateTranslateX(toAnimation);
+
+ break;
}
- else
+
+ if (TransitionAlwaysFades && TransitionType != TransitionTypes.Fade)
{
- fromAnimation.From = 0;
- fromAnimation.To = ActualWidth;
+ DoubleAnimation fromFadeAnimation = new DoubleAnimation();
+ fromFadeAnimation.From = 1;
+ fromFadeAnimation.To = 0;
+ fromFadeAnimation.Duration = TransitionDuration;
- toAnimation.From = -ActualWidth;
- toAnimation.To = 0;
- }
+ DoubleAnimation toFadeAnimation = new DoubleAnimation();
+ toFadeAnimation.From = 0;
+ toFadeAnimation.To = 1;
+ toFadeAnimation.Duration = TransitionDuration;
- fromElement.AnimateTranslateX(fromAnimation);
- toElement.AnimateTranslateX(toAnimation);
+ fromElement.AnimateOpacity(fromFadeAnimation);
+ toElement.AnimateOpacity(toFadeAnimation);
+ }
- break;
- }
+ fromElement.Activate();
+ toElement.Activate();
+ }
+ else
+ {
+ toElement.Activate();
+ toElement.Reset();
- if (TransitionAlwaysFades && TransitionType != TransitionTypes.Fade)
- {
- DoubleAnimation fromFadeAnimation = new DoubleAnimation();
- fromFadeAnimation.From = 1;
- fromFadeAnimation.To = 0;
- fromFadeAnimation.Duration = TransitionDuration;
+ INavigationViewModel toVM = toElement.Element.DataContext as INavigationViewModel;
+ if (toVM != null) toVM.OnNavigatedTo();
- DoubleAnimation toFadeAnimation = new DoubleAnimation();
- toFadeAnimation.From = 0;
- toFadeAnimation.To = 1;
- toFadeAnimation.Duration = TransitionDuration;
+ navigationCompleted = true;
+ }
+ }));
- fromElement.AnimateOpacity(fromFadeAnimation);
- toElement.AnimateOpacity(toFadeAnimation);
+ for (int i = 0; i < 30; i++)
+ {
+ if (navigationCompleted)
+ {
+ break;
+ }
+ Thread.Sleep(100);
}
- fromElement.Activate();
- toElement.Activate();
- }
- else
- {
- toElement.Activate();
- toElement.Reset();
-
- INavigationViewModel toVM = toElement.Element.DataContext as INavigationViewModel;
- if (toVM != null) toVM.OnNavigatedTo();
+ Dispatcher.BeginInvoke(new Action(() =>
+ {
+ NavigationCompleted?.Invoke();
+ }));
}
}
@@ -571,7 +625,19 @@ namespace Tango.SharedUI.Controls
public FrameworkElement NavigateTo(String navigationName, Action onCompleted = null)
{
- _onCompleted = onCompleted;
+ Action completed = null;
+
+ completed = () =>
+ {
+ try
+ {
+ onCompleted?.Invoke();
+ }
+ catch { }
+ NavigationCompleted -= completed;
+ };
+
+ NavigationCompleted += completed;
var element = Elements.SingleOrDefault(x => GetNavigationName(x) == navigationName || x.GetType().Name == navigationName);
@@ -586,7 +652,7 @@ namespace Tango.SharedUI.Controls
if (SelectedElement == element)
{
await Task.Delay((int)TransitionDuration.TimeSpan.TotalMilliseconds * 2);
- _onCompleted?.Invoke();
+ NavigationCompleted?.Invoke();
}
else
{
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Hubs/ExternalBridgeHub.cs b/Software/Visual_Studio/Web/Tango.MachineService/Hubs/ExternalBridgeHub.cs
index a09cd7954..4dd04d33e 100644
--- a/Software/Visual_Studio/Web/Tango.MachineService/Hubs/ExternalBridgeHub.cs
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Hubs/ExternalBridgeHub.cs
@@ -56,6 +56,11 @@ namespace Tango.MachineService.Hubs
_sessions.RemoveAll(x => x.ExternalBridge.ConnectionID == Context.ConnectionId);
}
+ public String Ping()
+ {
+ return "Ping";
+ }
+
public List<MachineInfo> GetAvailableMachines()
{
return _externalBridges.Select(x => x.MachineInfo).ToList();