aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2025-06-16 07:21:31 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2025-06-16 07:21:31 +0300
commitfe7108fd24e8dd403b4efb3557d32013ce1f9a06 (patch)
tree64917dd788554eb6f60400ae066002e8d2a93205 /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
parent56b93b90a8273af22b4430a2cf842d73163aafb6 (diff)
downloadTango-fe7108fd24e8dd403b4efb3557d32013ce1f9a06.tar.gz
Tango-fe7108fd24e8dd403b4efb3557d32013ce1f9a06.zip
Production data graph.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs78
1 files changed, 56 insertions, 22 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 2faee12ac..7b0f47927 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs
@@ -75,11 +75,14 @@ namespace Tango.PPC.UI.ViewModels
};
private DispatcherTimer _productiondata_timer;
+ private double _lastProductionDataProgress;
private bool startingJob = false;
private bool _jerricanDialogShowing;
private List<ColorSpace> _colorSpaces;
private bool _conversion_Busy;
private bool _printingEnded;
+ private double _totalProductionDataMeters;
+ private DateTime productionStartTime;
#region Properties
@@ -170,7 +173,7 @@ namespace Tango.PPC.UI.ViewModels
if (_isDyeingProcess != value)
{
_isDyeingProcess = value;
- RaisePropertyChangedAuto();
+ RaisePropertyChangedAuto();
}
}
}
@@ -330,7 +333,7 @@ namespace Tango.PPC.UI.ViewModels
}
}
- public WpfGraphController<DateTimeDataPoint, DoubleDataPoint> JobController { get; set; }
+ public WpfGraphController<TimeSpanDataPoint, DoubleDataPoint> JobController { get; set; }
private JobResumeModel _resumeModel;
public JobResumeModel ResumeModel
@@ -401,8 +404,10 @@ namespace Tango.PPC.UI.ViewModels
public MachineStatusViewVM()
{
+ productionStartTime = DateTime.Today.AddHours(Settings.ProductionDataStartTimeHours);
+
_productiondata_timer = new DispatcherTimer();
- _productiondata_timer.Interval = TimeSpan.FromMinutes(10);
+ _productiondata_timer.Interval = TimeSpan.FromSeconds(Settings.ProductionDataRefreshRateSeconds);
_productiondata_timer.Tick += _productiondata_timer_Tick;
@@ -469,10 +474,7 @@ namespace Tango.PPC.UI.ViewModels
MachineProvider.MachineOperator.MachineStatusChanged += MachineOperator_MachineStatusChanged;
- DateTime dateTime = DateTime.Now;
- DateTime onedayEarlier = dateTime.AddDays(-1);
-
- GetCollectionDyePropByStartTime(onedayEarlier);
+ GetCollectionDyePropByStartTime(productionStartTime);
_productiondata_timer.Start();
}
@@ -586,7 +588,29 @@ namespace Tango.PPC.UI.ViewModels
private void _productiondata_timer_Tick(object sender, EventArgs e)
{
- var CurrentDateTime = DateTime.Now;
+ if (MachineProvider.MachineOperator.IsPrinting)
+ {
+ if (RunningJobStatus != null)
+ {
+ var delta = RunningJobStatus.Progress - _lastProductionDataProgress;
+ _lastProductionDataProgress = RunningJobStatus.Progress;
+
+ if (BuildProvider.MachineType == MachineTypes.Eureka)
+ {
+ _totalProductionDataMeters += (delta * 4);
+ }
+ else
+ {
+ _totalProductionDataMeters += delta;
+ }
+
+ JobController.PushData(DateTime.Now.TimeOfDay, _totalProductionDataMeters);
+ }
+ else
+ {
+ _lastProductionDataProgress = 0;
+ }
+ }
}
private async void MidTankLevel_PressedEvent(object sender, JerricanLevelModel e)
@@ -641,6 +665,8 @@ namespace Tango.PPC.UI.ViewModels
CurrentBrushStop = null;
JobBrushStop = null;
+ JobController.PushData(DateTime.Now.TimeOfDay, _totalProductionDataMeters);
+
List<LiquidOutputModel> outputs = new List<LiquidOutputModel>();
var idsPacks = MachineProvider.Machine.Configuration.GetSupportedIdsPacks(Job.Rml).OrderBy(x => x.PackIndex).ToList();
@@ -1083,9 +1109,9 @@ namespace Tango.PPC.UI.ViewModels
public TimeToDyeValueCollection graphDyeingValuesCollection = new TimeToDyeValueCollection();
- private WpfGraphController<DateTimeDataPoint, DoubleDataPoint> CreateController(params WpfGraphDataSeries[] seriesCollection)
+ private WpfGraphController<TimeSpanDataPoint, DoubleDataPoint> CreateController(params WpfGraphDataSeries[] seriesCollection)
{
- var controller = new WpfGraphController<DateTimeDataPoint, DoubleDataPoint>();
+ var controller = new WpfGraphController<TimeSpanDataPoint, DoubleDataPoint>();
foreach (var series in seriesCollection)
{
@@ -1095,9 +1121,9 @@ namespace Tango.PPC.UI.ViewModels
controller.Range.AutoY = true;
controller.Range.MaximumY = 100;
controller.Range.MinimumY = 0;
- controller.Range.MaximumX = new DateTime(0).AddMinutes(30);
+ controller.Range.MaximumX = TimeSpan.FromHours(24);
- controller.RefreshRate = TimeSpan.FromMilliseconds(300000);//5 min
+ controller.RefreshRate = TimeSpan.FromSeconds(Settings.ProductionDataRefreshRateSeconds);
return controller;
}
@@ -1121,24 +1147,32 @@ namespace Tango.PPC.UI.ViewModels
{
using (ObservablesContext db = ObservablesContext.CreateDefault())
{
- var jobRuns = await db.JobRuns.Where(x => x.StartDate >= starttime).Select(x => new { x.StartDate, x.EndDate, x.EndPosition }).OrderBy(y => y.StartDate).ToListAsync();
- double allvalues = 0;
- graphDyeingValuesCollection.StartTime = starttime;
- for (int i = 0; i < jobRuns.Count; i++)
+ DateTime startTimeUTC = starttime.ToUniversalTime();
+
+ var jobRuns = await db.JobRuns.Where(x => x.StartDate >= startTimeUTC).Select(x => new { x.StartDate, x.EndDate, x.ActualStartPosition, x.ActualEndPosition }).OrderBy(y => y.StartDate).ToListAsync();
+
+ JobController.PushData(starttime.TimeOfDay, _totalProductionDataMeters);
+
+ foreach (var jobRun in jobRuns)
{
- JobController.PushData(jobRuns[i].StartDate, allvalues);
- if (i > 0)
+ JobController.PushData(jobRun.StartDate.ToLocalTime().TimeOfDay, _totalProductionDataMeters);
+
+ if (BuildProvider.MachineType == MachineTypes.Eureka)
+ {
+ _totalProductionDataMeters += (jobRun.ActualEndPosition - jobRun.ActualStartPosition) * 4;
+ }
+ else
{
- allvalues += jobRuns[i - 1].EndPosition;
+ _totalProductionDataMeters += jobRun.ActualEndPosition - jobRun.ActualStartPosition;
}
- graphDyeingValuesCollection.items.Add(new TimeToDyeValueItem() { startTime = jobRuns[i].StartDate, endTime = jobRuns[i].EndDate, totalValue = allvalues });
- JobController.PushData(jobRuns[i].EndDate, allvalues);
+
+ JobController.PushData(jobRun.EndDate.ToLocalTime().TimeOfDay, _totalProductionDataMeters);
}
}
}
catch (Exception ex)
{
- LogManager.Log(ex, "Error loading machine counters.");
+ LogManager.Log(ex, "Error loading production data.");
}
}