From 0bf4df21349aa175405ad3b462d466a72363dee4 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 14 Aug 2018 13:11:32 +0300 Subject: Reorganization of solution build paths ! Optimized production packages. --- .../Tango.MachineStudio.Developer.csproj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index c361a584d..bd7484de8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -17,7 +17,7 @@ true full false - ..\..\..\Build\Debug\ + ..\..\..\Build\Machine Studio\Debug\ DEBUG;TRACE prompt 4 @@ -25,7 +25,7 @@ pdbonly true - ..\..\..\Build\Release\ + ..\..\..\Build\Machine Studio\Release\ TRACE prompt 4 @@ -188,10 +188,6 @@ - - {bdbbe284-f564-4f51-af41-3df0434cec62} - Tango.EmbroideryUI - {37e4ceab-b54b-451f-b535-04cf7da9c459} ColorMine @@ -224,6 +220,10 @@ {b112d89a-a106-41ae-a0c1-4abc84c477f5} Tango.DragAndDrop + + {bdbbe284-f564-4f51-af41-3df0434cec62} + Tango.EmbroideryUI + {942134ac-6ea2-4500-8f22-0f739b70a05f} Tango.Hive -- cgit v1.3.1 From 84a8a6924abb7f78191d6f0d2290b55832c456ae Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 14 Aug 2018 15:05:17 +0300 Subject: Implemented color conversion error messages ! Implemented unified printing manager on PPC. Refactored job statuses and categories to DRAFT, COMPLETED, DISRUPTED. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 15400960 -> 15400960 bytes .../PMR/Messages/ColorLab/ConversionOutput.proto | 2 + .../ViewModels/MainViewVM.cs | 1 + .../Native/Tango.ColorLib/ColorConverter.cpp | 387 +++++++++++---------- .../PMR/ColorLab/ConversionOutput.pb-c.c | 32 +- .../PMR/ColorLab/ConversionOutput.pb-c.h | 5 +- .../Native/Tango.ColorLib/Tango.ColorLib.vcxproj | 2 +- .../Dialogs/FineTuningPaletteViewVM.cs | 2 +- .../Tango.PPC.Jobs/Messages/JobRemovedMessage.cs | 20 -- .../Tango.PPC.Jobs/Messages/JobSavedMessage.cs | 20 -- .../Tango.PPC.Jobs/Messages/JobSelectedMessage.cs | 6 + .../Modules/Tango.PPC.Jobs/Models/FineTuneItem.cs | 95 ----- .../Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj | 3 - .../Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs | 7 +- .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 81 +---- .../Tango.PPC.Jobs/ViewModels/JobsViewVM.cs | 10 +- .../Tango.PPC.Common/Messages/JobRemovedMessage.cs | 20 ++ .../Tango.PPC.Common/Messages/JobSavedMessage.cs | 20 ++ .../PPC/Tango.PPC.Common/Models/FineTuneItem.cs | 95 +++++ .../PPC/Tango.PPC.Common/PPCViewModel.cs | 7 + .../Tango.PPC.Common/Printing/IPrintingManager.cs | 21 ++ .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 4 + .../PPC/Tango.PPC.Publisher/MainWindowVM.cs | 2 +- .../Printing/DefaultPrintingManager.cs | 163 +++++++++ .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 1 + .../PPC/Tango.PPC.UI/ViewModelLocator.cs | 5 + .../ColorConversion/TangoColorConverter.cs | 18 + .../Tango.BL/Enumerations/JobCategories.cs | 12 +- .../Tango.BL/Enumerations/JobStatuses.cs | 27 +- .../Tango.PMR/ColorLab/ConversionOutput.cs | 65 +++- 31 files changed, 693 insertions(+), 440 deletions(-) delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Messages/JobRemovedMessage.cs delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Messages/JobSavedMessage.cs delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Models/FineTuneItem.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Messages/JobRemovedMessage.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Messages/JobSavedMessage.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Models/FineTuneItem.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Printing/IPrintingManager.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 3883dd3df..0be098ac7 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 17c39c511..0053ea2da 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/PMR/Messages/ColorLab/ConversionOutput.proto b/Software/PMR/Messages/ColorLab/ConversionOutput.proto index 9d53f28ba..4192addf1 100644 --- a/Software/PMR/Messages/ColorLab/ConversionOutput.proto +++ b/Software/PMR/Messages/ColorLab/ConversionOutput.proto @@ -11,4 +11,6 @@ message ConversionOutput repeated OutputCoordinates TripleCoordinates = 2; OutputCoordinates SingleCoordinates = 3; bool OutOfGamut = 5; + bool HasError = 6; + string ErrorMessage = 7; } \ No newline at end of file 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 f54de0814..dace2ceac 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 @@ -738,6 +738,7 @@ namespace Tango.MachineStudio.Developer.ViewModels try { var output = TangoColorConverter.GetSuggestions(stop); + stop.Red = output.SingleCoordinates.Red; stop.Green = output.SingleCoordinates.Green; stop.Blue = output.SingleCoordinates.Blue; diff --git a/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.cpp b/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.cpp index 2b8131657..48cb9f3df 100644 --- a/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.cpp +++ b/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.cpp @@ -103,17 +103,17 @@ void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(VectorXd Lab, VectorX for (int i = 0; i < 6; ++i) { Jab1(i, 0) = Jab(0); - Jab1(i, 1) = Jab(1) + dC*cos(hue + i*dH6); - Jab1(i, 2) = Jab(2) + dC*sin(hue + i*dH6); + Jab1(i, 1) = Jab(1) + dC * cos(hue + i * dH6); + Jab1(i, 2) = Jab(2) + dC * sin(hue + i * dH6); } int j1 = 0, j2 = 0; - double dC2 = dC*2.0; + double dC2 = dC * 2.0; for (int i = 0; i < 12; ++i) { j1 = i + 6; Jab1(j1, 0) = Jab(0); - Jab1(j1, 1) = Jab(1) + dC2*cos(hue + i*dH12); - Jab1(j1, 2) = Jab(2) + dC2*sin(hue + i*dH12); + Jab1(j1, 1) = Jab(1) + dC2 * cos(hue + i * dH12); + Jab1(j1, 2) = Jab(2) + dC2 * sin(hue + i * dH12); } /* for (int i = 0; i < 2; ++i) { @@ -223,7 +223,7 @@ void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(VectorXd Lab, VectorX void Tango::ColorLib::ColorConverter::FindTriplet(VectorXd Lab, MatrixXd Lab1, int nHive, int*indDataMax) { - int vecSize = nHive*(nHive - 1) / 2; + int vecSize = nHive * (nHive - 1) / 2; double *dECMC = new double[vecSize]; int **indexpairs = new int*[vecSize]; int ind = -1; @@ -875,7 +875,7 @@ void Tango::ColorLib::ColorConverter::VolumeToNLInkP(VectorXd Volume, VectorXd & //Solve System of Linear Equations MatrixXd MatNLIInv(m_nVolumes - 1, m_nVolumes - 1); MatNLIInv = MatNLI.inverse(); - VectorXd Result = MatNLIInv*RHSide; + VectorXd Result = MatNLIInv * RHSide; //VectorXd Result = MatNLI.colPivHouseholderQr().solve(RHSide); //rearrange solution ind = -1; @@ -909,7 +909,7 @@ void Tango::ColorLib::ColorConverter::NLInkPToVolume(VectorXd NLInk, VectorXd &V else for (i = 0; i < m_nInks; ++i) { - InkNorm(i) = MaxInk*NLInk(i) / InkSum; + InkNorm(i) = MaxInk * NLInk(i) / InkSum; Volume(i) = InkNorm(i) * m_maxNlPerCM(i) / 100; } return; @@ -1028,205 +1028,226 @@ VectorXd Tango::ColorLib::ColorConverter::DoubleToVector(double *doub, int nSize size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t input_buffer_size, uint8_t *& output_buffer) { - //Get Input - ConversionInput* conversionInput = (ConversionInput*)malloc(sizeof(ConversionInput)); + try + { + //Get Input + ConversionInput* conversionInput = (ConversionInput*)malloc(sizeof(ConversionInput)); - conversionInput = conversion_input__unpack(NULL, input_buffer_size, input_buffer); + conversionInput = conversion_input__unpack(NULL, input_buffer_size, input_buffer); - //Filter and arrange colors (Should change from 3 to 4 if black ink is included) - int expected_liquids = 3; - int original_input_liquids_count = conversionInput->inputcoordinates->n_inputliquids; - InputLiquid** original_input_liquids = conversionInput->inputcoordinates->inputliquids; + //Filter and arrange colors (Should change from 3 to 4 if black ink is included) + int expected_liquids = 3; + int original_input_liquids_count = conversionInput->inputcoordinates->n_inputliquids; + InputLiquid** original_input_liquids = conversionInput->inputcoordinates->inputliquids; - InputLiquid** filteredInputLiquids = (InputLiquid**)malloc(sizeof(InputLiquid*) * expected_liquids); + InputLiquid** filteredInputLiquids = (InputLiquid**)malloc(sizeof(InputLiquid*) * expected_liquids); - for (size_t i = 0; i < conversionInput->inputcoordinates->n_inputliquids; i++) - { - InputLiquid* liquid = conversionInput->inputcoordinates->inputliquids[i]; + for (size_t i = 0; i < conversionInput->inputcoordinates->n_inputliquids; i++) + { + InputLiquid* liquid = conversionInput->inputcoordinates->inputliquids[i]; - switch (liquid->liquidtype) + switch (liquid->liquidtype) + { + case LIQUID_TYPE__Cyan: + filteredInputLiquids[0] = liquid; + break; + case LIQUID_TYPE__Magenta: + filteredInputLiquids[1] = liquid; + break; + case LIQUID_TYPE__Yellow: + filteredInputLiquids[2] = liquid; + break; + } + } + + conversionInput->inputcoordinates->inputliquids = filteredInputLiquids; + conversionInput->inputcoordinates->n_inputliquids = expected_liquids; + //Filter and arrange colors + + + + //Initialize Output... + ConversionOutput *conversionOutput = (ConversionOutput*)malloc(sizeof(ConversionOutput)); + conversion_output__init(conversionOutput); + // ConversionOutput conversionOutput = CONVERSION_OUTPUT__INIT; + + + size_t n_elements = 0; + bool InGamut = false; + m_WP.Set(0.9505, 1.00, 1.0888); //D65 + //count number if inks + int numofInks = CountNumberofInks(conversionInput); + readColorTransformations(conversionInput); + + //Initialize CIECAM02 transformation + Illum IL = D65; + SURROUND sur = average; + CAM02CS CS = UCS; + m_Conv02 = new ColorConvert(IL, IL, Y_b, L_A, sur, CS); + + SetnA2BnSepIn(m_A2BTransform->GetSeparationsIn()); + SetnA2BnSepOut(m_A2BTransform->GetSeparationsOut()); + SetnB2AnSepIn(m_B2ATransform->GetSeparationsIn()); + SetnB2AnSepOut(m_B2ATransform->GetSeparationsOut()); + SetNumberOfInks(m_nB2AnSepOut); + // Compare Strip White point to Color Table White Point + CompareWhitePoints(); + + readCalibrationTables(conversionInput); + if (numofInks != m_nB2AnSepOut) + throw std::exception("Number of available inks does not match ink tables"); + + VectorXd InkOut(m_nB2AnSepOut); + VectorXd RGBOut(3); + VectorXd LabOut(3); + VectorXd NLInkOut(m_nB2AnSepOut); + VectorXd Volume(m_nB2AnSepOut); + //set maxNlPerCM + VectorXd NlperCM(m_nB2AnSepOut); + NlperCM.setZero(); + m_maxNlPerCM = NlperCM; + for (int i = 0; i < m_nB2AnSepOut; ++i) + SetMaxNLperCM(conversionInput->inputcoordinates->inputliquids[i]->maxnanoliterpercentimeter, i); + m_nVolumes = m_nB2AnSepOut; + int GamutRegion = 0; + //Convert input data to linear inks + if (conversionInput->colorspace == COLOR_SPACE__Volume) { - case LIQUID_TYPE__Cyan: - filteredInputLiquids[0] = liquid; - break; - case LIQUID_TYPE__Magenta: - filteredInputLiquids[1] = liquid; - break; - case LIQUID_TYPE__Yellow: - filteredInputLiquids[2] = liquid; - break; + ConvertVolumeToRGBDisplay(conversionInput, Volume, RGBOut, LabOut, GamutRegion); + InGamut = true; + } + else + { + ConvertColorToLinearInks(conversionInput, InkOut, RGBOut, LabOut, GamutRegion, InGamut); + //Convert to Nonlinear Inks + ConvertToNLInks(InkOut, NLInkOut); + //Convert to [nl/cm] + NLInkPToVolume(NLInkOut, Volume); + //OutputCoordinates outputCoords = OUTPUT_COORDINATES__INIT; + } + OutputCoordinates *outputCoords = (OutputCoordinates*)malloc(sizeof(OutputCoordinates)); + output_coordinates__init(outputCoords); + fillRGB(outputCoords, RGBOut); + fillVolume(outputCoords, Volume); + conversionOutput->has_outofgamut = true; + conversionOutput->outofgamut = !(InGamut); + conversionOutput->singlecoordinates = outputCoords; + + + //input was processed. + //process neighboring values + //nHive includes 2 outer neighbors og the central Lab value, chroma + delta, chroma + 2delta + // and variation in L positioned on the side of the beehive. + //The set is arrange in a 5x6 matrix, where the 5x5 contains the variation in (Hue, chroma) + // and the last 5 contain the variation in L + int nHive = 18; //22; // 18; + int MatHive = 25;// 30; //25; + + MatrixXd RGBHive(MatHive, 3); + VectorXd RGBHive1(3); + VectorXd VolumeHive1(3); + MatrixXd VolumeHive(MatHive, m_nVolumes); + int *GamutRegionV = new int[MatHive]; + for (int i = 0; i < MatHive + 1; ++i) + GamutRegionV[i] = -1; + + int indDataMax[2]; + int j = 0; + // Matrix values are initially set to -1; + RGBHive.setConstant(NegValue); + VolumeHive.setConstant(NegValue); + + ProcessHiveNeighbors(LabOut, RGBOut, Volume, GamutRegion, RGBHive, VolumeHive, nHive, GamutRegionV, indDataMax); + OutputCoordinates** hiveData = (OutputCoordinates**)malloc(sizeof(OutputCoordinates*) * MatHive); + conversionOutput->hivecoordinates = hiveData; + conversionOutput->n_hivecoordinates = MatHive; + conversionOutput->n_triplecoordinates = 3; + for (int i = 0; i < MatHive; i++) + { + // OutputCoordinates SingleCell = OUTPUT_COORDINATES__INIT; + hiveData[i] = (OutputCoordinates*)malloc(sizeof(OutputCoordinates)); + output_coordinates__init(hiveData[i]); + if (RGBHive(i, 0) != NegValue) + { + for (j = 0; j < 3; ++j) + RGBHive1(j) = RGBHive(i, j); + fillRGB(hiveData[i], RGBHive1); + for (j = 0; j < 3; ++j) + VolumeHive1(j) = VolumeHive(i, j); + fillVolume(hiveData[i], VolumeHive1); + hiveData[i]->has_processparameterstableindex = true; + hiveData[i]->processparameterstableindex = GamutRegionV[i]; + hiveData[i]->n_outputliquids = m_nInks; + } + conversionOutput->hivecoordinates[i] = hiveData[i]; } - } - conversionInput->inputcoordinates->inputliquids = filteredInputLiquids; - conversionInput->inputcoordinates->n_inputliquids = expected_liquids; - //Filter and arrange colors - - - - //Initialize Output... - ConversionOutput *conversionOutput = (ConversionOutput*)malloc(sizeof(ConversionOutput)); - conversion_output__init(conversionOutput); - // ConversionOutput conversionOutput = CONVERSION_OUTPUT__INIT; - - - size_t n_elements = 0; - bool InGamut = false; - m_WP.Set(0.9505, 1.00, 1.0888); //D65 - //count number if inks - int numofInks = CountNumberofInks(conversionInput); - readColorTransformations(conversionInput); - - //Initialize CIECAM02 transformation - Illum IL = D65; - SURROUND sur = average; - CAM02CS CS = UCS; - m_Conv02 = new ColorConvert(IL, IL, Y_b, L_A, sur, CS); - - SetnA2BnSepIn(m_A2BTransform->GetSeparationsIn()); - SetnA2BnSepOut(m_A2BTransform->GetSeparationsOut()); - SetnB2AnSepIn(m_B2ATransform->GetSeparationsIn()); - SetnB2AnSepOut(m_B2ATransform->GetSeparationsOut()); - SetNumberOfInks(m_nB2AnSepOut); - // Compare Strip White point to Color Table White Point - CompareWhitePoints(); - - readCalibrationTables(conversionInput); - if (numofInks != m_nB2AnSepOut) - throw std::exception("Number of available inks does not match ink tables"); - - VectorXd InkOut(m_nB2AnSepOut); - VectorXd RGBOut(3); - VectorXd LabOut(3); - VectorXd NLInkOut(m_nB2AnSepOut); - VectorXd Volume(m_nB2AnSepOut); - //set maxNlPerCM - VectorXd NlperCM(m_nB2AnSepOut); - NlperCM.setZero(); - m_maxNlPerCM = NlperCM; - for (int i = 0; i < m_nB2AnSepOut; ++i) - SetMaxNLperCM(conversionInput->inputcoordinates->inputliquids[i]->maxnanoliterpercentimeter, i); - m_nVolumes = m_nB2AnSepOut; - int GamutRegion = 0; - //Convert input data to linear inks - if (conversionInput->colorspace == COLOR_SPACE__Volume) - { - ConvertVolumeToRGBDisplay(conversionInput, Volume, RGBOut, LabOut, GamutRegion); - InGamut = true; - } - else - { - ConvertColorToLinearInks(conversionInput, InkOut, RGBOut, LabOut, GamutRegion, InGamut); - //Convert to Nonlinear Inks - ConvertToNLInks(InkOut, NLInkOut); - //Convert to [nl/cm] - NLInkPToVolume(NLInkOut, Volume); - //OutputCoordinates outputCoords = OUTPUT_COORDINATES__INIT; - } - OutputCoordinates *outputCoords = (OutputCoordinates*)malloc(sizeof(OutputCoordinates)); - output_coordinates__init(outputCoords); - fillRGB(outputCoords, RGBOut); - fillVolume(outputCoords, Volume); - conversionOutput->has_outofgamut = true; - conversionOutput->outofgamut = !(InGamut); - conversionOutput->singlecoordinates = outputCoords; - - - //input was processed. - //process neighboring values - //nHive includes 2 outer neighbors og the central Lab value, chroma + delta, chroma + 2delta - // and variation in L positioned on the side of the beehive. - //The set is arrange in a 5x6 matrix, where the 5x5 contains the variation in (Hue, chroma) - // and the last 5 contain the variation in L - int nHive = 18; //22; // 18; - int MatHive = 25;// 30; //25; - - MatrixXd RGBHive(MatHive, 3); - VectorXd RGBHive1(3); - VectorXd VolumeHive1(3); - MatrixXd VolumeHive(MatHive, m_nVolumes); - int *GamutRegionV = new int[MatHive]; - for (int i = 0; i < MatHive + 1; ++i) - GamutRegionV[i] = -1; - - int indDataMax[2]; - int j = 0; - // Matrix values are initially set to -1; - RGBHive.setConstant(NegValue); - VolumeHive.setConstant(NegValue); - - ProcessHiveNeighbors(LabOut, RGBOut, Volume, GamutRegion, RGBHive, VolumeHive, nHive, GamutRegionV, indDataMax); - OutputCoordinates** hiveData = (OutputCoordinates**)malloc(sizeof(OutputCoordinates*) * MatHive); - conversionOutput->hivecoordinates = hiveData; - conversionOutput->n_hivecoordinates = MatHive; - conversionOutput->n_triplecoordinates = 3; - for (int i = 0; i < MatHive; i++) - { - // OutputCoordinates SingleCell = OUTPUT_COORDINATES__INIT; - hiveData[i] = (OutputCoordinates*)malloc(sizeof(OutputCoordinates)); - output_coordinates__init(hiveData[i]); - if (RGBHive(i, 0) != NegValue) + + //Triplet + OutputCoordinates** TripletData = (OutputCoordinates**)malloc(sizeof(OutputCoordinates*) * 3); + conversionOutput->triplecoordinates = TripletData; + int tripletIndex[3] = { indDataMax[0] , (int)(12), indDataMax[1] }; + for (int i = 0; i < 3; ++i) { + // OutputCoordinates SingleCell = OUTPUT_COORDINATES__INIT; + TripletData[i] = (OutputCoordinates*)malloc(sizeof(OutputCoordinates)); + output_coordinates__init(TripletData[i]); for (j = 0; j < 3; ++j) - RGBHive1(j) = RGBHive(i, j); - fillRGB(hiveData[i], RGBHive1); + RGBHive1(j) = RGBHive(tripletIndex[i], j); + fillRGB(TripletData[i], RGBHive1); for (j = 0; j < 3; ++j) - VolumeHive1(j) = VolumeHive(i, j); - fillVolume(hiveData[i], VolumeHive1); - hiveData[i]->has_processparameterstableindex = true; - hiveData[i]->processparameterstableindex = GamutRegionV[i]; - hiveData[i]->n_outputliquids = m_nInks; + VolumeHive1(j) = VolumeHive(tripletIndex[i], j); + fillVolume(TripletData[i], VolumeHive1); + TripletData[i]->has_processparameterstableindex = true; + TripletData[i]->processparameterstableindex = GamutRegionV[tripletIndex[i]]; + TripletData[i]->n_outputliquids = m_nInks; + conversionOutput->triplecoordinates[i] = TripletData[i]; } - conversionOutput->hivecoordinates[i] = hiveData[i]; - } - - //Triplet - OutputCoordinates** TripletData = (OutputCoordinates**)malloc(sizeof(OutputCoordinates*) * 3); - conversionOutput->triplecoordinates = TripletData; - int tripletIndex[3] = { indDataMax[0] , (int)(12), indDataMax[1] }; - for (int i = 0; i < 3; ++i) - { - // OutputCoordinates SingleCell = OUTPUT_COORDINATES__INIT; - TripletData[i] = (OutputCoordinates*)malloc(sizeof(OutputCoordinates)); - output_coordinates__init(TripletData[i]); - for (j = 0; j < 3; ++j) - RGBHive1(j) = RGBHive(tripletIndex[i], j); - fillRGB(TripletData[i], RGBHive1); - for (j = 0; j < 3; ++j) - VolumeHive1(j) = VolumeHive(tripletIndex[i], j); - fillVolume(TripletData[i], VolumeHive1); - TripletData[i]->has_processparameterstableindex = true; - TripletData[i]->processparameterstableindex = GamutRegionV[tripletIndex[i]]; - TripletData[i]->n_outputliquids = m_nInks; - conversionOutput->triplecoordinates[i] = TripletData[i]; - } - - /* //Clean up - if (GamutRegionV != NULL) - { - delete GamutRegionV; - GamutRegionV = NULL; - } */ + /* //Clean up + if (GamutRegionV != NULL) + { + delete GamutRegionV; + GamutRegionV = NULL; + } */ - //Pack output... - output_buffer = (uint8_t*)malloc(conversion_output__get_packed_size(conversionOutput)); - int size = conversion_output__pack(conversionOutput, output_buffer); + //Pack output... + output_buffer = (uint8_t*)malloc(conversion_output__get_packed_size(conversionOutput)); + int size = conversion_output__pack(conversionOutput, output_buffer); #pragma region Free Conversion Input & Output - conversionInput->inputcoordinates->inputliquids = original_input_liquids; - conversionInput->inputcoordinates->n_inputliquids = original_input_liquids_count; + conversionInput->inputcoordinates->inputliquids = original_input_liquids; + conversionInput->inputcoordinates->n_inputliquids = original_input_liquids_count; - conversion_input__free_unpacked(conversionInput, NULL); + conversion_input__free_unpacked(conversionInput, NULL); - conversion_output__free_unpacked(conversionOutput, NULL); + conversion_output__free_unpacked(conversionOutput, NULL); #pragma endregion - return (size); + return (size); + } + catch (const std::exception& e) + { + //Notify Error... + ConversionOutput *conversionOutput = (ConversionOutput*)malloc(sizeof(ConversionOutput)); + conversion_output__init(conversionOutput); + + conversionOutput->has_haserror = true; + conversionOutput->haserror = true; + + const char* what = e.what(); + + conversionOutput->errormessage = (char*)malloc(strlen(what)); + strcpy(conversionOutput->errormessage, e.what()); + + output_buffer = (uint8_t*)malloc(conversion_output__get_packed_size(conversionOutput)); + int size = conversion_output__pack(conversionOutput, output_buffer); + return (size); + } } int Tango::ColorLib::ColorConverter::CountNumberofInks(ConversionInput* conversionInput) diff --git a/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ConversionOutput.pb-c.c b/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ConversionOutput.pb-c.c index bfc40f0a3..da44f28ac 100644 --- a/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ConversionOutput.pb-c.c +++ b/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ConversionOutput.pb-c.c @@ -52,7 +52,7 @@ void conversion_output__free_unpacked assert(message->base.descriptor == &conversion_output__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } -static const ProtobufCFieldDescriptor conversion_output__field_descriptors[4] = +static const ProtobufCFieldDescriptor conversion_output__field_descriptors[6] = { { "HiveCoordinates", @@ -102,8 +102,34 @@ static const ProtobufCFieldDescriptor conversion_output__field_descriptors[4] = 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, + { + "HasError", + 6, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_BOOL, + offsetof(ConversionOutput, has_haserror), + offsetof(ConversionOutput, haserror), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "ErrorMessage", + 7, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_STRING, + 0, /* quantifier_offset */ + offsetof(ConversionOutput, errormessage), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, }; static const unsigned conversion_output__field_indices_by_name[] = { + 5, /* field[5] = ErrorMessage */ + 4, /* field[4] = HasError */ 0, /* field[0] = HiveCoordinates */ 3, /* field[3] = OutOfGamut */ 2, /* field[2] = SingleCoordinates */ @@ -113,7 +139,7 @@ static const ProtobufCIntRange conversion_output__number_ranges[2 + 1] = { { 1, 0 }, { 5, 3 }, - { 0, 4 } + { 0, 6 } }; const ProtobufCMessageDescriptor conversion_output__descriptor = { @@ -123,7 +149,7 @@ const ProtobufCMessageDescriptor conversion_output__descriptor = "ConversionOutput", "", sizeof(ConversionOutput), - 4, + 6, conversion_output__field_descriptors, conversion_output__field_indices_by_name, 2, conversion_output__number_ranges, diff --git a/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ConversionOutput.pb-c.h b/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ConversionOutput.pb-c.h index 0c58721db..c85c11bd7 100644 --- a/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ConversionOutput.pb-c.h +++ b/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ConversionOutput.pb-c.h @@ -34,10 +34,13 @@ struct _ConversionOutput OutputCoordinates *singlecoordinates; protobuf_c_boolean has_outofgamut; protobuf_c_boolean outofgamut; + protobuf_c_boolean has_haserror; + protobuf_c_boolean haserror; + char *errormessage; }; #define CONVERSION_OUTPUT__INIT \ { PROTOBUF_C_MESSAGE_INIT (&conversion_output__descriptor) \ - , 0,NULL, 0,NULL, NULL, 0, 0 } + , 0,NULL, 0,NULL, NULL, 0, 0, 0, 0, NULL } /* ConversionOutput methods */ diff --git a/Software/Visual_Studio/Native/Tango.ColorLib/Tango.ColorLib.vcxproj b/Software/Visual_Studio/Native/Tango.ColorLib/Tango.ColorLib.vcxproj index 6a02e00a1..949ad79d8 100644 --- a/Software/Visual_Studio/Native/Tango.ColorLib/Tango.ColorLib.vcxproj +++ b/Software/Visual_Studio/Native/Tango.ColorLib/Tango.ColorLib.vcxproj @@ -74,7 +74,7 @@ true $(SolutionDir)Build\Native\Debug $(ProjectDir);$(IncludePath) - false + true true diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/FineTuningPaletteViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/FineTuningPaletteViewVM.cs index c706895ee..919cd94b2 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/FineTuningPaletteViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/FineTuningPaletteViewVM.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading.Tasks; using Tango.BL.ColorConversion; using Tango.BL.Entities; -using Tango.PPC.Jobs.Models; +using Tango.PPC.Common.Models; using Tango.SharedUI; namespace Tango.PPC.Jobs.Dialogs diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Messages/JobRemovedMessage.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Messages/JobRemovedMessage.cs deleted file mode 100644 index 711955582..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Messages/JobRemovedMessage.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL.Entities; - -namespace Tango.PPC.Jobs.Messages -{ - /// - /// Raises when a job has been removed. - /// - public class JobRemovedMessage - { - /// - /// Gets or sets the job. - /// - public Job Job { get; set; } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Messages/JobSavedMessage.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Messages/JobSavedMessage.cs deleted file mode 100644 index 59de56650..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Messages/JobSavedMessage.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL.Entities; - -namespace Tango.PPC.Jobs.Messages -{ - /// - /// Raises when a job has been saved. - /// - public class JobSavedMessage - { - /// - /// Gets or sets the job. - /// - public Job Job { get; set; } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Messages/JobSelectedMessage.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Messages/JobSelectedMessage.cs index 3b3843f29..721dce6ed 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Messages/JobSelectedMessage.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Messages/JobSelectedMessage.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL; using Tango.BL.Entities; namespace Tango.PPC.Jobs.Messages @@ -16,5 +17,10 @@ namespace Tango.PPC.Jobs.Messages /// Gets or sets the job. /// public Job Job { get; set; } + + /// + /// Gets or sets the db context. + /// + public ObservablesContext Context { get; set; } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Models/FineTuneItem.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Models/FineTuneItem.cs deleted file mode 100644 index a9b8019b4..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Models/FineTuneItem.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL.ColorConversion; -using Tango.BL.Entities; -using Tango.Core; -using Tango.PMR.ColorLab; - -namespace Tango.PPC.Jobs.Models -{ - /// - /// Represents a fine tuning item. - /// - /// - public class FineTuneItem : ExtendedObject - { - public event Action SelectedChanged; - - /// - /// Gets or sets the brush stops. - /// - public List BrushStops { get; set; } - - private List _suggestions; - /// - /// Gets or sets the triplet suggestions. - /// - public List Suggestions - { - get { return _suggestions; } - set { _suggestions = value; RaisePropertyChangedAuto(); } - } - - private List _hiveSuggestions; - /// - /// Gets or sets the hive suggestions. - /// - public List HiveSuggestions - { - get { return _hiveSuggestions; } - set { _hiveSuggestions = value; RaisePropertyChangedAuto(); } - } - - private bool _isSelected; - /// - /// Gets or sets a value indicating whether this instance is selected. - /// - public bool IsSelected - { - get { return _isSelected; } - set { _isSelected = value; RaisePropertyChangedAuto(); SelectedChanged?.Invoke(); } - } - - private ColorConversionSuggestion _selectedSuggestion; - /// - /// Gets or sets the selected triplet suggestion. - /// - public ColorConversionSuggestion SelectedSuggestion - { - get { return _selectedSuggestion; } - set { _selectedSuggestion = value; RaisePropertyChangedAuto(); } - } - - private ColorConversionSuggestion _selectedHiveSuggestion; - /// - /// Gets or sets the selected hive suggestion. - /// - public ColorConversionSuggestion SelectedHiveSuggestion - { - get { return _selectedHiveSuggestion; } - set { _selectedHiveSuggestion = value; RaisePropertyChangedAuto(); } - } - - /// - /// Initializes a new instance of the class. - /// - public FineTuneItem() - { - Suggestions = new List(); - BrushStops = new List(); - } - - /// - /// Initializes a new instance of the class. - /// - /// The conversion output. - public FineTuneItem(ConversionOutput conversionOutput) : this() - { - Suggestions = TangoColorConverter.CreateTrippletSuggestions(conversionOutput); - HiveSuggestions = TangoColorConverter.CreateHiveSuggestions(conversionOutput); - } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj index 9898ef987..4ab67fa31 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj @@ -167,10 +167,7 @@ - - - Code diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs index 2ba3971be..d46646698 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs @@ -3,9 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL; using Tango.BL.Entities; using Tango.Core.Commands; using Tango.PPC.Common; +using Tango.PPC.Common.Messages; using Tango.PPC.Jobs.Messages; using Tango.PPC.Jobs.Views; @@ -17,6 +19,8 @@ namespace Tango.PPC.Jobs.ViewModels /// public class JobSummeryViewVM : PPCViewModel { + private ObservablesContext _context; + private Job _job; /// /// Gets or sets the job. @@ -54,6 +58,7 @@ namespace Tango.PPC.Jobs.ViewModels /// The message. private void HandleJobSelectedMessage(JobSelectedMessage message) { + _context = message.Context; Job = message.Job; } @@ -74,7 +79,7 @@ namespace Tango.PPC.Jobs.ViewModels try { LogManager.Log("Start job command pressed. Starting job and navigating to job progress view..."); - MachineProvider.MachineOperator.Print(Job); + PrintingManager.Print(Job, _context); NavigationManager.NavigateTo(nameof(JobProgressView)); } catch (Exception ex) 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 392669087..a87340101 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 @@ -26,8 +26,9 @@ using Tango.PPC.Common.Navigation; using Tango.PPC.Jobs.NavigationObjects; using Tango.PPC.Jobs.ViewContracts; using System.Collections.ObjectModel; -using Tango.PPC.Jobs.Models; +using Tango.PPC.Common.Models; using Tango.Logging; +using Tango.PPC.Common.Messages; namespace Tango.PPC.Jobs.ViewModels { @@ -477,7 +478,7 @@ namespace Tango.PPC.Jobs.ViewModels try { LogManager.Log("Start job command pressed. Starting job and navigating to job progress view..."); - MachineProvider.MachineOperator.Print(Job); + PrintingManager.Print(Job, _db); NavigationManager.NavigateTo(nameof(JobProgressView)); } catch (Exception ex) @@ -705,51 +706,7 @@ namespace Tango.PPC.Jobs.ViewModels { LogManager.Log("Sample dye command pressed..."); - LogManager.Log("Cloning job..."); - Job sampleDyeJob = Job.Clone(); - sampleDyeJob.Guid = Job.Guid; - sampleDyeJob.Designation = BL.Enumerations.JobDesignations.SampleDye; - sampleDyeJob.Name = Job.Name; - - if (Job.JobType == BL.Enumerations.JobTypes.Embroidery) - { - sampleDyeJob.NumberOfUnits = Job.SampleUnitsOrMeters; - } - else - { - sampleDyeJob.NumberOfUnits = 1; - - foreach (var segment in sampleDyeJob.Segments) - { - segment.Length = Job.SampleUnitsOrMeters; - } - } - - SaveJob(false); - - var thisJob = Job; - var thisContext = _db; - - LogManager.Log("Executing sample dye job..."); - - MachineProvider.MachineOperator.Print(sampleDyeJob).Completed += async (x, e) => - { - try - { - thisJob.JobStatus = BL.Enumerations.JobStatuses.PendingApproval; - - if (Job != null && Job.Guid == thisJob.Guid) - { - thisJob.JobEditingState = BL.Enumerations.EditingStates.SampleDye; - thisJob.JobSampleDyeStatus = BL.Enumerations.SampleDyeStatuses.PendingApproval; - await thisContext.SaveChangesAsync(); - } - } - catch (Exception ex) - { - LogManager.Log(ex, "Error occurred after sample dye printing completed."); - } - }; + PrintingManager.PrintSample(Job, _db); NavigationManager.NavigateTo(nameof(JobProgressView)); } @@ -882,37 +839,9 @@ namespace Tango.PPC.Jobs.ViewModels { LogManager.Log("Start fine tunning job command pressed..."); - LogManager.Log("Cloning job..."); - Job fineTuneJob = Job.Clone(); - fineTuneJob.NumberOfUnits = 1; - fineTuneJob.Designation = BL.Enumerations.JobDesignations.FineTuning; - fineTuneJob.Guid = Job.Guid; - fineTuneJob.Name = Job.Name; - fineTuneJob.Segments.Clear(); - - foreach (var suggestion in FineTuneItems.Where(x => x.IsSelected).SelectMany(x => x.Suggestions)) - { - var segment = fineTuneJob.AddSolidSegment(suggestion.Color); - } - _jobs_fine_tune_items[Job.Guid] = FineTuneItems.ToList(); - var thisJob = Job; - var thisContext = _db; - - MachineProvider.MachineOperator.Print(fineTuneJob).Completed += async (x, e) => - { - try - { - thisJob.JobEditingState = BL.Enumerations.EditingStates.FineTuning; - thisJob.JobFineTuningStatus = BL.Enumerations.FineTuningStatuses.PendingApproval; - await thisContext.SaveChangesAsync(); - } - catch (Exception ex) - { - LogManager.Log(ex, "Error occurred after fine tunning job completed."); - } - }; + PrintingManager.PrintFineTuning(Job, _db, FineTuneItems); NavigationManager.NavigateTo(nameof(JobProgressView)); } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index 67eec2c6d..7b277ec2b 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -15,6 +15,7 @@ using Tango.Core.Commands; using Tango.Core.DI; using Tango.DragAndDrop; using Tango.PPC.Common; +using Tango.PPC.Common.Messages; using Tango.PPC.Jobs.Dialogs; using Tango.PPC.Jobs.Messages; using Tango.PPC.Jobs.Views; @@ -207,7 +208,7 @@ namespace Tango.PPC.Jobs.ViewModels { LogManager.Log($"Job '{job.Name}' selected."); await NavigationManager.NavigateTo(nameof(JobSummeryView)); - RaiseMessage(new JobSelectedMessage() { Job = job }); + RaiseMessage(new JobSelectedMessage() { Job = job, Context = _db }); } /// @@ -225,11 +226,6 @@ namespace Tango.PPC.Jobs.ViewModels Thread.Sleep(500); - if (_db != null) - { - _db.Dispose(); - } - _db = ObservablesContext.CreateDefault(); var jobs = _db.Jobs.Where(x => x.Machine.Guid == MachineProvider.Machine.Guid).ToObservableCollection(); @@ -321,7 +317,7 @@ namespace Tango.PPC.Jobs.ViewModels LogManager.Log($"Job {job.Name} added successfully."); - RaiseMessage(new JobSelectedMessage() { Job = job }); + RaiseMessage(new JobSelectedMessage() { Job = job, Context = _db }); await Task.Delay(200); await NavigationManager.NavigateTo(nameof(JobView)); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Messages/JobRemovedMessage.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Messages/JobRemovedMessage.cs new file mode 100644 index 000000000..9a24c31d0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Messages/JobRemovedMessage.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; + +namespace Tango.PPC.Common.Messages +{ + /// + /// Raises when a job has been removed. + /// + public class JobRemovedMessage + { + /// + /// Gets or sets the job. + /// + public Job Job { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Messages/JobSavedMessage.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Messages/JobSavedMessage.cs new file mode 100644 index 000000000..f055ba50c --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Messages/JobSavedMessage.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; + +namespace Tango.PPC.Common.Messages +{ + /// + /// Raises when a job has been saved. + /// + public class JobSavedMessage + { + /// + /// Gets or sets the job. + /// + public Job Job { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Models/FineTuneItem.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Models/FineTuneItem.cs new file mode 100644 index 000000000..7e29d41d2 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Models/FineTuneItem.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.ColorConversion; +using Tango.BL.Entities; +using Tango.Core; +using Tango.PMR.ColorLab; + +namespace Tango.PPC.Common.Models +{ + /// + /// Represents a fine tuning item. + /// + /// + public class FineTuneItem : ExtendedObject + { + public event Action SelectedChanged; + + /// + /// Gets or sets the brush stops. + /// + public List BrushStops { get; set; } + + private List _suggestions; + /// + /// Gets or sets the triplet suggestions. + /// + public List Suggestions + { + get { return _suggestions; } + set { _suggestions = value; RaisePropertyChangedAuto(); } + } + + private List _hiveSuggestions; + /// + /// Gets or sets the hive suggestions. + /// + public List HiveSuggestions + { + get { return _hiveSuggestions; } + set { _hiveSuggestions = value; RaisePropertyChangedAuto(); } + } + + private bool _isSelected; + /// + /// Gets or sets a value indicating whether this instance is selected. + /// + public bool IsSelected + { + get { return _isSelected; } + set { _isSelected = value; RaisePropertyChangedAuto(); SelectedChanged?.Invoke(); } + } + + private ColorConversionSuggestion _selectedSuggestion; + /// + /// Gets or sets the selected triplet suggestion. + /// + public ColorConversionSuggestion SelectedSuggestion + { + get { return _selectedSuggestion; } + set { _selectedSuggestion = value; RaisePropertyChangedAuto(); } + } + + private ColorConversionSuggestion _selectedHiveSuggestion; + /// + /// Gets or sets the selected hive suggestion. + /// + public ColorConversionSuggestion SelectedHiveSuggestion + { + get { return _selectedHiveSuggestion; } + set { _selectedHiveSuggestion = value; RaisePropertyChangedAuto(); } + } + + /// + /// Initializes a new instance of the class. + /// + public FineTuneItem() + { + Suggestions = new List(); + BrushStops = new List(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The conversion output. + public FineTuneItem(ConversionOutput conversionOutput) : this() + { + Suggestions = TangoColorConverter.CreateTrippletSuggestions(conversionOutput); + HiveSuggestions = TangoColorConverter.CreateHiveSuggestions(conversionOutput); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs index b2475b139..0fb2be851 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs @@ -11,6 +11,7 @@ using Tango.PPC.Common.Connection; using Tango.PPC.Common.ExternalBridge; using Tango.PPC.Common.Navigation; using Tango.PPC.Common.Notifications; +using Tango.PPC.Common.Printing; using Tango.Settings; using Tango.SharedUI; using static Tango.SharedUI.Controls.NavigationControl; @@ -67,6 +68,12 @@ namespace Tango.PPC.Common [TangoInject] public IPPCExternalBridgeService ExternalBridgeService { get; set; } + /// + /// Gets or sets the printing manager. + /// + [TangoInject] + public IPrintingManager PrintingManager { get; set; } + private PPCSettings _settings; /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Printing/IPrintingManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Printing/IPrintingManager.cs new file mode 100644 index 000000000..50682bf65 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Printing/IPrintingManager.cs @@ -0,0 +1,21 @@ +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.Integration.Operation; +using Tango.PPC.Common.Models; + +namespace Tango.PPC.Common.Printing +{ + public interface IPrintingManager + { + JobHandler Print(Job job, ObservablesContext context); + + JobHandler PrintSample(Job job, ObservablesContext context); + + JobHandler PrintFineTuning(Job job, ObservablesContext context, IEnumerable fineTuneItems); + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index d6accf6fd..0fe4f3f42 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -119,7 +119,10 @@ + + + @@ -133,6 +136,7 @@ + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs index db0936e56..48e4fdf01 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs @@ -174,7 +174,7 @@ namespace Tango.PPC.Publisher private void Publish() { - String _appPath = String.Format(AppDomain.CurrentDomain.BaseDirectory + "..\\..\\{0}\\PPC", SelectedBuildConfiguration); + String _appPath = String.Format(AppDomain.CurrentDomain.BaseDirectory + "..\\{0}", SelectedBuildConfiguration); Task.Factory.StartNew(() => { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs new file mode 100644 index 000000000..376cad16d --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs @@ -0,0 +1,163 @@ +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; +using Tango.Core.DI; +using Tango.Integration.Operation; +using Tango.PPC.Common.Connection; +using Tango.PPC.Common.Messages; +using Tango.PPC.Common.Models; +using Tango.PPC.Common.Navigation; +using Tango.PPC.Common.Printing; +using Tango.PPC.Jobs.Messages; + +namespace Tango.PPC.UI.Printing +{ + public class DefaultPrintingManager : ExtendedObject, IPrintingManager + { + private IMachineProvider _machineProvider; + + public DefaultPrintingManager(IMachineProvider machineProvider) + { + _machineProvider = machineProvider; + } + + public JobHandler Print(Job job, ObservablesContext context) + { + var handler = _machineProvider.MachineOperator.Print(job); + + handler.Completed += async (x, e) => + { + try + { + + job.JobStatus = BL.Enumerations.JobStatuses.Completed; + await context.SaveChangesAsync(); + RaiseJobSaved(job); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error occurred after job printing completed."); + } + }; + handler.Canceled += async (x, e) => + { + try + { + + job.JobStatus = BL.Enumerations.JobStatuses.Disrupted; + await context.SaveChangesAsync(); + RaiseJobSaved(job); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error occurred after job printing completed."); + } + }; + handler.Failed += async (x, e) => + { + try + { + + job.JobStatus = BL.Enumerations.JobStatuses.Disrupted; + await context.SaveChangesAsync(); + RaiseJobSaved(job); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error occurred after job printing completed."); + } + }; + + + return handler; + } + + public JobHandler PrintSample(Job job, ObservablesContext context) + { + LogManager.Log("Cloning job..."); + Job sampleDyeJob = job.Clone(); + sampleDyeJob.Guid = job.Guid; + sampleDyeJob.Designation = BL.Enumerations.JobDesignations.SampleDye; + sampleDyeJob.Name = job.Name; + + if (job.JobType == BL.Enumerations.JobTypes.Embroidery) + { + sampleDyeJob.NumberOfUnits = job.SampleUnitsOrMeters; + } + else + { + sampleDyeJob.NumberOfUnits = 1; + + foreach (var segment in sampleDyeJob.Segments) + { + segment.Length = job.SampleUnitsOrMeters; + } + } + + context.SaveChanges(); + RaiseJobSaved(job); + + LogManager.Log("Executing sample dye job..."); + + var handler = _machineProvider.MachineOperator.Print(sampleDyeJob); + handler.Completed += async (x, e) => + { + try + { + job.JobEditingState = BL.Enumerations.EditingStates.SampleDye; + job.JobSampleDyeStatus = BL.Enumerations.SampleDyeStatuses.PendingApproval; + await context.SaveChangesAsync(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error occurred after sample dye printing completed."); + } + }; + + return handler; + } + + public JobHandler PrintFineTuning(Job job, ObservablesContext context, IEnumerable fineTuneItems) + { + LogManager.Log("Cloning job..."); + Job fineTuneJob = job.Clone(); + fineTuneJob.NumberOfUnits = 1; + fineTuneJob.Designation = BL.Enumerations.JobDesignations.FineTuning; + fineTuneJob.Guid = job.Guid; + fineTuneJob.Name = job.Name; + fineTuneJob.Segments.Clear(); + + foreach (var suggestion in fineTuneItems.Where(x => x.IsSelected).SelectMany(x => x.Suggestions)) + { + var segment = fineTuneJob.AddSolidSegment(suggestion.Color); + } + + var handler = _machineProvider.MachineOperator.Print(fineTuneJob); + handler.Completed += async (x, e) => + { + try + { + job.JobEditingState = BL.Enumerations.EditingStates.FineTuning; + job.JobFineTuningStatus = BL.Enumerations.FineTuningStatuses.PendingApproval; + await context.SaveChangesAsync(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error occurred after fine tunning job completed."); + } + }; + + return handler; + } + + private void RaiseJobSaved(Job job) + { + TangoMessenger.Default.Send(new JobSavedMessage() { Job = job }); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index eae39d380..29ab4677a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -120,6 +120,7 @@ + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs index 7c3e7b9cf..61c2ca7c4 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs @@ -13,12 +13,14 @@ using Tango.PPC.Common.MachineSetup; using Tango.PPC.Common.Modules; using Tango.PPC.Common.Navigation; using Tango.PPC.Common.Notifications; +using Tango.PPC.Common.Printing; using Tango.PPC.Common.Threading; using Tango.PPC.UI.Authentication; using Tango.PPC.UI.Modules; using Tango.PPC.UI.Navigation; using Tango.PPC.UI.Notifications; using Tango.PPC.UI.PPCApplication; +using Tango.PPC.UI.Printing; using Tango.PPC.UI.Threading; using Tango.PPC.UI.ViewModels; using Tango.PPC.UI.Views; @@ -51,6 +53,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); + TangoIOC.Default.Unregister(); TangoIOC.Default.Register(new DefaultDispetcherProvider(Application.Current.Dispatcher)); TangoIOC.Default.Register(); @@ -64,6 +67,8 @@ namespace Tango.PPC.UI TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); + TangoIOC.Default.Register(); + //TangoIOC.Default.Register(new TeamFoundationServiceExtendedClient("https://twinetfs.visualstudio.com", String.Empty, "szzfokrceo4rhd4eqi5qpmxn3pa5iwl3q7tlqd36l2m7smz2ynoa")); TangoIOC.Default.Register(); diff --git a/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs b/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs index cc97164d2..c68ecd8c5 100644 --- a/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs +++ b/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs @@ -9,6 +9,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Media; using Tango.BL.Entities; +using Tango.Logging; using Tango.PMR; using Tango.PMR.ColorLab; @@ -26,6 +27,11 @@ namespace Tango.BL.ColorConversion NativePMR nativePMR = new NativePMR(Convert); ConversionOutput output = nativePMR.Invoke(conversionInput); + if (output.HasError) + { + throw LogManager.Default.Log(new ExternalException($"Color Conversion Error: {output.ErrorMessage}!"), LogCategory.Warning); + } + return output; } @@ -33,6 +39,12 @@ namespace Tango.BL.ColorConversion { NativePMR nativePMR = new NativePMR(Convert); ConversionOutput output = nativePMR.Invoke(conversionInput); + + if (output.HasError) + { + throw LogManager.Default.Log(new ExternalException($"Color Conversion Error: {output.ErrorMessage}!"), LogCategory.Warning); + } + return output; } @@ -65,6 +77,12 @@ namespace Tango.BL.ColorConversion NativePMR nativePMR = new NativePMR(Convert); ConversionOutput output = nativePMR.Invoke(conversionInput); + + if (output.HasError) + { + throw LogManager.Default.Log(new ExternalException($"Color Conversion Error: {output.ErrorMessage}!"), LogCategory.Warning); + } + return output; } diff --git a/Software/Visual_Studio/Tango.BL/Enumerations/JobCategories.cs b/Software/Visual_Studio/Tango.BL/Enumerations/JobCategories.cs index 8c3e9a4c7..db5c8c15a 100644 --- a/Software/Visual_Studio/Tango.BL/Enumerations/JobCategories.cs +++ b/Software/Visual_Studio/Tango.BL/Enumerations/JobCategories.cs @@ -9,11 +9,11 @@ namespace Tango.BL.Enumerations { public enum JobCategories { - [Description("READY")] - Ready, - [Description("NOT READY")] - NotReady, - [Description("ALL")] - All, + [Description("DRAFT")] + Draft, + [Description("COMPLETED")] + Completed, + [Description("DISRUPTED")] + Disrupted, } } diff --git a/Software/Visual_Studio/Tango.BL/Enumerations/JobStatuses.cs b/Software/Visual_Studio/Tango.BL/Enumerations/JobStatuses.cs index fd4a176fa..9857f664e 100644 --- a/Software/Visual_Studio/Tango.BL/Enumerations/JobStatuses.cs +++ b/Software/Visual_Studio/Tango.BL/Enumerations/JobStatuses.cs @@ -10,28 +10,19 @@ namespace Tango.BL.Enumerations { public enum JobStatuses { - //Not Ready - [JobStatus(JobCategories.NotReady, JobCategories.All)] + //Draft + [JobStatus(JobCategories.Draft)] [Description("Draft")] Draft, - [JobStatus(JobCategories.NotReady, JobCategories.All)] - [Description("Pending Approval")] - PendingApproval, - //Ready - [JobStatus(JobCategories.Ready, JobCategories.All)] - [Description("Ready")] - Ready, - [JobStatus(JobCategories.Ready, JobCategories.All)] - [Description("Approved")] - Approved, - [JobStatus(JobCategories.Ready, JobCategories.All)] - [Description("Disrupted")] - Disrupted, - - //All - [JobStatus(JobCategories.All)] + //Completed + [JobStatus(JobCategories.Completed)] [Description("Completed")] Completed, + + //Disrupted + [JobStatus(JobCategories.Disrupted)] + [Description("Disrupted")] + Disrupted, } } diff --git a/Software/Visual_Studio/Tango.PMR/ColorLab/ConversionOutput.cs b/Software/Visual_Studio/Tango.PMR/ColorLab/ConversionOutput.cs index 350cf09d4..3eb4664f3 100644 --- a/Software/Visual_Studio/Tango.PMR/ColorLab/ConversionOutput.cs +++ b/Software/Visual_Studio/Tango.PMR/ColorLab/ConversionOutput.cs @@ -23,17 +23,18 @@ namespace Tango.PMR.ColorLab { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "ChZDb252ZXJzaW9uT3V0cHV0LnByb3RvEhJUYW5nby5QTVIuQ29sb3JMYWIa", - "F091dHB1dENvb3JkaW5hdGVzLnByb3RvIuoBChBDb252ZXJzaW9uT3V0cHV0", + "F091dHB1dENvb3JkaW5hdGVzLnByb3RvIpICChBDb252ZXJzaW9uT3V0cHV0", "Ej4KD0hpdmVDb29yZGluYXRlcxgBIAMoCzIlLlRhbmdvLlBNUi5Db2xvckxh", "Yi5PdXRwdXRDb29yZGluYXRlcxJAChFUcmlwbGVDb29yZGluYXRlcxgCIAMo", "CzIlLlRhbmdvLlBNUi5Db2xvckxhYi5PdXRwdXRDb29yZGluYXRlcxJAChFT", "aW5nbGVDb29yZGluYXRlcxgDIAEoCzIlLlRhbmdvLlBNUi5Db2xvckxhYi5P", - "dXRwdXRDb29yZGluYXRlcxISCgpPdXRPZkdhbXV0GAUgASgIQh4KHGNvbS50", - "d2luZS50YW5nby5wbXIuY29sb3JsYWJiBnByb3RvMw==")); + "dXRwdXRDb29yZGluYXRlcxISCgpPdXRPZkdhbXV0GAUgASgIEhAKCEhhc0Vy", + "cm9yGAYgASgIEhQKDEVycm9yTWVzc2FnZRgHIAEoCUIeChxjb20udHdpbmUu", + "dGFuZ28ucG1yLmNvbG9ybGFiYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Tango.PMR.ColorLab.OutputCoordinatesReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.ColorLab.ConversionOutput), global::Tango.PMR.ColorLab.ConversionOutput.Parser, new[]{ "HiveCoordinates", "TripleCoordinates", "SingleCoordinates", "OutOfGamut" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.ColorLab.ConversionOutput), global::Tango.PMR.ColorLab.ConversionOutput.Parser, new[]{ "HiveCoordinates", "TripleCoordinates", "SingleCoordinates", "OutOfGamut", "HasError", "ErrorMessage" }, null, null, null) })); } #endregion @@ -68,6 +69,8 @@ namespace Tango.PMR.ColorLab { tripleCoordinates_ = other.tripleCoordinates_.Clone(); SingleCoordinates = other.singleCoordinates_ != null ? other.SingleCoordinates.Clone() : null; outOfGamut_ = other.outOfGamut_; + hasError_ = other.hasError_; + errorMessage_ = other.errorMessage_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -117,6 +120,28 @@ namespace Tango.PMR.ColorLab { } } + /// Field number for the "HasError" field. + public const int HasErrorFieldNumber = 6; + private bool hasError_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool HasError { + get { return hasError_; } + set { + hasError_ = value; + } + } + + /// Field number for the "ErrorMessage" field. + public const int ErrorMessageFieldNumber = 7; + private string errorMessage_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ErrorMessage { + get { return errorMessage_; } + set { + errorMessage_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ConversionOutput); @@ -134,6 +159,8 @@ namespace Tango.PMR.ColorLab { if(!tripleCoordinates_.Equals(other.tripleCoordinates_)) return false; if (!object.Equals(SingleCoordinates, other.SingleCoordinates)) return false; if (OutOfGamut != other.OutOfGamut) return false; + if (HasError != other.HasError) return false; + if (ErrorMessage != other.ErrorMessage) return false; return true; } @@ -144,6 +171,8 @@ namespace Tango.PMR.ColorLab { hash ^= tripleCoordinates_.GetHashCode(); if (singleCoordinates_ != null) hash ^= SingleCoordinates.GetHashCode(); if (OutOfGamut != false) hash ^= OutOfGamut.GetHashCode(); + if (HasError != false) hash ^= HasError.GetHashCode(); + if (ErrorMessage.Length != 0) hash ^= ErrorMessage.GetHashCode(); return hash; } @@ -164,6 +193,14 @@ namespace Tango.PMR.ColorLab { output.WriteRawTag(40); output.WriteBool(OutOfGamut); } + if (HasError != false) { + output.WriteRawTag(48); + output.WriteBool(HasError); + } + if (ErrorMessage.Length != 0) { + output.WriteRawTag(58); + output.WriteString(ErrorMessage); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -177,6 +214,12 @@ namespace Tango.PMR.ColorLab { if (OutOfGamut != false) { size += 1 + 1; } + if (HasError != false) { + size += 1 + 1; + } + if (ErrorMessage.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ErrorMessage); + } return size; } @@ -196,6 +239,12 @@ namespace Tango.PMR.ColorLab { if (other.OutOfGamut != false) { OutOfGamut = other.OutOfGamut; } + if (other.HasError != false) { + HasError = other.HasError; + } + if (other.ErrorMessage.Length != 0) { + ErrorMessage = other.ErrorMessage; + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -225,6 +274,14 @@ namespace Tango.PMR.ColorLab { OutOfGamut = input.ReadBool(); break; } + case 48: { + HasError = input.ReadBool(); + break; + } + case 58: { + ErrorMessage = input.ReadString(); + break; + } } } } -- cgit v1.3.1