aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2018-04-09 14:25:30 +0300
committerAvi Levkovich <avi@twine-s.com>2018-04-09 14:25:30 +0300
commite8e2f174cc7dc1e6c183e855834982d12e92833c (patch)
treeea8c5358d7e6928c513814c8619339f0c6790840 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels
parentf19e2e305d8baeafc30dde4fc0aa3fa37038869c (diff)
parentc1ed75027f069e204e52e48bfb610d2d225bbd72 (diff)
downloadTango-e8e2f174cc7dc1e6c183e855834982d12e92833c.tar.gz
Tango-e8e2f174cc7dc1e6c183e855834982d12e92833c.zip
mERGE
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/DateVM.cs22
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventDetailsViewVM.cs27
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/MainViewVM.cs84
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/TimelineEventGroup.cs28
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/TimelineViewVM.cs97
5 files changed, 221 insertions, 37 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/DateVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/DateVM.cs
deleted file mode 100644
index fd03d6328..000000000
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/DateVM.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Tango.Core;
-
-namespace Tango.MachineStudio.Logging.ViewModels
-{
- public class DateVM : ExtendedObject
- {
- public DateTime Date { get; set; }
-
- public String Description { get; set; }
-
- public DateVM(DateTime date)
- {
- Date = date;
- Description = date.ToLocalTime().ToShortDateString();
- }
- }
-}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventDetailsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventDetailsViewVM.cs
new file mode 100644
index 000000000..0e3d19748
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventDetailsViewVM.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.BL.Entities;
+using Tango.Core.Commands;
+using Tango.MachineStudio.Common.Notifications;
+using Tango.SharedUI;
+
+namespace Tango.MachineStudio.Logging.ViewModels
+{
+ public class EventDetailsViewVM : DialogViewVM
+ {
+ public MachinesEvent Event { get; set; }
+
+ public EventDetailsViewVM()
+ {
+
+ }
+
+ public EventDetailsViewVM(MachinesEvent ev) : this()
+ {
+ Event = ev;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/MainViewVM.cs
index 2b773c1c2..e5121e709 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/MainViewVM.cs
@@ -7,10 +7,13 @@ using System.Text;
using System.Threading.Tasks;
using Tango.BL;
using Tango.BL.Entities;
+using Tango.Core.Commands;
using Tango.MachineStudio.Common.EventLogging;
using Tango.MachineStudio.Common.Messages;
using Tango.MachineStudio.Common.Notifications;
using Tango.MachineStudio.Common.StudioApplication;
+using Tango.MachineStudio.Logging.Navigation;
+using Tango.MachineStudio.Logging.Views;
using Tango.SharedUI;
namespace Tango.MachineStudio.Logging.ViewModels
@@ -20,9 +23,9 @@ namespace Tango.MachineStudio.Logging.ViewModels
private INotificationProvider _notification;
private IStudioApplicationManager _application;
private IEventLogger _eventLogger;
- private DateVM _realTimeDate;
private ObservableCollection<MachinesEvent> _realTimeEvents;
private Machine _connectedMachine;
+ private LoggingNavigationManager _navigation;
private Machine _selectedMachine;
public Machine SelectedMachine
@@ -45,30 +48,68 @@ namespace Tango.MachineStudio.Logging.ViewModels
set { _selectedEvent = value; RaisePropertyChangedAuto(); OnSelectedEventChanged(); }
}
- private ObservableCollection<DateVM> _dates;
- public ObservableCollection<DateVM> Dates
+ private ObservableCollection<DateTime> _dates;
+ public ObservableCollection<DateTime> Dates
{
get { return _dates; }
set { _dates = value; RaisePropertyChangedAuto(); }
}
- private DateVM _selectedDate;
- public DateVM SelectedDate
+ private DateTime _selectedDate;
+ public DateTime SelectedDate
{
get { return _selectedDate; }
set { _selectedDate = value; RaisePropertyChangedAuto(); OnSelectedDateChanged(); }
}
- public MainViewVM(INotificationProvider notification, IEventLogger eventLogger, IStudioApplicationManager application)
+ private DateTime _minDate;
+ public DateTime MinDate
{
+ get { return _minDate; }
+ set { _minDate = value; RaisePropertyChangedAuto(); }
+ }
+
+ private DateTime _maxDate;
+ public DateTime MaxDate
+ {
+ get { return _maxDate; }
+ set { _maxDate = value; RaisePropertyChangedAuto(); }
+ }
+
+
+ private bool _isRealTime;
+ public bool IsRealTime
+ {
+ get { return _isRealTime; }
+ set { _isRealTime = value; RaisePropertyChangedAuto(); OnSelectedDateChanged(); }
+ }
+
+ private TimelineViewVM _timelineViewVM;
+
+ public TimelineViewVM TimelineViewVM
+ {
+ get { return _timelineViewVM; }
+ set { _timelineViewVM = value; RaisePropertyChangedAuto(); }
+ }
+
+ public RelayCommand<MachinesEvent> DisplayTimelineCommand { get; set; }
+
+ public RelayCommand NavigateToEventsCommand { get; set; }
+
+ public MainViewVM(INotificationProvider notification, IEventLogger eventLogger, IStudioApplicationManager application, LoggingNavigationManager navigation)
+ {
+ TimelineViewVM = new TimelineViewVM(notification);
+
+ _navigation = navigation;
_application = application;
_notification = notification;
_eventLogger = eventLogger;
- _realTimeDate = new DateVM(DateTime.Now) { Description = "Real Time" };
_realTimeEvents = new ObservableCollection<MachinesEvent>();
_eventLogger.NewLog += _eventLogger_NewLog;
RegisterMessage<MachineConnectionChangedMessage>(OnMachineConnectionChanged);
+ DisplayTimelineCommand = new RelayCommand<MachinesEvent>(DisplayTimeline);
+ NavigateToEventsCommand = new RelayCommand(() => _navigation.NavigateTo(LoggingNavigationView.EventsView));
}
private void OnMachineConnectionChanged(MachineConnectionChangedMessage msg)
@@ -88,7 +129,7 @@ namespace Tango.MachineStudio.Logging.ViewModels
{
InvokeUI(() =>
{
- _realTimeEvents.Add(machineEvent);
+ _realTimeEvents.Insert(0, machineEvent);
});
}
@@ -96,27 +137,30 @@ namespace Tango.MachineStudio.Logging.ViewModels
{
if (SelectedMachine != null)
{
- Dates = new ObservableCollection<DateVM>();
+ Dates = new ObservableCollection<DateTime>();
if (SelectedMachine == _connectedMachine)
{
- Dates.Add(_realTimeDate);
+ IsRealTime = true;
}
foreach (var day in SelectedMachine.MachinesEvents.GroupBy(x => x.DateTime.DayOfYear).Select(x => x.First().DateTime).OrderByDescending(x => x))
{
- Dates.Add(new DateVM(day));
+ Dates.Add(day);
}
+ MinDate = Dates.Min();
+ MaxDate = Dates.Max();
+
SelectedDate = Dates.FirstOrDefault();
}
}
private void OnSelectedDateChanged()
{
- if (SelectedDate != null)
+ if (SelectedDate != null && SelectedMachine != null)
{
- if (SelectedDate == _realTimeDate)
+ if (IsRealTime)
{
Events = _realTimeEvents;
}
@@ -129,10 +173,20 @@ namespace Tango.MachineStudio.Logging.ViewModels
private void OnSelectedEventChanged()
{
- if (SelectedEvent != null)
+ if (SelectedEvent != null && SelectedEvent.Type != BL.Enumerations.EventTypes.ApplicationStarted)
{
- _notification.ShowInfo(SelectedEvent.Description);
+ _notification.ShowModalDialog<EventDetailsViewVM, EventDetailsView>(new EventDetailsViewVM(SelectedEvent), (x) => { }, () => { });
}
}
+
+ private void DisplayTimeline(MachinesEvent ev)
+ {
+ var events = Events.OrderBy(x => x.DateTime).SkipWhile(x => x != ev).Skip(1).TakeWhile(x => x.DateTime > ev.DateTime && x.Type != BL.Enumerations.EventTypes.ApplicationStarted).ToObservableCollection();
+ events.Insert(0, ev);
+
+ TimelineViewVM.Initialize(events.ToList());
+
+ _navigation.NavigateTo(LoggingNavigationView.TimelineView);
+ }
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/TimelineEventGroup.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/TimelineEventGroup.cs
new file mode 100644
index 000000000..978348fd2
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/TimelineEventGroup.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.BL.Entities;
+using Tango.Core;
+
+namespace Tango.MachineStudio.Logging.ViewModels
+{
+ public class TimelineEventGroup : ExtendedObject
+ {
+ public String Name { get; set; }
+
+ public ObservableCollection<MachinesEvent> Events { get; set; }
+
+ public TimelineEventGroup()
+ {
+ Events = new ObservableCollection<MachinesEvent>();
+ }
+
+ public TimelineEventGroup(String name) : this()
+ {
+ Name = name;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/TimelineViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/TimelineViewVM.cs
new file mode 100644
index 000000000..edf53bbd2
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/TimelineViewVM.cs
@@ -0,0 +1,97 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.BL.Entities;
+using Tango.Core.Commands;
+using Tango.MachineStudio.Common.Notifications;
+using Tango.MachineStudio.Logging.Views;
+using Tango.SharedUI;
+
+namespace Tango.MachineStudio.Logging.ViewModels
+{
+ public class TimelineViewVM : ViewModel
+ {
+ private ObservableCollection<TimelineEventGroup> _timelineEventGroups;
+ public ObservableCollection<TimelineEventGroup> TimelineEventGroups
+ {
+ get { return _timelineEventGroups; }
+ set { _timelineEventGroups = value; RaisePropertyChangedAuto(); }
+ }
+
+ private TimeSpan _timelineMaxTime;
+ public TimeSpan TimelineMaxTime
+ {
+ get { return _timelineMaxTime; }
+ set { _timelineMaxTime = value; RaisePropertyChangedAuto(); }
+ }
+
+ private double _timelineScaleFactor;
+ public double TimelineScaleFactor
+ {
+ get { return _timelineScaleFactor; }
+ set
+ {
+
+ if (value < 0.1) value = 0.1;
+
+ _timelineScaleFactor = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private TimeSpan _currentPosition;
+
+ public TimeSpan CurrentPosition
+ {
+ get { return _currentPosition; }
+ set { _currentPosition = value; RaisePropertyChangedAuto(); }
+ }
+
+ private bool _enableTimeMarker;
+
+ public bool EnableTimeMarker
+ {
+ get { return _enableTimeMarker; }
+ set { _enableTimeMarker = value; RaisePropertyChangedAuto(); }
+ }
+
+ public RelayCommand<MachinesEvent> EventSelectedCommand { get; set; }
+
+
+ public TimelineViewVM(INotificationProvider notification)
+ {
+ TimelineScaleFactor = 10;
+ TimelineEventGroups = new ObservableCollection<TimelineEventGroup>();
+
+ EventSelectedCommand = new RelayCommand<MachinesEvent>((ev) =>
+ {
+ notification.ShowModalDialog<EventDetailsViewVM, EventDetailsView>(new EventDetailsViewVM(ev), (x) => { }, () => { });
+ });
+ }
+
+ public void Initialize(List<MachinesEvent> events)
+ {
+ TimelineEventGroups = new ObservableCollection<TimelineEventGroup>();
+
+ if (events != null && events.Count > 0)
+ {
+ foreach (var group in events.GroupBy(x => x.Group))
+ {
+ TimelineEventGroup evGroup = new TimelineEventGroup(group.Key.ToString().ToWords());
+
+ foreach (var e in group)
+ {
+ evGroup.Events.Add(e);
+ }
+
+ TimelineEventGroups.Add(evGroup);
+ }
+
+ TimelineMaxTime = events.Max(x => x.DateTime) - events.Min(x => x.DateTime);
+ }
+ }
+ }
+}