diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-03-04 15:28:15 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-03-04 15:28:15 +0200 |
| commit | 2b8e41b5279c2d3ab370595f6593b64ea734ef87 (patch) | |
| tree | 084ceaae9e1b65454e9e2264ce6fdb0511ca4cf9 /Software/Visual_Studio/Embroidery | |
| parent | d734bb5cf08ba2433b74fc86a8858d2437d1a237 (diff) | |
| download | Tango-2b8e41b5279c2d3ab370595f6593b64ea734ef87.tar.gz Tango-2b8e41b5279c2d3ab370595f6593b64ea734ef87.zip | |
Implemented job embroidery image capture, display export,
Implemented running job text to speech.
Diffstat (limited to 'Software/Visual_Studio/Embroidery')
11 files changed, 434 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Embroidery/Tango.Embroidery/Adapter.cpp b/Software/Visual_Studio/Embroidery/Tango.Embroidery/Adapter.cpp index 55eba8a93..3c68c0b57 100644 --- a/Software/Visual_Studio/Embroidery/Tango.Embroidery/Adapter.cpp +++ b/Software/Visual_Studio/Embroidery/Tango.Embroidery/Adapter.cpp @@ -7,6 +7,8 @@ #include "PMR\Embroidery\StitchFlag.pb-c.h" #include "PMR\Embroidery\StitchColor.pb-c.h" #include "PMR\Embroidery\Extents.pb-c.h" +#include "PMR\Embroidery\ConvertFileInput.pb-c.h" +#include "PMR\Embroidery\ConvertFileOutput.pb-c.h" @@ -93,3 +95,33 @@ size_t Adapter::AnalyzeEmbroideryFile(uint8_t * input_buffer, size_t input_buffe return analyze_output__pack(output, output_buffer); } + +size_t Adapter::ConvertFile(uint8_t * input_buffer, size_t input_buffer_size, uint8_t *& output_buffer) +{ + //Unpack input... + ConvertFileInput *input = convert_file_input__unpack(NULL, input_buffer_size, input_buffer); + + //Initialize Output... + ConvertFileOutput* output = (ConvertFileOutput*)malloc(sizeof(ConvertFileOutput)); + convert_file_output__init(output); + + EmbPattern* p = 0; + int successful = 0; + + output->has_successful = true; + + p = embPattern_create(); + + output->successful = embPattern_read(p, input->sourcefile); + + if (output->successful) + { + output->successful = embPattern_write(p, input->targetfile); + embPattern_free(p); + } + + //Pack output... + output_buffer = (uint8_t*)malloc(convert_file_output__get_packed_size(output)); + + return convert_file_output__pack(output, output_buffer); +} diff --git a/Software/Visual_Studio/Embroidery/Tango.Embroidery/Adapter.h b/Software/Visual_Studio/Embroidery/Tango.Embroidery/Adapter.h index 9b4de128a..fe5149952 100644 --- a/Software/Visual_Studio/Embroidery/Tango.Embroidery/Adapter.h +++ b/Software/Visual_Studio/Embroidery/Tango.Embroidery/Adapter.h @@ -6,7 +6,11 @@ class Adapter { public: Adapter(); + ~Adapter(); + size_t AnalyzeEmbroideryFile(uint8_t * input_buffer, size_t input_buffer_size, uint8_t *& output_buffer); + + size_t ConvertFile(uint8_t * input_buffer, size_t input_buffer_size, uint8_t *& output_buffer); }; diff --git a/Software/Visual_Studio/Embroidery/Tango.Embroidery/Exports.cpp b/Software/Visual_Studio/Embroidery/Tango.Embroidery/Exports.cpp index ba4ed6cbb..841a6adf4 100644 --- a/Software/Visual_Studio/Embroidery/Tango.Embroidery/Exports.cpp +++ b/Software/Visual_Studio/Embroidery/Tango.Embroidery/Exports.cpp @@ -13,3 +13,9 @@ extern "C" EXPORT_API size_t __cdecl AnalyzeEmbroideryFile(uint8_t* input_buffer return adapter.AnalyzeEmbroideryFile(input_buffer, input_buffer_size, output_buffer); } +extern "C" EXPORT_API size_t __cdecl ConvertFile(uint8_t* input_buffer, size_t input_buffer_size, uint8_t*& output_buffer) +{ + Adapter adapter; + return adapter.ConvertFile(input_buffer, input_buffer_size, output_buffer); +} + diff --git a/Software/Visual_Studio/Embroidery/Tango.Embroidery/PMR/Embroidery/ConvertFileInput.pb-c.c b/Software/Visual_Studio/Embroidery/Tango.Embroidery/PMR/Embroidery/ConvertFileInput.pb-c.c new file mode 100644 index 000000000..7bc45b2cf --- /dev/null +++ b/Software/Visual_Studio/Embroidery/Tango.Embroidery/PMR/Embroidery/ConvertFileInput.pb-c.c @@ -0,0 +1,105 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: ConvertFileInput.proto */ + +/* Do not generate deprecated warnings for self */ +#ifndef PROTOBUF_C__NO_DEPRECATED +#define PROTOBUF_C__NO_DEPRECATED +#endif + +#include "ConvertFileInput.pb-c.h" +void convert_file_input__init + (ConvertFileInput *message) +{ + static const ConvertFileInput init_value = CONVERT_FILE_INPUT__INIT; + *message = init_value; +} +size_t convert_file_input__get_packed_size + (const ConvertFileInput *message) +{ + assert(message->base.descriptor == &convert_file_input__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t convert_file_input__pack + (const ConvertFileInput *message, + uint8_t *out) +{ + assert(message->base.descriptor == &convert_file_input__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t convert_file_input__pack_to_buffer + (const ConvertFileInput *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &convert_file_input__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +ConvertFileInput * + convert_file_input__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (ConvertFileInput *) + protobuf_c_message_unpack (&convert_file_input__descriptor, + allocator, len, data); +} +void convert_file_input__free_unpacked + (ConvertFileInput *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &convert_file_input__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +static const ProtobufCFieldDescriptor convert_file_input__field_descriptors[2] = +{ + { + "SourceFile", + 1, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_STRING, + 0, /* quantifier_offset */ + offsetof(ConvertFileInput, sourcefile), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "TargetFile", + 2, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_STRING, + 0, /* quantifier_offset */ + offsetof(ConvertFileInput, targetfile), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned convert_file_input__field_indices_by_name[] = { + 0, /* field[0] = SourceFile */ + 1, /* field[1] = TargetFile */ +}; +static const ProtobufCIntRange convert_file_input__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 2 } +}; +const ProtobufCMessageDescriptor convert_file_input__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "ConvertFileInput", + "ConvertFileInput", + "ConvertFileInput", + "", + sizeof(ConvertFileInput), + 2, + convert_file_input__field_descriptors, + convert_file_input__field_indices_by_name, + 1, convert_file_input__number_ranges, + (ProtobufCMessageInit) convert_file_input__init, + NULL,NULL,NULL /* reserved[123] */ +}; diff --git a/Software/Visual_Studio/Embroidery/Tango.Embroidery/PMR/Embroidery/ConvertFileInput.pb-c.h b/Software/Visual_Studio/Embroidery/Tango.Embroidery/PMR/Embroidery/ConvertFileInput.pb-c.h new file mode 100644 index 000000000..085ba2129 --- /dev/null +++ b/Software/Visual_Studio/Embroidery/Tango.Embroidery/PMR/Embroidery/ConvertFileInput.pb-c.h @@ -0,0 +1,72 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: ConvertFileInput.proto */ + +#ifndef PROTOBUF_C_ConvertFileInput_2eproto__INCLUDED +#define PROTOBUF_C_ConvertFileInput_2eproto__INCLUDED + +#include <protobuf-c/protobuf-c.h> + +PROTOBUF_C__BEGIN_DECLS + +#if PROTOBUF_C_VERSION_NUMBER < 1003000 +# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1003000 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +#endif + + +typedef struct _ConvertFileInput ConvertFileInput; + + +/* --- enums --- */ + + +/* --- messages --- */ + +struct _ConvertFileInput +{ + ProtobufCMessage base; + char *sourcefile; + char *targetfile; +}; +#define CONVERT_FILE_INPUT__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&convert_file_input__descriptor) \ + , NULL, NULL } + + +/* ConvertFileInput methods */ +void convert_file_input__init + (ConvertFileInput *message); +size_t convert_file_input__get_packed_size + (const ConvertFileInput *message); +size_t convert_file_input__pack + (const ConvertFileInput *message, + uint8_t *out); +size_t convert_file_input__pack_to_buffer + (const ConvertFileInput *message, + ProtobufCBuffer *buffer); +ConvertFileInput * + convert_file_input__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void convert_file_input__free_unpacked + (ConvertFileInput *message, + ProtobufCAllocator *allocator); +/* --- per-message closures --- */ + +typedef void (*ConvertFileInput_Closure) + (const ConvertFileInput *message, + void *closure_data); + +/* --- services --- */ + + +/* --- descriptors --- */ + +extern const ProtobufCMessageDescriptor convert_file_input__descriptor; + +PROTOBUF_C__END_DECLS + + +#endif /* PROTOBUF_C_ConvertFileInput_2eproto__INCLUDED */ diff --git a/Software/Visual_Studio/Embroidery/Tango.Embroidery/PMR/Embroidery/ConvertFileOutput.pb-c.c b/Software/Visual_Studio/Embroidery/Tango.Embroidery/PMR/Embroidery/ConvertFileOutput.pb-c.c new file mode 100644 index 000000000..01121784f --- /dev/null +++ b/Software/Visual_Studio/Embroidery/Tango.Embroidery/PMR/Embroidery/ConvertFileOutput.pb-c.c @@ -0,0 +1,92 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: ConvertFileOutput.proto */ + +/* Do not generate deprecated warnings for self */ +#ifndef PROTOBUF_C__NO_DEPRECATED +#define PROTOBUF_C__NO_DEPRECATED +#endif + +#include "ConvertFileOutput.pb-c.h" +void convert_file_output__init + (ConvertFileOutput *message) +{ + static const ConvertFileOutput init_value = CONVERT_FILE_OUTPUT__INIT; + *message = init_value; +} +size_t convert_file_output__get_packed_size + (const ConvertFileOutput *message) +{ + assert(message->base.descriptor == &convert_file_output__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t convert_file_output__pack + (const ConvertFileOutput *message, + uint8_t *out) +{ + assert(message->base.descriptor == &convert_file_output__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t convert_file_output__pack_to_buffer + (const ConvertFileOutput *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &convert_file_output__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +ConvertFileOutput * + convert_file_output__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (ConvertFileOutput *) + protobuf_c_message_unpack (&convert_file_output__descriptor, + allocator, len, data); +} +void convert_file_output__free_unpacked + (ConvertFileOutput *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &convert_file_output__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +static const ProtobufCFieldDescriptor convert_file_output__field_descriptors[1] = +{ + { + "Successful", + 1, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_BOOL, + offsetof(ConvertFileOutput, has_successful), + offsetof(ConvertFileOutput, successful), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned convert_file_output__field_indices_by_name[] = { + 0, /* field[0] = Successful */ +}; +static const ProtobufCIntRange convert_file_output__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 1 } +}; +const ProtobufCMessageDescriptor convert_file_output__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "ConvertFileOutput", + "ConvertFileOutput", + "ConvertFileOutput", + "", + sizeof(ConvertFileOutput), + 1, + convert_file_output__field_descriptors, + convert_file_output__field_indices_by_name, + 1, convert_file_output__number_ranges, + (ProtobufCMessageInit) convert_file_output__init, + NULL,NULL,NULL /* reserved[123] */ +}; diff --git a/Software/Visual_Studio/Embroidery/Tango.Embroidery/PMR/Embroidery/ConvertFileOutput.pb-c.h b/Software/Visual_Studio/Embroidery/Tango.Embroidery/PMR/Embroidery/ConvertFileOutput.pb-c.h new file mode 100644 index 000000000..c3714ce09 --- /dev/null +++ b/Software/Visual_Studio/Embroidery/Tango.Embroidery/PMR/Embroidery/ConvertFileOutput.pb-c.h @@ -0,0 +1,72 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: ConvertFileOutput.proto */ + +#ifndef PROTOBUF_C_ConvertFileOutput_2eproto__INCLUDED +#define PROTOBUF_C_ConvertFileOutput_2eproto__INCLUDED + +#include <protobuf-c/protobuf-c.h> + +PROTOBUF_C__BEGIN_DECLS + +#if PROTOBUF_C_VERSION_NUMBER < 1003000 +# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1003000 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +#endif + + +typedef struct _ConvertFileOutput ConvertFileOutput; + + +/* --- enums --- */ + + +/* --- messages --- */ + +struct _ConvertFileOutput +{ + ProtobufCMessage base; + protobuf_c_boolean has_successful; + protobuf_c_boolean successful; +}; +#define CONVERT_FILE_OUTPUT__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&convert_file_output__descriptor) \ + , 0, 0 } + + +/* ConvertFileOutput methods */ +void convert_file_output__init + (ConvertFileOutput *message); +size_t convert_file_output__get_packed_size + (const ConvertFileOutput *message); +size_t convert_file_output__pack + (const ConvertFileOutput *message, + uint8_t *out); +size_t convert_file_output__pack_to_buffer + (const ConvertFileOutput *message, + ProtobufCBuffer *buffer); +ConvertFileOutput * + convert_file_output__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void convert_file_output__free_unpacked + (ConvertFileOutput *message, + ProtobufCAllocator *allocator); +/* --- per-message closures --- */ + +typedef void (*ConvertFileOutput_Closure) + (const ConvertFileOutput *message, + void *closure_data); + +/* --- services --- */ + + +/* --- descriptors --- */ + +extern const ProtobufCMessageDescriptor convert_file_output__descriptor; + +PROTOBUF_C__END_DECLS + + +#endif /* PROTOBUF_C_ConvertFileOutput_2eproto__INCLUDED */ diff --git a/Software/Visual_Studio/Embroidery/Tango.Embroidery/Tango.Embroidery.vcxproj b/Software/Visual_Studio/Embroidery/Tango.Embroidery/Tango.Embroidery.vcxproj index a1b46dae7..691cefcdc 100644 --- a/Software/Visual_Studio/Embroidery/Tango.Embroidery/Tango.Embroidery.vcxproj +++ b/Software/Visual_Studio/Embroidery/Tango.Embroidery/Tango.Embroidery.vcxproj @@ -148,6 +148,8 @@ <ClInclude Include="Adapter.h" /> <ClInclude Include="PMR\Embroidery\AnalyzeInput.pb-c.h" /> <ClInclude Include="PMR\Embroidery\AnalyzeOutput.pb-c.h" /> + <ClInclude Include="PMR\Embroidery\ConvertFileInput.pb-c.h" /> + <ClInclude Include="PMR\Embroidery\ConvertFileOutput.pb-c.h" /> <ClInclude Include="PMR\Embroidery\EmbroideryFile.pb-c.h" /> <ClInclude Include="PMR\Embroidery\Extents.pb-c.h" /> <ClInclude Include="PMR\Embroidery\Stitch.pb-c.h" /> @@ -161,6 +163,8 @@ <ClCompile Include="Exports.cpp" /> <ClCompile Include="PMR\Embroidery\AnalyzeInput.pb-c.c" /> <ClCompile Include="PMR\Embroidery\AnalyzeOutput.pb-c.c" /> + <ClCompile Include="PMR\Embroidery\ConvertFileInput.pb-c.c" /> + <ClCompile Include="PMR\Embroidery\ConvertFileOutput.pb-c.c" /> <ClCompile Include="PMR\Embroidery\EmbroideryFile.pb-c.c" /> <ClCompile Include="PMR\Embroidery\Extents.pb-c.c" /> <ClCompile Include="PMR\Embroidery\Stitch.pb-c.c" /> diff --git a/Software/Visual_Studio/Embroidery/Tango.Embroidery/Tango.Embroidery.vcxproj.filters b/Software/Visual_Studio/Embroidery/Tango.Embroidery/Tango.Embroidery.vcxproj.filters index 22880e107..1a925e6e7 100644 --- a/Software/Visual_Studio/Embroidery/Tango.Embroidery/Tango.Embroidery.vcxproj.filters +++ b/Software/Visual_Studio/Embroidery/Tango.Embroidery/Tango.Embroidery.vcxproj.filters @@ -51,6 +51,12 @@ <ClInclude Include="PMR\Embroidery\AnalyzeOutput.pb-c.h"> <Filter>PMR</Filter> </ClInclude> + <ClInclude Include="PMR\Embroidery\ConvertFileInput.pb-c.h"> + <Filter>PMR</Filter> + </ClInclude> + <ClInclude Include="PMR\Embroidery\ConvertFileOutput.pb-c.h"> + <Filter>PMR</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="Adapter.cpp"> @@ -83,5 +89,11 @@ <ClCompile Include="Exports.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="PMR\Embroidery\ConvertFileInput.pb-c.c"> + <Filter>PMR</Filter> + </ClCompile> + <ClCompile Include="PMR\Embroidery\ConvertFileOutput.pb-c.c"> + <Filter>PMR</Filter> + </ClCompile> </ItemGroup> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryFileConverter.cs b/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryFileConverter.cs new file mode 100644 index 000000000..b4752f2a6 --- /dev/null +++ b/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryFileConverter.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using Tango.PMR; +using Tango.PMR.Embroidery; + +namespace Tango.EmbroideryUI +{ + public static class EmbroideryFileConverter + { + [DllImport("Tango.Embroidery.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConvertFile")] + public static extern int ConvertFile(IntPtr data, int size, ref IntPtr output); + + public static void ConvertEmbroideryFile(String sourceFile, String targetFile) + { + ConvertFileInput input = new ConvertFileInput(); + input.SourceFile = sourceFile; + input.TargetFile = targetFile; + + + NativePMR<ConvertFileInput, ConvertFileOutput> nativePMR = new NativePMR<ConvertFileInput, ConvertFileOutput>(ConvertFile); + ConvertFileOutput output = nativePMR.Invoke(input); + + if (!output.Successful) + { + throw new IOException("Error occurred in native embroidery library."); + } + } + } +} diff --git a/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/Tango.EmbroideryUI.csproj b/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/Tango.EmbroideryUI.csproj index d8de4fd64..9ef098618 100644 --- a/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/Tango.EmbroideryUI.csproj +++ b/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/Tango.EmbroideryUI.csproj @@ -56,6 +56,7 @@ </Page> </ItemGroup> <ItemGroup> + <Compile Include="EmbroideryFileConverter.cs" /> <Compile Include="EmbroideryFileEditor.xaml.cs"> <DependentUpon>EmbroideryFileEditor.xaml</DependentUpon> </Compile> |
