aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs178
1 files changed, 169 insertions, 9 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs
index 68c0f1867..653c2368f 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs
@@ -20,11 +20,27 @@ using System.Timers;
using System.Windows.Threading;
using System.Diagnostics;
using Tango.PMR.Printing;
+using System.ComponentModel;
+using RealTimeGraphX.WPF;
+using RealTimeGraphX.DataPoints;
+using Tango.PPC.UI.Graphs;
namespace Tango.PPC.UI.ViewModels
{
public class MachineStatusViewVM : PPCViewModel
{
+ public enum StatisticTab
+ {
+ [Description("Production Data")]
+ Productiondata = 0,
+ [Description("Temperature")]
+ Temperature = 1,
+ [Description("Pressure")]
+ Pressure = 2,
+ [Description("Motor")]
+ Motor = 3
+ }
+
#region Properties
[TangoInject]
@@ -186,6 +202,13 @@ namespace Tango.PPC.UI.ViewModels
set { _midTankLevels = value; RaisePropertyChangedAuto(); }
}
+ private JerricanLevelModel _midTankLubLevel;
+ public JerricanLevelModel MidTankLubLevel
+ {
+ get { return _midTankLubLevel; }
+ set { _midTankLubLevel = value; RaisePropertyChangedAuto(); }
+ }
+
public MachineOverviewModel OverviewModel { get; set; }
private bool _isDisplayJobOutline;
@@ -210,6 +233,81 @@ namespace Tango.PPC.UI.ViewModels
public MachineOverviewErrorStates MachineErrorStates { get; set; }
+ private bool _isExpandedNotificatios;
+
+ public bool IsExpandedNotifications
+ {
+ get { return _isExpandedNotificatios; }
+ set {
+ _isExpandedNotificatios = value;
+ RaisePropertyChangedAuto();}
+ }
+
+ private int _selectedStatisticTabIndex;
+ /// <summary>
+ /// Gets or sets the index of the selected category.
+ /// </summary>
+ public int SelectedStatisticTabIndex
+ {
+ get { return _selectedStatisticTabIndex; }
+ set
+ {
+ if (_selectedStatisticTabIndex != value)
+ {
+ _selectedStatisticTabIndex = value;
+ RaisePropertyChangedAuto();
+ switch (_selectedStatisticTabIndex)
+ {
+ case 0:
+ {
+ SelectedStatisticTab = StatisticTab.Productiondata;
+ break;
+ }
+ case 1:
+ {
+ SelectedStatisticTab = StatisticTab.Temperature;
+ break;
+ }
+ case 2:
+ {
+ SelectedStatisticTab = StatisticTab.Pressure;
+ break;
+ }
+ case 3:
+ {
+ SelectedStatisticTab = StatisticTab.Motor;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ private StatisticTab _selectedStatisticTab;
+ /// <summary>
+ /// Gets or sets the selected category.
+ /// </summary>
+ ///
+ public StatisticTab SelectedStatisticTab
+ {
+ get
+ {
+ return _selectedStatisticTab;
+ }
+ set
+ {
+ if (_selectedStatisticTab != value)
+ {
+ _selectedStatisticTab = value;
+ RaisePropertyChangedAuto();
+ }
+ _selectedStatisticTabIndex = _selectedStatisticTab.ToInt32();
+ RaisePropertyChanged(nameof(SelectedStatisticTabIndex));
+ }
+ }
+
+ public WpfGraphController<DateTimeDataPoint, DoubleDataPoint> JobController { get; set; }
+
#endregion
#region Commands
@@ -258,17 +356,31 @@ namespace Tango.PPC.UI.ViewModels
OverviewModel = new MachineOverviewModel();
MachineErrorStates = new MachineOverviewErrorStates();
+
+ IsExpandedNotifications = false;
+ SelectedStatisticTabIndex = 0;
+
+ JobController = CreateController(CreateSeries("Total", GraphHelper.GraphColor.Green));
}
public override void OnApplicationReady()
{
base.OnApplicationReady();
+ EventLogger.EventReceived += EventLogger_EventReceived;
- MidTankLevels = MachineProvider.Machine.Configuration.NoneEmptyIdsPacks.Where(x => x.MidTankType.HasLevelMeasure || x.MidTankType.Type == MidTankTypes.LubricantMidTank).OrderBy(x => x.PackIndex).Select(x => new JerricanLevelModel()
+ MidTankLevels = MachineProvider.Machine.Configuration.NoneEmptyIdsPacks.Where(x => x.MidTankType.HasLevelMeasure ).OrderBy(x => x.PackIndex).Select(x => new JerricanLevelModel()
{
Max = x.MidTankType.LiterCapacity,
IDSPack = x,
- }).OrderBy(y => y.IDSPack.LiquidType.PreferredIndex).ToList();
+ }).OrderBy(y => y.IDSPack.LiquidType.Type).ToList();
+ var LubLevel = MachineProvider.Machine.Configuration.NoneEmptyIdsPacks.Where(x => x.MidTankType.Type == MidTankTypes.LubricantMidTank).FirstOrDefault();
+
+ MidTankLubLevel = new JerricanLevelModel();
+ if(LubLevel != null)
+ {
+ MidTankLubLevel.Max = LubLevel.MidTankType.LiterCapacity;
+ MidTankLubLevel.IDSPack = LubLevel;
+ };
MachineProvider.MachineOperator.MachineStatusChanged += MachineOperator_MachineStatusChanged;
@@ -276,7 +388,18 @@ namespace Tango.PPC.UI.ViewModels
#region Events
- private void MachineOperator_MachineStatusChanged(object sender, MachineStatus status)
+ private void EventLogger_EventReceived(object sender, MachinesEvent ev)
+ {
+ InvokeUI(() =>
+ {
+ if (ev.Category == EventTypeCategories.Error || ev.Category == EventTypeCategories.Critical)
+ {
+ IsExpandedNotifications = true;
+ }
+ });
+ }
+
+ private void MachineOperator_MachineStatusChanged(object sender, MachineStatus status)
{
UpdateMidTankLevels(status);
UpdateMachineStatusErrors(status);
@@ -287,7 +410,15 @@ namespace Tango.PPC.UI.ViewModels
{
foreach (var item in status.IDSPacksLevels)
{
- var model = MidTankLevels.SingleOrDefault(x => x.IDSPack.PackIndex == item.Index);
+ JerricanLevelModel model = null;
+ if (item.Index == 8)//lub
+ {
+ model = MidTankLubLevel;
+
+ }
+ else {
+ model = MidTankLevels.SingleOrDefault(x => x.IDSPack.PackIndex == item.Index);
+ }
if (model != null)
{
@@ -440,17 +571,17 @@ namespace Tango.PPC.UI.ViewModels
IsDyeingProcess = (RunningJobStatus != null && RunningJobStatus.CurrentSegment != null);
if (RunningJobStatus != null && RunningJobStatus.CurrentSegment != null)
{
- var segment = Job.Segments.FirstOrDefault(x => x.SegmentIndex == _runningJobStatus.CurrentSegment.SegmentIndex);
+ var currentSegmentIndex = Math.Max(_runningJobStatus.CurrentSegment.SegmentIndex - (Job.Segments.Count * RunningJobStatus.CurrentUnit), 0);
+ var segment = Job.Segments.FirstOrDefault(x => x.SegmentIndex == currentSegmentIndex);
+ // var segment = Job.Segments.FirstOrDefault(x => x.SegmentIndex == _runningJobStatus.CurrentSegment.SegmentIndex);
if (segment != null)
{
-
if (_handler.JobTicket.Segments.Count > 0)
{
JobBrushStop = _handler.JobTicket.Segments[Job.OrderedSegments.IndexOf(segment)].BrushStops.First();
- }
-
- CurrentBrushStop = segment.FirstBrushStop;
+ }
}
+ CurrentBrushStop = RunningJobStatus.CurrentSegment.FirstBrushStop;
}
}
@@ -565,6 +696,35 @@ namespace Tango.PPC.UI.ViewModels
}
}
+ private WpfGraphController<DateTimeDataPoint, DoubleDataPoint> CreateController(params WpfGraphDataSeries[] seriesCollection)
+ {
+ var controller = new WpfGraphController<DateTimeDataPoint, DoubleDataPoint>();
+
+ foreach (var series in seriesCollection)
+ {
+ controller.DataSeriesCollection.Add(series);
+ }
+
+ controller.Range.AutoY = true;
+ controller.Range.MaximumY = 100;
+ controller.Range.MinimumY = 0;
+ controller.Range.MaximumX = new DateTime(0).AddMinutes(30);
+
+ controller.RefreshRate = TimeSpan.FromMilliseconds(300000);//5 min
+
+ return controller;
+ }
+
+ private WpfGraphDataSeries CreateSeries(String name, GraphHelper.GraphColor fill)
+ {
+ WpfGraphDataSeries series = new WpfGraphDataSeries();
+ series.Name = name;
+ series.Fill = GraphHelper.GetGraphBrush(fill);
+ series.StrokeThickness = 1;
+ series.Stroke = GraphHelper.GetGraphStrokeColor();
+ return series;
+ }
+
#endregion
}
}