diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs index 52925ee59..d4bdfb7b2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Threading; using System.Xml.Serialization; using Tango.BL.Entities; using Tango.Core.Commands; @@ -19,6 +20,12 @@ namespace Tango.MachineStudio.Technician.TechItems [TechItem(5)] public class MultiGraphItem : TechItem { + private DispatcherTimer _timer; + private DateTime _recording_start_time; + + public event Action RecordingStarted; + public event Action RecordingStopped; + private TechMonitor _techMonitor; /// <summary> /// Gets or sets the db tech monitor. @@ -111,14 +118,40 @@ namespace Tango.MachineStudio.Technician.TechItems } } + private bool _isRecording; + /// <summary> + /// Gets or sets a value indicating whether this instance is recording. + /// </summary> + [XmlIgnore] + public bool IsRecording + { + get { return _isRecording; } + set { _isRecording = value; RaisePropertyChangedAuto(); } + } + + private TimeSpan _recordingTime; + [XmlIgnore] + public TimeSpan RecordingTime + { + get { return _recordingTime; } + set { _recordingTime = value; RaisePropertyChangedAuto(); } + } + [XmlIgnore] public RelayCommand ClearCommand { get; set; } + [XmlIgnore] + public RelayCommand ToggleRecordingCommand { get; set; } + /// <summary> /// Initializes a new instance of the <see cref="MultiGraphItem"/> class. /// </summary> public MultiGraphItem() : base() { + _timer = new DispatcherTimer(); + _timer.Tick += _timer_Tick; + _timer.Interval = TimeSpan.FromSeconds(1); + Max = 100; Name = "Multi Channel Graph"; Description = "Multi channel real-time graph"; @@ -131,6 +164,31 @@ namespace Tango.MachineStudio.Technician.TechItems Editor.InnerGraph.Controller.Clear(); } }); + + ToggleRecordingCommand = new RelayCommand(ToggleRecording); + } + + private void _timer_Tick(object sender, EventArgs e) + { + RecordingTime = DateTime.Now - _recording_start_time; + } + + private void ToggleRecording() + { + if (!IsRecording) + { + _recording_start_time = DateTime.Now; + IsRecording = true; + _timer.Start(); + RecordingStarted?.Invoke(); + } + else + { + _timer.Stop(); + IsRecording = false; + RecordingTime = TimeSpan.FromSeconds(0); + RecordingStopped?.Invoke(); + } } /// <summary> |
