aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2020-08-30 10:54:09 +0300
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2020-08-30 10:54:09 +0300
commit8e2e60ef069776aa6c3aab6a12e03ba1b228eea0 (patch)
tree31e7c9a2b26987a792d7e8fb2246da741a5e00bc /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels
parent47ab5344d38f85eceeb7a80dbb64ef9ed5de974b (diff)
downloadTango-8e2e60ef069776aa6c3aab6a12e03ba1b228eea0.tar.gz
Tango-8e2e60ef069776aa6c3aab6a12e03ba1b228eea0.zip
Color Calibrations. Applied buttons to import data from file and save data in to the current RML calibration tables.
Added shadow effect to popup search combobox.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/CalibrationDataViewVM.cs10
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs44
2 files changed, 53 insertions, 1 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/CalibrationDataViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/CalibrationDataViewVM.cs
index b34ef83bc..fd69fef35 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/CalibrationDataViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/CalibrationDataViewVM.cs
@@ -6,6 +6,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL.Calibration;
+using Tango.BL.Entities;
using Tango.Core.Commands;
using Tango.MachineStudio.Common;
using Tango.MachineStudio.Common.Notifications;
@@ -106,5 +107,14 @@ namespace Tango.MachineStudio.RML.ViewModels
_notification.ShowError("An error occurred while trying to export the calibration data.");
}
}
+
+ public void ApplyCalibrationData(LiquidType liquidType, List<CalibrationDataPointVM> newpoints)
+ {
+ CalibrationDataVM vm = LiquidsCalibrationData.FirstOrDefault(x => x.LiquidType == liquidType);
+ if(vm != null)
+ {
+ newpoints.ForEach(x => vm.CalibrationPoints.Add(x));
+ }
+ }
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs
index 4a6895df3..f7e93a4e6 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs
@@ -89,10 +89,12 @@ namespace Tango.MachineStudio.RML.ViewModels
get { return _hasError; }
set { _hasError = value; RaisePropertyChangedAuto(); }
}
-
+
+ public RelayCommand ImportDataCommand { get; set; }
public RelayCommand CreateGraphCommand { get; set; }
public RelayCommand CreateLinearizationGraphCommand { get; set; }
public RelayCommand ExportGraphCommand { get; set; }
+ public RelayCommand ApplyCalibrationDataCommand { get; set; }
public string LiquidTypeName
@@ -189,9 +191,11 @@ namespace Tango.MachineStudio.RML.ViewModels
};
Factor = 0;
HasError = false;
+ ImportDataCommand = new RelayCommand(ImportDataForCalcFactorExcel);
CreateGraphCommand = new RelayCommand(CreateGraph);
CreateLinearizationGraphCommand = new RelayCommand(CreateLinearizationGraph);
ExportGraphCommand = new RelayCommand(ExportGraph);
+ ApplyCalibrationDataCommand = new RelayCommand(ApplyCalibrationData);
this.Points = new List<DataPoint>();
TargetPoints = new List<DataPoint>();
LinearizationPoints = new List<DataPoint>();
@@ -236,7 +240,32 @@ namespace Tango.MachineStudio.RML.ViewModels
}
return 0.0;
}
+
+ private void ImportDataForCalcFactorExcel()
+ {
+ OpenFileDialog dlg = new OpenFileDialog();
+ try
+ {
+ dlg.Title = $"Import excel file for calculate Factor";
+ dlg.Filter = "Excel Files|*.xlsx";
+ if (dlg.ShowDialog().Value)
+ {
+ List<ColorLinearizationModel.LinearizationDataItem> items;//List<LinearizationDataItem> items
+ ColorLinearizationModel model = new ColorLinearizationModel();
+ model.GetDataFromFile(dlg.FileName, out items);
+ if (items.Count == 0)
+ return;
+ Measurements.Clear();
+ items.ForEach(x => Measurements.Add(new CalibrationMeasurementModel(x)));
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error importing excel file " + dlg.FileName);
+ _notification.ShowError("An error occurred while trying to import the selected excel file. Please check the file format if valid and is available to read.");
+ }
+ }
#region CreateGraph
private async void CreateGraph(object obj)
@@ -420,6 +449,19 @@ namespace Tango.MachineStudio.RML.ViewModels
Y = point.Y,
};
}
+
+ /// <summary>
+ /// Applies the calibration data.
+ /// </summary>
+ protected void ApplyCalibrationData()
+ {
+ if (LinearizationPoints.Count == 0)
+ return;
+
+ List<CalibrationDataPointVM> points = new List<CalibrationDataPointVM>();
+ LinearizationPoints.ToList().ForEach(x => points.Add(new CalibrationDataPointVM(x.X, x.Y)));
+ ViewModelLocator.MainViewVM.CalibrationDataViewVM.ApplyCalibrationData(LiquidType, points);
+ }
#endregion
}
}