diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-22 16:30:00 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-22 16:30:00 +0300 |
| commit | 86339c9b8e383b92e183ee443c5bfbebd05808e7 (patch) | |
| tree | 02e781b86e30d7615c657819ae8e1e98d6abfae8 /Software/Visual_Studio | |
| parent | 072ee0c67a5c9c45be60fa3da915a493731e5b35 (diff) | |
| download | Tango-86339c9b8e383b92e183ee443c5bfbebd05808e7.tar.gz Tango-86339c9b8e383b92e183ee443c5bfbebd05808e7.zip | |
ColorLab Module seems to be working ok...
Diffstat (limited to 'Software/Visual_Studio')
5 files changed, 127 insertions, 87 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs index 5b317e6d2..3764e00de 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs @@ -243,15 +243,10 @@ namespace Tango.MachineStudio.ColorLab.ViewModels { _notification = notification; - _dbContext = ObservablesContext.CreateDefault(); - CCT = new Cct(); SourceColor = new RgbVM(); SourceColor.ColorChanged += SourceColor_ColorChanged; - Machines = _dbContext.Machines.ToObservableCollection(); - ColorSpaces = _dbContext.ColorSpaces.ToObservableCollection(); - Rmls = _dbContext.Rmls.ToObservableCollection(); ImportForwardDataCommand = new RelayCommand(ImportForwardData, () => SelectedRML != null); ImportInverseDataCommand = new RelayCommand(ImportInverseData, () => SelectedRML != null); @@ -267,6 +262,21 @@ namespace Tango.MachineStudio.ColorLab.ViewModels GetHiveSuggestions(); } + public override void OnApplicationReady() + { + base.OnApplicationReady(); + + Task.Factory.StartNew(() => + { + _dbContext = ObservablesContext.CreateDefault(); + _dbContext.Configuration.LazyLoadingEnabled = false; + + Machines = _dbContext.Machines.ToObservableCollection(); + ColorSpaces = _dbContext.ColorSpaces.ToObservableCollection(); + Rmls = _dbContext.Rmls.ToObservableCollection(); + }); + } + #region ColorLab private void GetHiveSuggestions() @@ -417,6 +427,8 @@ namespace Tango.MachineStudio.ColorLab.ViewModels { if (SelectedMachine != null) { + _dbContext.GetConfiguration(x => x.Guid == SelectedMachine.ConfigurationGuid); + LiquidVolumes = SelectedMachine.Configuration.NoneEmptyIdsPacks.OrderBy(x => x.PackIndex).Select(x => new LiquidVolumeVM() { Color = x.LiquidType.Color, @@ -424,6 +436,9 @@ namespace Tango.MachineStudio.ColorLab.ViewModels IdsPack = x, }).ToObservableCollection(); + + LiquidVolumes.EnableCrossThreadOperations(); + LiquidVolumes.ToList().ForEach(x => x.VolumeChanged += (s, e) => OnLiquidVolumeChanged()); InvalidateLiquidFactorsCalibrationData(); @@ -515,42 +530,57 @@ namespace Tango.MachineStudio.ColorLab.ViewModels #region RML - private void InvalidateLiquidFactorsCalibrationData() + private async void InvalidateLiquidFactorsCalibrationData() { if (SelectedRML != null && SelectedMachine != null) { - LiquidTypesRmls = SelectedMachine.Configuration.NoneEmptyIdsPacks.OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == SelectedRML.Guid).ToList(); - //RmlProcessParametersTableGroup = SelectedRML.ProcessParametersTablesGroups.ToList().SingleOrDefault(x => x.Active); + await Task.Factory.StartNew(() => + { + using (_notification.PushTaskItem("Loading RML data...")) + { + _dbContext.GetConfiguration(x => x.Guid == SelectedMachine.ConfigurationGuid); + _dbContext.GetRmlCCTs(SelectedRML.Guid); + _dbContext.GetRmlCATs(SelectedRML.Guid, SelectedMachine.Guid); + _dbContext.GetRmlLiquidTypes(SelectedRML.Guid); - LiquidsCalibrationData = new ObservableCollection<CalibrationDataVM>(); + LiquidTypesRmls = SelectedMachine.Configuration.NoneEmptyIdsPacks.OrderBy(x => x.PackIndex).Select(x => x.LiquidType).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == SelectedRML.Guid).ToList(); + //RmlProcessParametersTableGroup = SelectedRML.ProcessParametersTablesGroups.ToList().SingleOrDefault(x => x.Active); - foreach (var idsPack in SelectedMachine.Configuration.NoneEmptyIdsPacks.OrderBy(x => x.PackIndex)) - { - CalibrationDataVM vm = new CalibrationDataVM(); - vm.Name = idsPack.LiquidType.Name; - vm.Color = idsPack.LiquidType.Color; - vm.IdsPack = idsPack; + LiquidsCalibrationData = new ObservableCollection<CalibrationDataVM>(); + LiquidsCalibrationData.EnableCrossThreadOperations(); - var cat = idsPack.LiquidType.Cats.FirstOrDefault(x => x.Machine == SelectedMachine && x.Rml == SelectedRML); + foreach (var idsPack in SelectedMachine.Configuration.NoneEmptyIdsPacks.OrderBy(x => x.PackIndex)) + { + CalibrationDataVM vm = new CalibrationDataVM(); + vm.Name = idsPack.LiquidType.Name; + vm.Color = idsPack.LiquidType.Color; + vm.IdsPack = idsPack; - if (cat != null) - { - var calData = cat.GetCalibrationData(); - vm.CalibrationPoints = calData.CalibrationPoints.Select(x => new CalibrationDataPointVM(x.X, x.Y)).ToObservableCollection(); - } + var cat = idsPack.LiquidType.Cats.FirstOrDefault(x => x.Machine == SelectedMachine && x.Rml == SelectedRML); - LiquidsCalibrationData.Add(vm); - } + if (cat != null) + { + var calData = cat.GetCalibrationData(); + vm.CalibrationPoints = calData.CalibrationPoints.Select(x => new CalibrationDataPointVM(x.X, x.Y)).ToObservableCollection(); + } - _isNewCCT = false; - CCT = SelectedRML.Ccts.FirstOrDefault(); + InvokeUINow(() => + { + LiquidsCalibrationData.Add(vm); + }); + } - if (CCT == null) - { - CCT = new Cct(); - CCT.Rml = SelectedRML; - _isNewCCT = true; - } + _isNewCCT = false; + CCT = SelectedRML.Ccts.FirstOrDefault(); + + if (CCT == null) + { + CCT = new Cct(); + CCT.Rml = SelectedRML; + _isNewCCT = true; + } + } + }); } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index eaa63ada8..fe585c39d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -400,6 +400,10 @@ <Project>{74e700b0-1156-4126-be40-ee450d3c3026}</Project> <Name>Tango.Transport</Name> </ProjectReference> + <ProjectReference Include="..\Modules\Tango.MachineStudio.ColorLab\Tango.MachineStudio.ColorLab.csproj"> + <Project>{4d183aca-552b-4135-ae81-7c5a8e5fc3b1}</Project> + <Name>Tango.MachineStudio.ColorLab</Name> + </ProjectReference> <ProjectReference Include="..\Modules\Tango.MachineStudio.DataCapture\Tango.MachineStudio.DataCapture.csproj"> <Project>{fc337a7f-1214-41d8-9992-78092a3b961e}</Project> <Name>Tango.MachineStudio.DataCapture</Name> diff --git a/Software/Visual_Studio/Tango.BL/ObservablesContextExtension.cs b/Software/Visual_Studio/Tango.BL/ObservablesContextExtension.cs index 04967734a..8d3389d32 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesContextExtension.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesContextExtension.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Data.Entity; using System.Data.Entity.Infrastructure; using System.Data.SQLite; @@ -169,14 +170,16 @@ namespace Tango.BL /// <returns></returns> public Configuration GetConfiguration(Expression<Func<Configuration, bool>> condition) { - return Configurations.Where(condition) - .Include(x => x.IdsPacks) - .Include(x => x.IdsPacks.Select(y => y.LiquidType)) - .Include(x => x.IdsPacks.Select(y => y.DispenserType)) - .Include(x => x.IdsPacks.Select(y => y.CartridgeType)) - .Include(x => x.IdsPacks.Select(y => y.DispenserType)) - .Include(x => x.IdsPacks.Select(y => y.IdsPackFormula)) - .SingleOrDefault(condition); + var config = Configurations.SingleOrDefault(condition); + + config.IdsPacks = IdsPacks.Where(x => x.ConfigurationGuid == config.Guid) + .Include(x => x.LiquidType) + .Include(x => x.DispenserType) + .Include(x => x.CartridgeType) + .Include(x => x.DispenserType) + .Include(x => x.IdsPackFormula).OrderBy(x => x.PackIndex).ToObservableCollection(); + + return config; } public HardwareVersion GetHardwareVersion(Expression<Func<HardwareVersion, bool>> condition) @@ -192,31 +195,6 @@ namespace Tango.BL version.HardwareWinders = HardwareWinders.Where(x => x.HardwareVersionGuid == version.Guid).Include(x => x.HardwareWinderType).ToList().OrderBy(x => x.HardwareWinderType.Code).ToObservableCollection(); return version; - - //return HardwareVersions.Where(condition) - - // .Include(x => x.HardwareBlowers.OrderBy(s => s.HardwareBlowerType.Code)) - // .Include(x => x.HardwareBlowers.Select(y => y.HardwareBlowerType)) - - // .Include(x => x.HardwareBreakSensors) - // .Include(x => x.HardwareBreakSensors.Select(y => y.HardwareBreakSensorType)) - - // .Include(x => x.HardwareDancers) - // .Include(x => x.HardwareDancers.Select(y => y.HardwareDancerType)) - - // .Include(x => x.HardwareMotors) - // .Include(x => x.HardwareMotors.Select(y => y.HardwareMotorType)) - - // .Include(x => x.HardwarePidControls) - // .Include(x => x.HardwarePidControls.Select(y => y.HardwarePidControlType)) - - // .Include(x => x.HardwareSpeedSensors) - // .Include(x => x.HardwareSpeedSensors.Select(y => y.HardwareSpeedSensorType)) - - // .Include(x => x.HardwareWinders) - // .Include(x => x.HardwareWinders.Select(y => y.HardwareWinderType)) - - // .SingleOrDefault(condition); } public HardwareVersion GetHardwareVersionByMachine(String machineGuid) @@ -230,6 +208,21 @@ namespace Tango.BL return ProcessParametersTablesGroups.Where(x => x.RmlGuid == rmlGuid && x.Active).Include(x => x.ProcessParametersTables).FirstOrDefault(); } + public ObservableCollection<Cct> GetRmlCCTs(String rmlGuid) + { + return Ccts.Where(x => x.RmlGuid == rmlGuid).ToObservableCollection(); + } + + public ObservableCollection<Cat> GetRmlCATs(String rmlGuid, String machineGuid) + { + return Cats.Where(x => x.MachineGuid == machineGuid && x.RmlGuid == rmlGuid).ToObservableCollection(); + } + + public ObservableCollection<LiquidTypesRml> GetRmlLiquidTypes(String rmlGuid) + { + return LiquidTypesRmls.Where(x => x.RmlGuid == rmlGuid).ToObservableCollection(); + } + #endregion } } diff --git a/Software/Visual_Studio/Tango.PMR/NativePMR.cs b/Software/Visual_Studio/Tango.PMR/NativePMR.cs index 1b56f12dc..14e740656 100644 --- a/Software/Visual_Studio/Tango.PMR/NativePMR.cs +++ b/Software/Visual_Studio/Tango.PMR/NativePMR.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Runtime.InteropServices; +using System.Runtime.ExceptionServices; namespace Tango.PMR { @@ -41,41 +42,49 @@ namespace Tango.PMR /// <param name="request">The request.</param> /// <param name="nativeMethod">The native method.</param> /// <returns></returns> + [HandleProcessCorruptedStateExceptions] public Response Invoke(Request request) { - //Serialize the request to byte array. - byte[] messageData = request.ToByteArray(); + try + { + //Serialize the request to byte array. + byte[] messageData = request.ToByteArray(); - //Allocate unmanaged array on memory. - IntPtr unmanagedArr = Marshal.AllocHGlobal(messageData.Length); + //Allocate unmanaged array on memory. + IntPtr unmanagedArr = Marshal.AllocHGlobal(messageData.Length); - //Copy the request data to the unmanaged array. - Marshal.Copy(messageData, 0, unmanagedArr, messageData.Length); + //Copy the request data to the unmanaged array. + Marshal.Copy(messageData, 0, unmanagedArr, messageData.Length); - //Initialize pointer for pointing to the result array. - IntPtr output = IntPtr.Zero; + //Initialize pointer for pointing to the result array. + IntPtr output = IntPtr.Zero; - //Invoke the native method. - int size = _nativeMethod(unmanagedArr, messageData.Length, ref output); + //Invoke the native method. + int size = _nativeMethod(unmanagedArr, messageData.Length, ref output); - if (size == 0) return null; + if (size == 0) return null; - //Initialize a new byte array for holding the native result. - byte[] responseData = new byte[size]; + //Initialize a new byte array for holding the native result. + byte[] responseData = new byte[size]; - //Copy the unmanaged byte array result to the managed result array. - Marshal.Copy(output, responseData, 0, size); + //Copy the unmanaged byte array result to the managed result array. + Marshal.Copy(output, responseData, 0, size); - //Generate response parser. - MessageParser<Response> parser = new MessageParser<Response>(() => Activator.CreateInstance<Response>()); + //Generate response parser. + MessageParser<Response> parser = new MessageParser<Response>(() => Activator.CreateInstance<Response>()); - //Parse the response - Response response = parser.ParseFrom(responseData); + //Parse the response + Response response = parser.ParseFrom(responseData); - //Free unmanaged memory. - Marshal.FreeHGlobal(unmanagedArr); + //Free unmanaged memory. + Marshal.FreeHGlobal(unmanagedArr); - return response; + return response; + } + catch (Exception) + { + throw; + } } } } diff --git a/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Tango.PMRGenerator.CLI.csproj b/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Tango.PMRGenerator.CLI.csproj index 7026fe389..cdc486130 100644 --- a/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Tango.PMRGenerator.CLI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Tango.PMRGenerator.CLI.csproj @@ -72,11 +72,15 @@ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.Protobuf\Tango.Protobuf.csproj"> + <Project>{40073806-914e-4e78-97ab-fa9639308ebe}</Project> + <Name>Tango.Protobuf</Name> + </ProjectReference> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file |
