From e2fbc8e6047fef09681b994efe2ca1043d25ac9d Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 16 Feb 2020 14:48:33 +0200 Subject: Implement Job Runs View. Create 2 views in Statistics. Implements Part of JobRunsView. Related Work Items: #2509 --- .../Converters/DateIsInListToBooleanConverter.cs | 29 ++ .../Converters/StringToBoolYesNoNullConverter.cs | 37 +++ .../Models/JobRunModel.cs | 46 ++- .../Models/JobRunStatisticsModel.cs | 45 +++ .../Tango.MachineStudio.Statistics.csproj | 19 ++ .../ViewModels/ChartsViewVM.cs | 362 +++++++++++++++++++++ .../ViewModels/JobRunsViewVM.cs | 209 ++++++++++++ .../ViewModels/MainViewVM.cs | 339 +------------------ .../Views/ChartsView.xaml | 110 +++++++ .../Views/ChartsView.xaml.cs | 35 ++ .../Views/JobRunsView.xaml | 239 ++++++++++++++ .../Views/JobRunsView.xaml.cs | 44 +++ .../Views/MainView.xaml | 114 ++----- .../Views/MainView.xaml.cs | 6 +- 14 files changed, 1184 insertions(+), 450 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/DateIsInListToBooleanConverter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/StringToBoolYesNoNullConverter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunStatisticsModel.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/ChartsViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/ChartsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/ChartsView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/DateIsInListToBooleanConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/DateIsInListToBooleanConverter.cs new file mode 100644 index 000000000..74e0c61d8 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/DateIsInListToBooleanConverter.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace Tango.MachineStudio.Statistics.Converters +{ + public class DateIsInListToBooleanConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + if (values.Length < 2 || !(values[0] is DateTime) || !(values[1] is IEnumerable)) + return false; + + var date = (DateTime)values[0]; + var dateList = (IEnumerable)values[1]; + + return dateList.ToList().Exists(x => x.ToLocalTime().ToShortDateString() == date.ToLocalTime().ToShortDateString()); + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/StringToBoolYesNoNullConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/StringToBoolYesNoNullConverter.cs new file mode 100644 index 000000000..f7633a7d0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/StringToBoolYesNoNullConverter.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; +using System.Windows.Data; + +namespace Tango.MachineStudio.Statistics.Converters +{ + public class StringToBoolYesNoNullConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if(value is bool) + { + return (bool)value ? "Yes" : "No"; + } + return "Null"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + //throw new NotImplementedException(); + if (value is ComboBoxItem) + { + string str_val = ((ComboBoxItem)value).Content.ToString(); + if (str_val.ToUpper() == "NO") + return false; + if (str_val.ToUpper() == "YES") + return true; + } + return null; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunModel.cs index 8e5642e3d..e269f761f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunModel.cs @@ -1,45 +1,37 @@ - -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Tango.BL; using Tango.BL.Entities; -using Tango.Core.ExtensionMethods; namespace Tango.MachineStudio.Statistics.Models { - public class JobRunModel : JobRun + public class JobRunModel { - private static Dictionary _machines = new Dictionary(); + public JobRun JobRun { get; set; } - public JobRunModel() - { + public Machine Machine { get; set; } - } + public User User { get; set; } - public JobRunModel(JobRun run) - { - run.MapPropertiesTo(this, MappingFlags.NoReferenceTypes); - } + public TimeSpan? UploadDuration { get; set; } + + public TimeSpan? HeatingDuration { get; set; } - public Task LoadMachine(ObservablesContext context) + + + public void Init() { - return Task.Factory.StartNew(() => + if (JobRun.HeatingStartDate != null) { - if (!_machines.ContainsKey(MachineGuid)) - { - Machine = context.Machines.SingleOrDefault(x => x.Guid == MachineGuid); - _machines.Add(MachineGuid, Machine); - } - else - { - Machine = _machines[MachineGuid]; - } - }); - } + UploadDuration = JobRun.HeatingStartDate - JobRun.StartDate; + } - public Machine Machine { get; set; } + if (JobRun.ActualStartDate != null && JobRun.HeatingStartDate != null) + { + HeatingDuration = JobRun.ActualStartDate - JobRun.HeatingStartDate; + } + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunStatisticsModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunStatisticsModel.cs new file mode 100644 index 000000000..98b719cae --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/JobRunStatisticsModel.cs @@ -0,0 +1,45 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.Core.ExtensionMethods; + +namespace Tango.MachineStudio.Statistics.Models +{ + public class JobRunStatisticsModel : JobRun + { + private static Dictionary _machines = new Dictionary(); + + public JobRunStatisticsModel() + { + + } + + public JobRunStatisticsModel(JobRun run) + { + run.MapPropertiesTo(this, MappingFlags.NoReferenceTypes); + } + + public Task LoadMachine(ObservablesContext context) + { + return Task.Factory.StartNew(() => + { + if (!_machines.ContainsKey(MachineGuid)) + { + Machine = context.Machines.SingleOrDefault(x => x.Guid == MachineGuid); + _machines.Add(MachineGuid, Machine); + } + else + { + Machine = _machines[MachineGuid]; + } + }); + } + + public Machine Machine { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Tango.MachineStudio.Statistics.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Tango.MachineStudio.Statistics.csproj index 36c371165..4b3535f83 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Tango.MachineStudio.Statistics.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Tango.MachineStudio.Statistics.csproj @@ -73,14 +73,25 @@ + + + PieChartTooltipControl.xaml + + + + ChartsView.xaml + + + JobRunsView.xaml + MainView.xaml @@ -95,6 +106,14 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/ChartsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/ChartsViewVM.cs new file mode 100644 index 000000000..b06261306 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/ChartsViewVM.cs @@ -0,0 +1,362 @@ +using LiveCharts; +using LiveCharts.Wpf; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Media; +using Tango.BL.Enumerations; +using Tango.MachineStudio.Common; +using Tango.MachineStudio.Statistics.Models; +using Tango.BL.Entities; +using Tango.SharedUI; +using Tango.BL; +using Tango.MachineStudio.Common.Notifications; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Statistics.ViewModels +{ + public class ChartsViewVM : ViewModel + { + private INotificationProvider _notification; + private ObservablesContext _context; + private List _job_runs; + private bool _loaded; + + #region Properties + private LabeledSeriesCollection _timelineJobStatusSeries; + public LabeledSeriesCollection TimelineJobStatusSeries + { + get { return _timelineJobStatusSeries; } + set { _timelineJobStatusSeries = value; RaisePropertyChangedAuto(); } + } + + private LabeledSeriesCollection _pieJobFailedReasons; + public LabeledSeriesCollection PieJobFailedReasons + { + get { return _pieJobFailedReasons; } + set { _pieJobFailedReasons = value; RaisePropertyChangedAuto(); } + } + + private LabeledSeriesCollection _printPerWeekSeries; + public LabeledSeriesCollection PrintPerWeekSeries + { + get { return _printPerWeekSeries; } + set { _printPerWeekSeries = value; RaisePropertyChangedAuto(); } + } + + private DateTime _startDate; + public DateTime StartDate + { + get { return _startDate; } + set { _startDate = value; RaisePropertyChangedAuto(); OnDateRangeChanged(); } + } + + private DateTime _endDate; + public DateTime EndDate + { + get { return _endDate; } + set { _endDate = value; RaisePropertyChangedAuto(); OnDateRangeChanged(); } + } + + 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(); } + } + #endregion + + public ChartsViewVM(INotificationProvider notificationProvider) + { + _notification = notificationProvider; + StartDate = DateTime.Now.AddMonths(-1); + EndDate = DateTime.Now; + } + + #region Generate Charts + + public async void Init() + { + using (_notification.PushTaskItem("Loading statistics...")) + { + IsFree = false; + + await Task.Factory.StartNew(() => + { + _context = ObservablesContext.CreateDefault(); + _job_runs = _context.JobRuns.OrderBy(x => x.StartDate).ToList().Select(x => new JobRunStatisticsModel(x)).ToList(); + foreach (var run in _job_runs) + { + run.LoadMachine(_context).GetAwaiter().GetResult(); + } + }); + + if (_job_runs.Count > 0) + { + MinDate = _job_runs.Min(x => x.StartDate); + MaxDate = _job_runs.Max(x => x.StartDate); + } + + InvokeUIOnIdle(() => + { + if (_loaded) + { + OnDateRangeChanged(); + } + }); + + _loaded = true; + IsFree = true; + } + } + + private List GetJobRunsByDateRange(DateTime startDate, DateTime endTime, JobRunStatus? status = null) + { + return _job_runs.Where(x => x.StartDate.ToLocalTime() >= startDate && x.StartDate.ToLocalTime() <= endTime && (status == null || x.JobRunStatus == status)).ToList(); + } + + private List GetJobRunsByDate(DateTime date, JobRunStatus? status = null) + { + return _job_runs.Where(x => x.StartDate.ToLocalTime().Date == date.Date && (status == null || x.JobRunStatus == status)).ToList(); + } + + private IEnumerable CreateDates(DateTime start, DateTime end) + { + for (DateTime date = start.Date; date.Date <= end.Date; date = date.AddDays(1)) + { + yield return date; + } + } + + private void GenerateTimelineJobStatusChart() + { + TimelineJobStatusSeries = new LabeledSeriesCollection() + { + Title = "Job Runs Status", + ChartTitle = "Number Of Runs", + LabelsTitle = "Date", + SeriesColors = new List() + { + Colors.Green, + Colors.Orange, + Colors.Red, + }, + }; + + Series completed_job_runs = new ColumnSeries() + { + Title = "Completed", + Values = new ChartValues(), + Fill = Brushes.Green, + MinWidth = 1, + + }; + Series aborted_job_runs = new ColumnSeries() + { + Title = "Aborted", + Values = new ChartValues(), + Fill = Brushes.Orange, + MinWidth = 1, + }; + Series failed_job_runs = new ColumnSeries() + { + Title = "Failed", + Values = new ChartValues(), + Fill = Brushes.Red, + MinWidth = 1, + }; + + if (EndDate - StartDate > TimeSpan.FromDays(40)) + { + completed_job_runs = new LineSeries() + { + Title = "Completed", + Values = new ChartValues(), + Fill = new SolidColorBrush(Colors.Green) { Opacity = 0.5 }, + MinWidth = 1, + PointGeometry = null, + StrokeThickness = 0, + + }; + aborted_job_runs = new LineSeries() + { + Title = "Aborted", + Values = new ChartValues(), + Fill = new SolidColorBrush(Colors.Orange) { Opacity = 0.5 }, + MinWidth = 1, + PointGeometry = null, + StrokeThickness = 0, + }; + failed_job_runs = new LineSeries() + { + Title = "Failed", + Values = new ChartValues(), + Fill = new SolidColorBrush(Colors.Red) { Opacity = 0.5 }, + MinWidth = 1, + PointGeometry = null, + StrokeThickness = 0, + }; + } + + foreach (var date in CreateDates(StartDate, EndDate)) + { + completed_job_runs.Values.Add(GetJobRunsByDate(date, JobRunStatus.Completed).Count()); + aborted_job_runs.Values.Add(GetJobRunsByDate(date, JobRunStatus.Aborted).Count()); + failed_job_runs.Values.Add(GetJobRunsByDate(date, JobRunStatus.Failed).Count()); + + TimelineJobStatusSeries.Labels.Add(date.ToShortDateString()); + } + + + + TimelineJobStatusSeries.SeriesCollection.Add(failed_job_runs); + TimelineJobStatusSeries.SeriesCollection.Add(aborted_job_runs); + TimelineJobStatusSeries.SeriesCollection.Add(completed_job_runs); + } + + private void GeneratePieFailedReasonsChart() + { + var groups = GetJobRunsByDateRange(StartDate, EndDate, JobRunStatus.Failed).GroupBy(x => x.FailedMessage).OrderBy(x => x.Count()); + + List colors = new List(); + + int max = groups.Count() > 0 ? groups.Max(x => x.Count()) : 0; + + for (int i = 0; i < groups.Count(); i++) + { + int count = groups.ElementAt(i).Count(); + double alpha = Math.Max(((double)(count) / max * 200), 20); + colors.Add(Color.FromArgb((byte)alpha, 200, 0, 0)); + } + + PieJobFailedReasons = new LabeledSeriesCollection() + { + Title = "Job Failure Reasons", + SeriesColors = colors, + }; + + int index = 0; + + foreach (var group in groups) + { + int count = group.Count(); + + var series = new PieSeries() + { + Title = group.First().FailedMessage, + Values = new ChartValues() { count }, + Fill = new SolidColorBrush(colors[index++]), + DataLabels = true, + ToolTip = group.First().FailedMessage, + }; + + PieJobFailedReasons.SeriesCollection.Add(series); + } + } + + private void GeneratePrintPerWeekChart() + { + List range_job_runs = GetJobRunsByDateRange(StartDate, EndDate); + + Dictionary> weeks_print_avg = new Dictionary>(); + + //Init machines weeks averages dictionary. + foreach (var machine in range_job_runs.Select(x => x.Machine).OrderBy(x => x.Name).DistinctBy(x => x.Guid)) + { + weeks_print_avg[machine] = new List(); + } + + //Create all available dates + List all_dates = range_job_runs.Select(x => x.StartDate).ToList(); + + //get first Sunday. + DateTime current_sunday = all_dates.FirstOrDefault(x => x.DayOfWeek == DayOfWeek.Sunday); + + if (current_sunday != null && all_dates.Count > 0) + { + //Iterate over each week starting from the earliest Sunday. + while (current_sunday <= all_dates.Last()) + { + var week_job_runs = range_job_runs.Where(x => x.EndPosition > 10 && x.StartDate >= current_sunday && x.StartDate <= current_sunday.AddDays(7)).ToList(); + + foreach (var machine_job_runs in week_job_runs.GroupBy(x => x.Machine)) + { + weeks_print_avg[machine_job_runs.Key].Add(machine_job_runs.Select(x => x.EndPosition).Average()); + } + + current_sunday = current_sunday.AddDays(8); + } + } + + Dictionary week_print_avg = new Dictionary(); + + //Init machines week average dictionary. + foreach (var machine in weeks_print_avg) + { + if (machine.Value.Count > 0) + { + week_print_avg[machine.Key] = machine.Value.Average(); + } + } + + //Init chart series + PrintPerWeekSeries = new LabeledSeriesCollection() + { + Title = "Average Printed Thread Per Week (m)", + ChartTitle = "Average Print Per Week (m)", + LabelsTitle = "Date", + SeriesColors = new List() + { + + }, + }; + + //Init series colors intensity by number of prints. + double max = week_print_avg.Count > 0 ? week_print_avg.Max(x => x.Value) : 0; + foreach (var machine in week_print_avg) + { + double a = (machine.Value / max); + PrintPerWeekSeries.SeriesColors.Add(Color.FromArgb((byte)(255d * (machine.Value / max)), 0, 200, 0)); + } + + //Init columns. + int index = 0; + + foreach (var machine in week_print_avg) + { + var series = new ColumnSeries() + { + Title = machine.Key.Name, + Values = new ChartValues() { (int)machine.Value }, + Fill = new SolidColorBrush(PrintPerWeekSeries.SeriesColors[index++]), + DataLabels = true, + ToolTip = machine.Key.SerialNumber, + }; + + PrintPerWeekSeries.SeriesCollection.Add(series); + } + } + + #endregion + + #region Filter by Date + public void OnDateRangeChanged() + { + if (_job_runs != null && _job_runs.Count > 0)// && _loaded) + { + GenerateTimelineJobStatusChart(); + GeneratePieFailedReasonsChart(); + GeneratePrintPerWeekChart(); + } + } + #endregion + + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs new file mode 100644 index 000000000..f03e7f67d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs @@ -0,0 +1,209 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Data.Entity; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Core.Commands; +using Tango.MachineStudio.Common; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.Statistics.Models; +using Tango.SharedUI; +using Tango.SharedUI.Components; + +namespace Tango.MachineStudio.Statistics.ViewModels +{ + public class JobRunsViewVM : ViewModel + { + private INotificationProvider _notification; + private List _allMachines; + private List _allUsers; + + #region Properties + + private List _jobRuns; + public List JobRuns + { + get { return _jobRuns; } + set + { + _jobRuns = value; + RaisePropertyChangedAuto(); + } + } + + private JobRunModel _selectedJobRun = null; + public JobRunModel SelectedJobRun + { + get { return _selectedJobRun; } + set + { + _selectedJobRun = value; + RaisePropertyChangedAuto(); + } + } + + private SelectedObjectCollection _selectedMachines; + public SelectedObjectCollection SelectedMachines + { + get { return _selectedMachines; } + set + { + _selectedMachines = value; + RaisePropertyChangedAuto(); + } + } + + private DateTime _startSelectedDate; + public DateTime StartSelectedDate + { + get { return _startSelectedDate; } + set { _startSelectedDate = value; RaisePropertyChangedAuto(); } + } + + private DateTime _endSelectedDate; + public DateTime EndSelectedDate + { + get { return _endSelectedDate; } + set { _endSelectedDate = value; RaisePropertyChangedAuto(); } + } + + protected Double _length; + public Double Length + { + get { return _length; } + set + { + _length = value; + RaisePropertyChangedAuto(); + } + } + + private JobSource _jobRunSource; + + public JobSource JobRunSource + { + get { return _jobRunSource; } + set { _jobRunSource = value; RaisePropertyChangedAuto(); } + } + + private JobRunStatus _jobRunStatus; + + public JobRunStatus JobRunStatus + { + get { return _jobRunStatus; } + set { _jobRunStatus = value; RaisePropertyChangedAuto(); } + } + + private bool? _isGradient; + + public bool? IsGradient + { + get { return _isGradient; } + set { + _isGradient = value; + RaisePropertyChangedAuto(); } + } + + private string _jobName; + + public string JobName + { + get { return _jobName; } + set { _jobName = value; } + } + + + #endregion + + public RelayCommand LoadJobRunsCommand { get; set; } + + public JobRunsViewVM(INotificationProvider notificationProvider) + { + _notification = notificationProvider; + JobRuns = new List(); + LoadJobRunsCommand = new RelayCommand( GetJobRuns); + } + + + public async void Init() + { + using (_notification.PushTaskItem("Loading job runs...")) + { + try + { + IsFree = false; + + using (var db = ObservablesContext.CreateDefault()) + { + _allMachines = await db.Machines.ToListAsync(); + _allUsers = await db.Users.ToListAsync(); + SelectedMachines = new SelectedObjectCollection(_allMachines.ToObservableCollection(), new ObservableCollection()); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error loading job runs."); + } + finally + { + IsFree = true; + } + } + } + + private async void GetJobRuns() + { + await LoadJobRuns(); + } + + private async Task LoadJobRuns() + { + using (_notification.PushTaskItem("Loading job runs...")) + { + try + { + IsFree = false; + + using (var db = ObservablesContext.CreateDefault()) + { + DateTime startUtc = StartSelectedDate.ToUniversalTime(); + TimeSpan offsetTime = (EndSelectedDate.Date == DateTime.Now.Date) ? DateTime.Now.TimeOfDay : new TimeSpan(23, 59, 59); + DateTime endUtc = EndSelectedDate.ToUniversalTime() + offsetTime; + + var runs = await db.JobRuns.Select(x => new JobRunModel() + { + JobRun = x, + Machine = _allMachines.FirstOrDefault(y => y.Guid == x.MachineGuid), + User = _allUsers.SingleOrDefault(y => y.Guid == x.UserGuid), + }).ToListAsync(); + + // .Query(y => y.Where + //(x => JobName == null || + //(x.JobName.ToString().ToLower().StartsWith(JobName) + //|| Length == null || (x.JobLength == Length) + //|| IsGradient == null || (x.IsGradient != null && x.IsGradient == IsGradient) + //|| ( x.JobRunSource == JobRunSource)))) + //.BuildAsync(); + + runs.ForEach(x => x.Init()); + + JobRuns = runs; + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error loading job runs."); + } + finally + { + IsFree = true; + } + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/MainViewVM.cs index dfbfe2648..4a75a41c8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/MainViewVM.cs @@ -19,349 +19,38 @@ namespace Tango.MachineStudio.Statistics.ViewModels { public class MainViewVM : StudioViewModel { - private ObservablesContext _context; - private List _job_runs; - private bool rendered; private INotificationProvider _notification; - private bool _loaded; - private LabeledSeriesCollection _timelineJobStatusSeries; - public LabeledSeriesCollection TimelineJobStatusSeries + private ChartsViewVM _chartsViewVM; + public ChartsViewVM ChartsViewVM { - get { return _timelineJobStatusSeries; } - set { _timelineJobStatusSeries = value; RaisePropertyChangedAuto(); } + get { return _chartsViewVM; } + set { _chartsViewVM = value; RaisePropertyChangedAuto(); } } - private LabeledSeriesCollection _pieJobFailedReasons; - public LabeledSeriesCollection PieJobFailedReasons + private JobRunsViewVM _jobRunsViewVM; + public JobRunsViewVM JobRunsViewVM { - get { return _pieJobFailedReasons; } - set { _pieJobFailedReasons = value; RaisePropertyChangedAuto(); } + get { return _jobRunsViewVM; } + set { _jobRunsViewVM = value; RaisePropertyChangedAuto(); } } - - private LabeledSeriesCollection _printPerWeekSeries; - public LabeledSeriesCollection PrintPerWeekSeries - { - get { return _printPerWeekSeries; } - set { _printPerWeekSeries = value; RaisePropertyChangedAuto(); } - } - - private DateTime _startDate; - public DateTime StartDate - { - get { return _startDate; } - set { _startDate = value; RaisePropertyChangedAuto(); OnDateRangeChanged(); } - } - - private DateTime _endDate; - public DateTime EndDate - { - get { return _endDate; } - set { _endDate = value; RaisePropertyChangedAuto(); OnDateRangeChanged(); } - } - - 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(); } - } - + public MainViewVM(INotificationProvider notificationProvider) { _notification = notificationProvider; - - StartDate = DateTime.Now.AddMonths(-1); - EndDate = DateTime.Now; + ChartsViewVM = new ChartsViewVM(_notification); + JobRunsViewVM = new JobRunsViewVM(_notification); } public override void OnApplicationReady() { - - } - - private List GetJobRunsByDateRange(DateTime startDate, DateTime endTime, JobRunStatus? status = null) - { - return _job_runs.Where(x => x.StartDate.ToLocalTime() >= startDate && x.StartDate.ToLocalTime() <= endTime && (status == null || x.JobRunStatus == status)).ToList(); - } - - private List GetJobRunsByDate(DateTime date, JobRunStatus? status = null) - { - return _job_runs.Where(x => x.StartDate.ToLocalTime().Date == date.Date && (status == null || x.JobRunStatus == status)).ToList(); - } - - private IEnumerable CreateDates(DateTime start, DateTime end) - { - for (DateTime date = start.Date; date.Date <= end.Date; date = date.AddDays(1)) - { - yield return date; - } + JobRunsViewVM.Init(); } - public override async void OnNavigatedTo() + public override void OnNavigatedTo() { base.OnNavigatedTo(); - - if (rendered) return; - - rendered = true; - - - using (_notification.PushTaskItem("Loading statistics...")) - { - IsFree = false; - - await Task.Factory.StartNew(() => - { - _context = ObservablesContext.CreateDefault(); - _job_runs = _context.JobRuns.OrderBy(x => x.StartDate).ToList().Select(x => new JobRunModel(x)).ToList(); - foreach (var run in _job_runs) - { - run.LoadMachine(_context).GetAwaiter().GetResult(); - } - }); - - if (_job_runs.Count > 0) - { - MinDate = _job_runs.Min(x => x.StartDate); - MaxDate = _job_runs.Max(x => x.StartDate); - } - - InvokeUIOnIdle(() => - { - OnDateRangeChanged(); - }); - - _loaded = true; - - IsFree = true; - } - } - - private void OnDateRangeChanged() - { - if (_job_runs != null && _job_runs.Count > 0 && _loaded) - { - GenerateTimelineJobStatusChart(); - GeneratePieFailedReasonsChart(); - GeneratePrintPerWeekChart(); - } - } - - private void GenerateTimelineJobStatusChart() - { - TimelineJobStatusSeries = new LabeledSeriesCollection() - { - Title = "Job Runs Status", - ChartTitle = "Number Of Runs", - LabelsTitle = "Date", - SeriesColors = new List() - { - Colors.Green, - Colors.Orange, - Colors.Red, - }, - }; - - Series completed_job_runs = new ColumnSeries() - { - Title = "Completed", - Values = new ChartValues(), - Fill = Brushes.Green, - MinWidth = 1, - - }; - Series aborted_job_runs = new ColumnSeries() - { - Title = "Aborted", - Values = new ChartValues(), - Fill = Brushes.Orange, - MinWidth = 1, - }; - Series failed_job_runs = new ColumnSeries() - { - Title = "Failed", - Values = new ChartValues(), - Fill = Brushes.Red, - MinWidth = 1, - }; - - if (EndDate - StartDate > TimeSpan.FromDays(40)) - { - completed_job_runs = new LineSeries() - { - Title = "Completed", - Values = new ChartValues(), - Fill = new SolidColorBrush(Colors.Green) { Opacity = 0.5 }, - MinWidth = 1, - PointGeometry = null, - StrokeThickness = 0, - - }; - aborted_job_runs = new LineSeries() - { - Title = "Aborted", - Values = new ChartValues(), - Fill = new SolidColorBrush(Colors.Orange) { Opacity = 0.5 }, - MinWidth = 1, - PointGeometry = null, - StrokeThickness = 0, - }; - failed_job_runs = new LineSeries() - { - Title = "Failed", - Values = new ChartValues(), - Fill = new SolidColorBrush(Colors.Red) { Opacity = 0.5 }, - MinWidth = 1, - PointGeometry = null, - StrokeThickness = 0, - }; - } - - foreach (var date in CreateDates(StartDate, EndDate)) - { - completed_job_runs.Values.Add(GetJobRunsByDate(date, JobRunStatus.Completed).Count()); - aborted_job_runs.Values.Add(GetJobRunsByDate(date, JobRunStatus.Aborted).Count()); - failed_job_runs.Values.Add(GetJobRunsByDate(date, JobRunStatus.Failed).Count()); - - TimelineJobStatusSeries.Labels.Add(date.ToShortDateString()); - } - - - - TimelineJobStatusSeries.SeriesCollection.Add(failed_job_runs); - TimelineJobStatusSeries.SeriesCollection.Add(aborted_job_runs); - TimelineJobStatusSeries.SeriesCollection.Add(completed_job_runs); - } - - private void GeneratePieFailedReasonsChart() - { - var groups = GetJobRunsByDateRange(StartDate, EndDate, JobRunStatus.Failed).GroupBy(x => x.FailedMessage).OrderBy(x => x.Count()); - - List colors = new List(); - - int max = groups.Count() > 0 ? groups.Max(x => x.Count()) : 0; - - for (int i = 0; i < groups.Count(); i++) - { - int count = groups.ElementAt(i).Count(); - double alpha = Math.Max(((double)(count) / max * 200), 20); - colors.Add(Color.FromArgb((byte)alpha, 200, 0, 0)); - } - - PieJobFailedReasons = new LabeledSeriesCollection() - { - Title = "Job Failure Reasons", - SeriesColors = colors, - }; - - int index = 0; - - foreach (var group in groups) - { - int count = group.Count(); - - var series = new PieSeries() - { - Title = group.First().FailedMessage, - Values = new ChartValues() { count }, - Fill = new SolidColorBrush(colors[index++]), - DataLabels = true, - ToolTip = group.First().FailedMessage, - }; - - PieJobFailedReasons.SeriesCollection.Add(series); - } - } - - private void GeneratePrintPerWeekChart() - { - List range_job_runs = GetJobRunsByDateRange(StartDate, EndDate); - - Dictionary> weeks_print_avg = new Dictionary>(); - - //Init machines weeks averages dictionary. - foreach (var machine in range_job_runs.Select(x => x.Machine).OrderBy(x => x.Name).DistinctBy(x => x.Guid)) - { - weeks_print_avg[machine] = new List(); - } - - //Create all available dates - List all_dates = range_job_runs.Select(x => x.StartDate).ToList(); - - //get first Sunday. - DateTime current_sunday = all_dates.FirstOrDefault(x => x.DayOfWeek == DayOfWeek.Sunday); - - if (current_sunday != null && all_dates.Count > 0) - { - //Iterate over each week starting from the earliest Sunday. - while (current_sunday <= all_dates.Last()) - { - var week_job_runs = range_job_runs.Where(x => x.EndPosition > 10 && x.StartDate >= current_sunday && x.StartDate <= current_sunday.AddDays(7)).ToList(); - - foreach (var machine_job_runs in week_job_runs.GroupBy(x => x.Machine)) - { - weeks_print_avg[machine_job_runs.Key].Add(machine_job_runs.Select(x => x.EndPosition).Average()); - } - - current_sunday = current_sunday.AddDays(8); - } - } - - Dictionary week_print_avg = new Dictionary(); - - //Init machines week average dictionary. - foreach (var machine in weeks_print_avg) - { - if (machine.Value.Count > 0) - { - week_print_avg[machine.Key] = machine.Value.Average(); - } - } - - //Init chart series - PrintPerWeekSeries = new LabeledSeriesCollection() - { - Title = "Average Printed Thread Per Week (m)", - ChartTitle = "Average Print Per Week (m)", - LabelsTitle = "Date", - SeriesColors = new List() - { - - }, - }; - - //Init series colors intensity by number of prints. - double max = week_print_avg.Count > 0 ? week_print_avg.Max(x => x.Value) : 0; - foreach (var machine in week_print_avg) - { - double a = (machine.Value / max); - PrintPerWeekSeries.SeriesColors.Add(Color.FromArgb((byte)(255d * (machine.Value / max)), 0, 200, 0)); - } - - //Init columns. - int index = 0; - - foreach (var machine in week_print_avg) - { - var series = new ColumnSeries() - { - Title = machine.Key.Name, - Values = new ChartValues() { (int)machine.Value }, - Fill = new SolidColorBrush(PrintPerWeekSeries.SeriesColors[index++]), - DataLabels = true, - ToolTip = machine.Key.SerialNumber, - }; - - PrintPerWeekSeries.SeriesCollection.Add(series); - } + ChartsViewVM.Init(); } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/ChartsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/ChartsView.xaml new file mode 100644 index 000000000..ecd7e01ed --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/ChartsView.xaml @@ -0,0 +1,110 @@ + + + + + + + + + + Start Date: + + + + + End Date: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/ChartsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/ChartsView.xaml.cs new file mode 100644 index 000000000..d79d88281 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/ChartsView.xaml.cs @@ -0,0 +1,35 @@ +using LiveCharts; +using LiveCharts.Wpf; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.Statistics.Views +{ + /// + /// Interaction logic for ChartsView.xaml + /// + public partial class ChartsView : UserControl + { + public ChartsView() + { + InitializeComponent(); + } + private void PieChart_DataHover(object sender, ChartPoint chartPoint) + { + var tooltip = ((chartPoint.ChartView as PieChart).DataTooltip as Tooltips.PieChartTooltipControl).Title; + txtPieTitle.Text = tooltip; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml new file mode 100644 index 000000000..4667959b8 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml @@ -0,0 +1,239 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + () + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TOTALS: + Cyan: + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs new file mode 100644 index 000000000..0966533b9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.Statistics.Views +{ + /// + /// Interaction logic for JobRunsView.xaml + /// + public partial class JobRunsView : UserControl + { + public JobRunsView() + { + InitializeComponent(); + } + private void Button_Click(object sender, RoutedEventArgs e) + { + selectMachineButton.IsChecked = true; + e.Handled = true; + } + private async void TextBox_GotFocus(object sender, RoutedEventArgs e) + { + await Task.Delay(200); + TextBox txtBox = sender as TextBox; + txtBox.SelectAll(); + } + + private void TextBox_PreviewMouseUp(object sender, MouseButtonEventArgs e) + { + e.Handled = true; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml index 55804c7b3..170d3276a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml @@ -11,100 +11,28 @@ xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf" mc:Ignorable="d" d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> - + - - + + - - - - Start Date: - - - - - End Date: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml.cs index 3948c4e5a..f0d1c39a7 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/MainView.xaml.cs @@ -28,10 +28,6 @@ namespace Tango.MachineStudio.Statistics.Views InitializeComponent(); } - private void PieChart_DataHover(object sender, ChartPoint chartPoint) - { - var tooltip = ((chartPoint.ChartView as PieChart).DataTooltip as Tooltips.PieChartTooltipControl).Title; - txtPieTitle.Text = tooltip; - } + } } -- cgit v1.3.1 From 09686240419bf92d2963564fb4a56f6e566468ce Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 24 Feb 2020 18:53:10 +0200 Subject: Added RmlQualification and HeadType enums to machine and RML. Filtered RML by head type on PPC. Updated SQLExaminer configurations.. Added all new rml and machine parameters to machine designer and RML modules. --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../Views/JobView.xaml | 8 ++--- .../Views/MachineSettingsView.xaml | 9 +++++ .../ViewModels/MainViewVM.cs | 11 ++++++ .../Tango.MachineStudio.RML/Views/RmlView.xaml | 11 ++++++ .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 4 +-- .../Tango.PPC.Jobs/ViewModels/JobsViewVM.cs | 2 +- .../ViewModels/MainViewVM.cs | 2 +- .../PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs | 6 ++-- .../Visual_Studio/PPC/Tango.PPC.UI/app.manifest | 2 +- .../Tango.BL/Builders/RmlsCollectionBuilder.cs | 11 +++++- .../Visual_Studio/Tango.BL/Entities/Machine.cs | 17 +++++++++ .../Tango.BL/Entities/ProcessParametersTable.cs | 8 +++++ Software/Visual_Studio/Tango.BL/Entities/Rml.cs | 39 +++++++++++++++++++++ .../Tango.BL/Enumerations/HeadTypes.cs | 14 ++++++++ .../Tango.BL/Enumerations/RmlQualifications.cs | 15 ++++++++ Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 4 ++- .../SQLExaminer/Configurations/OverrideData.xml | Bin 80438 -> 81980 bytes .../Configurations/ProvisionMachine.xml | Bin 87446 -> 87736 bytes .../SQLExaminer/Configurations/UpdateMachine.xml | Bin 54712 -> 55002 bytes 23 files changed, 149 insertions(+), 14 deletions(-) create mode 100644 Software/Visual_Studio/Tango.BL/Enumerations/HeadTypes.cs create mode 100644 Software/Visual_Studio/Tango.BL/Enumerations/RmlQualifications.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index bdc7134c7..1da670886 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index 3d480cd4e..13aed7905 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 07f4446e6..d3f041c38 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index e7664226d..a716c1359 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml index bf8eddd91..70422a8ca 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml @@ -680,7 +680,7 @@ - + @@ -792,7 +792,7 @@ - + MEDIA LIQUIDS ( Max Nanolitter/CM ) @@ -898,7 +898,7 @@ - + - - - - - - - - - - - - - - - - + - + - + + + + + + + + + + - - - - - - - - - - - - - - () - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Start Date: + + + + End Date: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs index 0966533b9..39b0d2c02 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs @@ -29,6 +29,23 @@ namespace Tango.MachineStudio.Statistics.Views selectMachineButton.IsChecked = true; e.Handled = true; } + + private void JobRunSourcesButton_Click(object sender, RoutedEventArgs e) + { + selectJobRunSources.IsChecked = true; + e.Handled = true; + } + private void IsGradientButton_Click(object sender, RoutedEventArgs e) + { + selectIsGradient.IsChecked = true; + e.Handled = true; + } + private void JobRunStatusButton_Click(object sender, RoutedEventArgs e) + { + selectJobRunStatus.IsChecked = true; + e.Handled = true; + } + private async void TextBox_GotFocus(object sender, RoutedEventArgs e) { await Task.Delay(200); @@ -40,5 +57,11 @@ namespace Tango.MachineStudio.Statistics.Views { e.Handled = true; } + + private void SelectMachineButton_Click(object sender, RoutedEventArgs e) + { + selectThreadsButton.IsChecked = true; + e.Handled = true; + } } } diff --git a/Software/Visual_Studio/Tango.BL/Builders/JobRunsBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/JobRunsBuilder.cs index ca755a04c..dd6852c44 100644 --- a/Software/Visual_Studio/Tango.BL/Builders/JobRunsBuilder.cs +++ b/Software/Visual_Studio/Tango.BL/Builders/JobRunsBuilder.cs @@ -5,15 +5,82 @@ using System.Text; using System.Threading.Tasks; using Tango.BL.Entities; using System.Data.Entity; +using Tango.BL.Enumerations; namespace Tango.BL.Builders { - public class JobRunsBuilder : EntityBuilderBase + public class JobRunsBuilder : EntityCollectionBuilderBase { public JobRunsBuilder(ObservablesContext context) : base(context) { } + public virtual JobRunsBuilder WithMachines(List machines) + { + return AddQueryStep(1, (query) => + { + if (machines != null && machines.Count > 0) + { + var machineIDs = new HashSet(machines.Select(p => p.Guid)); + return query.Where(x => machineIDs.Contains(x.MachineGuid)); + } + return query; + }); + } + + public virtual JobRunsBuilder WithJobSource(IEnumerable source) + { + return AddQueryStep(2, (query) => + { + if(source.Count() > 0) + { + int[] jobRunSourceArr = source.Select(x => (int)x).ToArray(); + return query.Where(x => jobRunSourceArr.Contains(x.JobSource)); + } + return query; + + }); + } + + public virtual JobRunsBuilder WithJobStatus(IEnumerable status) + { + return AddQueryStep(3, (query) => + { + if(status.Count() > 0) + { + int[] jobRunStatusArr = status.Select(x => (int)x).ToArray(); + + return query.Where(x => jobRunStatusArr.Contains(x.Status)); + } + return query; + + }); + } + + public virtual JobRunsBuilder WithGradient(IEnumerable isGradient) + { + return AddQueryStep(4, (query) => + { + if(isGradient.Count() > 0) + { + bool[] isGradientArr = isGradient.Select(x => (bool)x).ToArray(); + return query.Where(x => isGradientArr.Contains(x.IsGradient)); + } + return query; + }); + } + + public virtual JobRunsBuilder WithRmls(List rmlGuids) + { + return AddQueryStep(5, (query) => + { + if (rmlGuids != null && rmlGuids.Count > 0) + { + return query.Where(x => rmlGuids.Contains(x.MachineGuid)); + } + return query; + }); + } } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/JobRun.cs b/Software/Visual_Studio/Tango.BL/Entities/JobRun.cs index 6afb493cf..f422447fe 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/JobRun.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/JobRun.cs @@ -50,21 +50,24 @@ namespace Tango.BL.Entities { get { - if (_liquidQuantities != null) + if (_liquidQuantities == null) { - try + if (LiquidQuantityString != null) { - _liquidQuantities = JsonConvert.DeserializeObject>(LiquidQuantityString); + try + { + _liquidQuantities = JsonConvert.DeserializeObject>(LiquidQuantityString); + } + catch + { + _liquidQuantities = new List(); + } } - catch + else { _liquidQuantities = new List(); } } - else - { - _liquidQuantities = new List(); - } return _liquidQuantities; } diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToTwoDigitsTimeConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToTwoDigitsTimeConverter.cs index fb162d29b..8946020bf 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToTwoDigitsTimeConverter.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToTwoDigitsTimeConverter.cs @@ -12,6 +12,9 @@ namespace Tango.SharedUI.Converters { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { + if (value == null) + return ""; + TimeSpan time = (TimeSpan)value; if (time.TotalHours > 1) diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/AnalyzerResultBase.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/AnalyzerResultBase.cs index b7ee059b9..ec2940a73 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/AnalyzerResultBase.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analysis/AnalyzerResultBase.cs @@ -6,10 +6,11 @@ using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; +using Tango.Core; namespace Tango.DispenserAnalyzer.UI.Analysis { - public class AnalyzerResultBase : IAnalyzerResult + public class AnalyzerResultBase : ExtendedObject, IAnalyzerResult { public AnalyzerResultValue Result { get; set; } public List PlotValues { get; set; } @@ -25,29 +26,35 @@ namespace Tango.DispenserAnalyzer.UI.Analysis foreach (var prop in this.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).OrderByAlphaNumeric(x => x.Name)) { AnalyzerResultProperty aProp = new AnalyzerResultProperty(); - - if (prop.GetCustomAttribute() != null) + if (aProp.GetType() == typeof(IEnumerable<>)) { - aProp.Name = prop.GetCustomAttribute().Description; + continue; } - else + if (prop.GetCustomAttribute() != null) { - aProp.Name = prop.Name; + aProp.Name = prop.GetCustomAttribute().Description; + //} + //else + //{ + // aProp.Name = prop.Name; + //} + object val = prop.GetValue(this); + aProp.Value = (val is double) ? ((double)val).ToString("F") : val.ToString(); + props.Add(aProp); } - object val = prop.GetValue(this); - aProp.Value = (val is double) ? ((double)val).ToString("F") : val.ToString(); - - props.Add(aProp); + } return props; } } + public bool IsShowPlotResult { get; set; } public AnalyzerResultBase() { PlotValues = new List(); Result = AnalyzerResultValue.Undetermined; + IsShowPlotResult = false; } } } diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs index 17122ce66..16b8df8f1 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/FlowAnalyser.cs @@ -9,6 +9,8 @@ using Tango.DispenserAnalyzer.UI.Models; using MathNet.Numerics.LinearAlgebra; using System.Linq.Expressions; using System.Diagnostics; +using OxyPlot; +using System.Collections.ObjectModel; namespace Tango.DispenserAnalyzer.UI.Analyzers { @@ -33,40 +35,35 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers if (index % 2 == 1)//testing Flow-error { - List filteredValues = rangeTestValues.Skip(5000).ToList(); - // Move Average data + + List filteredValues = rangeTestValues.Skip(5000).ToList(); + + //Move Average data List tasks = new List(); int calc_count = (int)filteredValues.Count() / 4; int start_index = 0; while (start_index < filteredValues.Count()) { int calc_amount = (start_index + calc_count) >= (filteredValues.Count() - 4) ? filteredValues.Count() - start_index : calc_count; - var sliceToCalcMoveAverage = new List(); - sliceToCalcMoveAverage.AddRange(filteredValues.Skip(start_index).Take(calc_amount).ToList()); - + var source_filter = filteredValues.Skip(start_index).Take(calc_amount).ToList(); tasks.Add(Task.Run(() => { - filter.Filtering(sliceToCalcMoveAverage); + filter.Filtering(source_filter); })); - start_index += calc_amount; } Task.WaitAll(tasks.ToArray()); - //calculate difference Max Min values for each 250 values - int periodCalcMaxMin = 470; - List differenceMaxMin = new List(); - for (int i = 0; i < (filteredValues.Count - periodCalcMaxMin); i+= 200) + //calculate difference Max Min values for each 300 values + int periodCalcMaxMin = 500; + List differenceMaxMin = new List(); + for (int i = 0; i < (filteredValues.Count - periodCalcMaxMin); i+= 300) { var rangeItems =(filteredValues.Skip(i).Take(periodCalcMaxMin).ToList()); - differenceMaxMin.Add(rangeItems.Max(t => t.Pressure) - rangeItems.Min(t => t.Pressure)); + differenceMaxMin.Add((int)(rangeItems.Max(t => t.Pressure) - rangeItems.Min(t => t.Pressure))); } - //var rangeItems = filteredValues.Select((x, i) => new { x, i }).GroupBy(p => (p.i / 250)).Select(x => x.Select(v => v.x).ToList()); - //var differenceMaxMin = rangeItems.Select(x => x.Max(t => t.Pressure) - x.Min(t => t.Pressure)).ToList(); - FlowAnalyzerResult result = new FlowAnalyzerResult(); result.AverageValue = filteredValues.Average(t => t.Pressure); - result.SetLocalErrors(differenceMaxMin); results.Add(result); } @@ -76,59 +73,121 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers int avgMinIndex = rangeTestValues.Select(x => x.Index).Min(); int avgMaxIndex = rangeTestValues.Select(x => x.Index).Max(); double totalsec = TimeSpan.FromMilliseconds((avgMaxIndex - avgMinIndex) * 100).TotalSeconds; - result.Time = totalsec.ToString() + " sec"; + result.Time = totalsec.ToString() + " sec (succeed for period between 8 and 11 sec)"; ; result.Result = (totalsec <= 11 && totalsec >= 8) ? AnalyzerResultValue.Passed : AnalyzerResultValue.Failed; results.Add(result); } } + return results; }); } public class FlowAnalyzerResult : AnalyzerResultBase { + #region Properties [Description("Average Value")] public double AverageValue { get; set; } - [Description("Errors under 15")] - public string LocalErrorsUnder15 { get; set; } - - [Description("Errors greater than or equal to 15 and less than 20")] - public string LocalErrorsUnder20 { get; set; } + [Description("Max Error")] + public string LocalErrors { get; set; } + + private ObservableCollection _points; + public ObservableCollection Points + { + get { return _points; } + set + { + _points = value; + RaisePropertyChangedAuto(); + } + } + private int _step; + public int XStep + { + get { return _step; } + set { _step = value; RaisePropertyChangedAuto(); } + } - [Description("Errors greater than or equal to 20 and less than 25")] - public string LocalErrorsUnder25 { get; set; } + private double _from; + public double From + { + get { return _from; } + set{ _from = value; RaisePropertyChangedAuto(); } + } - [Description("Errors greater than or equal to 25 and less than 30")] - public string LocalErrorsUnder30 { get; set; } + private double _to; + public double To + { + get { return _to; } + set { _to = value; RaisePropertyChangedAuto();} + } + + #endregion Properties - public FlowAnalyzerResult() + public FlowAnalyzerResult():base() { - // AverageValue = MaxValue = MinValue = TotalValue = FilterAverageValue = FilterMaxValue = FilterMinValue = FilterTotalValue = 0.0; AverageValue = 0.0; Result = AnalyzerResultValue.Undetermined; + _from = 0; + _to = 35; + XStep = 1; + this.Points = new ObservableCollection(); } - public void SetLocalErrors(List differenceMaxMin) + /// + /// Calculate result, max error. Set oxy plot column chart. + /// + /// The difference maximum minimum. + public void SetLocalErrors(List differenceMaxMin) { - LocalErrorsUnder15 = BuildErrorLog(differenceMaxMin.Where(x => x < 15).ToList()); - LocalErrorsUnder20 = BuildErrorLog(differenceMaxMin.Where(x => x < 20 && x >= 15).ToList()); int count = differenceMaxMin.Where(x => x < 25 && x >= 20).Count(); Result = (count <= 10) ? AnalyzerResultValue.Passed : AnalyzerResultValue.Failed; - LocalErrorsUnder25 = BuildErrorLog(differenceMaxMin.Where(x => x < 25 && x >= 20).ToList()); - LocalErrorsUnder30 = BuildErrorLog(differenceMaxMin.Where(x => x < 30 && x >= 25).ToList()); + + int max_key = FindMaxErrorObject(differenceMaxMin); + + for (int i = 0; i <= max_key; i++) + { + int val = differenceMaxMin.Count(x => x == i); + if(val > 0 || Points.Count > 0) + { + Points.Add(new DataPoint(i, val)); + } + } + this.IsShowPlotResult = true; + RaisePropertyChanged("Points"); } - private string BuildErrorLog(List range_values) + private double BuildMeasurementError(List range_values) { int count = range_values.Count(); - string logerrors = (count > 10 ? "multiple" : count.ToString()); - if(count > 10 && AverageValue > 0) + return (count - (count * 0.98)); + } + + /// + /// Finds the maximum error object. Init LocalErrors message. Return max range value. + /// + private int FindMaxErrorObject(List range_values) + { + var countValArr = range_values.GroupBy(x => x).Select(t => new { Key = t.Key, Value = t.Count() }).OrderBy(x=>x.Key).ToArray(); + double merror = BuildMeasurementError(range_values); + double sum = 0; + int max_key = 0; + for (int i = countValArr.Count() - 1; i >= 0 ; i--) { - double persentageOfError = (range_values.Max()) / AverageValue * 100; - logerrors = $"multiple{Environment.NewLine} Percentage of errors {persentageOfError.ToString("F2")}"; + sum += countValArr[i].Value; + if (max_key == 0) + max_key = (int)countValArr[i].Key; + if (sum >= merror) + { + double persentageOfError = countValArr[i].Key / AverageValue * 100; + int range = (int)countValArr[i].Key; + int occurrence = countValArr[i].Value; + LocalErrors = $" {persentageOfError.ToString("F2")}% where range = {range.ToString()} and occurrence = {occurrence.ToString()}"; + break; + } } - return logerrors; + return max_key; } } diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PressureBuildUpAnalyser.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PressureBuildUpAnalyser.cs index 66e4eb3fb..52e0e8934 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PressureBuildUpAnalyser.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Analyzers/PressureBuildUpAnalyser.cs @@ -24,7 +24,7 @@ namespace Tango.DispenserAnalyzer.UI.Analyzers List rangeTestValues = csvRows.Where(x => x.Index > pair[0].Index && x.Index < pair[1].Index).ToList(); //testing PBU { - PrimingAnalyzerResult result = new PrimingAnalyzerResult(); + PrimingAnalyzerResult result = new PrimingAnalyzerResult(); int avgMinIndex = rangeTestValues.Select(x => x.Index).Min(); int avgMaxIndex = rangeTestValues.Select(x => x.Index).Max(); double totalsec = TimeSpan.FromMilliseconds((avgMaxIndex - avgMinIndex) * 100).TotalSeconds; diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml index c72bfcf0e..a330b4425 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml @@ -26,7 +26,7 @@ - + @@ -43,6 +43,7 @@ + - + @@ -70,77 +71,83 @@ - + - - - - + + + + + + + diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml.cs index 533a13e29..26d64c995 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/MainWindow.xaml.cs @@ -32,7 +32,7 @@ namespace Tango.DispenserAnalyzer.UI _vm = new MainWindowVM(); DataContext = _vm; _vm.PlotControl = PressurePlot; - CompositionTarget.Rendering += CompositionTargetRendering; + _vm.ResultsPanel = resultItems; foreach (var ax in PressurePlot.Axes) ax.Maximum = ax.Minimum = Double.NaN; @@ -63,17 +63,6 @@ namespace Tango.DispenserAnalyzer.UI } } - private void CompositionTargetRendering(object sender, EventArgs e) - { - //_vm.UpdateModel(); - if(_vm.ResetAllAxes) - { - _vm.ResetAllAxes = false; - foreach (var ax in PressurePlot.Axes) - ax.Maximum = ax.Minimum = Double.NaN; - PressurePlot.ResetAllAxes(); - } - PressurePlot.InvalidatePlot(true); - } + } } diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Tango.DispenserAnalyzer.UI.csproj b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Tango.DispenserAnalyzer.UI.csproj index fc195d7b5..1c2da6a01 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Tango.DispenserAnalyzer.UI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/Tango.DispenserAnalyzer.UI.csproj @@ -148,6 +148,8 @@ Tango.SharedUI - + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/MainWindowVM.cs b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/MainWindowVM.cs index 89678dd0e..2f047f88a 100644 --- a/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/MainWindowVM.cs +++ b/Software/Visual_Studio/Utilities/Tango.DispenserAnalyzer.UI/ViewModels/MainWindowVM.cs @@ -12,19 +12,32 @@ using System.Collections.ObjectModel; using System.IO; using System.Windows.Input; using Tango.DispenserAnalyzer.UI.Analysis; -using System.Reflection; -using Tango.DispenserAnalyzer.UI.Analyzers; using System.Windows; using System.Windows.Threading; using OxyPlot; using OxyPlot.Wpf; using OxyPlot.Annotations; using System.Windows.Media; +using System.Diagnostics; +using System.Windows.Documents; +using System.Windows.Controls; +using System.Windows.Xps; +using System.Windows.Xps.Packaging; +using System.Windows.Media.Imaging; namespace Tango.DispenserAnalyzer.UI.ViewModels { public class MainWindowVM: ViewModel { + private const string FILE_EXTENSION = ".xps"; + + public Plot PlotControl { get; set; } + + /// + /// Gets or sets the results panel. Using to save all results in xps file + /// + public System.Windows.Controls.ItemsControl ResultsPanel { get; set; } + private string _openFilePath; public string OpenFilePath { @@ -60,10 +73,11 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels get { return _testName.ToUpper() + " TEST"; } set { _testName = value; RaisePropertyChangedAuto(); } } - - public Plot PlotControl { get; set; } - + private IList _points; + /// + /// Binding to ItemsSource of line chart. + /// public IList Points { get { return _points; } @@ -81,6 +95,9 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels } private double _from; + /// + /// From use to binding to bottom axis min value + /// public double From { get { return _from; } @@ -89,8 +106,11 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels _from = value; RaisePropertyChangedAuto(); } } - + private double _to; + /// + /// To use to binding to bottom axis max value + /// public double To { get { return _to; } @@ -99,8 +119,8 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels _to = value; RaisePropertyChangedAuto(); } } - public bool ResetAllAxes { get; set; } + private bool _isRunning; /// /// Gets or sets a value indicating whether this instance is running. @@ -133,7 +153,6 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels XStep = 1; AnalyzerResults = new ObservableCollection(); _isRunning = false; - ResetAllAxes = false; this.Points = new List(); @@ -212,7 +231,6 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels To = 0; From = 0; int index = 0; - bool in_test_range = false; int last_labelIndex = 0; foreach (var item in data) @@ -243,25 +261,18 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels Command = String.IsNullOrWhiteSpace(item.Command) ? null : item.Command, Index = index }); - - if(!String.IsNullOrWhiteSpace(item.Command)) - { - in_test_range = !in_test_range; - } - if( pressure != 0 ) - { - if (TestName.Contains( "SEAL") && Points.Count ==0) - { - _from = pressure; - } - else - _from = Math.Min(pressure, _from); - _to = Math.Max(pressure, _to); - Points.Add(new DataPoint(index, pressure)); - } index++; } } + List res = await analyzer.Process(samples); + AnalyzerResults = new ObservableCollection(res); + + samples.ForEach(x => { if (x.Pressure != 0.0) + { Points.Add(new DataPoint(x.Index, x.Pressure)); } + }); + _to = Points.Max(x=>x.Y); + _from = TestName.Contains("sealtest") ? Points.FirstOrDefault(x=>x.X == 0).Y : Points.Min(x => x.Y); + data.Clear(); _to += 100; RaisePropertyChanged("To"); @@ -269,22 +280,144 @@ namespace Tango.DispenserAnalyzer.UI.ViewModels _from -= 100; RaisePropertyChanged("From"); XStep = (int)(Points.Count / 5); - - List res = await analyzer.Process(samples); - AnalyzerResults = new ObservableCollection(res); - + + PrintToXpsFile(); + IsRunning = false; + PlotControl.InvalidatePlot(true); } #endregion private void ResetSettings() { Points.Clear(); - ResetAllAxes = true; + AnalyzerResults.Clear(); TestName = ""; + foreach (var ax in PlotControl.Axes) + { + ax.Maximum = ax.Minimum = Double.NaN; + PlotControl.ResetAllAxes(); + } PlotControl.Annotations.Clear(); + PlotControl.InvalidatePlot(true); } - + + #region SaveInXps file + private void PrintToXpsFile() + { + try + { + if (File.Exists(OpenFilePath)) + { + var fileName = Path.GetFileNameWithoutExtension(OpenFilePath); + fileName += "_result"; + var ext = Path.GetExtension(OpenFilePath); + var dir = Path.GetDirectoryName(OpenFilePath); + var resultFile = Path.Combine(dir, string.Format("{0}-result{1}", Path.GetFileNameWithoutExtension(OpenFilePath), FILE_EXTENSION)); + SaveResultsAsXps(resultFile); + } + } + catch(Exception ex) + { + Debug.WriteLine(ex); + } + } + + public void SaveResultsAsXps( string fileName) + { + Panel panel = ResultsPanel.Parent as Panel; + if (panel != null) + { + int index = panel.Children.IndexOf(ResultsPanel); + panel.Children.Remove(ResultsPanel); + CreateDoc( fileName); + panel.Children.Insert(index, ResultsPanel); + } + else + { + ContentControl cc = ResultsPanel.Parent as ContentControl; + if (cc != null) + { + cc.Content = null; + CreateDoc(fileName); + cc.Content = ResultsPanel; + } + } + } + + private void CreateDoc( string fileName) + { + Dispatcher.CurrentDispatcher.Invoke( DispatcherPriority.Loaded, new Action(() => + { + PrintDialog printDlg = new PrintDialog(); + Size pageSize = new Size(printDlg.PrintableAreaWidth, printDlg.PrintableAreaHeight - 100); + Size reportSize = GetReportSize(ResultsPanel, printDlg); + + FixedDocument fixedDoc = new FixedDocument(); + PageContent pageContent = new PageContent(); + FixedPage fixedPage = new FixedPage(); + fixedPage.Children.Add(ResultsPanel); + + pageContent.BeginInit(); + ((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage); + pageContent.EndInit(); + + fixedDoc.Pages.Add(pageContent); + + InjectData(fixedDoc, AnalyzerResults); + //DocumentViewer documentViewer = new DocumentViewer(); + //documentViewer.Document = fixedDoc; + //documentViewer.UpdateLayout(); + + using (XpsDocument xpsd = new XpsDocument(fileName, FileAccess.Write)) + { + System.Windows.Xps.XpsDocumentWriter xw = XpsDocument.CreateXpsDocumentWriter(xpsd); + xw.Write(fixedDoc); + } + + fixedPage.Children.Remove(ResultsPanel); + })); + + + } + + /// + /// Injects the data to printed document. Without this the binding data to elements doesn't work. + /// + /// The document. + /// The data source. + protected void InjectData(FixedDocument document, object dataSource) + { + document.DataContext = new { AnalyzerResults = dataSource }; + + // we need to give the binding infrastructure a push as we + // are operating outside of the intended use of WPF + var dispatcher = Dispatcher.CurrentDispatcher; + dispatcher.Invoke(DispatcherPriority.SystemIdle, new DispatcherOperationCallback(delegate { return null; }), null); + } + + private static Size GetReportSize(ItemsControl reportContainer, PrintDialog printDialog = null) + { + if (printDialog == null) + printDialog = new PrintDialog(); + + double reportWidth = reportContainer.ActualWidth; + + double reportHeight = (reportWidth / printDialog.PrintableAreaWidth) * printDialog.PrintableAreaHeight; + + return new Size(reportWidth, reportHeight); + } + + public static void Print(IPlotModel model, string fileName, double width, double height) + { + using (var stream = File.Open(fileName, FileMode.Create, FileAccess.ReadWrite)) + { + var exporter = new XpsExporter { Width = width, Height = height}; + //PngExporter.Export(this.Plot.ActualModel, fileName, 600, 400, OxyColors.White) + exporter.Export(model, stream); + } + } + #endregion } } diff --git a/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs b/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs index c4ceff4e7..b89e83df8 100644 --- a/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs +++ b/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs @@ -70,7 +70,7 @@ namespace Tango.JobRunsGenerator if (run.JobName == null) run.JobName = job.Name; if (run.JobString == null) run.JobString = job.ToJobFileWhenLoaded().ToString(); if (run.LiquidQuantityString == null) run.LiquidQuantities = MachineOperator.CreateJobRunLiquidQuantities(job, machine.Configuration, job.Rml.GetActiveProcessGroup().ProcessParametersTables.First(), run.EndPosition, job.LengthIncludingNumberOfUnits); - if (run.UserGuid != null) run.UserGuid = job.UserGuid; + if (run.UserGuid == null) run.UserGuid = job.UserGuid; if (run.UploadingStartDate == null) run.UploadingStartDate = run.StartDate; if (run.HeatingStartDate == null) run.HeatingStartDate = run.StartDate; if (run.ActualStartDate == null) run.ActualStartDate = run.StartDate; -- cgit v1.3.1 From 228dca3384369f23d6dcad6a696cf491ab9d8840 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Wed, 26 Feb 2020 13:27:25 +0200 Subject: Fixed job runs collection builder. --- .../ViewModels/JobRunsViewVM.cs | 2 +- .../Tango.BL/Builders/JobRunsBuilder.cs | 86 ---------------------- .../Tango.BL/Builders/JobRunsCollectionBuilder.cs | 86 ++++++++++++++++++++++ Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 4 +- 4 files changed, 89 insertions(+), 89 deletions(-) delete mode 100644 Software/Visual_Studio/Tango.BL/Builders/JobRunsBuilder.cs create mode 100644 Software/Visual_Studio/Tango.BL/Builders/JobRunsCollectionBuilder.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs index 5c80a9564..cf74071c9 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs @@ -268,7 +268,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels TimeSpan offsetTime = (EndSelectedDate.Date == DateTime.Now.Date) ? DateTime.Now.TimeOfDay : new TimeSpan(23, 59, 59); DateTime endUtc = EndSelectedDate.ToUniversalTime() + offsetTime; - var runs = await new JobRunsBuilder(db).Set(x => x.ActualStartDate <= DbFunctions.TruncateTime(endUtc) && x.ActualStartDate >= DbFunctions.TruncateTime(startUtc.Date)) + var runs = await new JobRunsCollectionBuilder(db).Set(x => x.ActualStartDate <= DbFunctions.TruncateTime(endUtc) && x.ActualStartDate >= DbFunctions.TruncateTime(startUtc.Date)) .WithMachines(SelectedMachines.SynchedSource.ToList()) .WithJobSource(JobRunSelectedSources.SynchedSource) .WithJobStatus(JobRunSelectedStatuses.SynchedSource) diff --git a/Software/Visual_Studio/Tango.BL/Builders/JobRunsBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/JobRunsBuilder.cs deleted file mode 100644 index dd6852c44..000000000 --- a/Software/Visual_Studio/Tango.BL/Builders/JobRunsBuilder.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL.Entities; -using System.Data.Entity; -using Tango.BL.Enumerations; - -namespace Tango.BL.Builders -{ - public class JobRunsBuilder : EntityCollectionBuilderBase - { - public JobRunsBuilder(ObservablesContext context) : base(context) - { - - } - - public virtual JobRunsBuilder WithMachines(List machines) - { - return AddQueryStep(1, (query) => - { - if (machines != null && machines.Count > 0) - { - var machineIDs = new HashSet(machines.Select(p => p.Guid)); - return query.Where(x => machineIDs.Contains(x.MachineGuid)); - } - return query; - }); - } - - public virtual JobRunsBuilder WithJobSource(IEnumerable source) - { - return AddQueryStep(2, (query) => - { - if(source.Count() > 0) - { - int[] jobRunSourceArr = source.Select(x => (int)x).ToArray(); - return query.Where(x => jobRunSourceArr.Contains(x.JobSource)); - } - return query; - - }); - } - - public virtual JobRunsBuilder WithJobStatus(IEnumerable status) - { - return AddQueryStep(3, (query) => - { - if(status.Count() > 0) - { - int[] jobRunStatusArr = status.Select(x => (int)x).ToArray(); - - return query.Where(x => jobRunStatusArr.Contains(x.Status)); - } - return query; - - }); - } - - public virtual JobRunsBuilder WithGradient(IEnumerable isGradient) - { - return AddQueryStep(4, (query) => - { - if(isGradient.Count() > 0) - { - bool[] isGradientArr = isGradient.Select(x => (bool)x).ToArray(); - return query.Where(x => isGradientArr.Contains(x.IsGradient)); - } - return query; - }); - } - - public virtual JobRunsBuilder WithRmls(List rmlGuids) - { - return AddQueryStep(5, (query) => - { - if (rmlGuids != null && rmlGuids.Count > 0) - { - return query.Where(x => rmlGuids.Contains(x.MachineGuid)); - } - return query; - }); - } - } -} diff --git a/Software/Visual_Studio/Tango.BL/Builders/JobRunsCollectionBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/JobRunsCollectionBuilder.cs new file mode 100644 index 000000000..a1990c9ea --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Builders/JobRunsCollectionBuilder.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using System.Data.Entity; +using Tango.BL.Enumerations; + +namespace Tango.BL.Builders +{ + public class JobRunsCollectionBuilder : EntityCollectionBuilderBase + { + public JobRunsCollectionBuilder(ObservablesContext context) : base(context) + { + + } + + public virtual JobRunsCollectionBuilder WithMachines(List machines) + { + return AddQueryStep(1, (query) => + { + if (machines != null && machines.Count > 0) + { + var machineIDs = new HashSet(machines.Select(p => p.Guid)); + return query.Where(x => machineIDs.Contains(x.MachineGuid)); + } + return query; + }); + } + + public virtual JobRunsCollectionBuilder WithJobSource(IEnumerable source) + { + return AddQueryStep(2, (query) => + { + if(source.Count() > 0) + { + int[] jobRunSourceArr = source.Select(x => (int)x).ToArray(); + return query.Where(x => jobRunSourceArr.Contains(x.JobSource)); + } + return query; + + }); + } + + public virtual JobRunsCollectionBuilder WithJobStatus(IEnumerable status) + { + return AddQueryStep(3, (query) => + { + if(status.Count() > 0) + { + int[] jobRunStatusArr = status.Select(x => (int)x).ToArray(); + + return query.Where(x => jobRunStatusArr.Contains(x.Status)); + } + return query; + + }); + } + + public virtual JobRunsCollectionBuilder WithGradient(IEnumerable isGradient) + { + return AddQueryStep(4, (query) => + { + if(isGradient.Count() > 0) + { + bool[] isGradientArr = isGradient.Select(x => (bool)x).ToArray(); + return query.Where(x => isGradientArr.Contains(x.IsGradient)); + } + return query; + }); + } + + public virtual JobRunsCollectionBuilder WithRmls(List rmlGuids) + { + return AddQueryStep(5, (query) => + { + if (rmlGuids != null && rmlGuids.Count > 0) + { + return query.Where(x => rmlGuids.Contains(x.RmlGuid)); + } + return query; + }); + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index 2a5090c2e..6b6e8864d 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -107,7 +107,7 @@ - + @@ -610,7 +610,7 @@ - + \ No newline at end of file -- cgit v1.3.1 From afb6bbb2123932b3562e1af993eb847d8147bf58 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 26 Feb 2020 18:25:52 +0200 Subject: Major Changes Regarding RML & SPOOL parameters changes! --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes Software/PMR/Messages/Printing/JobSpool.proto | 2 + .../PMR/Messages/Printing/ProcessParameters.proto | 12 +- .../ViewModels/MainViewVM.cs | 2 +- .../ViewModels/MainViewVM.cs | 2 +- .../ViewModels/MainViewVM.cs | 4 +- .../Views/MachinesView.xaml | 2 +- .../Views/SpoolsView.xaml | 11 +- .../Tango.MachineStudio.RML.csproj | 7 + .../ViewModels/MainViewVM.cs | 74 ++++- .../Views/ProcessParametersView.xaml | 2 +- .../Tango.MachineStudio.RML/Views/RmlView.xaml | 9 +- .../Tango.MachineStudio.RML/Views/SpoolsView.xaml | 85 ++++++ .../Views/SpoolsView.xaml.cs | 28 ++ .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 2 +- .../Connection/DefaultMachineProvider.cs | 2 +- .../PPCApplication/DefaultPPCApplicationManager.cs | 2 +- .../ActionLogs/DefaultActionLogComparer.cs | 4 +- .../Visual_Studio/Tango.BL/Builders/JobBuilder.cs | 1 + .../Tango.BL/Builders/MachineBuilder.cs | 10 +- .../Visual_Studio/Tango.BL/Builders/RmlBuilder.cs | 8 + .../Tango.BL/Builders/RmlsCollectionBuilder.cs | 8 + .../Tango.BL/DTO/ProcessParametersTableDTOBase.cs | 16 - .../Visual_Studio/Tango.BL/DTO/RmlsSpoolDTO.cs | 14 + .../Visual_Studio/Tango.BL/DTO/RmlsSpoolDTOBase.cs | 73 +++++ .../Visual_Studio/Tango.BL/DTO/SpoolDTOBase.cs | 16 +- .../Visual_Studio/Tango.BL/DTO/SpoolTypeDTOBase.cs | 40 +++ .../Tango.BL/Entities/ColorSpaceBase.cs | 38 --- .../Visual_Studio/Tango.BL/Entities/MachineBase.cs | 132 --------- .../Tango.BL/Entities/MachineVersion.cs | 6 +- .../Tango.BL/Entities/ProcessParametersTable.cs | 4 +- .../Entities/ProcessParametersTableBase.cs | 84 ------ Software/Visual_Studio/Tango.BL/Entities/Rml.cs | 3 +- .../Visual_Studio/Tango.BL/Entities/RmlBase.cs | 76 ++--- .../Visual_Studio/Tango.BL/Entities/RmlsSpool.cs | 13 + .../Tango.BL/Entities/RmlsSpoolBase.cs | 327 +++++++++++++++++++++ .../Visual_Studio/Tango.BL/Entities/SpoolBase.cs | 70 ++++- .../Tango.BL/Entities/SpoolTypeBase.cs | 216 +++++++++++++- .../Tango.BL/Entities/SysdiagramBase.cs | 13 +- .../Visual_Studio/Tango.BL/ObservableEntity.cs | 6 +- .../Visual_Studio/Tango.BL/ObservableEntityDTO.cs | 6 +- .../Visual_Studio/Tango.BL/ObservablesContext.cs | 8 + .../ObservablesEntitiesAdapterExtension.cs | 38 +++ .../ObservablesStaticCollectionsExtension.cs | 38 +++ Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 6 +- .../ExtensionMethods/ObjectExtensions.cs | 12 +- .../Tango.Core/ExtensionMethods/TypeExtensions.cs | 15 + .../Visual_Studio/Tango.Core/Tango.Core.csproj | 2 +- .../Tango.DAL.Remote/DB/COLOR_SPACES.cs | 3 - .../Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs | 3 - .../DB/PROCESS_PARAMETERS_TABLES.cs | 2 - Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs | 6 +- .../Tango.DAL.Remote/DB/RMLS_SPOOLS.cs | 30 ++ .../Tango.DAL.Remote/DB/RemoteADO.Context.cs | 1 + .../Tango.DAL.Remote/DB/RemoteADO.edmx | 263 +++++++++-------- .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 162 +++++----- .../Visual_Studio/Tango.DAL.Remote/DB/SPOOL.cs | 9 +- .../Tango.DAL.Remote/DB/SPOOL_TYPES.cs | 9 +- .../Tango.DAL.Remote/Tango.DAL.Remote.csproj | 5 +- .../Tango.Integration/Operation/MachineOperator.cs | 25 +- .../Visual_Studio/Tango.PMR/Printing/JobSpool.cs | 37 ++- .../Tango.PMR/Printing/ProcessParameters.cs | 91 ++---- .../SQLExaminer/Configurations/OverrideData.xml | Bin 81980 -> 83216 bytes .../Configurations/ProvisionMachine.xml | Bin 87736 -> 88158 bytes .../Converters/EmptyStringToNullConverter.cs | 31 ++ .../Tango.SharedUI/Tango.SharedUI.csproj | 3 +- .../ObservablesGenerator.cs | 14 +- 70 files changed, 1528 insertions(+), 715 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml.cs create mode 100644 Software/Visual_Studio/Tango.BL/DTO/RmlsSpoolDTO.cs create mode 100644 Software/Visual_Studio/Tango.BL/DTO/RmlsSpoolDTOBase.cs create mode 100644 Software/Visual_Studio/Tango.BL/Entities/RmlsSpool.cs create mode 100644 Software/Visual_Studio/Tango.BL/Entities/RmlsSpoolBase.cs create mode 100644 Software/Visual_Studio/Tango.DAL.Remote/DB/RMLS_SPOOLS.cs create mode 100644 Software/Visual_Studio/Tango.SharedUI/Converters/EmptyStringToNullConverter.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index 22d662d7a..217886508 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index e887b17f9..f378adf0c 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index cbb2bf172..acb091ff8 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 662770d36..85ba181a9 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/PMR/Messages/Printing/JobSpool.proto b/Software/PMR/Messages/Printing/JobSpool.proto index a1d6b65ab..e9fa8ae5f 100644 --- a/Software/PMR/Messages/Printing/JobSpool.proto +++ b/Software/PMR/Messages/Printing/JobSpool.proto @@ -36,4 +36,6 @@ message JobSpool int32 BottomBackingRate = 9; + int32 LimitSwitchStartPointOffset = 10; + } diff --git a/Software/PMR/Messages/Printing/ProcessParameters.proto b/Software/PMR/Messages/Printing/ProcessParameters.proto index b4b334788..9dbc0e78b 100644 --- a/Software/PMR/Messages/Printing/ProcessParameters.proto +++ b/Software/PMR/Messages/Printing/ProcessParameters.proto @@ -68,16 +68,12 @@ message ProcessParameters double HeadZone12Temp = 26; - double StSpZone1Temp = 27; + double RBlowerFlow = 27; - double StSpZone2Temp = 28; + double RBlowerTemp = 28; - double RBlowerFlow = 29; + double LBlowerFlow = 29; - double RBlowerTemp = 30; - - double LBlowerFlow = 31; - - double LBlowerTemp = 32; + double LBlowerTemp = 30; } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index efbcaf5ad..c5df65f59 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -1622,7 +1622,7 @@ namespace Tango.MachineStudio.Developer.ViewModels { LogManager.Log("Invalidating liquid factors, process parameters and process group history..."); - _selectedRML = new RmlBuilder(_activeJobDbContext).Set(SelectedRML.Guid).WithAllParametersGroup().WithCAT(SelectedMachine.Guid).WithCCT().WithLiquidFactors().Build(); + _selectedRML = new RmlBuilder(_activeJobDbContext).Set(SelectedRML.Guid).WithAllParametersGroup().WithCAT(SelectedMachine.Guid).WithCCT().WithLiquidFactors().WithSpools().Build(); _selectedRMLBeforeLiquidFactorsSaves = RmlDTO.FromObservable(_selectedRML); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs index 0a8780346..cf66c1a34 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs @@ -233,7 +233,7 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels private void CopyParameters(object obj) { - obj.MapPropertiesTo(SelectedHardwareObject, MappingFlags.PrimitivesOnly, + obj.MapPropertiesTo(SelectedHardwareObject, MappingFlags.ValueTypesOnly, (prop) => !prop.PropertyType.IsEnum && diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs index e0d99d0f0..ed93b4308 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs @@ -523,7 +523,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels try { initHwConfig = false; - ActiveMachine = machineCreationDialogVM.SelectedMachineVersion.CreatePrototypeMachine(ActiveMachineAdapter.Context); + ActiveMachine = await machineCreationDialogVM.SelectedMachineVersion.CreatePrototypeMachine(ActiveMachineAdapter.Context); ActiveMachine.SerialNumber = machineCreationDialogVM.SerialNumber; ActiveMachine.Name = machineCreationDialogVM.Name; ActiveMachineAdapter.Context.Machines.Add(ActiveMachine); @@ -547,7 +547,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { var serial = machineCreationDialogVM.SerialNumber + "-" + (i + 1); - var existingDispenser = await ActiveMachineAdapter.Context.Dispensers.Include(x => x.IdsPacks).SingleAsync(x => x.SerialNumber == serial); + var existingDispenser = await ActiveMachineAdapter.Context.Dispensers.Include(x => x.IdsPacks).SingleOrDefaultAsync(x => x.SerialNumber == serial); if (existingDispenser != null) { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml index 446303aa2..a231e92a3 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml @@ -26,7 +26,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/SpoolsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/SpoolsView.xaml index 3663f72f8..f08da88d1 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/SpoolsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/SpoolsView.xaml @@ -9,8 +9,14 @@ xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:local="clr-namespace:Tango.MachineStudio.MachineDesigner.Views" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" mc:Ignorable="d" d:DesignHeight="720" d:DesignWidth="1280" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + + + + + @@ -67,10 +73,7 @@ - - - - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj index 2ff9ab0a3..9f3a95e0b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj @@ -118,6 +118,9 @@ RmlView.xaml + + SpoolsView.xaml + ResXFileCodeGenerator Resources.Designer.cs @@ -223,6 +226,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs index 3b3a307ad..b75d65fe0 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs @@ -87,6 +87,13 @@ namespace Tango.MachineStudio.RML.ViewModels set { _fiberSynths = value; RaisePropertyChangedAuto(); } } + private ObservableCollection _spoolTypes; + public ObservableCollection SpoolTypes + { + get { return _spoolTypes; } + set { _spoolTypes = value; RaisePropertyChangedAuto(); } + } + private Rml _selectedRML; public Rml SelectedRML { @@ -150,6 +157,14 @@ namespace Tango.MachineStudio.RML.ViewModels set { _colorConversionViewVM = value; RaisePropertyChangedAuto(); } } + private RmlsSpool _selectedSpool; + public RmlsSpool SelectedSpool + { + get { return _selectedSpool; } + set { _selectedSpool = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + /// /// Gets or sets the manage RML command. /// @@ -192,6 +207,16 @@ namespace Tango.MachineStudio.RML.ViewModels public RelayCommand ImportRMLFileCommand { get; set; } + /// + /// Gets or sets the add spool command. + /// + public RelayCommand AddSpoolCommand { get; set; } + + /// + /// Gets or sets the remove spool command. + /// + public RelayCommand RemoveSpoolCommand { get; set; } + public MainViewVM(INotificationProvider notificationProvider, IAuthenticationProvider authentication, IActionLogManager actionLogManager) { _notification = notificationProvider; @@ -215,6 +240,9 @@ namespace Tango.MachineStudio.RML.ViewModels ExportRMLFileCommand = new RelayCommand(ExportRmlFile, () => SelectedRML != null && IsFree); ImportRMLFileCommand = new RelayCommand(ImportRmlFile, () => IsFree); + + AddSpoolCommand = new RelayCommand(AddNewSpool); + RemoveSpoolCommand = new RelayCommand(RemoveSpool, () => SelectedSpool != null); } public override void OnApplicationReady() @@ -281,6 +309,7 @@ namespace Tango.MachineStudio.RML.ViewModels .WithActiveParametersGroup() .WithLiquidFactors() .WithCCT() + .WithSpools() .BuildAsync(); if (ActiveRML.Cct != null) @@ -382,6 +411,7 @@ namespace Tango.MachineStudio.RML.ViewModels LinearMassDensityUnits = _active_context.LinearMassDensityUnits.ToObservableCollection(); FiberShapes = _active_context.FiberShapes.ToObservableCollection(); FiberSynths = _active_context.FiberSynths.ToObservableCollection(); + SpoolTypes = _active_context.SpoolTypes.ToObservableCollection(); } private async void AddNewRml() @@ -495,7 +525,7 @@ namespace Tango.MachineStudio.RML.ViewModels using (var context = ObservablesContext.CreateDefault()) { - var rml = await new RmlBuilder(context).Set(SelectedRML.Guid).WithActiveParametersGroup().WithLiquidFactors().BuildAsync(); + var rml = await new RmlBuilder(context).Set(SelectedRML.Guid).WithActiveParametersGroup().WithLiquidFactors().WithSpools().BuildAsync(); Rml cloned = new Rml(); rml.MapPropertiesTo(cloned, MappingFlags.NoReferenceTypes); @@ -532,6 +562,15 @@ namespace Tango.MachineStudio.RML.ViewModels cloned.LiquidTypesRmls.Add(l); } + foreach (var spool in rml.RmlsSpools) + { + RmlsSpool s = new RmlsSpool(); + spool.MapPropertiesTo(s, MappingFlags.ValueTypesOnly); + s.RmlGuid = cloned.Guid; + s.SpoolTypeGuid = spool.SpoolTypeGuid; + cloned.RmlsSpools.Add(s); + } + context.Rmls.Add(cloned); await context.SaveChangesAsync(); @@ -709,17 +748,19 @@ namespace Tango.MachineStudio.RML.ViewModels _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.RmlSaved, _authentication.CurrentUser, _rmlBeforeSave.Name, _rmlBeforeSave, rmlAfter, "RML saved using Machine Studio."); _rmlBeforeSave = rmlAfter; + + LoadActiveRML(ActiveRML.Guid); } } catch (Exception ex) { LogManager.Log(ex, $"Error saving RML {ActiveRML.Name}"); - _notification.ShowError($"An error occurred while trying to save the current RML.\n{ex.Message}"); + _notification.ShowError($"An error occurred while trying to save the current RML.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; } - - LoadActiveRML(ActiveRML.Guid); - - IsFree = true; } private void BackToRmls() @@ -905,5 +946,26 @@ namespace Tango.MachineStudio.RML.ViewModels } #endregion + + #region Spools + + private void AddNewSpool() + { + _active_context.RmlsSpools.Add(new RmlsSpool() + { + Rml = ActiveRML, + }); + } + + private void RemoveSpool() + { + if (SelectedSpool != null) + { + _active_context.RmlsSpools.Remove(SelectedSpool); + ActiveRML.RmlsSpools.Remove(SelectedSpool); + } + } + + #endregion } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ProcessParametersView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ProcessParametersView.xaml index cae614aeb..03bf65522 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ProcessParametersView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ProcessParametersView.xaml @@ -32,7 +32,7 @@ - ACTIVE PROCESS GROUP + ACTIVE PROCESS GROUP diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml index 2c8d538d0..6ee41ac38 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml @@ -159,18 +159,18 @@ - + - COLOR CONVERSION + COLOR CONVERSION - + @@ -211,6 +211,9 @@ + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml new file mode 100644 index 000000000..6eae05c76 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + SPOOLS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml.cs new file mode 100644 index 000000000..6e363681c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.RML.Views +{ + /// + /// Interaction logic for SpoolsView.xaml + /// + public partial class SpoolsView : UserControl + { + public SpoolsView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index 18ca6bd1f..efaf98966 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -468,7 +468,7 @@ namespace Tango.PPC.Jobs.ViewModels Job.ValidateOnPropertyChanged = true; LogManager.Log("Loading RMLS..."); - Rmls = (await new RmlsCollectionBuilder(_db).SetAll().WithActiveParametersGroup().WithCAT(Job.MachineGuid).WithCCT().WithLiquidFactors().ForHeadType(MachineProvider.Machine.MachineHeadType).ForSite(MachineProvider.Machine.SiteGuid).BuildAsync()).ToList(); + Rmls = (await new RmlsCollectionBuilder(_db).SetAll().WithActiveParametersGroup().WithCAT(Job.MachineGuid).WithCCT().WithLiquidFactors().WithSpools().ForHeadType(MachineProvider.Machine.MachineHeadType).ForSite(MachineProvider.Machine.SiteGuid).BuildAsync()).ToList(); LogManager.Log("Loading Color Spaces..."); ColorSpaces = await _db.ColorSpaces.ToListAsync(); LogManager.Log("Loading Spool Types..."); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs index 0475f43ac..acdf20fa8 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs @@ -276,7 +276,7 @@ namespace Tango.PPC.Common.Connection public async Task SaveMachine() { await _context.SaveChangesAsync(); - Machine = await new MachineBuilder(_context).SetFirst().WithSettings().BuildAsync(); + Machine = await new MachineBuilder(_context).SetFirst().BuildAsync(); TangoMessenger.Default.Send(new MachineSettingsSavedMessage() { Machine = Machine }); } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index 003938303..62799c09c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -268,7 +268,7 @@ namespace Tango.PPC.UI.PPCApplication ObservablesStaticCollections.Instance.Initialize(); LogManager.Log("Loading machine from database..."); _machineContext = ObservablesContext.CreateDefault(); - _machine = new MachineBuilder(_machineContext).SetFirst().WithVersion().WithSettings().WithOrganization().WithConfiguration().WithSpools().WithCats().Build(); + _machine = new MachineBuilder(_machineContext).SetFirst().WithVersion().WithOrganization().WithConfiguration().WithSpools().WithCats().Build(); } diff --git a/Software/Visual_Studio/Tango.BL/ActionLogs/DefaultActionLogComparer.cs b/Software/Visual_Studio/Tango.BL/ActionLogs/DefaultActionLogComparer.cs index 0b29dcc8c..1504bab2d 100644 --- a/Software/Visual_Studio/Tango.BL/ActionLogs/DefaultActionLogComparer.cs +++ b/Software/Visual_Studio/Tango.BL/ActionLogs/DefaultActionLogComparer.cs @@ -57,11 +57,11 @@ namespace Tango.BL.ActionLogs scannedObjects.Add(after); } - foreach (var prop in GetProperties(before, after).OrderByDescending(x => x.PropertyType.IsPrimitive || x.PropertyType.IsValueType || x.PropertyType == typeof(String))) + foreach (var prop in GetProperties(before, after).OrderByDescending(x => x.PropertyType.IsValueTypeOrString())) { if (prop.PropertyType == typeof(byte[]) || GetShouldIgnore(prop, before, after)) continue; - if (prop.PropertyType.IsPrimitive || prop.PropertyType.IsValueType || prop.PropertyType == typeof(String)) + if (prop.PropertyType.IsValueTypeOrString()) { object beforeValue = null; object afterValue = null; diff --git a/Software/Visual_Studio/Tango.BL/Builders/JobBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/JobBuilder.cs index e64ad3fd5..c74a5af3d 100644 --- a/Software/Visual_Studio/Tango.BL/Builders/JobBuilder.cs +++ b/Software/Visual_Studio/Tango.BL/Builders/JobBuilder.cs @@ -64,6 +64,7 @@ namespace Tango.BL.Builders WithActiveParametersGroup(). WithCCT(). WithCAT(Entity.MachineGuid). + WithSpools(). WithLiquidFactors().Build(); }); } diff --git a/Software/Visual_Studio/Tango.BL/Builders/MachineBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/MachineBuilder.cs index e3bf4f98c..fd9d14baa 100644 --- a/Software/Visual_Studio/Tango.BL/Builders/MachineBuilder.cs +++ b/Software/Visual_Studio/Tango.BL/Builders/MachineBuilder.cs @@ -15,17 +15,9 @@ namespace Tango.BL.Builders } - public virtual MachineBuilder WithSettings() - { - return AddQueryStep(1, (query) => - { - return query.Include(x => x.DefaultColorSpace).Include(x => x.DefaultRml).Include(x => x.DefaultSpoolType); - }); - } - public virtual MachineBuilder WithVersion() { - return AddQueryStep(2, (query) => + return AddQueryStep(1, (query) => { return query.Include(x => x.MachineVersion); }); diff --git a/Software/Visual_Studio/Tango.BL/Builders/RmlBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/RmlBuilder.cs index ec777e599..d71f50f7a 100644 --- a/Software/Visual_Studio/Tango.BL/Builders/RmlBuilder.cs +++ b/Software/Visual_Studio/Tango.BL/Builders/RmlBuilder.cs @@ -35,6 +35,14 @@ namespace Tango.BL.Builders }); } + public virtual RmlBuilder WithSpools() + { + return AddQueryStep(2, (query) => + { + return query.Include(x => x.RmlsSpools); + }); + } + public virtual RmlBuilder WithAllParametersGroup() { return AddStep(1, () => diff --git a/Software/Visual_Studio/Tango.BL/Builders/RmlsCollectionBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/RmlsCollectionBuilder.cs index 8a5b4b00c..630f43495 100644 --- a/Software/Visual_Studio/Tango.BL/Builders/RmlsCollectionBuilder.cs +++ b/Software/Visual_Studio/Tango.BL/Builders/RmlsCollectionBuilder.cs @@ -55,6 +55,14 @@ namespace Tango.BL.Builders }); } + public virtual RmlsCollectionBuilder WithSpools() + { + return AddQueryStep(4, (query) => + { + return query.Include(x => x.RmlsSpools); + }); + } + public virtual RmlsCollectionBuilder WithAllParametersGroup() { return AddStep(1, () => diff --git a/Software/Visual_Studio/Tango.BL/DTO/ProcessParametersTableDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/ProcessParametersTableDTOBase.cs index 060aa8889..2d431b9df 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/ProcessParametersTableDTOBase.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/ProcessParametersTableDTOBase.cs @@ -245,22 +245,6 @@ namespace Tango.BL.DTO get; set; } - /// - /// st sp zone1 temp - /// - public Double StSpZone1Temp - { - get; set; - } - - /// - /// st sp zone2 temp - /// - public Double StSpZone2Temp - { - get; set; - } - /// /// r blower flow /// diff --git a/Software/Visual_Studio/Tango.BL/DTO/RmlsSpoolDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/RmlsSpoolDTO.cs new file mode 100644 index 000000000..c2839f8a0 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/DTO/RmlsSpoolDTO.cs @@ -0,0 +1,14 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.BL.DTO +{ + public class RmlsSpoolDTO : RmlsSpoolDTOBase + { + + } +} diff --git a/Software/Visual_Studio/Tango.BL/DTO/RmlsSpoolDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/RmlsSpoolDTOBase.cs new file mode 100644 index 000000000..1598a321f --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/DTO/RmlsSpoolDTOBase.cs @@ -0,0 +1,73 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Tango Observables Generator +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. Do not modify! +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; + +namespace Tango.BL.DTO +{ + public abstract class RmlsSpoolDTOBase : ObservableEntityDTO + { + + /// + /// spool type guid + /// + public String SpoolTypeGuid + { + get; set; + } + + /// + /// rml guid + /// + public String RmlGuid + { + get; set; + } + + /// + /// rotations per passage + /// + public Nullable RotationsPerPassage + { + get; set; + } + + /// + /// length + /// + public Nullable Length + { + get; set; + } + + /// + /// backing rate + /// + public Nullable BackingRate + { + get; set; + } + + /// + /// bottom backing rate + /// + public Nullable BottomBackingRate + { + get; set; + } + + } +} diff --git a/Software/Visual_Studio/Tango.BL/DTO/SpoolDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/SpoolDTOBase.cs index 346fc4e6d..c25b254da 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/SpoolDTOBase.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/SpoolDTOBase.cs @@ -40,7 +40,7 @@ namespace Tango.BL.DTO /// /// start offset pulses /// - public Int32 StartOffsetPulses + public Nullable StartOffsetPulses { get; set; } @@ -48,7 +48,7 @@ namespace Tango.BL.DTO /// /// backing rate /// - public Int32 BackingRate + public Nullable BackingRate { get; set; } @@ -56,7 +56,7 @@ namespace Tango.BL.DTO /// /// segment offset pulses /// - public Int32 SegmentOffsetPulses + public Nullable SegmentOffsetPulses { get; set; } @@ -64,7 +64,15 @@ namespace Tango.BL.DTO /// /// bottom backing rate /// - public Int32 BottomBackingRate + public Nullable BottomBackingRate + { + get; set; + } + + /// + /// limit switch start point offset + /// + public Nullable LimitSwitchStartPointOffset { get; set; } diff --git a/Software/Visual_Studio/Tango.BL/DTO/SpoolTypeDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/SpoolTypeDTOBase.cs index 6edd26e22..5b02cb536 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/SpoolTypeDTOBase.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/SpoolTypeDTOBase.cs @@ -69,5 +69,45 @@ namespace Tango.BL.DTO get; set; } + /// + /// start offset pulses + /// + public Int32 StartOffsetPulses + { + get; set; + } + + /// + /// backing rate + /// + public Int32 BackingRate + { + get; set; + } + + /// + /// segment offset pulses + /// + public Int32 SegmentOffsetPulses + { + get; set; + } + + /// + /// bottom backing rate + /// + public Int32 BottomBackingRate + { + get; set; + } + + /// + /// limit switch start point offset + /// + public Int32 LimitSwitchStartPointOffset + { + get; set; + } + } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/ColorSpaceBase.cs b/Software/Visual_Studio/Tango.BL/Entities/ColorSpaceBase.cs index b35ca0431..b21332829 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/ColorSpaceBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/ColorSpaceBase.cs @@ -39,8 +39,6 @@ namespace Tango.BL.Entities public event EventHandler> JobsChanged; - public event EventHandler> MachinesChanged; - protected Int32 _code; /// @@ -199,31 +197,6 @@ namespace Tango.BL.Entities } } - protected SynchronizedObservableCollection _machines; - - /// - /// Gets or sets the colorspacebase machines. - /// - - public virtual SynchronizedObservableCollection Machines - { - get - { - return _machines; - } - - set - { - if (_machines != value) - { - _machines = value; - - OnMachinesChanged(value); - - } - } - } - /// /// Called when the Code has changed. /// @@ -278,15 +251,6 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(Jobs)); } - /// - /// Called when the Machines has changed. - /// - protected virtual void OnMachinesChanged(SynchronizedObservableCollection machines) - { - MachinesChanged?.Invoke(this, machines); - RaisePropertyChanged(nameof(Machines)); - } - /// /// Initializes a new instance of the class. /// @@ -297,8 +261,6 @@ namespace Tango.BL.Entities Jobs = new SynchronizedObservableCollection(); - Machines = new SynchronizedObservableCollection(); - } } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/MachineBase.cs b/Software/Visual_Studio/Tango.BL/Entities/MachineBase.cs index 56e6ebe24..a80e78fec 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/MachineBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/MachineBase.cs @@ -75,8 +75,6 @@ namespace Tango.BL.Entities public event EventHandler> CatsChanged; - public event EventHandler DefaultColorSpaceChanged; - public event EventHandler ConfigurationChanged; public event EventHandler> JobsChanged; @@ -87,10 +85,6 @@ namespace Tango.BL.Entities public event EventHandler OrganizationChanged; - public event EventHandler DefaultRmlChanged; - - public event EventHandler DefaultSpoolTypeChanged; - public event EventHandler> SpoolsChanged; protected String _serialnumber; @@ -284,7 +278,6 @@ namespace Tango.BL.Entities /// [Column("DEFAULT_RML_GUID")] - [ForeignKey("DefaultRml")] public String DefaultRmlGuid { @@ -389,7 +382,6 @@ namespace Tango.BL.Entities /// [Column("DEFAULT_COLOR_SPACE_GUID")] - [ForeignKey("DefaultColorSpace")] public String DefaultColorSpaceGuid { @@ -442,7 +434,6 @@ namespace Tango.BL.Entities /// [Column("DEFAULT_SPOOL_TYPE_GUID")] - [ForeignKey("DefaultSpoolType")] public String DefaultSpoolTypeGuid { @@ -945,38 +936,6 @@ namespace Tango.BL.Entities } } - protected ColorSpace _defaultcolorspace; - - /// - /// Gets or sets the machinebase color spaces. - /// - - [XmlIgnore] - [JsonIgnore] - public virtual ColorSpace DefaultColorSpace - { - get - { - return _defaultcolorspace; - } - - set - { - if (_defaultcolorspace != value) - { - _defaultcolorspace = value; - - if (DefaultColorSpace != null) - { - DefaultColorSpaceGuid = DefaultColorSpace.Guid; - } - - OnDefaultColorSpaceChanged(value); - - } - } - } - protected Configuration _configuration; /// @@ -1123,70 +1082,6 @@ namespace Tango.BL.Entities } } - protected Rml _defaultrml; - - /// - /// Gets or sets the machinebase rml. - /// - - [XmlIgnore] - [JsonIgnore] - public virtual Rml DefaultRml - { - get - { - return _defaultrml; - } - - set - { - if (_defaultrml != value) - { - _defaultrml = value; - - if (DefaultRml != null) - { - DefaultRmlGuid = DefaultRml.Guid; - } - - OnDefaultRmlChanged(value); - - } - } - } - - protected SpoolType _defaultspooltype; - - /// - /// Gets or sets the machinebase spool types. - /// - - [XmlIgnore] - [JsonIgnore] - public virtual SpoolType DefaultSpoolType - { - get - { - return _defaultspooltype; - } - - set - { - if (_defaultspooltype != value) - { - _defaultspooltype = value; - - if (DefaultSpoolType != null) - { - DefaultSpoolTypeGuid = DefaultSpoolType.Guid; - } - - OnDefaultSpoolTypeChanged(value); - - } - } - } - protected SynchronizedObservableCollection _spools; /// @@ -1428,15 +1323,6 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(Cats)); } - /// - /// Called when the DefaultColorSpace has changed. - /// - protected virtual void OnDefaultColorSpaceChanged(ColorSpace defaultcolorspace) - { - DefaultColorSpaceChanged?.Invoke(this, defaultcolorspace); - RaisePropertyChanged(nameof(DefaultColorSpace)); - } - /// /// Called when the Configuration has changed. /// @@ -1482,24 +1368,6 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(Organization)); } - /// - /// Called when the DefaultRml has changed. - /// - protected virtual void OnDefaultRmlChanged(Rml defaultrml) - { - DefaultRmlChanged?.Invoke(this, defaultrml); - RaisePropertyChanged(nameof(DefaultRml)); - } - - /// - /// Called when the DefaultSpoolType has changed. - /// - protected virtual void OnDefaultSpoolTypeChanged(SpoolType defaultspooltype) - { - DefaultSpoolTypeChanged?.Invoke(this, defaultspooltype); - RaisePropertyChanged(nameof(DefaultSpoolType)); - } - /// /// Called when the Spools has changed. /// diff --git a/Software/Visual_Studio/Tango.BL/Entities/MachineVersion.cs b/Software/Visual_Studio/Tango.BL/Entities/MachineVersion.cs index 3f386beb2..7b90623d8 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/MachineVersion.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/MachineVersion.cs @@ -40,11 +40,13 @@ namespace Tango.BL.Entities EntitySerializationFlags.IgnoreGuids | EntitySerializationFlags.IgnoreReferenceTypes); } - public Machine CreatePrototypeMachine(ObservablesContext context) + public async Task CreatePrototypeMachine(ObservablesContext context) { Machine m = new Machine(); - Machine machine = Machine.FromJson(PrototypeMachineData, new EntitySerializationStrategy() + String protoTypeData = (await context.MachineVersions.SingleOrDefaultAsync(x => x.Guid == Guid)).PrototypeMachineData; + + Machine machine = Machine.FromJson(protoTypeData, new EntitySerializationStrategy() .Include(() => m.Configuration) .Ignore(() => m.Name) .Ignore(() => m.MachinesEvents) diff --git a/Software/Visual_Studio/Tango.BL/Entities/ProcessParametersTable.cs b/Software/Visual_Studio/Tango.BL/Entities/ProcessParametersTable.cs index f8d39862d..0a78dbc93 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/ProcessParametersTable.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/ProcessParametersTable.cs @@ -62,8 +62,8 @@ namespace Tango.BL.Entities heaters.Add(HeadZone10Temp); heaters.Add(HeadZone11Temp); heaters.Add(HeadZone12Temp); - heaters.Add(StSpZone1Temp); - heaters.Add(StSpZone2Temp); + heaters.Add(LBlowerTemp); + heaters.Add(RBlowerTemp); return heaters.Average(); } diff --git a/Software/Visual_Studio/Tango.BL/Entities/ProcessParametersTableBase.cs b/Software/Visual_Studio/Tango.BL/Entities/ProcessParametersTableBase.cs index 1d70aee98..2d9f1e4fb 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/ProcessParametersTableBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/ProcessParametersTableBase.cs @@ -81,10 +81,6 @@ namespace Tango.BL.Entities public event EventHandler HeadZone12TempChanged; - public event EventHandler StSpZone1TempChanged; - - public event EventHandler StSpZone2TempChanged; - public event EventHandler RBlowerFlowChanged; public event EventHandler RBlowerTempChanged; @@ -954,68 +950,6 @@ namespace Tango.BL.Entities } } - protected Double _stspzone1temp; - - /// - /// Gets or sets the processparameterstablebase st sp zone1 temp. - /// - - [Column("ST_SP_ZONE1_TEMP")] - - [StringFormat("0.0")] - - [PropertyIndex(21)] - - public Double StSpZone1Temp - { - get - { - return _stspzone1temp; - } - - set - { - if (_stspzone1temp != value) - { - _stspzone1temp = value; - - OnStSpZone1TempChanged(value); - - } - } - } - - protected Double _stspzone2temp; - - /// - /// Gets or sets the processparameterstablebase st sp zone2 temp. - /// - - [Column("ST_SP_ZONE2_TEMP")] - - [StringFormat("0.0")] - - [PropertyIndex(22)] - - public Double StSpZone2Temp - { - get - { - return _stspzone2temp; - } - - set - { - if (_stspzone2temp != value) - { - _stspzone2temp = value; - - OnStSpZone2TempChanged(value); - - } - } - } - protected Double _rblowerflow; /// @@ -1415,24 +1349,6 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(HeadZone12Temp)); } - /// - /// Called when the StSpZone1Temp has changed. - /// - protected virtual void OnStSpZone1TempChanged(Double stspzone1temp) - { - StSpZone1TempChanged?.Invoke(this, stspzone1temp); - RaisePropertyChanged(nameof(StSpZone1Temp)); - } - - /// - /// Called when the StSpZone2Temp has changed. - /// - protected virtual void OnStSpZone2TempChanged(Double stspzone2temp) - { - StSpZone2TempChanged?.Invoke(this, stspzone2temp); - RaisePropertyChanged(nameof(StSpZone2Temp)); - } - /// /// Called when the RBlowerFlow has changed. /// diff --git a/Software/Visual_Studio/Tango.BL/Entities/Rml.cs b/Software/Visual_Studio/Tango.BL/Entities/Rml.cs index ddaacfbd0..679226fd2 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Rml.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Rml.cs @@ -103,12 +103,13 @@ namespace Tango.BL.Entities { return Task.Factory.StartNew(() => { - var rml = new RmlBuilder(context).Set(Guid).WithActiveParametersGroup().WithCCT().WithLiquidFactors().Build(); + var rml = new RmlBuilder(context).Set(Guid).WithActiveParametersGroup().WithCCT().WithLiquidFactors().WithSpools().Build(); String result = rml.ToJson(new EntitySerializationStrategy() .Include(() => rml.Cct) .Include(() => rml.LiquidTypesRmls) .Include(() => rml.ProcessParametersTablesGroups) + .Include(() => rml.RmlsSpools) .Include(typeof(ProcessParametersTablesGroup).GetProperty(nameof(ProcessParametersTablesGroup.ProcessParametersTables))), EntitySerializationFlags.IgnoreCollections | EntitySerializationFlags.IgnoreReferenceTypes | EntitySerializationFlags.Indented); diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs index 41ae660ee..a592fc694 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs @@ -91,8 +91,6 @@ namespace Tango.BL.Entities public event EventHandler> LiquidTypesRmlsChanged; - public event EventHandler> MachinesChanged; - public event EventHandler MediaConditionChanged; public event EventHandler MediaMaterialChanged; @@ -101,6 +99,8 @@ namespace Tango.BL.Entities public event EventHandler> ProcessParametersTablesGroupsChanged; + public event EventHandler> RmlsSpoolsChanged; + public event EventHandler> SitesRmlsChanged; protected String _name; @@ -1161,31 +1161,6 @@ namespace Tango.BL.Entities } } - protected SynchronizedObservableCollection _machines; - - /// - /// Gets or sets the rmlbase machines. - /// - - public virtual SynchronizedObservableCollection Machines - { - get - { - return _machines; - } - - set - { - if (_machines != value) - { - _machines = value; - - OnMachinesChanged(value); - - } - } - } - protected MediaCondition _mediacondition; /// @@ -1307,6 +1282,31 @@ namespace Tango.BL.Entities } } + protected SynchronizedObservableCollection _rmlsspools; + + /// + /// Gets or sets the rmlbase rmls spools. + /// + + public virtual SynchronizedObservableCollection RmlsSpools + { + get + { + return _rmlsspools; + } + + set + { + if (_rmlsspools != value) + { + _rmlsspools = value; + + OnRmlsSpoolsChanged(value); + + } + } + } + protected SynchronizedObservableCollection _sitesrmls; /// @@ -1620,15 +1620,6 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(LiquidTypesRmls)); } - /// - /// Called when the Machines has changed. - /// - protected virtual void OnMachinesChanged(SynchronizedObservableCollection machines) - { - MachinesChanged?.Invoke(this, machines); - RaisePropertyChanged(nameof(Machines)); - } - /// /// Called when the MediaCondition has changed. /// @@ -1665,6 +1656,15 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(ProcessParametersTablesGroups)); } + /// + /// Called when the RmlsSpools has changed. + /// + protected virtual void OnRmlsSpoolsChanged(SynchronizedObservableCollection rmlsspools) + { + RmlsSpoolsChanged?.Invoke(this, rmlsspools); + RaisePropertyChanged(nameof(RmlsSpools)); + } + /// /// Called when the SitesRmls has changed. /// @@ -1688,10 +1688,10 @@ namespace Tango.BL.Entities LiquidTypesRmls = new SynchronizedObservableCollection(); - Machines = new SynchronizedObservableCollection(); - ProcessParametersTablesGroups = new SynchronizedObservableCollection(); + RmlsSpools = new SynchronizedObservableCollection(); + SitesRmls = new SynchronizedObservableCollection(); } diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlsSpool.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlsSpool.cs new file mode 100644 index 000000000..633180541 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlsSpool.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.BL.Entities +{ + public class RmlsSpool : RmlsSpoolBase + { + + } +} diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlsSpoolBase.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlsSpoolBase.cs new file mode 100644 index 000000000..fee4ef6b4 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlsSpoolBase.cs @@ -0,0 +1,327 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Tango Observables Generator +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. Do not modify! +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Xml.Serialization; +using Newtonsoft.Json; +using System.Linq; +using Tango.DAL.Remote.DB; +using Tango.Core; +using System.ComponentModel; +using Tango.Core.CustomAttributes; + +namespace Tango.BL.Entities +{ + [Table("RMLS_SPOOLS")] + public abstract class RmlsSpoolBase : ObservableEntity + { + + public event EventHandler> RotationsPerPassageChanged; + + public event EventHandler> LengthChanged; + + public event EventHandler> BackingRateChanged; + + public event EventHandler> BottomBackingRateChanged; + + public event EventHandler RmlChanged; + + public event EventHandler SpoolTypeChanged; + + protected String _spooltypeguid; + + /// + /// Gets or sets the rmlsspoolbase spool type guid. + /// + + [Column("SPOOL_TYPE_GUID")] + [ForeignKey("SpoolType")] + + public String SpoolTypeGuid + { + get + { + return _spooltypeguid; + } + + set + { + if (_spooltypeguid != value) + { + _spooltypeguid = value; + + } + } + } + + protected String _rmlguid; + + /// + /// Gets or sets the rmlsspoolbase rml guid. + /// + + [Column("RML_GUID")] + [ForeignKey("Rml")] + + public String RmlGuid + { + get + { + return _rmlguid; + } + + set + { + if (_rmlguid != value) + { + _rmlguid = value; + + } + } + } + + protected Nullable _rotationsperpassage; + + /// + /// Gets or sets the rmlsspoolbase rotations per passage. + /// + + [Column("ROTATIONS_PER_PASSAGE")] + + public Nullable RotationsPerPassage + { + get + { + return _rotationsperpassage; + } + + set + { + if (_rotationsperpassage != value) + { + _rotationsperpassage = value; + + OnRotationsPerPassageChanged(value); + + } + } + } + + protected Nullable _length; + + /// + /// Gets or sets the rmlsspoolbase length. + /// + + [Column("LENGTH")] + + public Nullable Length + { + get + { + return _length; + } + + set + { + if (_length != value) + { + _length = value; + + OnLengthChanged(value); + + } + } + } + + protected Nullable _backingrate; + + /// + /// Gets or sets the rmlsspoolbase backing rate. + /// + + [Column("BACKING_RATE")] + + public Nullable BackingRate + { + get + { + return _backingrate; + } + + set + { + if (_backingrate != value) + { + _backingrate = value; + + OnBackingRateChanged(value); + + } + } + } + + protected Nullable _bottombackingrate; + + /// + /// Gets or sets the rmlsspoolbase bottom backing rate. + /// + + [Column("BOTTOM_BACKING_RATE")] + + public Nullable BottomBackingRate + { + get + { + return _bottombackingrate; + } + + set + { + if (_bottombackingrate != value) + { + _bottombackingrate = value; + + OnBottomBackingRateChanged(value); + + } + } + } + + protected Rml _rml; + + /// + /// Gets or sets the rmlsspoolbase rml. + /// + + [XmlIgnore] + [JsonIgnore] + public virtual Rml Rml + { + get + { + return _rml; + } + + set + { + if (_rml != value) + { + _rml = value; + + if (Rml != null) + { + RmlGuid = Rml.Guid; + } + + OnRmlChanged(value); + + } + } + } + + protected SpoolType _spooltype; + + /// + /// Gets or sets the rmlsspoolbase spool types. + /// + + [XmlIgnore] + [JsonIgnore] + public virtual SpoolType SpoolType + { + get + { + return _spooltype; + } + + set + { + if (_spooltype != value) + { + _spooltype = value; + + if (SpoolType != null) + { + SpoolTypeGuid = SpoolType.Guid; + } + + OnSpoolTypeChanged(value); + + } + } + } + + /// + /// Called when the RotationsPerPassage has changed. + /// + protected virtual void OnRotationsPerPassageChanged(Nullable rotationsperpassage) + { + RotationsPerPassageChanged?.Invoke(this, rotationsperpassage); + RaisePropertyChanged(nameof(RotationsPerPassage)); + } + + /// + /// Called when the Length has changed. + /// + protected virtual void OnLengthChanged(Nullable length) + { + LengthChanged?.Invoke(this, length); + RaisePropertyChanged(nameof(Length)); + } + + /// + /// Called when the BackingRate has changed. + /// + protected virtual void OnBackingRateChanged(Nullable backingrate) + { + BackingRateChanged?.Invoke(this, backingrate); + RaisePropertyChanged(nameof(BackingRate)); + } + + /// + /// Called when the BottomBackingRate has changed. + /// + protected virtual void OnBottomBackingRateChanged(Nullable bottombackingrate) + { + BottomBackingRateChanged?.Invoke(this, bottombackingrate); + RaisePropertyChanged(nameof(BottomBackingRate)); + } + + /// + /// Called when the Rml has changed. + /// + protected virtual void OnRmlChanged(Rml rml) + { + RmlChanged?.Invoke(this, rml); + RaisePropertyChanged(nameof(Rml)); + } + + /// + /// Called when the SpoolType has changed. + /// + protected virtual void OnSpoolTypeChanged(SpoolType spooltype) + { + SpoolTypeChanged?.Invoke(this, spooltype); + RaisePropertyChanged(nameof(SpoolType)); + } + + /// + /// Initializes a new instance of the class. + /// + public RmlsSpoolBase() : base() + { + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/Entities/SpoolBase.cs b/Software/Visual_Studio/Tango.BL/Entities/SpoolBase.cs index 303f2ecbb..b1ac62815 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/SpoolBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/SpoolBase.cs @@ -27,13 +27,15 @@ namespace Tango.BL.Entities public abstract class SpoolBase : ObservableEntity { - public event EventHandler StartOffsetPulsesChanged; + public event EventHandler> StartOffsetPulsesChanged; - public event EventHandler BackingRateChanged; + public event EventHandler> BackingRateChanged; - public event EventHandler SegmentOffsetPulsesChanged; + public event EventHandler> SegmentOffsetPulsesChanged; - public event EventHandler BottomBackingRateChanged; + public event EventHandler> BottomBackingRateChanged; + + public event EventHandler> LimitSwitchStartPointOffsetChanged; public event EventHandler MachineChanged; @@ -91,7 +93,7 @@ namespace Tango.BL.Entities } } - protected Int32 _startoffsetpulses; + protected Nullable _startoffsetpulses; /// /// Gets or sets the spoolbase start offset pulses. @@ -99,7 +101,7 @@ namespace Tango.BL.Entities [Column("START_OFFSET_PULSES")] - public Int32 StartOffsetPulses + public Nullable StartOffsetPulses { get { @@ -118,7 +120,7 @@ namespace Tango.BL.Entities } } - protected Int32 _backingrate; + protected Nullable _backingrate; /// /// Gets or sets the spoolbase backing rate. @@ -126,7 +128,7 @@ namespace Tango.BL.Entities [Column("BACKING_RATE")] - public Int32 BackingRate + public Nullable BackingRate { get { @@ -145,7 +147,7 @@ namespace Tango.BL.Entities } } - protected Int32 _segmentoffsetpulses; + protected Nullable _segmentoffsetpulses; /// /// Gets or sets the spoolbase segment offset pulses. @@ -153,7 +155,7 @@ namespace Tango.BL.Entities [Column("SEGMENT_OFFSET_PULSES")] - public Int32 SegmentOffsetPulses + public Nullable SegmentOffsetPulses { get { @@ -172,7 +174,7 @@ namespace Tango.BL.Entities } } - protected Int32 _bottombackingrate; + protected Nullable _bottombackingrate; /// /// Gets or sets the spoolbase bottom backing rate. @@ -180,7 +182,7 @@ namespace Tango.BL.Entities [Column("BOTTOM_BACKING_RATE")] - public Int32 BottomBackingRate + public Nullable BottomBackingRate { get { @@ -199,6 +201,33 @@ namespace Tango.BL.Entities } } + protected Nullable _limitswitchstartpointoffset; + + /// + /// Gets or sets the spoolbase limit switch start point offset. + /// + + [Column("LIMIT_SWITCH_START_POINT_OFFSET")] + + public Nullable LimitSwitchStartPointOffset + { + get + { + return _limitswitchstartpointoffset; + } + + set + { + if (_limitswitchstartpointoffset != value) + { + _limitswitchstartpointoffset = value; + + OnLimitSwitchStartPointOffsetChanged(value); + + } + } + } + protected Machine _machine; /// @@ -266,7 +295,7 @@ namespace Tango.BL.Entities /// /// Called when the StartOffsetPulses has changed. /// - protected virtual void OnStartOffsetPulsesChanged(Int32 startoffsetpulses) + protected virtual void OnStartOffsetPulsesChanged(Nullable startoffsetpulses) { StartOffsetPulsesChanged?.Invoke(this, startoffsetpulses); RaisePropertyChanged(nameof(StartOffsetPulses)); @@ -275,7 +304,7 @@ namespace Tango.BL.Entities /// /// Called when the BackingRate has changed. /// - protected virtual void OnBackingRateChanged(Int32 backingrate) + protected virtual void OnBackingRateChanged(Nullable backingrate) { BackingRateChanged?.Invoke(this, backingrate); RaisePropertyChanged(nameof(BackingRate)); @@ -284,7 +313,7 @@ namespace Tango.BL.Entities /// /// Called when the SegmentOffsetPulses has changed. /// - protected virtual void OnSegmentOffsetPulsesChanged(Int32 segmentoffsetpulses) + protected virtual void OnSegmentOffsetPulsesChanged(Nullable segmentoffsetpulses) { SegmentOffsetPulsesChanged?.Invoke(this, segmentoffsetpulses); RaisePropertyChanged(nameof(SegmentOffsetPulses)); @@ -293,12 +322,21 @@ namespace Tango.BL.Entities /// /// Called when the BottomBackingRate has changed. /// - protected virtual void OnBottomBackingRateChanged(Int32 bottombackingrate) + protected virtual void OnBottomBackingRateChanged(Nullable bottombackingrate) { BottomBackingRateChanged?.Invoke(this, bottombackingrate); RaisePropertyChanged(nameof(BottomBackingRate)); } + /// + /// Called when the LimitSwitchStartPointOffset has changed. + /// + protected virtual void OnLimitSwitchStartPointOffsetChanged(Nullable limitswitchstartpointoffset) + { + LimitSwitchStartPointOffsetChanged?.Invoke(this, limitswitchstartpointoffset); + RaisePropertyChanged(nameof(LimitSwitchStartPointOffset)); + } + /// /// Called when the Machine has changed. /// diff --git a/Software/Visual_Studio/Tango.BL/Entities/SpoolTypeBase.cs b/Software/Visual_Studio/Tango.BL/Entities/SpoolTypeBase.cs index 778369948..a3e59bbc7 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/SpoolTypeBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/SpoolTypeBase.cs @@ -39,9 +39,19 @@ namespace Tango.BL.Entities public event EventHandler RotationsPerPassageChanged; + public event EventHandler StartOffsetPulsesChanged; + + public event EventHandler BackingRateChanged; + + public event EventHandler SegmentOffsetPulsesChanged; + + public event EventHandler BottomBackingRateChanged; + + public event EventHandler LimitSwitchStartPointOffsetChanged; + public event EventHandler> JobsChanged; - public event EventHandler> MachinesChanged; + public event EventHandler> RmlsSpoolsChanged; public event EventHandler> SpoolsChanged; @@ -207,6 +217,141 @@ namespace Tango.BL.Entities } } + protected Int32 _startoffsetpulses; + + /// + /// Gets or sets the spooltypebase start offset pulses. + /// + + [Column("START_OFFSET_PULSES")] + + public Int32 StartOffsetPulses + { + get + { + return _startoffsetpulses; + } + + set + { + if (_startoffsetpulses != value) + { + _startoffsetpulses = value; + + OnStartOffsetPulsesChanged(value); + + } + } + } + + protected Int32 _backingrate; + + /// + /// Gets or sets the spooltypebase backing rate. + /// + + [Column("BACKING_RATE")] + + public Int32 BackingRate + { + get + { + return _backingrate; + } + + set + { + if (_backingrate != value) + { + _backingrate = value; + + OnBackingRateChanged(value); + + } + } + } + + protected Int32 _segmentoffsetpulses; + + /// + /// Gets or sets the spooltypebase segment offset pulses. + /// + + [Column("SEGMENT_OFFSET_PULSES")] + + public Int32 SegmentOffsetPulses + { + get + { + return _segmentoffsetpulses; + } + + set + { + if (_segmentoffsetpulses != value) + { + _segmentoffsetpulses = value; + + OnSegmentOffsetPulsesChanged(value); + + } + } + } + + protected Int32 _bottombackingrate; + + /// + /// Gets or sets the spooltypebase bottom backing rate. + /// + + [Column("BOTTOM_BACKING_RATE")] + + public Int32 BottomBackingRate + { + get + { + return _bottombackingrate; + } + + set + { + if (_bottombackingrate != value) + { + _bottombackingrate = value; + + OnBottomBackingRateChanged(value); + + } + } + } + + protected Int32 _limitswitchstartpointoffset; + + /// + /// Gets or sets the spooltypebase limit switch start point offset. + /// + + [Column("LIMIT_SWITCH_START_POINT_OFFSET")] + + public Int32 LimitSwitchStartPointOffset + { + get + { + return _limitswitchstartpointoffset; + } + + set + { + if (_limitswitchstartpointoffset != value) + { + _limitswitchstartpointoffset = value; + + OnLimitSwitchStartPointOffsetChanged(value); + + } + } + } + protected SynchronizedObservableCollection _jobs; /// @@ -232,26 +377,26 @@ namespace Tango.BL.Entities } } - protected SynchronizedObservableCollection _machines; + protected SynchronizedObservableCollection _rmlsspools; /// - /// Gets or sets the spooltypebase machines. + /// Gets or sets the spooltypebase rmls spools. /// - public virtual SynchronizedObservableCollection Machines + public virtual SynchronizedObservableCollection RmlsSpools { get { - return _machines; + return _rmlsspools; } set { - if (_machines != value) + if (_rmlsspools != value) { - _machines = value; + _rmlsspools = value; - OnMachinesChanged(value); + OnRmlsSpoolsChanged(value); } } @@ -336,6 +481,51 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(RotationsPerPassage)); } + /// + /// Called when the StartOffsetPulses has changed. + /// + protected virtual void OnStartOffsetPulsesChanged(Int32 startoffsetpulses) + { + StartOffsetPulsesChanged?.Invoke(this, startoffsetpulses); + RaisePropertyChanged(nameof(StartOffsetPulses)); + } + + /// + /// Called when the BackingRate has changed. + /// + protected virtual void OnBackingRateChanged(Int32 backingrate) + { + BackingRateChanged?.Invoke(this, backingrate); + RaisePropertyChanged(nameof(BackingRate)); + } + + /// + /// Called when the SegmentOffsetPulses has changed. + /// + protected virtual void OnSegmentOffsetPulsesChanged(Int32 segmentoffsetpulses) + { + SegmentOffsetPulsesChanged?.Invoke(this, segmentoffsetpulses); + RaisePropertyChanged(nameof(SegmentOffsetPulses)); + } + + /// + /// Called when the BottomBackingRate has changed. + /// + protected virtual void OnBottomBackingRateChanged(Int32 bottombackingrate) + { + BottomBackingRateChanged?.Invoke(this, bottombackingrate); + RaisePropertyChanged(nameof(BottomBackingRate)); + } + + /// + /// Called when the LimitSwitchStartPointOffset has changed. + /// + protected virtual void OnLimitSwitchStartPointOffsetChanged(Int32 limitswitchstartpointoffset) + { + LimitSwitchStartPointOffsetChanged?.Invoke(this, limitswitchstartpointoffset); + RaisePropertyChanged(nameof(LimitSwitchStartPointOffset)); + } + /// /// Called when the Jobs has changed. /// @@ -346,12 +536,12 @@ namespace Tango.BL.Entities } /// - /// Called when the Machines has changed. + /// Called when the RmlsSpools has changed. /// - protected virtual void OnMachinesChanged(SynchronizedObservableCollection machines) + protected virtual void OnRmlsSpoolsChanged(SynchronizedObservableCollection rmlsspools) { - MachinesChanged?.Invoke(this, machines); - RaisePropertyChanged(nameof(Machines)); + RmlsSpoolsChanged?.Invoke(this, rmlsspools); + RaisePropertyChanged(nameof(RmlsSpools)); } /// @@ -371,7 +561,7 @@ namespace Tango.BL.Entities Jobs = new SynchronizedObservableCollection(); - Machines = new SynchronizedObservableCollection(); + RmlsSpools = new SynchronizedObservableCollection(); Spools = new SynchronizedObservableCollection(); diff --git a/Software/Visual_Studio/Tango.BL/Entities/SysdiagramBase.cs b/Software/Visual_Studio/Tango.BL/Entities/SysdiagramBase.cs index 6be908bb4..5480d47f1 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/SysdiagramBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/SysdiagramBase.cs @@ -27,17 +27,19 @@ namespace Tango.BL.Entities public abstract class SysdiagramBase : ObservableEntity { - public event EventHandler> VersionChanged; + public event EventHandler> VersionChanged; public event EventHandler DefinitionChanged; - protected SynchronizedObservableCollection _version; + protected Nullable _version; /// /// Gets or sets the sysdiagrambase version. /// - public virtual SynchronizedObservableCollection Version + [Column("version")] + + public Nullable Version { get { @@ -86,7 +88,7 @@ namespace Tango.BL.Entities /// /// Called when the Version has changed. /// - protected virtual void OnVersionChanged(SynchronizedObservableCollection version) + protected virtual void OnVersionChanged(Nullable version) { VersionChanged?.Invoke(this, version); RaisePropertyChanged(nameof(Version)); @@ -106,9 +108,6 @@ namespace Tango.BL.Entities /// public SysdiagramBase() : base() { - - Version = new SynchronizedObservableCollection(); - } } } diff --git a/Software/Visual_Studio/Tango.BL/ObservableEntity.cs b/Software/Visual_Studio/Tango.BL/ObservableEntity.cs index e3bba77bd..a6dcdbbec 100644 --- a/Software/Visual_Studio/Tango.BL/ObservableEntity.cs +++ b/Software/Visual_Studio/Tango.BL/ObservableEntity.cs @@ -283,7 +283,7 @@ namespace Tango.BL foreach (var prop in typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.SetMethod != null)) { - if (!prop.PropertyType.IsGenericType) + if (!prop.PropertyType.IsGenericTypeAndNotNullable()) { prop.SetValue(cloned, prop.GetValue(this)); } @@ -378,7 +378,7 @@ namespace Tango.BL if (flags.HasFlag(EntitySerializationFlags.IgnoreReferenceTypes)) { - var props = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => !x.PropertyType.IsPrimitive && !x.PropertyType.IsGenericType && x.PropertyType != typeof(byte[]) && x.PropertyType != typeof(String) && x.PropertyType != typeof(DateTime)).ToList(); + var props = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => !x.PropertyType.IsPrimitive && !x.PropertyType.IsGenericType && !x.PropertyType.IsNullable() && x.PropertyType != typeof(byte[]) && x.PropertyType != typeof(String) && x.PropertyType != typeof(DateTime)).ToList(); foreach (var prop in props) { @@ -388,7 +388,7 @@ namespace Tango.BL if (flags.HasFlag(EntitySerializationFlags.IgnoreCollections)) { - var props = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType.IsGenericType).ToList(); + var props = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType.IsGenericTypeAndNotNullable()).ToList(); foreach (var prop in props) { diff --git a/Software/Visual_Studio/Tango.BL/ObservableEntityDTO.cs b/Software/Visual_Studio/Tango.BL/ObservableEntityDTO.cs index 4c5ca6ae4..ce4cb3550 100644 --- a/Software/Visual_Studio/Tango.BL/ObservableEntityDTO.cs +++ b/Software/Visual_Studio/Tango.BL/ObservableEntityDTO.cs @@ -53,7 +53,7 @@ namespace Tango.BL var observableProp = typeof(T).GetProperty(prop.Name); if (observableProp != null) { - if (prop.PropertyType.IsPrimitive || prop.PropertyType.IsValueType || prop.PropertyType == typeof(String) || prop.PropertyType == typeof(byte[])) + if (prop.PropertyType.IsValueTypeOrString() || prop.PropertyType == typeof(byte[])) { prop.SetValue(dto, observableProp.GetValue(observable)); } @@ -114,7 +114,7 @@ namespace Tango.BL var observableProp = typeof(T).GetProperty(prop.Name); if (observableProp != null) { - if (prop.PropertyType.IsPrimitive || prop.PropertyType.IsValueType || prop.PropertyType == typeof(String) || prop.PropertyType == typeof(byte[])) + if (prop.PropertyType.IsValueTypeOrString() || prop.PropertyType == typeof(byte[])) { observableProp.SetValue(observable, prop.GetValue(this)); } @@ -189,7 +189,7 @@ namespace Tango.BL var observableProp = typeof(T).GetProperty(prop.Name); if (observableProp != null) { - if (prop.PropertyType.IsPrimitive || prop.PropertyType.IsValueType || prop.PropertyType == typeof(String) || prop.PropertyType == typeof(byte[])) + if (prop.PropertyType.IsValueTypeOrString() || prop.PropertyType == typeof(byte[])) { var observableValue = observableProp.GetValue(observable); var dtoValue = prop.GetValue(this); diff --git a/Software/Visual_Studio/Tango.BL/ObservablesContext.cs b/Software/Visual_Studio/Tango.BL/ObservablesContext.cs index 3511a7624..b2881c741 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesContext.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesContext.cs @@ -494,6 +494,14 @@ namespace Tango.BL get; set; } + /// + /// Gets or sets the RmlsSpools. + /// + public DbSet RmlsSpools + { + get; set; + } + /// /// Gets or sets the Roles. /// diff --git a/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs b/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs index cccc2fcae..59b5253bc 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs @@ -2141,6 +2141,42 @@ namespace Tango.BL } + private ObservableCollection _rmlsspools; + /// + /// Gets or sets the RmlsSpools. + /// + public ObservableCollection RmlsSpools + { + get + { + return _rmlsspools; + } + + set + { + _rmlsspools = value; RaisePropertyChanged(nameof(RmlsSpools)); + } + + } + + private ICollectionView _rmlsspoolsViewSource; + /// + /// Gets or sets the RmlsSpools View Source. + /// + public ICollectionView RmlsSpoolsViewSource + { + get + { + return _rmlsspoolsViewSource; + } + + set + { + _rmlsspoolsViewSource = value; RaisePropertyChanged(nameof(RmlsSpoolsViewSource)); + } + + } + private ObservableCollection _roles; /// /// Gets or sets the Roles. @@ -2985,6 +3021,8 @@ namespace Tango.BL RmlsViewSource = CreateCollectionView(Rmls); + RmlsSpoolsViewSource = CreateCollectionView(RmlsSpools); + RolesViewSource = CreateCollectionView(Roles); RolesPermissionsViewSource = CreateCollectionView(RolesPermissions); diff --git a/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs b/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs index 4e108deb2..178a62595 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs @@ -2141,6 +2141,42 @@ namespace Tango.BL } + private ObservableCollection _rmlsspools; + /// + /// Gets or sets the RmlsSpools. + /// + public ObservableCollection RmlsSpools + { + get + { + return _rmlsspools; + } + + set + { + _rmlsspools = value; RaisePropertyChanged(nameof(RmlsSpools)); + } + + } + + private ICollectionView _rmlsspoolsViewSource; + /// + /// Gets or sets the RmlsSpools View Source. + /// + public ICollectionView RmlsSpoolsViewSource + { + get + { + return _rmlsspoolsViewSource; + } + + set + { + _rmlsspoolsViewSource = value; RaisePropertyChanged(nameof(RmlsSpoolsViewSource)); + } + + } + private ObservableCollection _roles; /// /// Gets or sets the Roles. @@ -2985,6 +3021,8 @@ namespace Tango.BL RmlsViewSource = CreateCollectionView(Rmls); + RmlsSpoolsViewSource = CreateCollectionView(RmlsSpools); + RolesViewSource = CreateCollectionView(Roles); RolesPermissionsViewSource = CreateCollectionView(RolesPermissions); diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index 2a5090c2e..f222f8ff6 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -248,6 +248,8 @@ + + @@ -358,6 +360,8 @@ + + @@ -610,7 +614,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs index e8ef9addd..cee991507 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs @@ -35,9 +35,9 @@ namespace Tango.Core.ExtensionMethods NoReferenceTypes = 8, /// - /// Map only primitive values. + /// Map only value types. /// - PrimitivesOnly, + ValueTypesOnly, } /// @@ -59,7 +59,7 @@ namespace Tango.Core.ExtensionMethods foreach (var prop in typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.SetMethod != null)) { - if (!prop.PropertyType.IsGenericType) + if (!prop.PropertyType.IsGenericTypeAndNotNullable()) { prop.SetValue(cloned, prop.GetValue(obj)); } @@ -78,7 +78,7 @@ namespace Tango.Core.ExtensionMethods { foreach (var prop in typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.SetMethod != null)) { - if (!prop.PropertyType.IsGenericType) + if (!prop.PropertyType.IsGenericTypeAndNotNullable()) { prop.SetValue(destination, prop.GetValue(source)); } @@ -104,7 +104,7 @@ namespace Tango.Core.ExtensionMethods if (!condition(prop)) continue; } - if (!propType.IsPrimitive && flags.HasFlag(MappingFlags.PrimitivesOnly)) + if (!propType.IsValueType && flags.HasFlag(MappingFlags.ValueTypesOnly)) { continue; } @@ -141,7 +141,7 @@ namespace Tango.Core.ExtensionMethods /// The destination. public static void MapPrimitivesTo(this object source, object destination) { - source.MapPropertiesTo(destination, MappingFlags.PrimitivesOnly); + source.MapPropertiesTo(destination, MappingFlags.ValueTypesOnly); } /// diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/TypeExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/TypeExtensions.cs index c6fd3d811..66978ec19 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/TypeExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/TypeExtensions.cs @@ -122,4 +122,19 @@ public static class TypeExtensions { return type.GetProperties().Where(x => x.GetCustomAttribute() != null); } + + public static bool IsGenericTypeAndNotNullable(this Type type) + { + return type.IsGenericType && Nullable.GetUnderlyingType(type) == null; + } + + public static bool IsNullable(this Type type) + { + return Nullable.GetUnderlyingType(type) != null; + } + + public static bool IsValueTypeOrString(this Type type) + { + return type.IsValueType || type == typeof(String); + } } diff --git a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj index 891c5e58f..7c794c276 100644 --- a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj +++ b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj @@ -205,7 +205,7 @@ - + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/COLOR_SPACES.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/COLOR_SPACES.cs index d2a9c4479..e1a81b759 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/COLOR_SPACES.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/COLOR_SPACES.cs @@ -19,7 +19,6 @@ namespace Tango.DAL.Remote.DB { this.BRUSH_STOPS = new HashSet(); this.JOBS = new HashSet(); - this.MACHINES = new HashSet(); } public int ID { get; set; } @@ -34,7 +33,5 @@ namespace Tango.DAL.Remote.DB public virtual ICollection BRUSH_STOPS { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection JOBS { get; set; } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection MACHINES { get; set; } } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs index 7f4aa62a9..d4bf7c867 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs @@ -60,7 +60,6 @@ namespace Tango.DAL.Remote.DB [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection CATS { get; set; } - public virtual COLOR_SPACES COLOR_SPACES { get; set; } public virtual CONFIGURATION CONFIGURATION { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection JOBS { get; set; } @@ -68,8 +67,6 @@ namespace Tango.DAL.Remote.DB [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection MACHINES_EVENTS { get; set; } public virtual ORGANIZATION ORGANIZATION { get; set; } - public virtual RML RML { get; set; } - public virtual SPOOL_TYPES SPOOL_TYPES { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection SPOOLS { get; set; } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/PROCESS_PARAMETERS_TABLES.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/PROCESS_PARAMETERS_TABLES.cs index bfa6bbe58..2a04633bf 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/PROCESS_PARAMETERS_TABLES.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/PROCESS_PARAMETERS_TABLES.cs @@ -45,8 +45,6 @@ namespace Tango.DAL.Remote.DB public double HEAD_ZONE10_TEMP { get; set; } public double HEAD_ZONE11_TEMP { get; set; } public double HEAD_ZONE12_TEMP { get; set; } - public double ST_SP_ZONE1_TEMP { get; set; } - public double ST_SP_ZONE2_TEMP { get; set; } public double R_BLOWER_FLOW { get; set; } public double R_BLOWER_TEMP { get; set; } public double L_BLOWER_FLOW { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs index 2c0ac2a33..2772e1958 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs @@ -21,8 +21,8 @@ namespace Tango.DAL.Remote.DB this.COLOR_CATALOGS_ITEMS_RECIPES = new HashSet(); this.JOBS = new HashSet(); this.LIQUID_TYPES_RMLS = new HashSet(); - this.MACHINES = new HashSet(); this.PROCESS_PARAMETERS_TABLES_GROUPS = new HashSet(); + this.RMLS_SPOOLS = new HashSet(); this.SITES_RMLS = new HashSet(); } @@ -73,14 +73,14 @@ namespace Tango.DAL.Remote.DB public virtual LINEAR_MASS_DENSITY_UNITS LINEAR_MASS_DENSITY_UNITS { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection LIQUID_TYPES_RMLS { get; set; } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection MACHINES { get; set; } public virtual MEDIA_CONDITIONS MEDIA_CONDITIONS { get; set; } public virtual MEDIA_MATERIALS MEDIA_MATERIALS { get; set; } public virtual MEDIA_PURPOSES MEDIA_PURPOSES { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection PROCESS_PARAMETERS_TABLES_GROUPS { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection RMLS_SPOOLS { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection SITES_RMLS { get; set; } } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RMLS_SPOOLS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RMLS_SPOOLS.cs new file mode 100644 index 000000000..a314530ec --- /dev/null +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RMLS_SPOOLS.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.DAL.Remote.DB +{ + using System; + using System.Collections.Generic; + + public partial class RMLS_SPOOLS + { + public int ID { get; set; } + public string GUID { get; set; } + public System.DateTime LAST_UPDATED { get; set; } + public string SPOOL_TYPE_GUID { get; set; } + public string RML_GUID { get; set; } + public Nullable ROTATIONS_PER_PASSAGE { get; set; } + public Nullable LENGTH { get; set; } + public Nullable BACKING_RATE { get; set; } + public Nullable BOTTOM_BACKING_RATE { get; set; } + + public virtual RML RML { get; set; } + public virtual SPOOL_TYPES SPOOL_TYPES { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs index 2a158ad49..62ae00ce7 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs @@ -84,6 +84,7 @@ namespace Tango.DAL.Remote.DB public virtual DbSet PROCESS_PARAMETERS_TABLES { get; set; } public virtual DbSet PROCESS_PARAMETERS_TABLES_GROUPS { get; set; } public virtual DbSet RMLS { get; set; } + public virtual DbSet RMLS_SPOOLS { get; set; } public virtual DbSet ROLES { get; set; } public virtual DbSet ROLES_PERMISSIONS { get; set; } public virtual DbSet SEGMENTS { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index bed5ba7eb..4bccfc804 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -878,8 +878,6 @@ - - @@ -936,6 +934,20 @@ + + + + + + + + + + + + + + @@ -1013,6 +1025,11 @@ + + + + + @@ -1023,10 +1040,11 @@ - - - - + + + + + @@ -1851,18 +1869,6 @@ - - - - - - - - - - - - @@ -1943,30 +1949,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -2107,6 +2089,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2390,6 +2400,7 @@ + @@ -2611,10 +2622,6 @@ - - - - @@ -2639,14 +2646,6 @@ - - - - - - - - @@ -2691,6 +2690,14 @@ + + + + + + + + @@ -2824,6 +2831,7 @@ + @@ -2932,10 +2940,6 @@ - - - - @@ -3112,14 +3116,6 @@ - - - - - - - - @@ -3160,10 +3156,18 @@ + + + + + + + + @@ -3439,7 +3443,6 @@ - @@ -4062,14 +4065,11 @@ - - - @@ -4199,8 +4199,6 @@ - - @@ -4267,13 +4265,29 @@ - + + + + + + + + + + + + + + + + + @@ -4364,8 +4378,13 @@ + + + + + - + @@ -4377,10 +4396,11 @@ - - - - + + + + + @@ -4847,18 +4867,6 @@ - - - - - - - - - - - - @@ -5433,30 +5441,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -5585,6 +5569,20 @@ + + + + + + + + + + + + + + @@ -5599,6 +5597,20 @@ + + + + + + + + + + + + + + @@ -6608,8 +6620,6 @@ - - @@ -6697,6 +6707,21 @@ + + + + + + + + + + + + + + + @@ -6770,6 +6795,11 @@ + + + + + @@ -6785,6 +6815,7 @@ + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index b7e5e116a..354839477 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,84 +5,85 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -105,7 +106,6 @@ - @@ -150,8 +150,6 @@ - - @@ -162,7 +160,9 @@ + + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/SPOOL.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/SPOOL.cs index 74996acd0..d983a5d69 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/SPOOL.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/SPOOL.cs @@ -19,10 +19,11 @@ namespace Tango.DAL.Remote.DB public System.DateTime LAST_UPDATED { get; set; } public string SPOOL_TYPE_GUID { get; set; } public string MACHINE_GUID { get; set; } - public int START_OFFSET_PULSES { get; set; } - public int BACKING_RATE { get; set; } - public int SEGMENT_OFFSET_PULSES { get; set; } - public int BOTTOM_BACKING_RATE { get; set; } + public Nullable START_OFFSET_PULSES { get; set; } + public Nullable BACKING_RATE { get; set; } + public Nullable SEGMENT_OFFSET_PULSES { get; set; } + public Nullable BOTTOM_BACKING_RATE { get; set; } + public Nullable LIMIT_SWITCH_START_POINT_OFFSET { get; set; } public virtual MACHINE MACHINE { get; set; } public virtual SPOOL_TYPES SPOOL_TYPES { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/SPOOL_TYPES.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/SPOOL_TYPES.cs index 1d8b75f90..af2355553 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/SPOOL_TYPES.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/SPOOL_TYPES.cs @@ -18,7 +18,7 @@ namespace Tango.DAL.Remote.DB public SPOOL_TYPES() { this.JOBS = new HashSet(); - this.MACHINES = new HashSet(); + this.RMLS_SPOOLS = new HashSet(); this.SPOOLS = new HashSet(); } @@ -31,11 +31,16 @@ namespace Tango.DAL.Remote.DB public double WEIGHT { get; set; } public double DIAMETER { get; set; } public double ROTATIONS_PER_PASSAGE { get; set; } + public int START_OFFSET_PULSES { get; set; } + public int BACKING_RATE { get; set; } + public int SEGMENT_OFFSET_PULSES { get; set; } + public int BOTTOM_BACKING_RATE { get; set; } + public int LIMIT_SWITCH_START_POINT_OFFSET { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection JOBS { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection MACHINES { get; set; } + public virtual ICollection RMLS_SPOOLS { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection SPOOLS { get; set; } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj b/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj index 0a0cad6e2..7ea9a77a7 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj +++ b/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj @@ -255,6 +255,9 @@ RemoteADO.tt + + RemoteADO.tt + RemoteADO.tt @@ -368,7 +371,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 5711882a3..4084e4ee7 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -2189,8 +2189,8 @@ namespace Tango.Integration.Operation tiLiquid.Volume = 100; } } - //Modify transparent brush stops. + //Modify transparent brush stops. if (EnableJobLiquidQuantityValidation) { ValidateJobLiquidQuantity(job, processParameters, job.Machine.Configuration); @@ -2236,23 +2236,28 @@ namespace Tango.Integration.Operation ticket.NumberOfUnits = (uint)Math.Max(job.NumberOfUnits, 1); } + //Spool parameters ticket.Spool = new JobSpool(); - job.SpoolType.MapPrimitivesTo(ticket.Spool); + ticket.Spool.JobSpoolType = (JobSpoolType)job.SpoolType.Code; - var spool = job.Machine.Spools.SingleOrDefault(x => x.SpoolType == job.SpoolType); - - if (spool == null) + //Override spool parameters from RML Spool calibration + var rmlSpool = job.Rml.RmlsSpools.FirstOrDefault(x => x.SpoolType.Guid == job.SpoolType.Guid); + if (rmlSpool != null) { - throw new InvalidOperationException("Job spool type is not registered with this machine."); + ticket.Spool.RotationsPerPassage = rmlSpool.RotationsPerPassage != null ? rmlSpool.RotationsPerPassage.Value : ticket.Spool.RotationsPerPassage; + ticket.Spool.Length = rmlSpool.Length != null ? rmlSpool.Length.Value : ticket.Spool.Length; + ticket.Spool.BackingRate = rmlSpool.BackingRate != null ? rmlSpool.BackingRate.Value : ticket.Spool.BackingRate; + ticket.Spool.BottomBackingRate = rmlSpool.BottomBackingRate != null ? rmlSpool.BottomBackingRate.Value : ticket.Spool.BottomBackingRate; } - else + + //Override spool parameters from Machine Spool calibration + var machineSpool = job.Machine.Spools.FirstOrDefault(x => x.SpoolType.Guid == job.SpoolType.Guid); + if (machineSpool != null) { - spool.MapPrimitivesTo(ticket.Spool); + ticket.Spool.LimitSwitchStartPointOffset = machineSpool.LimitSwitchStartPointOffset != null ? machineSpool.LimitSwitchStartPointOffset.Value : ticket.Spool.LimitSwitchStartPointOffset; } - ticket.Spool.JobSpoolType = (JobSpoolType)job.SpoolType.Code; - ProcessParameters process = new ProcessParameters(); processParameters.MapPrimitivesTo(process); ticket.ProcessParameters = process; diff --git a/Software/Visual_Studio/Tango.PMR/Printing/JobSpool.cs b/Software/Visual_Studio/Tango.PMR/Printing/JobSpool.cs index 7261ba19b..c716906e6 100644 --- a/Software/Visual_Studio/Tango.PMR/Printing/JobSpool.cs +++ b/Software/Visual_Studio/Tango.PMR/Printing/JobSpool.cs @@ -23,17 +23,18 @@ namespace Tango.PMR.Printing { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "Cg5Kb2JTcG9vbC5wcm90bxISVGFuZ28uUE1SLlByaW50aW5nGhJKb2JTcG9v", - "bFR5cGUucHJvdG8i+QEKCEpvYlNwb29sEjYKDEpvYlNwb29sVHlwZRgBIAEo", + "bFR5cGUucHJvdG8ingIKCEpvYlNwb29sEjYKDEpvYlNwb29sVHlwZRgBIAEo", "DjIgLlRhbmdvLlBNUi5QcmludGluZy5Kb2JTcG9vbFR5cGUSDgoGTGVuZ3Ro", "GAIgASgBEg4KBldlaWdodBgDIAEoARIQCghEaWFtZXRlchgEIAEoARIbChNS", "b3RhdGlvbnNQZXJQYXNzYWdlGAUgASgBEhkKEVN0YXJ0T2Zmc2V0UHVsc2Vz", "GAYgASgFEhMKC0JhY2tpbmdSYXRlGAcgASgFEhsKE1NlZ21lbnRPZmZzZXRQ", - "dWxzZXMYCCABKAUSGQoRQm90dG9tQmFja2luZ1JhdGUYCSABKAVCHgocY29t", - "LnR3aW5lLnRhbmdvLnBtci5wcmludGluZ2IGcHJvdG8z")); + "dWxzZXMYCCABKAUSGQoRQm90dG9tQmFja2luZ1JhdGUYCSABKAUSIwobTGlt", + "aXRTd2l0Y2hTdGFydFBvaW50T2Zmc2V0GAogASgFQh4KHGNvbS50d2luZS50", + "YW5nby5wbXIucHJpbnRpbmdiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Tango.PMR.Printing.JobSpoolTypeReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Printing.JobSpool), global::Tango.PMR.Printing.JobSpool.Parser, new[]{ "JobSpoolType", "Length", "Weight", "Diameter", "RotationsPerPassage", "StartOffsetPulses", "BackingRate", "SegmentOffsetPulses", "BottomBackingRate" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Printing.JobSpool), global::Tango.PMR.Printing.JobSpool.Parser, new[]{ "JobSpoolType", "Length", "Weight", "Diameter", "RotationsPerPassage", "StartOffsetPulses", "BackingRate", "SegmentOffsetPulses", "BottomBackingRate", "LimitSwitchStartPointOffset" }, null, null, null) })); } #endregion @@ -73,6 +74,7 @@ namespace Tango.PMR.Printing { backingRate_ = other.backingRate_; segmentOffsetPulses_ = other.segmentOffsetPulses_; bottomBackingRate_ = other.bottomBackingRate_; + limitSwitchStartPointOffset_ = other.limitSwitchStartPointOffset_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -179,6 +181,17 @@ namespace Tango.PMR.Printing { } } + /// Field number for the "LimitSwitchStartPointOffset" field. + public const int LimitSwitchStartPointOffsetFieldNumber = 10; + private int limitSwitchStartPointOffset_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int LimitSwitchStartPointOffset { + get { return limitSwitchStartPointOffset_; } + set { + limitSwitchStartPointOffset_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as JobSpool); @@ -201,6 +214,7 @@ namespace Tango.PMR.Printing { if (BackingRate != other.BackingRate) return false; if (SegmentOffsetPulses != other.SegmentOffsetPulses) return false; if (BottomBackingRate != other.BottomBackingRate) return false; + if (LimitSwitchStartPointOffset != other.LimitSwitchStartPointOffset) return false; return true; } @@ -216,6 +230,7 @@ namespace Tango.PMR.Printing { if (BackingRate != 0) hash ^= BackingRate.GetHashCode(); if (SegmentOffsetPulses != 0) hash ^= SegmentOffsetPulses.GetHashCode(); if (BottomBackingRate != 0) hash ^= BottomBackingRate.GetHashCode(); + if (LimitSwitchStartPointOffset != 0) hash ^= LimitSwitchStartPointOffset.GetHashCode(); return hash; } @@ -262,6 +277,10 @@ namespace Tango.PMR.Printing { output.WriteRawTag(72); output.WriteInt32(BottomBackingRate); } + if (LimitSwitchStartPointOffset != 0) { + output.WriteRawTag(80); + output.WriteInt32(LimitSwitchStartPointOffset); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -294,6 +313,9 @@ namespace Tango.PMR.Printing { if (BottomBackingRate != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(BottomBackingRate); } + if (LimitSwitchStartPointOffset != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(LimitSwitchStartPointOffset); + } return size; } @@ -329,6 +351,9 @@ namespace Tango.PMR.Printing { if (other.BottomBackingRate != 0) { BottomBackingRate = other.BottomBackingRate; } + if (other.LimitSwitchStartPointOffset != 0) { + LimitSwitchStartPointOffset = other.LimitSwitchStartPointOffset; + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -375,6 +400,10 @@ namespace Tango.PMR.Printing { BottomBackingRate = input.ReadInt32(); break; } + case 80: { + LimitSwitchStartPointOffset = input.ReadInt32(); + break; + } } } } diff --git a/Software/Visual_Studio/Tango.PMR/Printing/ProcessParameters.cs b/Software/Visual_Studio/Tango.PMR/Printing/ProcessParameters.cs index 33521d40b..ef290e431 100644 --- a/Software/Visual_Studio/Tango.PMR/Printing/ProcessParameters.cs +++ b/Software/Visual_Studio/Tango.PMR/Printing/ProcessParameters.cs @@ -23,7 +23,7 @@ namespace Tango.PMR.Printing { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "ChdQcm9jZXNzUGFyYW1ldGVycy5wcm90bxISVGFuZ28uUE1SLlByaW50aW5n", - "IucFChFQcm9jZXNzUGFyYW1ldGVycxITCgtEeWVpbmdTcGVlZBgBIAEoARIU", + "IrkFChFQcm9jZXNzUGFyYW1ldGVycxITCgtEeWVpbmdTcGVlZBgBIAEoARIU", "CgxNaW5JbmtVcHRha2UYAiABKAESFAoMTWF4SW5rVXB0YWtlGAMgASgBEhUK", "DUZlZWRlclRlbnNpb24YBCABKAESFQoNUHVsbGVyVGVuc2lvbhgFIAEoARIV", "Cg1XaW5kZXJUZW5zaW9uGAYgASgBEhEKCU1peGVyVGVtcBgHIAEoARIVCg1I", @@ -36,15 +36,14 @@ namespace Tango.PMR.Printing { "EyABKAESEgoKVGFibGVJbmRleBgUIAEoBRIVCg1IZWFkWm9uZTdUZW1wGBUg", "ASgBEhUKDUhlYWRab25lOFRlbXAYFiABKAESFQoNSGVhZFpvbmU5VGVtcBgX", "IAEoARIWCg5IZWFkWm9uZTEwVGVtcBgYIAEoARIWCg5IZWFkWm9uZTExVGVt", - "cBgZIAEoARIWCg5IZWFkWm9uZTEyVGVtcBgaIAEoARIVCg1TdFNwWm9uZTFU", - "ZW1wGBsgASgBEhUKDVN0U3Bab25lMlRlbXAYHCABKAESEwoLUkJsb3dlckZs", - "b3cYHSABKAESEwoLUkJsb3dlclRlbXAYHiABKAESEwoLTEJsb3dlckZsb3cY", - "HyABKAESEwoLTEJsb3dlclRlbXAYICABKAFCHgocY29tLnR3aW5lLnRhbmdv", - "LnBtci5wcmludGluZ2IGcHJvdG8z")); + "cBgZIAEoARIWCg5IZWFkWm9uZTEyVGVtcBgaIAEoARITCgtSQmxvd2VyRmxv", + "dxgbIAEoARITCgtSQmxvd2VyVGVtcBgcIAEoARITCgtMQmxvd2VyRmxvdxgd", + "IAEoARITCgtMQmxvd2VyVGVtcBgeIAEoAUIeChxjb20udHdpbmUudGFuZ28u", + "cG1yLnByaW50aW5nYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Printing.ProcessParameters), global::Tango.PMR.Printing.ProcessParameters.Parser, new[]{ "DyeingSpeed", "MinInkUptake", "MaxInkUptake", "FeederTension", "PullerTension", "WinderTension", "MixerTemp", "HeadZone1Temp", "HeadZone2Temp", "HeadZone3Temp", "HeadZone4Temp", "HeadZone5Temp", "HeadZone6Temp", "DryerAirFlow", "DryerZone1Temp", "DryerZone2Temp", "DryerZone3Temp", "DryerBufferLength", "HeadAirFlow", "TableIndex", "HeadZone7Temp", "HeadZone8Temp", "HeadZone9Temp", "HeadZone10Temp", "HeadZone11Temp", "HeadZone12Temp", "StSpZone1Temp", "StSpZone2Temp", "RBlowerFlow", "RBlowerTemp", "LBlowerFlow", "LBlowerTemp" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Printing.ProcessParameters), global::Tango.PMR.Printing.ProcessParameters.Parser, new[]{ "DyeingSpeed", "MinInkUptake", "MaxInkUptake", "FeederTension", "PullerTension", "WinderTension", "MixerTemp", "HeadZone1Temp", "HeadZone2Temp", "HeadZone3Temp", "HeadZone4Temp", "HeadZone5Temp", "HeadZone6Temp", "DryerAirFlow", "DryerZone1Temp", "DryerZone2Temp", "DryerZone3Temp", "DryerBufferLength", "HeadAirFlow", "TableIndex", "HeadZone7Temp", "HeadZone8Temp", "HeadZone9Temp", "HeadZone10Temp", "HeadZone11Temp", "HeadZone12Temp", "RBlowerFlow", "RBlowerTemp", "LBlowerFlow", "LBlowerTemp" }, null, null, null) })); } #endregion @@ -101,8 +100,6 @@ namespace Tango.PMR.Printing { headZone10Temp_ = other.headZone10Temp_; headZone11Temp_ = other.headZone11Temp_; headZone12Temp_ = other.headZone12Temp_; - stSpZone1Temp_ = other.stSpZone1Temp_; - stSpZone2Temp_ = other.stSpZone2Temp_; rBlowerFlow_ = other.rBlowerFlow_; rBlowerTemp_ = other.rBlowerTemp_; lBlowerFlow_ = other.lBlowerFlow_; @@ -400,30 +397,8 @@ namespace Tango.PMR.Printing { } } - /// Field number for the "StSpZone1Temp" field. - public const int StSpZone1TempFieldNumber = 27; - private double stSpZone1Temp_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double StSpZone1Temp { - get { return stSpZone1Temp_; } - set { - stSpZone1Temp_ = value; - } - } - - /// Field number for the "StSpZone2Temp" field. - public const int StSpZone2TempFieldNumber = 28; - private double stSpZone2Temp_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double StSpZone2Temp { - get { return stSpZone2Temp_; } - set { - stSpZone2Temp_ = value; - } - } - /// Field number for the "RBlowerFlow" field. - public const int RBlowerFlowFieldNumber = 29; + public const int RBlowerFlowFieldNumber = 27; private double rBlowerFlow_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public double RBlowerFlow { @@ -434,7 +409,7 @@ namespace Tango.PMR.Printing { } /// Field number for the "RBlowerTemp" field. - public const int RBlowerTempFieldNumber = 30; + public const int RBlowerTempFieldNumber = 28; private double rBlowerTemp_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public double RBlowerTemp { @@ -445,7 +420,7 @@ namespace Tango.PMR.Printing { } /// Field number for the "LBlowerFlow" field. - public const int LBlowerFlowFieldNumber = 31; + public const int LBlowerFlowFieldNumber = 29; private double lBlowerFlow_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public double LBlowerFlow { @@ -456,7 +431,7 @@ namespace Tango.PMR.Printing { } /// Field number for the "LBlowerTemp" field. - public const int LBlowerTempFieldNumber = 32; + public const int LBlowerTempFieldNumber = 30; private double lBlowerTemp_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public double LBlowerTemp { @@ -505,8 +480,6 @@ namespace Tango.PMR.Printing { if (HeadZone10Temp != other.HeadZone10Temp) return false; if (HeadZone11Temp != other.HeadZone11Temp) return false; if (HeadZone12Temp != other.HeadZone12Temp) return false; - if (StSpZone1Temp != other.StSpZone1Temp) return false; - if (StSpZone2Temp != other.StSpZone2Temp) return false; if (RBlowerFlow != other.RBlowerFlow) return false; if (RBlowerTemp != other.RBlowerTemp) return false; if (LBlowerFlow != other.LBlowerFlow) return false; @@ -543,8 +516,6 @@ namespace Tango.PMR.Printing { if (HeadZone10Temp != 0D) hash ^= HeadZone10Temp.GetHashCode(); if (HeadZone11Temp != 0D) hash ^= HeadZone11Temp.GetHashCode(); if (HeadZone12Temp != 0D) hash ^= HeadZone12Temp.GetHashCode(); - if (StSpZone1Temp != 0D) hash ^= StSpZone1Temp.GetHashCode(); - if (StSpZone2Temp != 0D) hash ^= StSpZone2Temp.GetHashCode(); if (RBlowerFlow != 0D) hash ^= RBlowerFlow.GetHashCode(); if (RBlowerTemp != 0D) hash ^= RBlowerTemp.GetHashCode(); if (LBlowerFlow != 0D) hash ^= LBlowerFlow.GetHashCode(); @@ -663,28 +634,20 @@ namespace Tango.PMR.Printing { output.WriteRawTag(209, 1); output.WriteDouble(HeadZone12Temp); } - if (StSpZone1Temp != 0D) { - output.WriteRawTag(217, 1); - output.WriteDouble(StSpZone1Temp); - } - if (StSpZone2Temp != 0D) { - output.WriteRawTag(225, 1); - output.WriteDouble(StSpZone2Temp); - } if (RBlowerFlow != 0D) { - output.WriteRawTag(233, 1); + output.WriteRawTag(217, 1); output.WriteDouble(RBlowerFlow); } if (RBlowerTemp != 0D) { - output.WriteRawTag(241, 1); + output.WriteRawTag(225, 1); output.WriteDouble(RBlowerTemp); } if (LBlowerFlow != 0D) { - output.WriteRawTag(249, 1); + output.WriteRawTag(233, 1); output.WriteDouble(LBlowerFlow); } if (LBlowerTemp != 0D) { - output.WriteRawTag(129, 2); + output.WriteRawTag(241, 1); output.WriteDouble(LBlowerTemp); } } @@ -770,12 +733,6 @@ namespace Tango.PMR.Printing { if (HeadZone12Temp != 0D) { size += 2 + 8; } - if (StSpZone1Temp != 0D) { - size += 2 + 8; - } - if (StSpZone2Temp != 0D) { - size += 2 + 8; - } if (RBlowerFlow != 0D) { size += 2 + 8; } @@ -874,12 +831,6 @@ namespace Tango.PMR.Printing { if (other.HeadZone12Temp != 0D) { HeadZone12Temp = other.HeadZone12Temp; } - if (other.StSpZone1Temp != 0D) { - StSpZone1Temp = other.StSpZone1Temp; - } - if (other.StSpZone2Temp != 0D) { - StSpZone2Temp = other.StSpZone2Temp; - } if (other.RBlowerFlow != 0D) { RBlowerFlow = other.RBlowerFlow; } @@ -1007,26 +958,18 @@ namespace Tango.PMR.Printing { break; } case 217: { - StSpZone1Temp = input.ReadDouble(); - break; - } - case 225: { - StSpZone2Temp = input.ReadDouble(); - break; - } - case 233: { RBlowerFlow = input.ReadDouble(); break; } - case 241: { + case 225: { RBlowerTemp = input.ReadDouble(); break; } - case 249: { + case 233: { LBlowerFlow = input.ReadDouble(); break; } - case 257: { + case 241: { LBlowerTemp = input.ReadDouble(); break; } diff --git a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/OverrideData.xml b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/OverrideData.xml index c0d3aa837..e340a65ca 100644 Binary files a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/OverrideData.xml and b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/OverrideData.xml differ diff --git a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml index d33b19137..b8c949c2a 100644 Binary files a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml and b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml differ diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/EmptyStringToNullConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/EmptyStringToNullConverter.cs new file mode 100644 index 000000000..8d62178c7 --- /dev/null +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/EmptyStringToNullConverter.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace Tango.SharedUI.Converters +{ + public class EmptyStringToNullConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return value; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null) + { + if (String.IsNullOrWhiteSpace(value.ToString())) + { + return null; + } + } + + return value; + } + } +} diff --git a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj index dddaa750c..092afd777 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj +++ b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj @@ -100,6 +100,7 @@ + @@ -243,7 +244,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs b/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs index ac20feb04..208adf63f 100644 --- a/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs +++ b/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs @@ -154,6 +154,14 @@ namespace Tango.DBObservablesGenerator.CLI { codeField.Type = String.Format("Nullable<{0}>", "DateTime"); } + else if (field.PropertyType == typeof(Nullable)) + { + codeField.Type = String.Format("Nullable<{0}>", "Int32"); + } + else if (field.PropertyType == typeof(Nullable)) + { + codeField.Type = String.Format("Nullable<{0}>", "Double"); + } else { codeField.Type = String.Format("SynchronizedObservableCollection<{0}>", DalNameToStandardName(field.PropertyType.GenericTypeArguments.Single().Name).SingularizeMVC()); @@ -237,7 +245,7 @@ namespace Tango.DBObservablesGenerator.CLI //Generate Enumerations... using (RemoteDB db = new RemoteDB(SettingsManager.Default.GetOrCreate().DataSource)) { - foreach (var tableProp in db.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType.IsGenericType)) + foreach (var tableProp in db.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType.IsGenericTypeAndNotNullable())) { try { @@ -387,7 +395,7 @@ namespace Tango.DBObservablesGenerator.CLI codeField.Description = FirstCharacterToLower(DalNameToStandardName(name)); - if (field.PropertyType.IsGenericType) + if (field.PropertyType.IsGenericTypeAndNotNullable()) { continue; } @@ -435,7 +443,7 @@ namespace Tango.DBObservablesGenerator.CLI //Generate Enumerations... using (RemoteDB db = new RemoteDB(SettingsManager.Default.GetOrCreate().DataSource)) { - foreach (var tableProp in db.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType.IsGenericType)) + foreach (var tableProp in db.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType.IsGenericTypeAndNotNullable())) { try { -- cgit v1.3.1 From 882a6d54d60f05f3bf542ab43c3681f64152df41 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Thu, 27 Feb 2020 00:34:46 +0200 Subject: Added thread parameters DB, PMR, MachineOperator merging, Machine Studio. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes Software/PMR/Messages/Printing/JobTicket.proto | 3 + .../PMR/Messages/Printing/ThreadParameters.proto | 19 + .../Controls/JobOutlineControl.cs | 14 + .../Tango.MachineStudio.RML.csproj | 7 + .../ViewModels/MainViewVM.cs | 154 ++++---- .../Tango.MachineStudio.RML/Views/MainView.xaml | 2 +- .../Tango.MachineStudio.RML/Views/RmlView.xaml | 5 +- .../Views/ThreadParametersView.xaml | 82 +++++ .../Views/ThreadParametersView.xaml.cs | 28 ++ .../Tango.PPC.Jobs/Controls/JobOutlineControl.cs | 14 + Software/Visual_Studio/Tango.BL/DTO/RmlDTOBase.cs | 72 ++++ .../Visual_Studio/Tango.BL/Entities/RmlBase.cs | 342 ++++++++++++++++++ Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs | 9 + .../Tango.DAL.Remote/DB/RemoteADO.Designer.cs | 2 +- .../Tango.DAL.Remote/DB/RemoteADO.edmx | 27 ++ .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 140 ++++---- .../Operation/IMachineOperator.cs | 9 - .../Tango.Integration/Operation/MachineOperator.cs | 224 +----------- .../Visual_Studio/Tango.PMR/Printing/JobTicket.cs | 66 +++- .../Tango.PMR/Printing/ThreadParameters.cs | 386 +++++++++++++++++++++ Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj | 3 +- 23 files changed, 1219 insertions(+), 389 deletions(-) create mode 100644 Software/PMR/Messages/Printing/ThreadParameters.proto create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ThreadParametersView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ThreadParametersView.xaml.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Printing/ThreadParameters.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index acb091ff8..d291434cb 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 85ba181a9..15e009d48 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/PMR/Messages/Printing/JobTicket.proto b/Software/PMR/Messages/Printing/JobTicket.proto index 9824f6ef0..b442893cd 100644 --- a/Software/PMR/Messages/Printing/JobTicket.proto +++ b/Software/PMR/Messages/Printing/JobTicket.proto @@ -5,6 +5,7 @@ import "ProcessParameters.proto"; import "JobWindingMethod.proto"; import "JobSpool.proto"; import "JobUploadStrategy.proto"; +import "ThreadParameters.proto"; package Tango.PMR.Printing; option java_package = "com.twine.tango.pmr.printing"; @@ -35,4 +36,6 @@ message JobTicket //sample winding winds each segment densely on a small part of the spool, end moves one for the next segment bool SampleWinding = 14; + + ThreadParameters ThreadParameters = 15; } \ No newline at end of file diff --git a/Software/PMR/Messages/Printing/ThreadParameters.proto b/Software/PMR/Messages/Printing/ThreadParameters.proto new file mode 100644 index 000000000..f5d18d1fe --- /dev/null +++ b/Software/PMR/Messages/Printing/ThreadParameters.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +package Tango.PMR.Printing; +option java_package = "com.twine.tango.pmr.printing"; + +message ThreadParameters +{ + int32 FeederP = 1; + int32 FeederI = 2; + int32 FeederD = 3; + + int32 PullerP = 4; + int32 PullerI = 5; + int32 PullerD = 6; + + int32 WinderP = 7; + int32 WinderI = 8; + int32 WinderD = 9; +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Controls/JobOutlineControl.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Controls/JobOutlineControl.cs index ee570ac34..5a3f5d337 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Controls/JobOutlineControl.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Controls/JobOutlineControl.cs @@ -136,6 +136,20 @@ namespace Tango.MachineStudio.Developer.Controls _sizeControl.Height += NORMAL_FONT_HEIGHT; } } + //JobTicket.ThreadParameters + if (job.ThreadParameters != null) + { + _sizeControl.Height += 20; + DrawHeaderText(drawingContext, "THREAD PARAMETERS", 17, LevelOffset.level_0); + _sizeControl.Height += TITLE_FONT_HEIGHT; + _sizeControl.Height += 5.0; + basicProps = GetNameValueList(job.ThreadParameters); + foreach (var prop in basicProps) + { + DrawNameValueText(drawingContext, prop, LevelOffset.level_1, PackIconKind.Settings); + _sizeControl.Height += NORMAL_FONT_HEIGHT; + } + } //JobTicket.Segments if (job.Segments != null) { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj index 9f3a95e0b..f448932a0 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj @@ -118,6 +118,9 @@ RmlView.xaml + + ThreadParametersView.xaml + SpoolsView.xaml @@ -226,6 +229,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + MSBuild:Compile Designer diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs index b75d65fe0..1ceaf07df 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs @@ -283,102 +283,114 @@ namespace Tango.MachineStudio.RML.ViewModels { using (_notification.PushTaskItem("Loading RML...")) { - IsFree = false; - - if (_active_context != null) + try { - _active_context.Dispose(); - } - - _active_context = ObservablesContext.CreateDefault(); + IsFree = false; - CCTS = _active_context.Ccts - .Select(x => new CctModel() + if (_active_context != null) { - Guid = x.Guid, - FileName = x.FileName, + _active_context.Dispose(); + } - }).ToObservableCollection(); + _active_context = ObservablesContext.CreateDefault(); - CCTS.Where(x => String.IsNullOrWhiteSpace(x.FileName)).ToList().ForEach(x => x.FileName = x.Guid); + CCTS = _active_context.Ccts + .Select(x => new CctModel() + { + Guid = x.Guid, + FileName = x.FileName, - LoadRmlProperties(); + }).ToObservableCollection(); - ActiveRML = await new RmlBuilder(_active_context) - .Set(guid) - .WithActiveParametersGroup() - .WithLiquidFactors() - .WithCCT() - .WithSpools() - .BuildAsync(); + CCTS.Where(x => String.IsNullOrWhiteSpace(x.FileName)).ToList().ForEach(x => x.FileName = x.Guid); - if (ActiveRML.Cct != null) - { - SelectedCCT = CCTS.SingleOrDefault(x => x.Guid == ActiveRML.Cct.Guid); - } + LoadRmlProperties(); - if (ActiveRML.ProcessParametersTablesGroups.ToList().Count == 0) - { - if (!_notification.ShowQuestion("Could not find any process group for the selected RML. Would you like to create one?")) + ActiveRML = await new RmlBuilder(_active_context) + .Set(guid) + .WithActiveParametersGroup() + .WithLiquidFactors() + .WithCCT() + .WithSpools() + .BuildAsync(); + + if (ActiveRML.Cct != null) { - _notification.ShowError("Cannot load an RML with no process group."); - IsFree = true; - return; + SelectedCCT = CCTS.SingleOrDefault(x => x.Guid == ActiveRML.Cct.Guid); } - else + + if (ActiveRML.ProcessParametersTablesGroups.ToList().Count == 0) { - ProcessParametersTablesGroup group = new ProcessParametersTablesGroup(); - group.Name = "Active Group"; - group.Active = true; - group.ProcessParametersTables.Add(new ProcessParametersTable() + if (!_notification.ShowQuestion("Could not find any process group for the selected RML. Would you like to create one?")) + { + _notification.ShowError("Cannot load an RML with no process group."); + IsFree = true; + return; + } + else { - Name = "Process Table 1", - }); + ProcessParametersTablesGroup group = new ProcessParametersTablesGroup(); + group.Name = "Active Group"; + group.Active = true; + group.ProcessParametersTables.Add(new ProcessParametersTable() + { + Name = "Process Table 1", + }); - group.Rml = ActiveRML; + group.Rml = ActiveRML; - _active_context.ProcessParametersTablesGroups.Add(group); - _active_context.ProcessParametersTables.Add(group.ProcessParametersTables[0]); - await _active_context.SaveChangesAsync(); - LoadActiveRML(ActiveRML.Guid); - return; + _active_context.ProcessParametersTablesGroups.Add(group); + _active_context.ProcessParametersTables.Add(group.ProcessParametersTables[0]); + await _active_context.SaveChangesAsync(); + LoadActiveRML(ActiveRML.Guid); + return; + } } - } - - ActiveProcessParametersGroup = ActiveRML.ProcessParametersTablesGroups.ToList().FirstOrDefault(); - ActiveProcessParametersTableView = CollectionViewSource.GetDefaultView(ActiveProcessParametersGroup.ProcessParametersTables); - ActiveProcessParametersTableView.SortDescriptions.Add(new SortDescription(nameof(ProcessParametersTable.TableIndex), ListSortDirection.Ascending)); - CalibrationDataViewVM = new CalibrationDataViewVM(_notification); - LiquidTypesRmls = ActiveRML.LiquidTypesRmls; + ActiveProcessParametersGroup = ActiveRML.ProcessParametersTablesGroups.ToList().FirstOrDefault(); + ActiveProcessParametersTableView = CollectionViewSource.GetDefaultView(ActiveProcessParametersGroup.ProcessParametersTables); + ActiveProcessParametersTableView.SortDescriptions.Add(new SortDescription(nameof(ProcessParametersTable.TableIndex), ListSortDirection.Ascending)); - foreach (var liquidTypeRml in LiquidTypesRmls) - { - CalibrationDataVM catVM = new CalibrationDataVM(liquidTypeRml.LiquidType); + CalibrationDataViewVM = new CalibrationDataViewVM(_notification); + LiquidTypesRmls = ActiveRML.LiquidTypesRmls; - if (liquidTypeRml.DefaultCatData != null) + foreach (var liquidTypeRml in LiquidTypesRmls) { - catVM.CalibrationPoints = liquidTypeRml.GetCalibrationData().CalibrationPoints.Select(x => new CalibrationDataPointVM(x.X, x.Y)).ToObservableCollection(); - } + CalibrationDataVM catVM = new CalibrationDataVM(liquidTypeRml.LiquidType); - CalibrationDataViewVM.LiquidsCalibrationData.Add(catVM); - } + if (liquidTypeRml.DefaultCatData != null) + { + catVM.CalibrationPoints = liquidTypeRml.GetCalibrationData().CalibrationPoints.Select(x => new CalibrationDataPointVM(x.X, x.Y)).ToObservableCollection(); + } - ColorConversionViewVM = new ColorConversionViewVM(_notification) - { - RML = ActiveRML, - CCT = SelectedCCT, - LiquidsCalibrationData = CalibrationDataViewVM.LiquidsCalibrationData, - LiquidTypesRmls = LiquidTypesRmls, - }; + CalibrationDataViewVM.LiquidsCalibrationData.Add(catVM); + } + + ColorConversionViewVM = new ColorConversionViewVM(_notification) + { + RML = ActiveRML, + CCT = SelectedCCT, + LiquidsCalibrationData = CalibrationDataViewVM.LiquidsCalibrationData, + LiquidTypesRmls = LiquidTypesRmls, + }; - _rmlBeforeSave = RmlDTO.FromObservable(ActiveRML); + _rmlBeforeSave = RmlDTO.FromObservable(ActiveRML); - View.NavigateTo(RmlNavigationView.RmlView); + View.NavigateTo(RmlNavigationView.RmlView); - InvalidateRelayCommands(); + InvalidateRelayCommands(); - IsFree = true; + IsFree = true; + } + catch (Exception ex) + { + LogManager.Log($"Error loading RML '{ActiveRML.Name}'..."); + _notification.ShowError($"Error loading the selected thread.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } } } @@ -490,7 +502,7 @@ namespace Tango.MachineStudio.RML.ViewModels if (rml_jobs.Count > 0) { - _notification.ShowError($"The following jobs must be removed or change thread type before the selected thread can be deleted:\n{String.Join("\n",rml_jobs.Select(x => $"{x.Machine.SerialNumber} => {x.Name}"))}"); + _notification.ShowError($"The following jobs must be removed or change thread type before the selected thread can be deleted:\n{String.Join("\n", rml_jobs.Select(x => $"{x.Machine.SerialNumber} => {x.Name}"))}"); return; } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/MainView.xaml index ab5207722..e52ac4ece 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/MainView.xaml @@ -9,7 +9,7 @@ xmlns:local="clr-namespace:Tango.MachineStudio.RML.Views" mc:Ignorable="d" d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml index 6ee41ac38..e967c7d83 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml @@ -149,9 +149,12 @@ - + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ThreadParametersView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ThreadParametersView.xaml new file mode 100644 index 000000000..ef2923303 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ThreadParametersView.xaml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + THREAD PARAMETERS + + + + + + + + + FEEDER + + + + + + + + + + + + + + PULLER + + + + + + + + + + + + + + WINDER + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ThreadParametersView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ThreadParametersView.xaml.cs new file mode 100644 index 000000000..aa63e48fb --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ThreadParametersView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.RML.Views +{ + /// + /// Interaction logic for SpoolsView.xaml + /// + public partial class ThreadParametersView : UserControl + { + public ThreadParametersView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobOutlineControl.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobOutlineControl.cs index e6f090fdd..0d6a2f6be 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobOutlineControl.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobOutlineControl.cs @@ -143,6 +143,20 @@ namespace Tango.PPC.Jobs _sizeControl.Height += NORMAL_FONT_HEIGHT; } } + //JobTicket.ThreadParameters + if (job.ThreadParameters != null) + { + _sizeControl.Height += 20; + DrawHeaderText(drawingContext, "THREAD PARAMETERS", 17, LevelOffset.level_0); + _sizeControl.Height += TITLE_FONT_HEIGHT; + _sizeControl.Height += 5.0; + basicProps = GetNameValueList(job.ThreadParameters); + foreach (var prop in basicProps) + { + DrawNameValueText(drawingContext, prop, LevelOffset.level_1, TouchIconKind.Settings); + _sizeControl.Height += NORMAL_FONT_HEIGHT; + } + } //JobTicket.Segments if (job.Segments != null) { diff --git a/Software/Visual_Studio/Tango.BL/DTO/RmlDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/RmlDTOBase.cs index 0c5c0480d..7ffc640f1 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/RmlDTOBase.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/RmlDTOBase.cs @@ -269,5 +269,77 @@ namespace Tango.BL.DTO get; set; } + /// + /// feeder p + /// + public Int32 FeederP + { + get; set; + } + + /// + /// feeder i + /// + public Int32 FeederI + { + get; set; + } + + /// + /// feeder d + /// + public Int32 FeederD + { + get; set; + } + + /// + /// puller p + /// + public Int32 PullerP + { + get; set; + } + + /// + /// puller i + /// + public Int32 PullerI + { + get; set; + } + + /// + /// puller d + /// + public Int32 PullerD + { + get; set; + } + + /// + /// winder p + /// + public Int32 WinderP + { + get; set; + } + + /// + /// winder i + /// + public Int32 WinderI + { + get; set; + } + + /// + /// winder d + /// + public Int32 WinderD + { + get; set; + } + } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs index a592fc694..758c7fa41 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs @@ -75,6 +75,24 @@ namespace Tango.BL.Entities public event EventHandler SpoolsCalibrationsStringChanged; + public event EventHandler FeederPChanged; + + public event EventHandler FeederIChanged; + + public event EventHandler FeederDChanged; + + public event EventHandler PullerPChanged; + + public event EventHandler PullerIChanged; + + public event EventHandler PullerDChanged; + + public event EventHandler WinderPChanged; + + public event EventHandler WinderIChanged; + + public event EventHandler WinderDChanged; + public event EventHandler> CatsChanged; public event EventHandler CctChanged; @@ -933,6 +951,249 @@ namespace Tango.BL.Entities } } + protected Int32 _feederp; + + /// + /// Gets or sets the rmlbase feeder p. + /// + + [Column("FEEDER_P")] + + public Int32 FeederP + { + get + { + return _feederp; + } + + set + { + if (_feederp != value) + { + _feederp = value; + + OnFeederPChanged(value); + + } + } + } + + protected Int32 _feederi; + + /// + /// Gets or sets the rmlbase feeder i. + /// + + [Column("FEEDER_I")] + + public Int32 FeederI + { + get + { + return _feederi; + } + + set + { + if (_feederi != value) + { + _feederi = value; + + OnFeederIChanged(value); + + } + } + } + + protected Int32 _feederd; + + /// + /// Gets or sets the rmlbase feeder d. + /// + + [Column("FEEDER_D")] + + public Int32 FeederD + { + get + { + return _feederd; + } + + set + { + if (_feederd != value) + { + _feederd = value; + + OnFeederDChanged(value); + + } + } + } + + protected Int32 _pullerp; + + /// + /// Gets or sets the rmlbase puller p. + /// + + [Column("PULLER_P")] + + public Int32 PullerP + { + get + { + return _pullerp; + } + + set + { + if (_pullerp != value) + { + _pullerp = value; + + OnPullerPChanged(value); + + } + } + } + + protected Int32 _pulleri; + + /// + /// Gets or sets the rmlbase puller i. + /// + + [Column("PULLER_I")] + + public Int32 PullerI + { + get + { + return _pulleri; + } + + set + { + if (_pulleri != value) + { + _pulleri = value; + + OnPullerIChanged(value); + + } + } + } + + protected Int32 _pullerd; + + /// + /// Gets or sets the rmlbase puller d. + /// + + [Column("PULLER_D")] + + public Int32 PullerD + { + get + { + return _pullerd; + } + + set + { + if (_pullerd != value) + { + _pullerd = value; + + OnPullerDChanged(value); + + } + } + } + + protected Int32 _winderp; + + /// + /// Gets or sets the rmlbase winder p. + /// + + [Column("WINDER_P")] + + public Int32 WinderP + { + get + { + return _winderp; + } + + set + { + if (_winderp != value) + { + _winderp = value; + + OnWinderPChanged(value); + + } + } + } + + protected Int32 _winderi; + + /// + /// Gets or sets the rmlbase winder i. + /// + + [Column("WINDER_I")] + + public Int32 WinderI + { + get + { + return _winderi; + } + + set + { + if (_winderi != value) + { + _winderi = value; + + OnWinderIChanged(value); + + } + } + } + + protected Int32 _winderd; + + /// + /// Gets or sets the rmlbase winder d. + /// + + [Column("WINDER_D")] + + public Int32 WinderD + { + get + { + return _winderd; + } + + set + { + if (_winderd != value) + { + _winderd = value; + + OnWinderDChanged(value); + + } + } + } + protected SynchronizedObservableCollection _cats; /// @@ -1548,6 +1809,87 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(SpoolsCalibrationsString)); } + /// + /// Called when the FeederP has changed. + /// + protected virtual void OnFeederPChanged(Int32 feederp) + { + FeederPChanged?.Invoke(this, feederp); + RaisePropertyChanged(nameof(FeederP)); + } + + /// + /// Called when the FeederI has changed. + /// + protected virtual void OnFeederIChanged(Int32 feederi) + { + FeederIChanged?.Invoke(this, feederi); + RaisePropertyChanged(nameof(FeederI)); + } + + /// + /// Called when the FeederD has changed. + /// + protected virtual void OnFeederDChanged(Int32 feederd) + { + FeederDChanged?.Invoke(this, feederd); + RaisePropertyChanged(nameof(FeederD)); + } + + /// + /// Called when the PullerP has changed. + /// + protected virtual void OnPullerPChanged(Int32 pullerp) + { + PullerPChanged?.Invoke(this, pullerp); + RaisePropertyChanged(nameof(PullerP)); + } + + /// + /// Called when the PullerI has changed. + /// + protected virtual void OnPullerIChanged(Int32 pulleri) + { + PullerIChanged?.Invoke(this, pulleri); + RaisePropertyChanged(nameof(PullerI)); + } + + /// + /// Called when the PullerD has changed. + /// + protected virtual void OnPullerDChanged(Int32 pullerd) + { + PullerDChanged?.Invoke(this, pullerd); + RaisePropertyChanged(nameof(PullerD)); + } + + /// + /// Called when the WinderP has changed. + /// + protected virtual void OnWinderPChanged(Int32 winderp) + { + WinderPChanged?.Invoke(this, winderp); + RaisePropertyChanged(nameof(WinderP)); + } + + /// + /// Called when the WinderI has changed. + /// + protected virtual void OnWinderIChanged(Int32 winderi) + { + WinderIChanged?.Invoke(this, winderi); + RaisePropertyChanged(nameof(WinderI)); + } + + /// + /// Called when the WinderD has changed. + /// + protected virtual void OnWinderDChanged(Int32 winderd) + { + WinderDChanged?.Invoke(this, winderd); + RaisePropertyChanged(nameof(WinderD)); + } + /// /// Called when the Cats has changed. /// diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs index 2772e1958..6f5119865 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs @@ -60,6 +60,15 @@ namespace Tango.DAL.Remote.DB public int QUALIFICATION_LEVEL { get; set; } public Nullable QUALIFICATION_DATE { get; set; } public string SPOOLS_CALIBRATIONS_STRING { get; set; } + public int FEEDER_P { get; set; } + public int FEEDER_I { get; set; } + public int FEEDER_D { get; set; } + public int PULLER_P { get; set; } + public int PULLER_I { get; set; } + public int PULLER_D { get; set; } + public int WINDER_P { get; set; } + public int WINDER_I { get; set; } + public int WINDER_D { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection CATS { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Designer.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Designer.cs index 17bc2683d..d26e67908 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Designer.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Designer.cs @@ -1,4 +1,4 @@ -// T4 code generation is enabled for model 'D:\Development\Tango\Software\Visual_Studio\Tango.DAL.Remote\DB\RemoteADO.edmx'. +// T4 code generation is enabled for model 'C:\DATA\Development\Tango\Software\Visual_Studio\Tango.DAL.Remote\DB\RemoteADO.edmx'. // To enable legacy code generation, change the value of the 'Code Generation Strategy' designer // property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model // is open in the designer. diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index 4bccfc804..f10a28eee 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -933,6 +933,15 @@ + + + + + + + + + @@ -4257,6 +4266,15 @@ + + + + + + + + + @@ -6670,6 +6688,15 @@ + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index 354839477..6785d4c6e 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,85 +5,85 @@ - - - - - + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - + + + + + + + - + - - + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs index 44128a2ae..b6698a208 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs @@ -273,15 +273,6 @@ namespace Tango.Integration.Operation /// Task Print(Job job); - /// - /// Executes a print stub for emulating a full job. - /// The process parameters table will be calculated using color conversion gamut region. - /// This method cannot accept brush stops with 'Volume' as color space. - /// - /// The job. - /// - Task PrintStub(Job job); - /// /// Prints the specified job using the specified job parameters. /// diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 4084e4ee7..d020fd2a6 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -2258,6 +2258,10 @@ namespace Tango.Integration.Operation ticket.Spool.LimitSwitchStartPointOffset = machineSpool.LimitSwitchStartPointOffset != null ? machineSpool.LimitSwitchStartPointOffset.Value : ticket.Spool.LimitSwitchStartPointOffset; } + //Thread parameters + ticket.ThreadParameters = new ThreadParameters(); + job.Rml.MapPrimitivesTo(ticket.ThreadParameters); + ProcessParameters process = new ProcessParameters(); processParameters.MapPrimitivesTo(process); ticket.ProcessParameters = process; @@ -2629,226 +2633,6 @@ namespace Tango.Integration.Operation }); } - /// - /// Executes a print stub for emulating a full job. - /// The process parameters table will be calculated using color conversion gamut region. - /// This method cannot accept brush stops with 'Volume' as color space. - /// - /// The job. - /// - /// - /// Cannot print a brush stop with volume color space when process parameters table has not been specified. - /// or - /// Could not print while status = " + Status - /// - /// - /// Job RML is null - /// or - /// Could not locate an active process parameters tables group for RML " + job.Rml.Name - /// or - /// Could not locate process parameters table index " + processParametersTableIndex + " in group " + processGroup.Name + " for RML " + job.Rml.Name - /// or - /// Liquid volume not found for color conversion output liquid '" + outputLiquid.LiquidType + "'. - /// - public Task PrintStub(Job job) - { - return Task.Factory.StartNew(() => - { - - //Check not brush stop has color space 'Volume'. - if (job.Segments.SelectMany(x => x.BrushStops).ToList().Exists(x => x.ColorSpace.Code == ColorSpaces.Volume.ToInt32())) - { - throw new InvalidOperationException("Cannot print a brush stop with volume color space when process parameters table has not been specified."); - } - - //Get least common process parameters table index. - int processParametersTableIndex = 0; - - if (job.Rml == null) - { - throw new NullReferenceException("Job RML is null"); - } - - var processGroup = job.Rml.ProcessParametersTablesGroups.FirstOrDefault(x => x.Active); - - if (processGroup == null) - { - throw new NullReferenceException("Could not locate an active process parameters tables group for RML " + job.Rml.Name); - } - - var processParameters = processGroup.ProcessParametersTables.FirstOrDefault(x => x.TableIndex == processParametersTableIndex); - - if (processParameters == null) - { - throw new NullReferenceException("Could not locate process parameters table index " + processParametersTableIndex + " in group " + processGroup.Name + " for RML " + job.Rml.Name); - } - - //Perform color correction - foreach (var stop in job.Segments.SelectMany(x => x.BrushStops)) - { - if (stop.LiquidVolumes == null) - { - stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters); - } - - foreach (var liquidVolume in stop.LiquidVolumes) - { - liquidVolume.Volume = 10; - } - } - - if (!CanPrint) - { - throw new InvalidOperationException("Could not print while status = " + Status); - } - - RunningJob = null; - RunningJobStatus = null; - - var originalJob = job; - - CurrentProcessParameters = processParameters; - - StubJobRequest request = new StubJobRequest(); - - if (job.NumberOfUnits < 1) - { - job.NumberOfUnits = 1; - } - - job = job.Clone(); - - var segments = job.OrderedSegments.ToList(); - - for (int i = 0; i < job.NumberOfUnits - 1; i++) - { - foreach (var s in segments) - { - job.Segments.Add(s); - } - } - - JobTicket ticket = new JobTicket(); - ticket.Guid = originalJob.Guid; - ticket.EnableInterSegment = job.EnableInterSegment; - ticket.InterSegmentLength = job.InterSegmentLength; - ticket.Length = job.Length; - ticket.WindingMethod = (JobWindingMethod)job.WindingMethod.Code; - ticket.Spool = new JobSpool(); - - job.SpoolType.MapPrimitivesTo(ticket.Spool); - ticket.Spool.JobSpoolType = (JobSpoolType)job.SpoolType.Code; - - ProcessParameters process = new ProcessParameters(); - processParameters.MapPrimitivesTo(process); - ticket.ProcessParameters = process; - - foreach (var segment in job.OrderedSegments) - { - JobSegment jobSegment = new JobSegment(); - jobSegment.Length = segment.LengthWithFactor; - jobSegment.Name = segment.Name; - - foreach (var stop in segment.BrushStops) - { - JobBrushStop jobStop = new JobBrushStop(); - jobStop.Index = stop.StopIndex; - jobStop.OffsetPercent = stop.OffsetPercent; - jobStop.OffsetMeters = stop.OffsetMeters; - - if (stop.LiquidVolumes == null) - { - stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters); - } - - foreach (var liquidVolume in stop.LiquidVolumes) - { - JobDispenser dispenser = new JobDispenser(); - dispenser.Index = liquidVolume.IdsPack.PackIndex; - dispenser.Volume = liquidVolume.Volume; - dispenser.DispenserLiquidType = (DispenserLiquidType)liquidVolume.IdsPack.LiquidType.Code; - dispenser.DispenserStepDivision = (DispenserStepDivision)liquidVolume.DispenserStepDivision; - - dispenser.NanoliterPerPulse = liquidVolume.IdsPack.Dispenser.NlPerPulse; - - dispenser.LiquidMaxNanoliterPerCentimeter = liquidVolume.LiquidMaxNanoliterPerCentimeter; - dispenser.NanoliterPerCentimeter = liquidVolume.NanoliterPerCentimeter; - dispenser.NanolitterPerSecond = liquidVolume.NanoliterPerSecond; - dispenser.PulsePerSecond = liquidVolume.PulsePerSecond; - - jobStop.Dispensers.Add(dispenser); - } - - jobSegment.BrushStops.Add(jobStop); - } - - ticket.Segments.Add(jobSegment); - } - - request.JobTicket = ticket; - - JobHandler handler = null; - - handler = new JobHandler(async () => - { - try - { - var result = await SendRequest(new StubAbortJobRequest(), new TransportRequestConfig() { ShouldLog = true }); - OnPrintingAborted(handler, originalJob); - handler.RaiseCanceled(); - } - catch (Exception ex) - { - LogManager.Log(ex, "Failed to cancel job."); - } - }, originalJob, ticket, processParameters, JobHandlingMode); - - handler.StatusChanged += (x, s) => - { - RunningJobStatus = s; - }; - - bool responseLogged = false; - - SendContinuousRequest(request, new TransportContinuousRequestConfig() { ContinuousTimeout = ContinuousRequestTimeout, ShouldLog = true }).Subscribe((response) => - { - handler.RaiseStatusReceived(response.Message.Status); - - if (!responseLogged) - { - responseLogged = true; - Status = MachineStatuses.Printing; - RunningJob = originalJob; - OnPrintingStarted(handler, originalJob); - } - }, (ex) => - { - if (!(ex is ContinuousResponseAbortedException)) - { - Status = MachineStatuses.ReadyToDye; - - if (!handler.IsCanceled) - { - OnPrintingFailed(handler, originalJob, ex); - handler.RaiseFailed(ex); - } - } - else - { - Status = MachineStatuses.ReadyToDye; - } - }, () => - { - Status = MachineStatuses.ReadyToDye; - OnPrintingCompleted(handler, originalJob); - handler.RaiseCompleted(); - }); - - return handler; - - }); - } - /// /// Uploads the specified process parameters to the embedded device. /// diff --git a/Software/Visual_Studio/Tango.PMR/Printing/JobTicket.cs b/Software/Visual_Studio/Tango.PMR/Printing/JobTicket.cs index b6ac9c9e1..0431913a4 100644 --- a/Software/Visual_Studio/Tango.PMR/Printing/JobTicket.cs +++ b/Software/Visual_Studio/Tango.PMR/Printing/JobTicket.cs @@ -25,23 +25,25 @@ namespace Tango.PMR.Printing { "Cg9Kb2JUaWNrZXQucHJvdG8SElRhbmdvLlBNUi5QcmludGluZxoQSm9iU2Vn", "bWVudC5wcm90bxoXUHJvY2Vzc1BhcmFtZXRlcnMucHJvdG8aFkpvYldpbmRp", "bmdNZXRob2QucHJvdG8aDkpvYlNwb29sLnByb3RvGhdKb2JVcGxvYWRTdHJh", - "dGVneS5wcm90byLxAwoJSm9iVGlja2V0EgwKBEd1aWQYASABKAkSDAoETmFt", - "ZRgCIAEoCRIaChJFbmFibGVJbnRlclNlZ21lbnQYAyABKAgSGgoSSW50ZXJT", - "ZWdtZW50TGVuZ3RoGAQgASgBEg4KBkxlbmd0aBgFIAEoARJAChFQcm9jZXNz", - "UGFyYW1ldGVycxgGIAEoCzIlLlRhbmdvLlBNUi5QcmludGluZy5Qcm9jZXNz", - "UGFyYW1ldGVycxI7Cg1XaW5kaW5nTWV0aG9kGAcgASgOMiQuVGFuZ28uUE1S", - "LlByaW50aW5nLkpvYldpbmRpbmdNZXRob2QSKwoFU3Bvb2wYCCABKAsyHC5U", - "YW5nby5QTVIuUHJpbnRpbmcuSm9iU3Bvb2wSMAoIU2VnbWVudHMYCSADKAsy", - "Hi5UYW5nby5QTVIuUHJpbnRpbmcuSm9iU2VnbWVudBI9Cg5VcGxvYWRTdHJh", - "dGVneRgKIAEoDjIlLlRhbmdvLlBNUi5QcmludGluZy5Kb2JVcGxvYWRTdHJh", - "dGVneRIaChJKb2JEZXNjcmlwdGlvbkZpbGUYCyABKAkSGQoRRW5hYmxlTHVi", - "cmljYXRpb24YDCABKAgSFQoNTnVtYmVyT2ZVbml0cxgNIAEoDRIVCg1TYW1w", - "bGVXaW5kaW5nGA4gASgIQh4KHGNvbS50d2luZS50YW5nby5wbXIucHJpbnRp", - "bmdiBnByb3RvMw==")); + "dGVneS5wcm90bxoWVGhyZWFkUGFyYW1ldGVycy5wcm90byKxBAoJSm9iVGlj", + "a2V0EgwKBEd1aWQYASABKAkSDAoETmFtZRgCIAEoCRIaChJFbmFibGVJbnRl", + "clNlZ21lbnQYAyABKAgSGgoSSW50ZXJTZWdtZW50TGVuZ3RoGAQgASgBEg4K", + "Bkxlbmd0aBgFIAEoARJAChFQcm9jZXNzUGFyYW1ldGVycxgGIAEoCzIlLlRh", + "bmdvLlBNUi5QcmludGluZy5Qcm9jZXNzUGFyYW1ldGVycxI7Cg1XaW5kaW5n", + "TWV0aG9kGAcgASgOMiQuVGFuZ28uUE1SLlByaW50aW5nLkpvYldpbmRpbmdN", + "ZXRob2QSKwoFU3Bvb2wYCCABKAsyHC5UYW5nby5QTVIuUHJpbnRpbmcuSm9i", + "U3Bvb2wSMAoIU2VnbWVudHMYCSADKAsyHi5UYW5nby5QTVIuUHJpbnRpbmcu", + "Sm9iU2VnbWVudBI9Cg5VcGxvYWRTdHJhdGVneRgKIAEoDjIlLlRhbmdvLlBN", + "Ui5QcmludGluZy5Kb2JVcGxvYWRTdHJhdGVneRIaChJKb2JEZXNjcmlwdGlv", + "bkZpbGUYCyABKAkSGQoRRW5hYmxlTHVicmljYXRpb24YDCABKAgSFQoNTnVt", + "YmVyT2ZVbml0cxgNIAEoDRIVCg1TYW1wbGVXaW5kaW5nGA4gASgIEj4KEFRo", + "cmVhZFBhcmFtZXRlcnMYDyABKAsyJC5UYW5nby5QTVIuUHJpbnRpbmcuVGhy", + "ZWFkUGFyYW1ldGVyc0IeChxjb20udHdpbmUudGFuZ28ucG1yLnByaW50aW5n", + "YgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { global::Tango.PMR.Printing.JobSegmentReflection.Descriptor, global::Tango.PMR.Printing.ProcessParametersReflection.Descriptor, global::Tango.PMR.Printing.JobWindingMethodReflection.Descriptor, global::Tango.PMR.Printing.JobSpoolReflection.Descriptor, global::Tango.PMR.Printing.JobUploadStrategyReflection.Descriptor, }, + new pbr::FileDescriptor[] { global::Tango.PMR.Printing.JobSegmentReflection.Descriptor, global::Tango.PMR.Printing.ProcessParametersReflection.Descriptor, global::Tango.PMR.Printing.JobWindingMethodReflection.Descriptor, global::Tango.PMR.Printing.JobSpoolReflection.Descriptor, global::Tango.PMR.Printing.JobUploadStrategyReflection.Descriptor, global::Tango.PMR.Printing.ThreadParametersReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Printing.JobTicket), global::Tango.PMR.Printing.JobTicket.Parser, new[]{ "Guid", "Name", "EnableInterSegment", "InterSegmentLength", "Length", "ProcessParameters", "WindingMethod", "Spool", "Segments", "UploadStrategy", "JobDescriptionFile", "EnableLubrication", "NumberOfUnits", "SampleWinding" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Printing.JobTicket), global::Tango.PMR.Printing.JobTicket.Parser, new[]{ "Guid", "Name", "EnableInterSegment", "InterSegmentLength", "Length", "ProcessParameters", "WindingMethod", "Spool", "Segments", "UploadStrategy", "JobDescriptionFile", "EnableLubrication", "NumberOfUnits", "SampleWinding", "ThreadParameters" }, null, null, null) })); } #endregion @@ -86,6 +88,7 @@ namespace Tango.PMR.Printing { enableLubrication_ = other.enableLubrication_; numberOfUnits_ = other.numberOfUnits_; sampleWinding_ = other.sampleWinding_; + ThreadParameters = other.threadParameters_ != null ? other.ThreadParameters.Clone() : null; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -249,6 +252,17 @@ namespace Tango.PMR.Printing { } } + /// Field number for the "ThreadParameters" field. + public const int ThreadParametersFieldNumber = 15; + private global::Tango.PMR.Printing.ThreadParameters threadParameters_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Tango.PMR.Printing.ThreadParameters ThreadParameters { + get { return threadParameters_; } + set { + threadParameters_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as JobTicket); @@ -276,6 +290,7 @@ namespace Tango.PMR.Printing { if (EnableLubrication != other.EnableLubrication) return false; if (NumberOfUnits != other.NumberOfUnits) return false; if (SampleWinding != other.SampleWinding) return false; + if (!object.Equals(ThreadParameters, other.ThreadParameters)) return false; return true; } @@ -296,6 +311,7 @@ namespace Tango.PMR.Printing { if (EnableLubrication != false) hash ^= EnableLubrication.GetHashCode(); if (NumberOfUnits != 0) hash ^= NumberOfUnits.GetHashCode(); if (SampleWinding != false) hash ^= SampleWinding.GetHashCode(); + if (threadParameters_ != null) hash ^= ThreadParameters.GetHashCode(); return hash; } @@ -359,6 +375,10 @@ namespace Tango.PMR.Printing { output.WriteRawTag(112); output.WriteBool(SampleWinding); } + if (threadParameters_ != null) { + output.WriteRawTag(122); + output.WriteMessage(ThreadParameters); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -404,6 +424,9 @@ namespace Tango.PMR.Printing { if (SampleWinding != false) { size += 1 + 1; } + if (threadParameters_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(ThreadParameters); + } return size; } @@ -458,6 +481,12 @@ namespace Tango.PMR.Printing { if (other.SampleWinding != false) { SampleWinding = other.SampleWinding; } + if (other.threadParameters_ != null) { + if (threadParameters_ == null) { + threadParameters_ = new global::Tango.PMR.Printing.ThreadParameters(); + } + ThreadParameters.MergeFrom(other.ThreadParameters); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -530,6 +559,13 @@ namespace Tango.PMR.Printing { SampleWinding = input.ReadBool(); break; } + case 122: { + if (threadParameters_ == null) { + threadParameters_ = new global::Tango.PMR.Printing.ThreadParameters(); + } + input.ReadMessage(threadParameters_); + break; + } } } } diff --git a/Software/Visual_Studio/Tango.PMR/Printing/ThreadParameters.cs b/Software/Visual_Studio/Tango.PMR/Printing/ThreadParameters.cs new file mode 100644 index 000000000..3c927627f --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Printing/ThreadParameters.cs @@ -0,0 +1,386 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ThreadParameters.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Printing { + + /// Holder for reflection information generated from ThreadParameters.proto + public static partial class ThreadParametersReflection { + + #region Descriptor + /// File descriptor for ThreadParameters.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static ThreadParametersReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChZUaHJlYWRQYXJhbWV0ZXJzLnByb3RvEhJUYW5nby5QTVIuUHJpbnRpbmci", + "qwEKEFRocmVhZFBhcmFtZXRlcnMSDwoHRmVlZGVyUBgBIAEoBRIPCgdGZWVk", + "ZXJJGAIgASgFEg8KB0ZlZWRlckQYAyABKAUSDwoHUHVsbGVyUBgEIAEoBRIP", + "CgdQdWxsZXJJGAUgASgFEg8KB1B1bGxlckQYBiABKAUSDwoHV2luZGVyUBgH", + "IAEoBRIPCgdXaW5kZXJJGAggASgFEg8KB1dpbmRlckQYCSABKAVCHgocY29t", + "LnR3aW5lLnRhbmdvLnBtci5wcmludGluZ2IGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Printing.ThreadParameters), global::Tango.PMR.Printing.ThreadParameters.Parser, new[]{ "FeederP", "FeederI", "FeederD", "PullerP", "PullerI", "PullerD", "WinderP", "WinderI", "WinderD" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class ThreadParameters : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ThreadParameters()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Printing.ThreadParametersReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ThreadParameters() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ThreadParameters(ThreadParameters other) : this() { + feederP_ = other.feederP_; + feederI_ = other.feederI_; + feederD_ = other.feederD_; + pullerP_ = other.pullerP_; + pullerI_ = other.pullerI_; + pullerD_ = other.pullerD_; + winderP_ = other.winderP_; + winderI_ = other.winderI_; + winderD_ = other.winderD_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ThreadParameters Clone() { + return new ThreadParameters(this); + } + + /// Field number for the "FeederP" field. + public const int FeederPFieldNumber = 1; + private int feederP_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FeederP { + get { return feederP_; } + set { + feederP_ = value; + } + } + + /// Field number for the "FeederI" field. + public const int FeederIFieldNumber = 2; + private int feederI_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FeederI { + get { return feederI_; } + set { + feederI_ = value; + } + } + + /// Field number for the "FeederD" field. + public const int FeederDFieldNumber = 3; + private int feederD_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FeederD { + get { return feederD_; } + set { + feederD_ = value; + } + } + + /// Field number for the "PullerP" field. + public const int PullerPFieldNumber = 4; + private int pullerP_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int PullerP { + get { return pullerP_; } + set { + pullerP_ = value; + } + } + + /// Field number for the "PullerI" field. + public const int PullerIFieldNumber = 5; + private int pullerI_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int PullerI { + get { return pullerI_; } + set { + pullerI_ = value; + } + } + + /// Field number for the "PullerD" field. + public const int PullerDFieldNumber = 6; + private int pullerD_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int PullerD { + get { return pullerD_; } + set { + pullerD_ = value; + } + } + + /// Field number for the "WinderP" field. + public const int WinderPFieldNumber = 7; + private int winderP_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int WinderP { + get { return winderP_; } + set { + winderP_ = value; + } + } + + /// Field number for the "WinderI" field. + public const int WinderIFieldNumber = 8; + private int winderI_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int WinderI { + get { return winderI_; } + set { + winderI_ = value; + } + } + + /// Field number for the "WinderD" field. + public const int WinderDFieldNumber = 9; + private int winderD_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int WinderD { + get { return winderD_; } + set { + winderD_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ThreadParameters); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ThreadParameters other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (FeederP != other.FeederP) return false; + if (FeederI != other.FeederI) return false; + if (FeederD != other.FeederD) return false; + if (PullerP != other.PullerP) return false; + if (PullerI != other.PullerI) return false; + if (PullerD != other.PullerD) return false; + if (WinderP != other.WinderP) return false; + if (WinderI != other.WinderI) return false; + if (WinderD != other.WinderD) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (FeederP != 0) hash ^= FeederP.GetHashCode(); + if (FeederI != 0) hash ^= FeederI.GetHashCode(); + if (FeederD != 0) hash ^= FeederD.GetHashCode(); + if (PullerP != 0) hash ^= PullerP.GetHashCode(); + if (PullerI != 0) hash ^= PullerI.GetHashCode(); + if (PullerD != 0) hash ^= PullerD.GetHashCode(); + if (WinderP != 0) hash ^= WinderP.GetHashCode(); + if (WinderI != 0) hash ^= WinderI.GetHashCode(); + if (WinderD != 0) hash ^= WinderD.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (FeederP != 0) { + output.WriteRawTag(8); + output.WriteInt32(FeederP); + } + if (FeederI != 0) { + output.WriteRawTag(16); + output.WriteInt32(FeederI); + } + if (FeederD != 0) { + output.WriteRawTag(24); + output.WriteInt32(FeederD); + } + if (PullerP != 0) { + output.WriteRawTag(32); + output.WriteInt32(PullerP); + } + if (PullerI != 0) { + output.WriteRawTag(40); + output.WriteInt32(PullerI); + } + if (PullerD != 0) { + output.WriteRawTag(48); + output.WriteInt32(PullerD); + } + if (WinderP != 0) { + output.WriteRawTag(56); + output.WriteInt32(WinderP); + } + if (WinderI != 0) { + output.WriteRawTag(64); + output.WriteInt32(WinderI); + } + if (WinderD != 0) { + output.WriteRawTag(72); + output.WriteInt32(WinderD); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (FeederP != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(FeederP); + } + if (FeederI != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(FeederI); + } + if (FeederD != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(FeederD); + } + if (PullerP != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(PullerP); + } + if (PullerI != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(PullerI); + } + if (PullerD != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(PullerD); + } + if (WinderP != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(WinderP); + } + if (WinderI != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(WinderI); + } + if (WinderD != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(WinderD); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ThreadParameters other) { + if (other == null) { + return; + } + if (other.FeederP != 0) { + FeederP = other.FeederP; + } + if (other.FeederI != 0) { + FeederI = other.FeederI; + } + if (other.FeederD != 0) { + FeederD = other.FeederD; + } + if (other.PullerP != 0) { + PullerP = other.PullerP; + } + if (other.PullerI != 0) { + PullerI = other.PullerI; + } + if (other.PullerD != 0) { + PullerD = other.PullerD; + } + if (other.WinderP != 0) { + WinderP = other.WinderP; + } + if (other.WinderI != 0) { + WinderI = other.WinderI; + } + if (other.WinderD != 0) { + WinderD = other.WinderD; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + FeederP = input.ReadInt32(); + break; + } + case 16: { + FeederI = input.ReadInt32(); + break; + } + case 24: { + FeederD = input.ReadInt32(); + break; + } + case 32: { + PullerP = input.ReadInt32(); + break; + } + case 40: { + PullerI = input.ReadInt32(); + break; + } + case 48: { + PullerD = input.ReadInt32(); + break; + } + case 56: { + WinderP = input.ReadInt32(); + break; + } + case 64: { + WinderI = input.ReadInt32(); + break; + } + case 72: { + WinderD = input.ReadInt32(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj index 0eecc5283..3dd9d7f48 100644 --- a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj +++ b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj @@ -283,6 +283,7 @@ + @@ -322,7 +323,7 @@ - + \ No newline at end of file -- cgit v1.3.1 From c9ba7c0b806818cdcbcd10fb03805a61608b4233 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Thu, 27 Feb 2020 16:03:06 +0200 Subject: Liquid quantities implementation in xaml. Related Work Items: #2509 --- .../Converters/DateIsInListToBooleanConverter.cs | 29 -------- .../MidTankLevelToElementHeightConverter.cs | 41 +++++++++++ .../Converters/StringToFirstLetterConverter.cs | 30 ++++++++ .../Tango.MachineStudio.Statistics.csproj | 3 +- .../ViewModels/JobRunsViewVM.cs | 79 +++++++++++++++++----- .../Views/JobRunsView.xaml | 78 ++++++++++++--------- 6 files changed, 181 insertions(+), 79 deletions(-) delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/DateIsInListToBooleanConverter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/MidTankLevelToElementHeightConverter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/StringToFirstLetterConverter.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/DateIsInListToBooleanConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/DateIsInListToBooleanConverter.cs deleted file mode 100644 index 74e0c61d8..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/DateIsInListToBooleanConverter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Data; - -namespace Tango.MachineStudio.Statistics.Converters -{ - public class DateIsInListToBooleanConverter : IMultiValueConverter - { - public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) - { - if (values.Length < 2 || !(values[0] is DateTime) || !(values[1] is IEnumerable)) - return false; - - var date = (DateTime)values[0]; - var dateList = (IEnumerable)values[1]; - - return dateList.ToList().Exists(x => x.ToLocalTime().ToShortDateString() == date.ToLocalTime().ToShortDateString()); - } - - public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/MidTankLevelToElementHeightConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/MidTankLevelToElementHeightConverter.cs new file mode 100644 index 000000000..e9f513cc3 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/MidTankLevelToElementHeightConverter.cs @@ -0,0 +1,41 @@ +using System; +using System.Globalization; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace Tango.MachineStudio.Statistics.Converters +{ + public class MidTankLevelToElementHeightConverter : IMultiValueConverter + { + public const double MAX_QUANTITY = 130000000; + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + try + { + double parentActualHeight; + Double.TryParse(values[0].ToString(), out parentActualHeight); + double quantity; + Double.TryParse(values[1].ToString(), out quantity); + + double midTankLevel = (double)Math.Min(quantity, MAX_QUANTITY); + double delta = ((midTankLevel / MAX_QUANTITY) * parentActualHeight); + if (midTankLevel < (MAX_QUANTITY/10))// if quantity < 10|% set 2 pixel + delta = 2.0; + var test = delta; + return test;// (parentActualHeight - (midTankLevel / MAX_QUANTITY) * parentActualHeight); + } + catch + { + return 0d; + } + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/StringToFirstLetterConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/StringToFirstLetterConverter.cs new file mode 100644 index 000000000..a1c9561b9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/StringToFirstLetterConverter.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace Tango.MachineStudio.Statistics.Converters +{ + public class StringToFirstLetterConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null && value.ToString().Length > 1) + { + return value.ToString().First().ToString(); + } + else + { + return value; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Tango.MachineStudio.Statistics.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Tango.MachineStudio.Statistics.csproj index fa62578a1..603429f94 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Tango.MachineStudio.Statistics.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Tango.MachineStudio.Statistics.csproj @@ -75,8 +75,9 @@ + - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs index cf74071c9..07e431751 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs @@ -25,11 +25,14 @@ namespace Tango.MachineStudio.Statistics.ViewModels private List _allMachines; private List _allUsers; private List _rmlsModels; - private List _allJobRuns; + private List _allJobRuns; #region Properties private ObservableCollection _jobRuns; + /// + /// Gets or sets the job runs. Contains filtered data of JobRunModel. + /// public ObservableCollection JobRuns { get { return _jobRuns; } @@ -41,6 +44,9 @@ namespace Tango.MachineStudio.Statistics.ViewModels } private JobRunModel _selectedJobRun = null; + /// + /// Gets or sets the JobRunModel. Binding to selected item of grid items. + /// public JobRunModel SelectedJobRun { get { return _selectedJobRun; } @@ -52,6 +58,9 @@ namespace Tango.MachineStudio.Statistics.ViewModels } private SelectedObjectCollection _selectedMachines; + /// + /// Gets or sets the selected machines. Contains all available machines and selected machines. Binding to ComboBox Machines. + /// public SelectedObjectCollection SelectedMachines { get { return _selectedMachines; } @@ -63,6 +72,9 @@ namespace Tango.MachineStudio.Statistics.ViewModels } private DateTime _startSelectedDate; + /// + /// Gets or sets the start selected date. + /// public DateTime StartSelectedDate { get { return _startSelectedDate; } @@ -70,6 +82,9 @@ namespace Tango.MachineStudio.Statistics.ViewModels } private DateTime _endSelectedDate; + /// + /// Gets or sets the end selected date. + /// public DateTime EndSelectedDate { get { return _endSelectedDate; } @@ -77,6 +92,9 @@ namespace Tango.MachineStudio.Statistics.ViewModels } protected Double _lengthLowerValue; + /// + /// Gets or sets the length lower value of Range Slider + /// public Double LengthLowerValue { get { return _lengthLowerValue; } @@ -88,6 +106,9 @@ namespace Tango.MachineStudio.Statistics.ViewModels } protected Double _lengthUpperValue; + /// + /// Gets or sets the length upper value of Range Slider. + /// public Double LengthUpperValue { get { return _lengthUpperValue; } @@ -99,6 +120,9 @@ namespace Tango.MachineStudio.Statistics.ViewModels } private SelectedObjectCollection _jobRunSelectedSources; + /// + /// Gets or sets the job run selected sources. Binding to ComboBox "Source". + /// public SelectedObjectCollection JobRunSelectedSources { get { return _jobRunSelectedSources; } @@ -106,6 +130,9 @@ namespace Tango.MachineStudio.Statistics.ViewModels } private SelectedObjectCollection _jobRunSelectedStatuses; + /// + /// Gets or sets the job run selected statuses. Binding to ComboBox "Status". + /// public SelectedObjectCollection JobRunSelectedStatuses { get { return _jobRunSelectedStatuses; } @@ -113,6 +140,9 @@ namespace Tango.MachineStudio.Statistics.ViewModels } public SelectedObjectCollection _isGradientSelection; + /// + /// Gets or sets the is gradient selection. Binding to ComboBox "IsGradient". + /// public SelectedObjectCollection IsGradientSelection { get { return _isGradientSelection; } @@ -124,6 +154,9 @@ namespace Tango.MachineStudio.Statistics.ViewModels } private SelectedObjectCollection _selectedThreads; + /// + /// Gets or sets the selected threads. Contains all available threads and selected threads. Binding to ComboBox "Thread". + /// public SelectedObjectCollection SelectedThreads { get { return _selectedThreads; } @@ -137,21 +170,26 @@ namespace Tango.MachineStudio.Statistics.ViewModels /// /// Gets or sets the JobRuns providers. /// - public ISuggestionProvider JobRunsProvider { get; set; } + public ISuggestionProvider JobsProvider { get; set; } - private JobRun _jobRun; - public JobRun JobRun + private Job _selectedJob; + /// + /// Gets or sets the job. Used as Sele + /// + public Job SelectedJob { - get { return _jobRun; } - set { - _jobRun = value; - if (_jobRun != null) - { - SelectedJobName = _jobRun.JobName; - } - RaisePropertyChangedAuto(); } + get { return _selectedJob; } + set + { + _selectedJob = value; + SelectedJobName = _selectedJob != null ? _selectedJob.Name : ""; + RaisePropertyChangedAuto(); + } } + /// + /// Gets or sets the name of the selected job. Used in filter. + /// private string SelectedJobName { get; set; } @@ -209,12 +247,12 @@ namespace Tango.MachineStudio.Statistics.ViewModels }); IsGradientSelection.SelectionChanged -= (x, y) => RaisePropertyChanged(nameof(IsGradientSelection)); IsGradientSelection.SelectionChanged += (x, y) => RaisePropertyChanged(nameof(IsGradientSelection)); - JobRunsProvider = new SuggestionProvider((filter) => + JobsProvider = new SuggestionProvider((filter) => { try { SelectedJobName = filter; - return _allJobRuns.Where(x => x.JobName != null && x.JobName.ToString().StartsWith(filter, StringComparison.CurrentCultureIgnoreCase)).ToList(); + return _allJobRuns.Where(x => x.Name != null && x.Name.ToString().StartsWith(filter, StringComparison.CurrentCultureIgnoreCase)).ToList(); } catch { @@ -223,7 +261,10 @@ namespace Tango.MachineStudio.Statistics.ViewModels }); } - + + /// + /// Initializes this instance. Called form main view VM in OnApplicationReady + /// public async void Init() { using (_notification.PushTaskItem("Loading job runs...")) @@ -234,7 +275,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels using (var db = ObservablesContext.CreateDefault()) { - _allJobRuns = await db.JobRuns.ToListAsync(); ; + _allJobRuns = await db.Jobs.ToListAsync(); ; _allMachines = await db.Machines.ToListAsync(); _allUsers = await db.Users.Include(x => x.Contact).ToListAsync(); _rmlsModels = await db.Rmls.Select(x=> new RmlModel(){ Name = x.Name, Guid = x.Guid}).ToListAsync(); @@ -253,7 +294,10 @@ namespace Tango.MachineStudio.Statistics.ViewModels } } } - + + /// + /// Loads the job runs by filters. + /// private async Task LoadJobRuns() { using (_notification.PushTaskItem("Loading job runs...")) @@ -273,6 +317,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels .WithJobSource(JobRunSelectedSources.SynchedSource) .WithJobStatus(JobRunSelectedStatuses.SynchedSource) .WithGradient(IsGradientSelection.SynchedSource) + .WithRmls(SelectedThreads.SynchedSource.Select(x => x.Guid).ToList()) .Query(y => y.Where(x => (String.IsNullOrEmpty(SelectedJobName) || x.JobName.ToString().ToLower().StartsWith(SelectedJobName.ToLower())) && ( x.JobLength < LengthUpperValue && x.JobLength >= LengthLowerValue) )) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml index c89cd5819..c82fa3beb 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml @@ -17,14 +17,13 @@ - - - + + + + + + + + + + + + + + + + + + + + + + @@ -92,7 +120,7 @@ - + @@ -100,7 +128,7 @@ - + @@ -129,12 +157,11 @@ - + - - + @@ -237,7 +264,7 @@ - + @@ -259,7 +286,7 @@ - + @@ -268,10 +295,10 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + @@ -50,7 +82,7 @@ - + @@ -65,6 +97,11 @@ + + @@ -85,7 +122,7 @@ - + @@ -96,7 +133,7 @@ - + @@ -120,20 +157,13 @@ - - - - - - - - - - - - - - + + + + + + + @@ -154,10 +184,9 @@ - - - - + + + @@ -167,7 +196,7 @@ - + @@ -181,19 +210,13 @@ - - - - - - - - - - - - - + + + + + + + @@ -201,7 +224,7 @@ - + @@ -217,19 +240,13 @@ - - - - - - - - - - - - - + + + + + + + @@ -239,14 +256,14 @@ - - - - + + + - + @@ -264,19 +281,12 @@ - - - - - - - - - - - - - + + + + + + @@ -310,20 +320,14 @@ - - + + + + + - - - - - - - - - - - + + @@ -334,30 +338,41 @@ - + - - + + + + + + + + + @@ -68,34 +84,6 @@ - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -475,11 +537,142 @@ - - - TOTALS: - Cyan: - + + + + + + + + + + + + + + + + + + + + + + + + Total Thread Consumption per thread: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs index c460e2a9b..2b3ed79ca 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs @@ -1,4 +1,6 @@ -using System; +using LiveCharts; +using LiveCharts.Wpf; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -79,5 +81,6 @@ namespace Tango.MachineStudio.Statistics.Views } } } + } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/packages.config index 31c5f029f..6938c8a4b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/packages.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/packages.config @@ -1,6 +1,7 @@  + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config index 59f92d6b9..d70e2180b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config @@ -152,6 +152,10 @@ + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.BL/Entities/JobRun.cs b/Software/Visual_Studio/Tango.BL/Entities/JobRun.cs index f422447fe..45bfd9840 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/JobRun.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/JobRun.cs @@ -7,6 +7,7 @@ using System.Text; using System.Threading.Tasks; using Tango.BL.Enumerations; using Tango.BL.ValueObjects; +using Tango.PMR.Exports; namespace Tango.BL.Entities { @@ -82,6 +83,28 @@ namespace Tango.BL.Entities } } + private JobFile _jobFile; + [NotMapped] + [JsonIgnore] + public JobFile JobFile + { + get + { + if (_jobFile == null && JobString != null) + { + _jobFile = JobFile.Parser.ParseJson(JobString); + } + + return _jobFile; + } + set { _jobFile = value; } + } + + public Task CreateAssociatedJob() + { + return Job.FromJobFile(JobFile, MachineGuid, UserGuid); + } + protected override void RaisePropertyChanged(string propName) { base.RaisePropertyChanged(propName); -- cgit v1.3.1 From b188d7bfd91062f65474bd139bb8a434694f117b Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 15 Mar 2020 15:46:03 +0200 Subject: Fixed issue with job run start date. Fixed issue with ActionLogs busy indication. --- .../ViewModels/MainViewVM.cs | 71 ++++++++++++---------- .../Views/MainView.xaml | 2 +- .../ViewModels/JobRunsViewVM.cs | 23 ++++--- .../JobRuns/BasicJobRunsLogger.cs | 4 +- .../Tango.Integration/Operation/MachineOperator.cs | 9 +++ .../Operation/PrintingEventArgs.cs | 1 + 6 files changed, 63 insertions(+), 47 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs index 534bb364f..df2643d88 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/ViewModels/MainViewVM.cs @@ -16,12 +16,15 @@ using Tango.BL.ValueObjects; using Tango.Core.Commands; using Tango.Core.ExtensionMethods; using Tango.MachineStudio.Common; +using Tango.MachineStudio.Common.Notifications; using Tango.SharedUI.Components; namespace Tango.MachineStudio.ActionLogs.ViewModels { public class MainViewVM : StudioViewModel { + private INotificationProvider _notification; + #region Properties private DateTime _startSelectedDate; @@ -83,30 +86,23 @@ namespace Tango.MachineStudio.ActionLogs.ViewModels set { _differenceObject = value; RaisePropertyChangedAuto(); } } - - private bool _isRunning; - public bool IsRunning - { - get { return _isRunning; } - set { _isRunning = value; } - } - #endregion public RelayCommand SearchCommand { get; set; } public RelayCommand CopyToClipBoardCommand { get; set; } public RelayCommand CopyRelateObjectIDCommand { get; set; } - public MainViewVM() + public MainViewVM(INotificationProvider notification) { + _notification = notification; + ActionLogs = new ObservableCollection(); - SearchCommand = new RelayCommand(GetActionLogs, () => !IsRunning); + SearchCommand = new RelayCommand(GetActionLogs, () => IsFree); CopyRelateObjectIDCommand = new RelayCommand(CopyRelateObjectID); CopyToClipBoardCommand = new RelayCommand(CopyToClipBoard, () => SelectedActionLog != null && SelectedActionLog.DifferenceObject != null); DateTime now = DateTime.Now; StartSelectedDate = now.AddMonths(-1); EndSelectedDate = now; - _isRunning = false; var source = Enum.GetValues(typeof(ActionLogType)).Cast().ToObservableCollection(); var syncedSource = Enum.GetValues(typeof(ActionLogType)).Cast().ToObservableCollection(); @@ -139,27 +135,40 @@ namespace Tango.MachineStudio.ActionLogs.ViewModels if (String.IsNullOrWhiteSpace(filter)) filter = null; - using (ObservablesContext db = ObservablesContext.CreateDefault()) + try + { + IsFree = false; + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + + DateTime startUtc = new DateTime(StartSelectedDate.Date.Ticks, DateTimeKind.Utc); + TimeSpan offsetTime = (EndSelectedDate.Date == DateTime.Now.Date) ? DateTime.Now.TimeOfDay : new TimeSpan(24, 0, 0); + DateTime endUtc = new DateTime(EndSelectedDate.Date.Ticks + offsetTime.Ticks, DateTimeKind.Utc); + + Debug.Write($"TEST TIME {startUtc} from {endUtc} " + System.Environment.NewLine); + + ActionLogs = await new ActionLogsCollectionBuilder(db).Set(x => x.LastUpdated <= DbFunctions.TruncateTime(endUtc) && x.LastUpdated >= DbFunctions.TruncateTime(startUtc)) + .WithUsers() + .WithActionType(SelectedActionLogTypes.SynchedSource.ToArray()) + .Query(y => y.Where + (x => filter == null || + (x.ID.ToString().ToLower().StartsWith(filter) + || (x.RelatedObjectName != null && x.RelatedObjectName.ToLower().StartsWith(filter)) + || (x.RelatedObjectGuid != null && x.RelatedObjectGuid.ToLower().StartsWith(filter)) + || (x.User != null && x.User.Contact != null && x.User.Contact.FullName.ToLower().StartsWith(filter))))) + .BuildAsync(); + } + } + catch (Exception ex) + { + IsFree = true; + LogManager.Log(ex, "Error getting action logs."); + _notification.ShowError($"Error occurred while trying to retrieve the action logs.\n{ex.Message}"); + } + finally { - - DateTime startUtc = new DateTime(StartSelectedDate.Date.Ticks, DateTimeKind.Utc); - TimeSpan offsetTime = (EndSelectedDate.Date == DateTime.Now.Date) ? DateTime.Now.TimeOfDay : new TimeSpan(24, 0, 0); - DateTime endUtc = new DateTime(EndSelectedDate.Date.Ticks + offsetTime.Ticks, DateTimeKind.Utc); - - Debug.Write($"TEST TIME {startUtc} from {endUtc} " + System.Environment.NewLine); - - IsRunning = true; - ActionLogs = await new ActionLogsCollectionBuilder(db).Set(x => x.LastUpdated <= DbFunctions.TruncateTime(endUtc) && x.LastUpdated >= DbFunctions.TruncateTime(startUtc)) - .WithUsers() - .WithActionType(SelectedActionLogTypes.SynchedSource.ToArray()) - .Query(y => y.Where - (x => filter == null || - (x.ID.ToString().ToLower().StartsWith(filter) - || (x.RelatedObjectName != null && x.RelatedObjectName.ToLower().StartsWith(filter)) - || (x.RelatedObjectGuid != null && x.RelatedObjectGuid.ToLower().StartsWith(filter)) - || (x.User != null && x.User.Contact != null && x.User.Contact.FullName.ToLower().StartsWith(filter))))) - .BuildAsync(); - IsRunning = false; + IsFree = true; } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml index 3a7eaa802..fd640bae5 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ActionLogs/Views/MainView.xaml @@ -207,7 +207,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs index d57a1c96c..9bf69137d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs @@ -188,7 +188,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels RaisePropertyChangedAuto(); } } - + public StatisticsValueCollection StatisticsValueCollection { get; set; } #endregion @@ -253,7 +253,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels { using (ObservablesContext db = ObservablesContext.CreateDefault()) { - return db.Jobs.Where(x => x.Name!= null && x.Name.ToLower().Contains(filter.ToLower())).ToList(); + return db.Jobs.Where(x => x.Name != null && x.Name.ToLower().Contains(filter.ToLower())).ToList(); } } else @@ -267,7 +267,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels return null; } }); - + StatisticsValueCollection = new StatisticsValueCollection(); } @@ -326,7 +326,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels .WithJobStatus(JobRunSelectedStatuses.SynchedSource) .WithGradient(IsGradientSelection.SynchedSource) .WithRmls(SelectedThreads.SynchedSource.Select(x => x.Guid).ToList()) - .Query(y => y.Where(x => ( String.IsNullOrEmpty(jobName) || x.JobName.ToLower().StartsWith(jobName.ToLower())) + .Query(y => y.Where(x => (String.IsNullOrEmpty(jobName) || x.JobName.ToLower().StartsWith(jobName.ToLower())) && (x.JobLength < LengthUpperValue && x.JobLength >= LengthLowerValue))) .BuildListAsync(); @@ -343,7 +343,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels GenerateStatistics(); } - + } catch (Exception ex) { @@ -387,9 +387,8 @@ namespace Tango.MachineStudio.Statistics.ViewModels protected void GenerateUploadDuration() { - var val = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.UploadDuration != null).Average(x => x.UploadDuration.Value.Ticks); - TimeSpan ts = new TimeSpan(Convert.ToInt64(val)); - StatisticsValueCollection.AddStatisticsValue("Average Upload Duration", Math.Max(ts.TotalMinutes, 0), " minutes"); + var val = (long)JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.UploadDuration != null).Average(x => x.UploadDuration.Value.TotalMilliseconds); + StatisticsValueCollection.AddStatisticsValue("Average Upload Duration", Math.Max(TimeSpan.FromMilliseconds(val).TotalMinutes, 0), " minutes"); } protected void GenerateHeatingDuration() @@ -425,18 +424,18 @@ namespace Tango.MachineStudio.Statistics.ViewModels protected void CreateThreadConsumptionPerThread() { var temp = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.Rml != null).GroupBy(x => x.Rml.Name); - List result = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.Rml != null && !String.IsNullOrEmpty(z.Rml.Name)).GroupBy(x => x.Rml.Name).Select(y => new StatisticsValue { Name = y.Key, Value = y.Sum(x => x.JobRun.EndPosition), Unit="m" }).ToList(); + List result = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.Rml != null && !String.IsNullOrEmpty(z.Rml.Name)).GroupBy(x => x.Rml.Name).Select(y => new StatisticsValue { Name = y.Key, Value = y.Sum(x => x.JobRun.EndPosition), Unit = "m" }).ToList(); StatisticsValueCollection.CreateThreadConsumptionPerThread(result); } protected void GenerateAllLiquidQuantities() { - var db_liquidQuantities = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.JobRun.LiquidQuantities.Count > 0).Select(y=> y.JobRun.LiquidQuantities).ToList(); + var db_liquidQuantities = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.JobRun.LiquidQuantities.Count > 0).Select(y => y.JobRun.LiquidQuantities).ToList(); List allLiquidQuantities = new List(); - + foreach (LiquidTypes ltype in (LiquidTypes[])Enum.GetValues(typeof(LiquidTypes))) { - var liquidQuantityByTypeList = db_liquidQuantities.Select(x => x.SingleOrDefault(y => y.LiquidType == ltype)).Where(x=>x!=null); + var liquidQuantityByTypeList = db_liquidQuantities.Select(x => x.SingleOrDefault(y => y.LiquidType == ltype)).Where(x => x != null); var count = liquidQuantityByTypeList != null ? liquidQuantityByTypeList.Sum(x => x.Quantity) : 0; JobRunLiquidQuantity lq = new JobRunLiquidQuantity() { LiquidType = ltype, Quantity = count }; allLiquidQuantities.Add(lq); diff --git a/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs b/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs index f2fb2f16e..0fadd1baa 100644 --- a/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs +++ b/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs @@ -17,7 +17,6 @@ namespace Tango.Integration.JobRuns /// public class BasicJobRunsLogger : ExtendedObject, IJobRunsLogger { - private DateTime _start_date; private Job _job; #region Properties @@ -96,7 +95,7 @@ namespace Tango.Integration.JobRuns JobRun run = new JobRun(); run.UserGuid = _job.UserGuid; - run.StartDate = _start_date; + run.StartDate = e.StartDate; run.UploadingStartDate = e.UploadingStartTime; run.HeatingStartDate = e.HeatingStartTime; run.ActualStartDate = e.ActualStartTime; @@ -187,7 +186,6 @@ namespace Tango.Integration.JobRuns private void Machine_PrintingStarted(object sender, PrintingEventArgs e) { _job = e.Job; - _start_date = DateTime.UtcNow; } #endregion diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 9768498c6..b17321942 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -75,6 +75,8 @@ namespace Tango.Integration.Operation private List _currentJobLiquidQuantities; private DateTime _diagnosticsTime; private MachineStatus _machineStatusBeforeJobStart; + + private DateTime _jobStartDate; private DateTime? _jobUploadingStartDate; private DateTime? _jobHeatingStartDate; private DateTime? _jobActualStartDate; @@ -1050,6 +1052,7 @@ namespace Tango.Integration.Operation PrintingStarted?.Invoke(this, new PrintingEventArgs(handler, job) { LiquidQuantities = _currentJobLiquidQuantities.ToList(), + StartDate = _jobStartDate, }); } @@ -1063,6 +1066,7 @@ namespace Tango.Integration.Operation PrintingCompleted?.Invoke(this, new PrintingEventArgs(handler, job) { LiquidQuantities = _currentJobLiquidQuantities.ToList(), + StartDate = _jobStartDate, UploadingStartTime = _jobUploadingStartDate, HeatingStartTime = _jobHeatingStartDate, ActualStartTime = _jobActualStartDate, @@ -1082,6 +1086,7 @@ namespace Tango.Integration.Operation PrintingFailed?.Invoke(this, new PrintingFailedEventArgs(handler, job, exception) { LiquidQuantities = _currentJobLiquidQuantities.ToList(), + StartDate = _jobStartDate, UploadingStartTime = _jobUploadingStartDate, HeatingStartTime = _jobHeatingStartDate, ActualStartTime = _jobActualStartDate, @@ -1099,6 +1104,7 @@ namespace Tango.Integration.Operation PrintingAborted?.Invoke(this, new PrintingEventArgs(handler, job) { LiquidQuantities = _currentJobLiquidQuantities.ToList(), + StartDate = _jobStartDate, UploadingStartTime = _jobUploadingStartDate, HeatingStartTime = _jobHeatingStartDate, ActualStartTime = _jobActualStartDate, @@ -1116,6 +1122,7 @@ namespace Tango.Integration.Operation PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, job) { LiquidQuantities = _currentJobLiquidQuantities.ToList(), + StartDate = _jobStartDate, UploadingStartTime = _jobUploadingStartDate, HeatingStartTime = _jobHeatingStartDate, ActualStartTime = _jobActualStartDate, @@ -2159,6 +2166,8 @@ namespace Tango.Integration.Operation throw new InvalidOperationException("Could not print while status = " + Status); } + _jobStartDate = DateTime.UtcNow; + LogManager.Log($"Executing job '{job.Name}'..."); _currentJobLiquidQuantities = new List(); diff --git a/Software/Visual_Studio/Tango.Integration/Operation/PrintingEventArgs.cs b/Software/Visual_Studio/Tango.Integration/Operation/PrintingEventArgs.cs index f68204127..b088b9046 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/PrintingEventArgs.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/PrintingEventArgs.cs @@ -13,6 +13,7 @@ namespace Tango.Integration.Operation public JobHandler JobHandler { get; private set; } public Job Job { get; private set; } public List LiquidQuantities { get; set; } + public DateTime StartDate { get; set; } public DateTime? UploadingStartTime { get; set; } public DateTime? HeatingStartTime { get; set; } public DateTime? ActualStartTime { get; set; } -- cgit v1.3.1 From 56678ae530fe45b0880053793ab46f47051e4dc6 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 15 Mar 2020 16:12:26 +0200 Subject: MS Statistics Job Runs page. Added comments. --- .../Converters/NanoLiterToLiterFormatConverter.cs | 2 +- .../Models/StatisticsValueCollection.cs | 49 ++++++++++++++++-- .../ViewModels/JobRunsViewVM.cs | 59 +++++++++++++++++----- .../Views/JobRunsView.xaml | 25 ++++++++- 4 files changed, 113 insertions(+), 22 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/NanoLiterToLiterFormatConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/NanoLiterToLiterFormatConverter.cs index 3c25bfe4f..23d7564e8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/NanoLiterToLiterFormatConverter.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/NanoLiterToLiterFormatConverter.cs @@ -14,7 +14,7 @@ namespace Tango.MachineStudio.Statistics.Converters { try { - double val =(double) ((int)value) / 1000000; + double val =(double) ((int)value) / 1000000000; return val.ToString("N2", CultureInfo.InvariantCulture); } catch{ } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs index 2a298777b..2ad165d79 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs @@ -35,6 +35,9 @@ namespace Tango.MachineStudio.Statistics.Models private ObservableCollection _statisticsCollection; + /// + /// Gets or sets the statistics collection of StatisticsValue object. + /// public ObservableCollection StatisticsCollection { get { return _statisticsCollection; } @@ -44,16 +47,25 @@ namespace Tango.MachineStudio.Statistics.Models } private List _threadConsumptionPerThread; - + /// + /// Gets or sets the thread consumption per thread list. + /// public List ThreadConsumptionPerThread { get { return _threadConsumptionPerThread; } set { _threadConsumptionPerThread = value; RaisePropertyChangedAuto(); } } + /// + /// Gets or sets the thread consumption per thread collection. + /// public CompositeCollection ThreadConsumptionPerThreadCollection { get; set; } private LabeledSeriesCollection _pieJobSource; + + /// + /// Gets or sets the pie job source. + /// public LabeledSeriesCollection PieJobSource { get { return _pieJobSource; } @@ -61,6 +73,10 @@ namespace Tango.MachineStudio.Statistics.Models } private LabeledSeriesCollection _pieJobRunStatus; + + /// + /// Gets or sets the pie job run status. + /// public LabeledSeriesCollection PieJobRunStatus { get { return _pieJobRunStatus; } @@ -68,6 +84,10 @@ namespace Tango.MachineStudio.Statistics.Models } private LabeledSeriesCollection _pieGradientSolid; + + /// + /// Gets or sets the pie gradient solid. + /// public LabeledSeriesCollection PieGradientSolid { get { return _pieGradientSolid; } @@ -75,6 +95,10 @@ namespace Tango.MachineStudio.Statistics.Models } private List _liquidQuantities; + + /// + /// Gets or sets the liquid quantities. + /// public List LiquidQuantities { get @@ -91,6 +115,9 @@ namespace Tango.MachineStudio.Statistics.Models private int _totalLiquidQuantities; + /// + /// Gets or sets the total liquid quantities. + /// public int TotalLiquidQuantities { get { return _totalLiquidQuantities; } @@ -128,6 +155,9 @@ namespace Tango.MachineStudio.Statistics.Models }; } + /// + /// Cleans all values. + /// public void Clean() { StatisticsCollection.Clear(); @@ -138,21 +168,27 @@ namespace Tango.MachineStudio.Statistics.Models PieGradientSolid.SeriesCollection.Clear(); } - public void AddStatisticsValue( string name, double value, string unit) + /// + /// Adds the statistics value. + /// + public void AddStatisticsValue(string name, double value, string unit) { - StatisticsCollection.Add(new StatisticsValue() { Name = name, Value=value, Unit = unit }); + StatisticsCollection.Add(new StatisticsValue() { Name = name, Value = value, Unit = unit }); RaisePropertyChanged("StatisticsCollection"); } + /// + /// Creates the thread consumption per thread. + /// public void CreateThreadConsumptionPerThread(List threads) { ThreadConsumptionPerThreadCollection.Add(new CollectionContainer() { Collection = threads.Take(threads.Count() > 2 ? 2 : threads.Count()) }); if (threads.Count() > 2) { - ThreadConsumptionPerThreadCollection.Add(new CollectionContainer() { Collection = new List() { new MoreValue(){ Text="More threads ..." } } }); + ThreadConsumptionPerThreadCollection.Add(new CollectionContainer() { Collection = new List() { new MoreValue() { Text = "More threads ..." } } }); ThreadConsumptionPerThread = threads.Skip(2).ToList(); } - + RaisePropertyChanged("ThreadConsumptionPerThreadCollection"); } @@ -259,6 +295,9 @@ namespace Tango.MachineStudio.Statistics.Models } #endregion + /// + /// Generates the statistics liquid quantity and TotalLiquidQuantities. + /// public void GenerateStatisticsLiquidQuantity(List liquidQuantities) { LiquidQuantities = liquidQuantities; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs index d57a1c96c..ed52c2352 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs @@ -177,7 +177,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels private Job _selectedJob; /// - /// Gets or sets the job. Used as Sele + /// Gets or sets the job. /// public Job SelectedJob { @@ -188,7 +188,10 @@ namespace Tango.MachineStudio.Statistics.ViewModels RaisePropertyChangedAuto(); } } - + + /// + /// Gets or sets the statistics value collection. Class - container included calculated statistic values. + /// public StatisticsValueCollection StatisticsValueCollection { get; set; } #endregion @@ -356,26 +359,37 @@ namespace Tango.MachineStudio.Statistics.ViewModels } } + #region GenerateS_StatisticsValueCollection + + /// + /// Generates the statistics. + /// protected void GenerateStatistics() { StatisticsValueCollection.Clean(); GenerateTotalRunsLength(); GenerateRunsDuration(); - GenerateUploadDuration(); - GenerateHeatingDuration(); + GenerateAverageUploadDuration(); + GenerateAverageHeatingDuration(); GenerateTotalThreadConsumption(); GeneratePieCharts(); CreateThreadConsumptionPerThread(); GenerateAllLiquidQuantities(); } - + + /// + /// Generates the total length of the job runs. + /// protected void GenerateTotalRunsLength() { double val = JobRuns.Where(z => z.JobRun.EndPosition > 0).Sum(x => x.JobRun.JobLength); StatisticsValueCollection.AddStatisticsValue("Total Runs Length", val, " m"); } + /// + /// Generates the duration and average of the job runs. + /// protected void GenerateRunsDuration() { var selection = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.JobRun.EndDate != null && z.JobRun.ActualStartDate != null); @@ -385,26 +399,36 @@ namespace Tango.MachineStudio.Statistics.ViewModels StatisticsValueCollection.AddStatisticsValue("Average Runs Duration", average, " hours"); } - protected void GenerateUploadDuration() + /// + /// Generates the average upload duration of the job runs. + /// + protected void GenerateAverageUploadDuration() { - var val = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.UploadDuration != null).Average(x => x.UploadDuration.Value.Ticks); - TimeSpan ts = new TimeSpan(Convert.ToInt64(val)); - StatisticsValueCollection.AddStatisticsValue("Average Upload Duration", Math.Max(ts.TotalMinutes, 0), " minutes"); + var average = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.UploadDuration != null && z.UploadDuration.Value.Ticks > 0).Average(x => x.UploadDuration.Value.TotalMinutes); + StatisticsValueCollection.AddStatisticsValue("Average Upload Duration", Math.Max(average, 0), " minutes"); } - protected void GenerateHeatingDuration() + /// + /// Generates the average duration heating of the job runs. + /// + protected void GenerateAverageHeatingDuration() { - var val = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.HeatingDuration != null).Average(x => x.HeatingDuration.Value.Ticks); - TimeSpan ts = new TimeSpan(Convert.ToInt64(val)); - StatisticsValueCollection.AddStatisticsValue("Average Heating Duration", Math.Max(ts.TotalMinutes, 0), " minutes"); + var average = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.HeatingDuration != null && z.HeatingDuration.Value.Ticks > 0).Average(x => x.HeatingDuration.Value.TotalMinutes); + StatisticsValueCollection.AddStatisticsValue("Average Heating Duration", Math.Max(average, 0), " minutes"); } + /// + /// Generates the total thread consumption by EndPosition. + /// protected void GenerateTotalThreadConsumption() { double val = JobRuns.Where(z => z.JobRun.EndPosition > 0).Sum(x => x.JobRun.EndPosition); StatisticsValueCollection.AddStatisticsValue("Total Thread Consumption", val, " m"); } + /// + /// Generates the pie charts in percentage: JobSource, JobRunStatus, Gradient. + /// protected void GeneratePieCharts() { int PPCCount = JobRuns.Count(x => x.JobRun.Source == JobSource.Local); @@ -422,6 +446,9 @@ namespace Tango.MachineStudio.Statistics.ViewModels } + /// + /// Creates the thread consumption per thread. + /// protected void CreateThreadConsumptionPerThread() { var temp = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.Rml != null).GroupBy(x => x.Rml.Name); @@ -429,6 +456,9 @@ namespace Tango.MachineStudio.Statistics.ViewModels StatisticsValueCollection.CreateThreadConsumptionPerThread(result); } + /// + /// Generates all liquid quantities. + /// protected void GenerateAllLiquidQuantities() { var db_liquidQuantities = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.JobRun.LiquidQuantities.Count > 0).Select(y=> y.JobRun.LiquidQuantities).ToList(); @@ -436,13 +466,14 @@ namespace Tango.MachineStudio.Statistics.ViewModels foreach (LiquidTypes ltype in (LiquidTypes[])Enum.GetValues(typeof(LiquidTypes))) { - var liquidQuantityByTypeList = db_liquidQuantities.Select(x => x.SingleOrDefault(y => y.LiquidType == ltype)).Where(x=>x!=null); + var liquidQuantityByTypeList = db_liquidQuantities.Select(x => x.FirstOrDefault(y => y.LiquidType == ltype)).Where(x=>x!=null); var count = liquidQuantityByTypeList != null ? liquidQuantityByTypeList.Sum(x => x.Quantity) : 0; JobRunLiquidQuantity lq = new JobRunLiquidQuantity() { LiquidType = ltype, Quantity = count }; allLiquidQuantities.Add(lq); } StatisticsValueCollection.GenerateStatisticsLiquidQuantity(allLiquidQuantities); } + #endregion } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml index 4790402d5..58d94aca1 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml @@ -554,13 +554,24 @@ - + - Total Thread Consumption per thread: + + + + + @@ -669,6 +680,16 @@ + + + -- cgit v1.3.1 From 1e563685f9c74fc7cfc204b714a1401002eba5fd Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 15 Mar 2020 17:11:16 +0200 Subject: Machine Studio. Statistics Job Runs page, change colors of pies, a little changes in GUI. --- .../Models/StatisticsValueCollection.cs | 20 ++++++++++++-------- .../ViewModels/JobRunsViewVM.cs | 18 +++++++++--------- .../Views/JobRunsView.xaml | 12 ++++++------ 3 files changed, 27 insertions(+), 23 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs index 2ad165d79..287e09009 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs @@ -11,6 +11,8 @@ using System.Windows.Media; using Tango.BL.Enumerations; using Tango.BL.ValueObjects; using Tango.Core; +using System.Windows.Media; +using System.Windows; namespace Tango.MachineStudio.Statistics.Models { @@ -133,8 +135,10 @@ namespace Tango.MachineStudio.Statistics.Models ThreadConsumptionPerThreadCollection = new CompositeCollection(); _pieColors = new List(); - _pieColors.Add(Color.FromRgb(239, 131, 43));//green - _pieColors.Add(Color.FromRgb(144, 233, 144));//orange + _pieColors.Add(((SolidColorBrush)Application.Current.Resources["RedBrush100"]).Color); + _pieColors.Add(((SolidColorBrush)Application.Current.Resources["OrangeBrush300"]).Color); + _pieColors.Add(((SolidColorBrush)Application.Current.Resources["GreenBrush300"]).Color); + _pieColors.Add(((SolidColorBrush)Application.Current.Resources["BlueBrush100"]).Color); _pieColors.Add(Color.FromRgb(100, 184, 236));//blue @@ -202,7 +206,7 @@ namespace Tango.MachineStudio.Statistics.Models { Title = "PPC", Values = new ChartValues() { PPCCount }, - Fill = new SolidColorBrush(_pieColors[0]), + Fill = new SolidColorBrush(_pieColors[2]), DataLabels = true, ToolTip = "", LabelPoint = labelPoint @@ -215,7 +219,7 @@ namespace Tango.MachineStudio.Statistics.Models { Title = "MS", Values = new ChartValues() { MSCount }, - Fill = new SolidColorBrush(_pieColors[2]), + Fill = new SolidColorBrush(_pieColors[3]), DataLabels = true, ToolTip = "", LabelPoint = labelPoint @@ -242,7 +246,7 @@ namespace Tango.MachineStudio.Statistics.Models { Title = "Aborted", Values = new ChartValues() { abortedCount }, - Fill = new SolidColorBrush(_pieColors[2]), + Fill = new SolidColorBrush(_pieColors[1]), DataLabels = true, ToolTip = "", LabelPoint = labelPoint, @@ -254,7 +258,7 @@ namespace Tango.MachineStudio.Statistics.Models { Title = "Completed", Values = new ChartValues() { completedCount }, - Fill = new SolidColorBrush(_pieColors[1]), + Fill = new SolidColorBrush(_pieColors[2]), DataLabels = true, ToolTip = "", LabelPoint = labelPoint @@ -270,7 +274,7 @@ namespace Tango.MachineStudio.Statistics.Models { Title = "Solid", Values = new ChartValues() { solidCount }, - Fill = new SolidColorBrush(_pieColors[0]), + Fill = new SolidColorBrush(_pieColors[2]), DataLabels = true, ToolTip = "", LabelPoint = labelPoint @@ -281,7 +285,7 @@ namespace Tango.MachineStudio.Statistics.Models { Title = "Gradient", Values = new ChartValues() { gradientCount }, - Fill = new SolidColorBrush(_pieColors[2]), + Fill = new SolidColorBrush(_pieColors[3]), DataLabels = true, ToolTip = "", LabelPoint = labelPoint diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs index ed7bbec56..ca40273f9 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs @@ -368,10 +368,10 @@ namespace Tango.MachineStudio.Statistics.ViewModels { StatisticsValueCollection.Clean(); GenerateTotalRunsLength(); + GenerateTotalThreadConsumption(); GenerateRunsDuration(); GenerateAverageUploadDuration(); GenerateAverageHeatingDuration(); - GenerateTotalThreadConsumption(); GeneratePieCharts(); CreateThreadConsumptionPerThread(); @@ -395,8 +395,8 @@ namespace Tango.MachineStudio.Statistics.ViewModels var selection = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.JobRun.EndDate != null && z.JobRun.ActualStartDate != null); double val = selection.Sum(x => (x.JobRun.EndDate - x.JobRun.ActualStartDate).Value.TotalHours); StatisticsValueCollection.AddStatisticsValue("Total Runs Duration", val, " hours"); - double average = selection.Average(x => (x.JobRun.EndDate - x.JobRun.ActualStartDate).Value.TotalHours); - StatisticsValueCollection.AddStatisticsValue("Average Runs Duration", average, " hours"); + double average = selection.Average(x => (x.JobRun.EndDate - x.JobRun.ActualStartDate).Value.TotalMilliseconds); + StatisticsValueCollection.AddStatisticsValue("Average Runs Duration", Math.Max(TimeSpan.FromMilliseconds(average).TotalHours, 0), " hours"); } /// @@ -404,8 +404,8 @@ namespace Tango.MachineStudio.Statistics.ViewModels /// protected void GenerateAverageUploadDuration() { - var val = (long)JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.UploadDuration != null).Average(x => x.UploadDuration.Value.TotalMilliseconds); - StatisticsValueCollection.AddStatisticsValue("Average Upload Duration", Math.Max(TimeSpan.FromMilliseconds(val).TotalMinutes, 0), " minutes"); + var average = (long)JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.UploadDuration != null).Average(x => x.UploadDuration.Value.TotalMilliseconds); + StatisticsValueCollection.AddStatisticsValue("Average Upload Duration", Math.Max(TimeSpan.FromMilliseconds(average).TotalMinutes, 0), " minutes"); } /// @@ -413,8 +413,8 @@ namespace Tango.MachineStudio.Statistics.ViewModels /// protected void GenerateAverageHeatingDuration() { - var average = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.HeatingDuration != null && z.HeatingDuration.Value.Ticks > 0).Average(x => x.HeatingDuration.Value.TotalMinutes); - StatisticsValueCollection.AddStatisticsValue("Average Heating Duration", Math.Max(average, 0), " minutes"); + var average = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.HeatingDuration != null && z.HeatingDuration.Value.Ticks > 0).Average(x => x.HeatingDuration.Value.TotalMilliseconds); + StatisticsValueCollection.AddStatisticsValue("Average Heating Duration", Math.Max(TimeSpan.FromMilliseconds(average).TotalMinutes, 0), " minutes"); } /// @@ -423,7 +423,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels protected void GenerateTotalThreadConsumption() { double val = JobRuns.Where(z => z.JobRun.EndPosition > 0).Sum(x => x.JobRun.EndPosition); - StatisticsValueCollection.AddStatisticsValue("Total Thread Consumption", val, " m"); + StatisticsValueCollection.AddStatisticsValue("Actual Total Runs Length", val, " m"); } /// @@ -466,7 +466,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels foreach (LiquidTypes ltype in (LiquidTypes[])Enum.GetValues(typeof(LiquidTypes))) { - var liquidQuantityByTypeList = db_liquidQuantities.Select(x => x.SingleOrDefault(y => y.LiquidType == ltype)).Where(x => x != null); + var liquidQuantityByTypeList = db_liquidQuantities.Select(x => x.FirstOrDefault(y => y.LiquidType == ltype)).Where(x => x != null); var count = liquidQuantityByTypeList != null ? liquidQuantityByTypeList.Sum(x => x.Quantity) : 0; JobRunLiquidQuantity lq = new JobRunLiquidQuantity() { LiquidType = ltype, Quantity = count }; allLiquidQuantities.Add(lq); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml index 58d94aca1..057647858 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml @@ -552,7 +552,7 @@ - + @@ -560,7 +560,7 @@ - + - + -- cgit v1.3.1 From ab31d366a5d9e5c6f8e9ce1bcb4e76e9ab46d526 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Mon, 16 Mar 2020 16:12:49 +0200 Subject: MS. Statistic Job Runs page. Add "Total Runs: Integer". --- .../Models/StatisticsValueCollection.cs | 10 +++++----- .../Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs | 9 ++++++++- .../Tango.MachineStudio.Statistics/Views/JobRunsView.xaml | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs index eab4eecde..ef5527406 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Models/StatisticsValueCollection.cs @@ -20,7 +20,7 @@ namespace Tango.MachineStudio.Statistics.Models { public string Name { get; set; } - public double Value { get; set; } + public object Value { get; set; } public string Unit { get; set; } } @@ -139,7 +139,7 @@ namespace Tango.MachineStudio.Statistics.Models _pieColors.Add(((SolidColorBrush)Application.Current.Resources["OrangeBrush"]).Color); _pieColors.Add(((SolidColorBrush)Application.Current.Resources["GreenBrush"]).Color); _pieColors.Add(((SolidColorBrush)Application.Current.Resources["BlueBrush100"]).Color); - _pieColors.Add(Color.FromRgb(100, 184, 236));//blue + _pieColors.Add(Colors.Yellow); PieJobSource = new LabeledSeriesCollection() @@ -175,7 +175,7 @@ namespace Tango.MachineStudio.Statistics.Models /// /// Adds the statistics value. /// - public void AddStatisticsValue(string name, double value, string unit) + public void AddStatisticsValue(string name, object value, string unit) { StatisticsCollection.Add(new StatisticsValue() { Name = name, Value = value, Unit = unit }); RaisePropertyChanged("StatisticsCollection"); @@ -206,7 +206,7 @@ namespace Tango.MachineStudio.Statistics.Models { Title = "PPC", Values = new ChartValues() { PPCCount }, - Fill = new SolidColorBrush(_pieColors[2]), + Fill = new SolidColorBrush(_pieColors[4]), DataLabels = true, ToolTip = "", LabelPoint = labelPoint @@ -274,7 +274,7 @@ namespace Tango.MachineStudio.Statistics.Models { Title = "Solid", Values = new ChartValues() { solidCount }, - Fill = new SolidColorBrush(_pieColors[2]), + Fill = new SolidColorBrush(_pieColors[4]), DataLabels = true, ToolTip = "", LabelPoint = labelPoint diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs index ca40273f9..94d06a178 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs @@ -367,6 +367,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels protected void GenerateStatistics() { StatisticsValueCollection.Clean(); + GenerateTotalRunsCount(); GenerateTotalRunsLength(); GenerateTotalThreadConsumption(); GenerateRunsDuration(); @@ -377,7 +378,13 @@ namespace Tango.MachineStudio.Statistics.ViewModels CreateThreadConsumptionPerThread(); GenerateAllLiquidQuantities(); } - + + protected void GenerateTotalRunsCount() + {//Total Runs: + int val =JobRuns.Where(z => z.JobRun.EndPosition > 0).Count(); + StatisticsValueCollection.AddStatisticsValue("Total Runs ", val, " "); + } + /// /// Generates the total length of the job runs. /// diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml index ecc846903..af363b32a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml @@ -554,7 +554,7 @@ - + -- cgit v1.3.1 From 062292c7b822247d74e4470dd8a509284b0d5eda Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Tue, 17 Mar 2020 05:14:20 +0200 Subject: Changes to file system monitoring. --- .../ViewModels/FileSystemViewVM.cs | 32 ++++++++- .../ViewModels/MonitoringViewVM.cs | 68 +++++++++++++------ .../Tango.FSE.PPCConsole/Views/FileSystemView.xaml | 76 ++++++++++++---------- .../Views/MainView.xaml | 2 +- .../Tango.FileSystem/FileSystemManager.cs | 16 +++++ 5 files changed, 136 insertions(+), 58 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs index f9eff7e6f..20a960243 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs @@ -29,15 +29,27 @@ namespace Tango.FSE.PPCConsole.ViewModels set { _currentPath = value; RaisePropertyChangedAuto(); } } + private List _drives; + public List Drives + { + get { return _drives; } + set { _drives = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand NavigateCommand { get; set; } public RelayCommand OpenItemCommand { get; set; } public RelayCommand BackCommand { get; set; } + public RelayCommand NavigateSpecialFolderCommand { get; set; } + public RelayCommand NavigateToFolderCommand { get; set; } public FileSystemViewVM() { NavigateCommand = new RelayCommand(NavigateToCurrentPath); OpenItemCommand = new RelayCommand(OpenFileSystemItem); BackCommand = new RelayCommand(NavigateBack, () => !(CurrentItem is FolderItem) || !(CurrentItem as FolderItem).IsRoot); + NavigateSpecialFolderCommand = new RelayCommand(NavigateToSpecialFolder); + NavigateToFolderCommand = new RelayCommand(async (x) => await Navigate(x)); } private async void NavigateBack() @@ -82,7 +94,13 @@ namespace Tango.FSE.PPCConsole.ViewModels } } - private async Task Navigate(String path) + private async void NavigateToSpecialFolder(string folder) + { + Environment.SpecialFolder specialFolder = (Environment.SpecialFolder)Enum.Parse(typeof(Environment.SpecialFolder), folder); + await Navigate(null, specialFolder); + } + + private async Task Navigate(String path, Environment.SpecialFolder? specialFolder = null) { try { @@ -94,9 +112,21 @@ namespace Tango.FSE.PPCConsole.ViewModels { CurrentItem = await FileSystemProvider.GetFolder(path) as FileSystemItem; } + else if (specialFolder != null) + { + CurrentItem = await FileSystemProvider.GetSpecialFolder(specialFolder.Value) as FileSystemItem; + } else { CurrentItem = await FileSystemProvider.GetThisPC() as FileSystemItem; + try + { + Drives = (CurrentItem as IFileSystemContainer).Items.Cast().ToList(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error setting file system drives menu."); + } } } catch (Exception ex) diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MonitoringViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MonitoringViewVM.cs index 229a7ad61..54282ebf2 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MonitoringViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MonitoringViewVM.cs @@ -80,7 +80,7 @@ namespace Tango.FSE.PPCConsole.ViewModels RAMController = CreateController(CreateSeries("Total", GraphHelper.GraphColor.White), CreateSeries("Application", GraphHelper.GraphColor.Yellow)); UsedDiskSpace = 1000 * 40; AvailableDiskSpace = 1000 * 60; - DiskSpacePointLabel = (point) => + DiskSpacePointLabel = (point) => { return $"{(point.Y / 1000d).ToString("0.0")} GB"; }; @@ -120,6 +120,16 @@ namespace Tango.FSE.PPCConsole.ViewModels base.OnApplicationStarted(); PerformanceProvider.PerformancePackageAvailable += PerformanceProvider_PerformancePackageAvailable; MachineProvider.MachineDisconnected += MachineProvider_MachineDisconnected; + MachineProvider.MachineConnected += MachineProvider_MachineConnected; + } + + private void MachineProvider_MachineConnected(object sender, Common.Connection.MachineConnectedEventArgs e) + { + CPUController.Clear(); + RAMController.Clear(); + AvailableDiskSpace = 0; + UsedDiskSpace = 0; + LoadSystemInformation(); } private void MachineProvider_MachineDisconnected(object sender, Common.Connection.MachineDisconnectedEventArgs e) @@ -150,34 +160,50 @@ namespace Tango.FSE.PPCConsole.ViewModels e.Package.ApplicationRAM }); - UsedDiskSpace = e.Package.DiskCapacity - e.Package.AvailableDiskSpace; - AvailableDiskSpace = e.Package.AvailableDiskSpace; + //Disk Space + var usedDiskSpace = e.Package.DiskCapacity - e.Package.AvailableDiskSpace; + var availableDiskSpace = e.Package.AvailableDiskSpace; + + if (Math.Abs(UsedDiskSpace - usedDiskSpace) > 10) + { + UsedDiskSpace = usedDiskSpace; + } + + if (Math.Abs(AvailableDiskSpace - availableDiskSpace) > 10) + { + AvailableDiskSpace = availableDiskSpace; + } } - public override async void OnNavigatedTo() + public override void OnNavigatedTo() { base.OnNavigatedTo(); if (MachineProvider.IsConnected) { - if (SystemInfo == null) + LoadSystemInformation(); + } + } + + private async void LoadSystemInformation() + { + if (SystemInfo == null) + { + try + { + FetchingSystemInfo = true; + SystemInfo = await SystemInfoProvider.GetSystemInformationPackage(); + SelectedSystemObjectCollection = SystemInfo.System.FirstOrDefault(); + } + catch (Exception ex) + { + FetchingSystemInfo = false; + LogManager.Log(ex, "Error retrieving system information from remote machine."); + await NotificationProvider.ShowWarning("Error retrieving the remote machine tablet system information."); + } + finally { - try - { - FetchingSystemInfo = true; - SystemInfo = await SystemInfoProvider.GetSystemInformationPackage(); - SelectedSystemObjectCollection = SystemInfo.System.FirstOrDefault(); - } - catch (Exception ex) - { - FetchingSystemInfo = false; - LogManager.Log(ex, "Error retrieving system information from remote machine."); - await NotificationProvider.ShowWarning("Error retrieving the remote machine tablet system information."); - } - finally - { - FetchingSystemInfo = false; - } + FetchingSystemInfo = false; } } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/FileSystemView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/FileSystemView.xaml index fc23ca42c..ecc344324 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/FileSystemView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/FileSystemView.xaml @@ -45,39 +45,41 @@ - - - - - - - - - - - + + + + + + + + + + + + + - + - + @@ -94,20 +96,24 @@ Devices - Local Disk 1 - Local Disk 2 + + + + + + + Computer - Desktop - Downloads - Documents - Tango + Desktop + Documents + Application Data - + - + diff --git a/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs b/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs index f0b86becf..44c8f1901 100644 --- a/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs +++ b/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Tango.FileSystem.Network; @@ -41,6 +42,21 @@ namespace Tango.FileSystem return GetRoot(); } + try + { + if (request.Path.Count(x => x == '%') == 2) + { + var variable = Regex.Match(request.Path, "(?<=%)(.*?)(?=%)").Value; + request.Path = request.Path.Replace($"%{variable}%", Environment.ExpandEnvironmentVariables($"%{variable}%")); + } + } + catch + { + throw new ArgumentException("Could not parse environment variable."); + } + + request.Path = Path.GetFullPath(request.Path); + if (!Directory.Exists(request.Path)) { throw new DirectoryNotFoundException("The specified directory could not be located."); -- cgit v1.3.1