aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels
diff options
context:
space:
mode:
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/MainViewVM.cs115
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/TimelineEventGroup.cs28
3 files changed, 129 insertions, 36 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/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/MainViewVM.cs
index 2b773c1c2..81b0a587c 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,12 @@ 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.SharedUI;
namespace Tango.MachineStudio.Logging.ViewModels
@@ -20,9 +22,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 +47,88 @@ 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 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();
+ }
+ }
+
+ public RelayCommand<MachinesEvent> DisplayTimelineCommand { get; set; }
+
+ public RelayCommand NavigateToEventsCommand { get; set; }
+
+ public MainViewVM(INotificationProvider notification, IEventLogger eventLogger, IStudioApplicationManager application, LoggingNavigationManager navigation)
+ {
+ _navigation = navigation;
_application = application;
_notification = notification;
_eventLogger = eventLogger;
- _realTimeDate = new DateVM(DateTime.Now) { Description = "Real Time" };
_realTimeEvents = new ObservableCollection<MachinesEvent>();
_eventLogger.NewLog += _eventLogger_NewLog;
+ TimelineScaleFactor = 10;
+
RegisterMessage<MachineConnectionChangedMessage>(OnMachineConnectionChanged);
+ DisplayTimelineCommand = new RelayCommand<MachinesEvent>(DisplayTimeline);
+ NavigateToEventsCommand = new RelayCommand(() => _navigation.NavigateTo(LoggingNavigationView.EventsView));
}
private void OnMachineConnectionChanged(MachineConnectionChangedMessage msg)
@@ -88,7 +148,7 @@ namespace Tango.MachineStudio.Logging.ViewModels
{
InvokeUI(() =>
{
- _realTimeEvents.Add(machineEvent);
+ _realTimeEvents.Insert(0, machineEvent);
});
}
@@ -96,27 +156,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 +192,34 @@ namespace Tango.MachineStudio.Logging.ViewModels
private void OnSelectedEventChanged()
{
- if (SelectedEvent != null)
+ if (SelectedEvent != null && SelectedEvent.Type != BL.Enumerations.EventTypes.ApplicationStarted)
{
_notification.ShowInfo(SelectedEvent.Description);
}
}
+
+ 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);
+
+ TimelineEventGroups = new ObservableCollection<TimelineEventGroup>();
+
+ 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);
+
+ _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;
+ }
+ }
+}