diff options
| -rw-r--r-- | Software/DB/Tango.mdf | bin | 75497472 -> 75497472 bytes | |||
| -rw-r--r-- | Software/DB/Tango_log.ldf | bin | 22675456 -> 22675456 bytes | |||
| -rw-r--r-- | Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs | 55 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.PMR/NativePMR.cs | 19 |
4 files changed, 42 insertions, 32 deletions
diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf Binary files differindex 2468d8559..fda449446 100644 --- a/Software/DB/Tango.mdf +++ b/Software/DB/Tango.mdf diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf Binary files differindex de658cfa8..ec0a2e6b6 100644 --- a/Software/DB/Tango_log.ldf +++ b/Software/DB/Tango_log.ldf diff --git a/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs b/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs index 776fa7448..e94dd851b 100644 --- a/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs +++ b/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs @@ -17,16 +17,31 @@ namespace Tango.BL.ColorConversion { public static class TangoColorConverter { - [DllImport("Tango.ColorLib.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Convert")] - private static extern int Convert(IntPtr data, int size, ref IntPtr output); + static class NativeMethods + { + [DllImport("kernel32.dll")] + public static extern IntPtr LoadLibrary(string dllToLoad); - public static ConversionOutput GetSuggestions(BrushStop brushStop) + [DllImport("kernel32.dll")] + public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName); + + [DllImport("kernel32.dll")] + public static extern bool FreeLibrary(IntPtr hModule); + } + + private static ConversionOutput Convert(ConversionInput conversionInput) { - ConversionInput conversionInput = CreateConversionInput(brushStop); + IntPtr pDll = NativeMethods.LoadLibrary(@"Tango.ColorLib.dll"); + IntPtr pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pDll, "Convert"); + NativeMethodDelegate convert = (NativeMethodDelegate)Marshal.GetDelegateForFunctionPointer( + pAddressOfFunctionToCall, + typeof(NativeMethodDelegate)); - NativePMR<ConversionInput, ConversionOutput> nativePMR = new NativePMR<ConversionInput, ConversionOutput>(Convert); + NativePMR<ConversionInput, ConversionOutput> nativePMR = new NativePMR<ConversionInput, ConversionOutput>(convert); ConversionOutput output = nativePMR.Invoke(conversionInput); + bool result = NativeMethods.FreeLibrary(pDll); + if (output.HasError) { throw new ExternalException($"Color Conversion Error: {output.ErrorMessage}!"); @@ -35,16 +50,16 @@ namespace Tango.BL.ColorConversion return output; } - public static ConversionOutput GetSuggestions(ConversionInput conversionInput) + public static ConversionOutput GetSuggestions(BrushStop brushStop) { - NativePMR<ConversionInput, ConversionOutput> nativePMR = new NativePMR<ConversionInput, ConversionOutput>(Convert); - ConversionOutput output = nativePMR.Invoke(conversionInput); - - if (output.HasError) - { - throw LogManager.Default.Log(new ExternalException($"Color Conversion Error: {output.ErrorMessage}!"), LogCategory.Warning); - } + ConversionInput conversionInput = CreateConversionInput(brushStop); + ConversionOutput output = Convert(conversionInput); + return output; + } + public static ConversionOutput GetSuggestions(ConversionInput conversionInput) + { + ConversionOutput output = Convert(conversionInput); return output; } @@ -59,9 +74,9 @@ namespace Tango.BL.ColorConversion conversionInput.InputCoordinates.Green = Math.Max((int)color.G, 1); conversionInput.InputCoordinates.Blue = Math.Max((int)color.B, 1); - conversionInput.ThreadL = 92.1815;//brushStop.Segment.Job.Rml.MediaColor.L; - conversionInput.ThreadA = 2.2555;//brushStop.Segment.Job.Rml.MediaColor.A; - conversionInput.ThreadB = -10.9325;//brushStop.Segment.Job.Rml.MediaColor.B; + conversionInput.ThreadL = 92.1815;//brushStop.Segment.Job.Rml.WhitePoint.L; + conversionInput.ThreadA = 2.2555;//brushStop.Segment.Job.Rml.WhitePoint.A; + conversionInput.ThreadB = -10.9325;//brushStop.Segment.Job.Rml.WhitePoint.B; conversionInput.ForwardData = ByteString.CopyFrom(job.Rml.Ccts.FirstOrDefault().ForwardData); @@ -104,13 +119,7 @@ namespace Tango.BL.ColorConversion }); } - NativePMR<ConversionInput, ConversionOutput> nativePMR = new NativePMR<ConversionInput, ConversionOutput>(Convert); - ConversionOutput output = nativePMR.Invoke(conversionInput); - - if (output.HasError) - { - throw LogManager.Default.Log(new ExternalException($"Color Conversion Error: {output.ErrorMessage}!"), LogCategory.Warning); - } + ConversionOutput output = Convert(conversionInput); return output; } diff --git a/Software/Visual_Studio/Tango.PMR/NativePMR.cs b/Software/Visual_Studio/Tango.PMR/NativePMR.cs index 14e740656..5666fbeb0 100644 --- a/Software/Visual_Studio/Tango.PMR/NativePMR.cs +++ b/Software/Visual_Studio/Tango.PMR/NativePMR.cs @@ -10,6 +10,16 @@ using System.Runtime.ExceptionServices; namespace Tango.PMR { /// <summary> + /// Represents a standard C++ protobuf method delegate. + /// </summary> + /// <param name="requestArray">The request array.</param> + /// <param name="requestArraySize">Size of the request array.</param> + /// <param name="resultArray">The result array.</param> + /// <returns>The size of the result array.</returns> + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate int NativeMethodDelegate(IntPtr requestArray, int requestArraySize, ref IntPtr resultArray); + + /// <summary> /// Represents a PMR wrapper for invoking native protobuf supported methods. /// </summary> /// <typeparam name="Request">The type of the Request.</typeparam> @@ -28,15 +38,6 @@ namespace Tango.PMR } /// <summary> - /// Represents a standard C++ protobuf method delegate. - /// </summary> - /// <param name="requestArray">The request array.</param> - /// <param name="requestArraySize">Size of the request array.</param> - /// <param name="resultArray">The result array.</param> - /// <returns>The size of the result array.</returns> - public delegate int NativeMethodDelegate(IntPtr requestArray, int requestArraySize, ref IntPtr resultArray); - - /// <summary> /// Invokes the native method with the specified request. /// </summary> /// <param name="request">The request.</param> |
