From 2b8e41b5279c2d3ab370595f6593b64ea734ef87 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 4 Mar 2018 15:28:15 +0200 Subject: Implemented job embroidery image capture, display export, Implemented running job text to speech. --- .../Embroidery/Tango.Embroidery/Adapter.cpp | 32 +++ .../Embroidery/Tango.Embroidery/Adapter.h | 4 + .../Embroidery/Tango.Embroidery/Exports.cpp | 6 + .../PMR/Embroidery/ConvertFileInput.pb-c.c | 105 +++++++++ .../PMR/Embroidery/ConvertFileInput.pb-c.h | 72 ++++++ .../PMR/Embroidery/ConvertFileOutput.pb-c.c | 92 ++++++++ .../PMR/Embroidery/ConvertFileOutput.pb-c.h | 72 ++++++ .../Tango.Embroidery/Tango.Embroidery.vcxproj | 4 + .../Tango.Embroidery.vcxproj.filters | 12 + .../Tango.EmbroideryUI/EmbroideryFileConverter.cs | 34 +++ .../Tango.EmbroideryUI/Tango.EmbroideryUI.csproj | 1 + .../Modules/Tango.MachineStudio.DB/DBModule.cs | 1 + .../DataCaptureModule.cs | 1 + .../Converters/ByteArrayToBitmapSourceConverter.cs | 29 +++ .../DeveloperModule.cs | 1 + .../Images/job-emb.png | Bin 0 -> 1626 bytes .../Tango.MachineStudio.Developer.csproj | 17 ++ .../ViewModels/EmbroideryDisplayViewVM.cs | 38 ++++ .../ViewModels/MainViewVM.cs | 98 ++++++++- .../Views/EmbroideryDisplayView.xaml | 51 +++++ .../Views/EmbroideryDisplayView.xaml.cs | 28 +++ .../Views/EmbroideryImportView.xaml | 2 +- .../Views/EmbroideryImportView.xaml.cs | 9 + .../Views/JobView.xaml | 4 +- .../Views/MachineJobSelectionView.xaml | 25 ++- .../Views/MainView.xaml | 4 +- .../Modules/Tango.MachineStudio.Developer/bip.wav | Bin 0 -> 161420 bytes .../HardwareDesignerModule.cs | 1 + .../MachineDesignerModule.cs | 1 + .../Tango.MachineStudio.Stubs/StubsModule.cs | 1 + .../SynchronizationModule.cs | 1 + .../TechnicianModule.cs | 1 + .../ExtensionMethods/CommonDialogExtensions.cs | 15 ++ .../Tango.MachineStudio.Common/IStudioModule.cs | 1 + .../Notifications/INotificationProvider.cs | 11 + .../Tango.MachineStudio.Common/StudioModuleBase.cs | 1 + .../Tango.MachineStudio.Common.csproj | 1 + .../DefaultAuthenticationProvider.cs | 1 + .../Notifications/DefaultNotificationProvider.cs | 50 +++++ .../MachineStudioUpdateService.svc.cs | 1 + .../Tango.BL/Dispensing/DispensingCalcAttribute.cs | 1 + .../Tango.BL/Dispensing/DispensingCalcResolver.cs | 1 + .../Tango.BL/Dispensing/LubricantDispensingCalc.cs | 1 + .../Dispensing/StandardColorDispensingCalc.cs | 1 + .../Dispensing/TransparentLiquidDispensingCalc.cs | 1 + Software/Visual_Studio/Tango.BL/Entities/Job.cs | 80 +++++++ .../Tango.BL/Enumerations/ActionTypes.cs | 2 +- .../Tango.BL/Enumerations/CartridgeTypes.cs | 2 +- .../Tango.BL/Enumerations/ColorSpaces.cs | 2 +- .../Tango.BL/Enumerations/DispenserTypes.cs | 2 +- .../Tango.BL/Enumerations/EventTypes.cs | 2 +- .../Tango.BL/Enumerations/FiberShapes.cs | 2 +- .../Tango.BL/Enumerations/FiberSynths.cs | 2 +- .../Tango.BL/Enumerations/HardwareDancerTypes.cs | 2 +- .../Tango.BL/Enumerations/HardwareMotorTypes.cs | 2 +- .../Enumerations/HardwarePidControlTypes.cs | 2 +- .../Tango.BL/Enumerations/HardwareWinderTypes.cs | 2 +- .../Tango.BL/Enumerations/IdsPackFormulas.cs | 2 +- .../Enumerations/LinearMassDensityUnits.cs | 2 +- .../Tango.BL/Enumerations/LiquidTypes.cs | 2 +- .../Tango.BL/Enumerations/MediaConditions.cs | 2 +- .../Tango.BL/Enumerations/MediaMaterials.cs | 2 +- .../Tango.BL/Enumerations/MediaPurposes.cs | 2 +- .../Tango.BL/Enumerations/MidTankTypes.cs | 2 +- .../Tango.BL/Enumerations/Permissions.cs | 2 +- .../Visual_Studio/Tango.BL/Enumerations/Rmls.cs | 2 +- .../Visual_Studio/Tango.BL/Enumerations/Roles.cs | 2 +- .../Tango.BL/Enumerations/SpoolTypes.cs | 2 +- .../Tango.BL/Enumerations/TechDispensers.cs | 2 +- .../Tango.BL/Enumerations/TechHeaters.cs | 2 +- .../Visual_Studio/Tango.BL/Enumerations/TechIos.cs | 2 +- .../Tango.BL/Enumerations/TechMonitors.cs | 2 +- .../Tango.BL/Enumerations/TechMotors.cs | 2 +- .../Tango.BL/Enumerations/TechValves.cs | 2 +- .../Tango.BL/Enumerations/WindingMethods.cs | 2 +- .../Visual_Studio/Tango.BL/ObservablesContext.cs | 10 - .../Tango.BL/ObservablesContextExtension.cs | 10 + .../Tango.BL/ObservablesExtensions/BrushStop.cs | 3 +- .../Tango.BL/ObservablesExtensions/User.cs | 1 + .../Templates/ObservablesContextCodeFile.cshtml | 10 - .../ExtensionMethods/BitmapSourceExtensions.cs | 242 +++++++++++++++++++++ .../Tango.Core/Helpers/EmbeddedResourceHelper.cs | 19 ++ .../Visual_Studio/Tango.Core/Tango.Core.csproj | 3 + Software/Visual_Studio/Tango.DAL.Remote/DB/JOB.cs | 4 + .../Tango.DAL.Remote/DB/RemoteADO.edmx | 12 + .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 132 +++++------ .../Tango.PMR/Embroidery/ConvertFileInput.cs | 188 ++++++++++++++++ .../Tango.PMR/Embroidery/ConvertFileOutput.cs | 159 ++++++++++++++ .../Visual_Studio/Tango.PMR/ExtensionMethods.cs | 2 +- Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj | 2 + 90 files changed, 1631 insertions(+), 137 deletions(-) create mode 100644 Software/Visual_Studio/Embroidery/Tango.Embroidery/PMR/Embroidery/ConvertFileInput.pb-c.c create mode 100644 Software/Visual_Studio/Embroidery/Tango.Embroidery/PMR/Embroidery/ConvertFileInput.pb-c.h create mode 100644 Software/Visual_Studio/Embroidery/Tango.Embroidery/PMR/Embroidery/ConvertFileOutput.pb-c.c create mode 100644 Software/Visual_Studio/Embroidery/Tango.Embroidery/PMR/Embroidery/ConvertFileOutput.pb-c.h create mode 100644 Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryFileConverter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/ByteArrayToBitmapSourceConverter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/job-emb.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/EmbroideryDisplayViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryDisplayView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryDisplayView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/bip.wav create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/CommonDialogExtensions.cs create mode 100644 Software/Visual_Studio/Tango.Core/ExtensionMethods/BitmapSourceExtensions.cs create mode 100644 Software/Visual_Studio/Tango.Core/Helpers/EmbeddedResourceHelper.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Embroidery/ConvertFileInput.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Embroidery/ConvertFileOutput.cs (limited to 'Software/Visual_Studio') 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__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__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 @@ + + @@ -161,6 +163,8 @@ + + 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 @@ PMR + + PMR + + + PMR + @@ -83,5 +89,11 @@ Source Files + + PMR + + + PMR + \ 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 nativePMR = new NativePMR(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 @@ + EmbroideryFileEditor.xaml diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs index 01cbee209..b53f28bd4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Media.Imaging; using Tango.BL.Entities; +using Tango.BL.Enumerations; using Tango.MachineStudio.Common; using Tango.MachineStudio.DB.Views; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/DataCaptureModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/DataCaptureModule.cs index f3bdb974e..38e82257f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/DataCaptureModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/DataCaptureModule.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Media.Imaging; using Tango.BL.Entities; +using Tango.BL.Enumerations; using Tango.MachineStudio.Common; using Tango.MachineStudio.DataCapture.Views; using Tango.SharedUI.Helpers; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/ByteArrayToBitmapSourceConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/ByteArrayToBitmapSourceConverter.cs new file mode 100644 index 000000000..d839b0060 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/ByteArrayToBitmapSourceConverter.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace Tango.MachineStudio.Developer.Converters +{ + public class ByteArrayToBitmapSourceConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + byte[] bytes = value as byte[]; + if (bytes != null) + { + return bytes.ToBitmapSource(); + } + + return value; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs index 0dc35e3bf..9ac8de012 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Media.Imaging; using Tango.BL.Entities; +using Tango.BL.Enumerations; using Tango.MachineStudio.Common; using Tango.MachineStudio.Developer.Views; using Tango.SharedUI.Helpers; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/job-emb.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/job-emb.png new file mode 100644 index 000000000..15f9c73bb Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/job-emb.png differ 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 7bf4d22cd..378fb443b 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 @@ -67,6 +67,7 @@ + ..\..\..\packages\System.Reactive.Core.3.1.1\lib\net46\System.Reactive.Core.dll @@ -82,6 +83,7 @@ ..\..\..\packages\System.Reactive.Windows.Threading.3.1.1\lib\net45\System.Reactive.Windows.Threading.dll + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll @@ -105,6 +107,7 @@ + @@ -120,8 +123,12 @@ + + + EmbroideryDisplayView.xaml + EmbroideryImportView.xaml @@ -141,6 +148,10 @@ RunningJobView.xaml + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -336,5 +347,11 @@ + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/EmbroideryDisplayViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/EmbroideryDisplayViewVM.cs new file mode 100644 index 000000000..74cb2ffa6 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/EmbroideryDisplayViewVM.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.Core.Commands; +using Tango.MachineStudio.Common.Notifications; +using Tango.SharedUI; + +namespace Tango.MachineStudio.Developer.ViewModels +{ + public class EmbroideryDisplayViewVM : DialogViewVM + { + private Job _job; + + public Job Job + { + get { return _job; } + set { _job = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand ExportCommand { get; set; } + + public EmbroideryDisplayViewVM() + { + ExportCommand = new RelayCommand(() => + { + Accept(); + }); + } + + public EmbroideryDisplayViewVM(Job job) : this() + { + Job = job; + } + } +} 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 c265c7d25..76fe33a87 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 @@ -28,6 +28,11 @@ using Tango.BL; using Microsoft.Win32; using Tango.PMR.Embroidery; using Tango.EmbroideryUI; +using System.IO; +using System.Windows; +using Tango.Core.Helpers; +using System.Speech.Synthesis; +using System.Media; namespace Tango.MachineStudio.Developer.ViewModels { @@ -38,7 +43,8 @@ namespace Tango.MachineStudio.Developer.ViewModels public class MainViewVM : ViewModel, IShutdownRequestBlocker, IShutdownListener { private static object _syncLock = new object(); - private const string EMB_FORMATS = "Embroidery Files|*.pes;*.hus"; + private const string EMB_FORMATS_EXPORT = "Baby Lock (PES)|*.pes|Tajima (DST)|*.dst|EXP|*.exp|PCS|*.pcs|HUS|*.hus|KSM|*.ksm"; + private const string EMB_FORMATS_IMPORT = "Embroidery Files|*.pes;*.hus;*.dst"; private INotificationProvider _notification; private TimeSpan _runningJobEstimatedDuration; @@ -49,6 +55,8 @@ namespace Tango.MachineStudio.Developer.ViewModels private ObservablesContext _machineDbContext; private ObservablesContext _activeJobDbContext; private LogManager LogManager = LogManager.Default; + private SpeechSynthesizer _speech; + private SoundPlayer _soundPlayer; #region Properties @@ -577,6 +585,10 @@ namespace Tango.MachineStudio.Developer.ViewModels /// public RelayCommand ImportEmbroideryFileCommand { get; set; } + /// + /// Gets or sets the display job embroidery file command. + /// + public RelayCommand DisplayJobEmbroideryFileCommand { get; set; } #endregion #region Constructors @@ -625,6 +637,10 @@ namespace Tango.MachineStudio.Developer.ViewModels LogManager.Log("Initializing relay commands..."); + _speech = new SpeechSynthesizer(); + _soundPlayer = new SoundPlayer(EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.MachineStudio.Developer.bip.wav")); + _speech.SelectVoice(_speech.GetInstalledVoices().LastOrDefault(x => x.VoiceInfo.Gender == VoiceGender.Female).VoiceInfo.Name); + //Initialize Commands... EditMachineCommand = new RelayCommand(EditMachine, () => SelectedMachine != null); EditRMLCommand = new RelayCommand(EditRML, () => SelectedRML != null); @@ -648,6 +664,7 @@ namespace Tango.MachineStudio.Developer.ViewModels SaveProcessParametersCommand = new RelayCommand(SaveProcessParameters, () => SelectedRML != null && SelectedRML.ProcessParametersTablesGroups.Count > 0); PushProcessParametersCommand = new RelayCommand(PushProcessParameters, () => SelectedRML != null && SelectedRML.ProcessParametersTablesGroups.Count > 0 && SelectedProcessParametersTable != null && MachineOperator != null); ImportEmbroideryFileCommand = new RelayCommand(ImportEmbroideryFile, () => SelectedMachine != null); + DisplayJobEmbroideryFileCommand = new RelayCommand(DisplayJobEmbroideryFile); ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; } @@ -891,6 +908,9 @@ namespace Tango.MachineStudio.Developer.ViewModels LogManager.Log("Setting job failed state..."); IsJobRunning = false; IsJobFailed = true; + + _soundPlayer.Play(); + _speech.SpeakAsync("Job Failed!"); } /// @@ -901,6 +921,8 @@ namespace Tango.MachineStudio.Developer.ViewModels LogManager.Log("Setting job completed state..."); IsJobRunning = false; IsJobCompleted = true; + _soundPlayer.Play(); + _speech.SpeakAsync("Job Completed!"); } /// @@ -958,12 +980,27 @@ namespace Tango.MachineStudio.Developer.ViewModels } if (remaining < segmentDuration) { - segment.Started = true; + if (!segment.Started) + { + segment.Started = true; + _soundPlayer.Play(); + + if (segment.ID != -1) + { + _speech.SpeakAsync(String.Format("Segment {0} Started.", segment.SegmentIndex)); + } + else + { + _speech.SpeakAsync(String.Format("Inter Segment Started.")); + } + } } if (remaining <= TimeSpan.Zero) { - segment.Completed = true; - segment.Started = false; + if (!segment.Completed) + { + segment.Completed = true; + } } } }; @@ -1020,6 +1057,7 @@ namespace Tango.MachineStudio.Developer.ViewModels segments.Add(new Segment() { Length = job.InterSegmentLength, + ID = -1, BrushStops = new System.Collections.ObjectModel.ObservableCollection() { new BrushStop() @@ -1588,18 +1626,20 @@ namespace Tango.MachineStudio.Developer.ViewModels { OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Select embroidery file"; - dlg.Filter = EMB_FORMATS; - if (dlg.ShowDialog().Value) + dlg.Filter = EMB_FORMATS_IMPORT; + if (dlg.ShowDialogCenter()) { + var view = new EmbroideryImportView(); + _notification.ShowModalDialog( - new EmbroideryImportViewVM() { FileName = dlg.FileName }, + new EmbroideryImportViewVM() { FileName = dlg.FileName }, view, (vm) => { String jobName = _notification.ShowTextInput("Please provide a job name", "Name"); if (jobName != null) { - AddJobFromEmbroideryFile(jobName, vm.Paths.ToList(), vm.EmbroideryFile); + AddJobFromEmbroideryFile(jobName, vm.Paths.ToList(), vm.EmbroideryFile, dlg.FileName, view.EmbroideryImageBytes); } }, () => @@ -1609,7 +1649,7 @@ namespace Tango.MachineStudio.Developer.ViewModels } } - private async void AddJobFromEmbroideryFile(String jobName, List paths, EmbroideryFile embroideryFile) + private async void AddJobFromEmbroideryFile(String jobName, List paths, EmbroideryFile embroideryFile, String fileName, byte[] imageBytes) { LogManager.Log(String.Format("Adding new job from embroidery file {0}...", jobName)); @@ -1623,12 +1663,17 @@ namespace Tango.MachineStudio.Developer.ViewModels job.SpoolType = _machineDbContext.SpoolTypes.FirstOrDefault(); job.Machine = SelectedMachine; + job.EmbroideryFileName = Path.GetFileName(fileName); + job.EmbroideryFileData = File.ReadAllBytes(fileName); + job.EmbroideryJpeg = imageBytes; + job.HasEmbroideryFile = true; + foreach (var path in paths.Skip(1)) { Segment segment = new Segment(); segment.Length = path.Length / 1000d; segment.Name = "Embroidery Segment"; - segment.SegmentIndex = paths.IndexOf(path) + 1; + segment.SegmentIndex = paths.IndexOf(path) + 2; if (path.Brush is SolidColorBrush) { @@ -1639,7 +1684,7 @@ namespace Tango.MachineStudio.Developer.ViewModels Red = brush.Color.R, Green = brush.Color.G, Blue = brush.Color.B, - ColorSpace = _machineDbContext.ColorSpaces.ToList().SingleOrDefault(x => x.Code == BL.Entities.ColorSpaces.RGB.ToInt32()), + ColorSpace = _machineDbContext.ColorSpaces.ToList().SingleOrDefault(x => x.Code == BL.Enumerations.ColorSpaces.RGB.ToInt32()), }); } else @@ -1655,7 +1700,7 @@ namespace Tango.MachineStudio.Developer.ViewModels Green = stop.Color.G, Blue = stop.Color.B, OffsetPercent = stop.Offset, - ColorSpace = _machineDbContext.ColorSpaces.ToList().SingleOrDefault(x => x.Code == BL.Entities.ColorSpaces.RGB.ToInt32()), + ColorSpace = _machineDbContext.ColorSpaces.ToList().SingleOrDefault(x => x.Code == BL.Enumerations.ColorSpaces.RGB.ToInt32()), }); } } @@ -1670,6 +1715,35 @@ namespace Tango.MachineStudio.Developer.ViewModels LoadSelectedJob(); } + private void DisplayJobEmbroideryFile(Job job) + { + _notification.ShowModalDialog(new EmbroideryDisplayViewVM(job), (vm) => + { + + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Title = "Select embroidery file location and format"; + dlg.Filter = EMB_FORMATS_EXPORT; + dlg.FileName = job.EmbroideryFileName; + if (dlg.ShowDialogCenter()) + { + try + { + String tempPath = PathHelper.GetTempFolderPath(); + String filePath = Path.Combine(tempPath, job.EmbroideryFileName); + File.WriteAllBytes(filePath, job.EmbroideryFileData); + EmbroideryFileConverter.ConvertEmbroideryFile(filePath, dlg.FileName); + _notification.ShowInfo("Embroidery file exported successfully."); + } + catch (Exception ex) + { + LogManager.Log(ex, "An error has occurred while trying to export the attached embroidery file."); + _notification.ShowError("An error has occurred while trying to export the attached embroidery file."); + } + } + + }, () => { }); + } + #endregion #region Override Methods diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryDisplayView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryDisplayView.xaml new file mode 100644 index 000000000..a753453f9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryDisplayView.xaml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryDisplayView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryDisplayView.xaml.cs new file mode 100644 index 000000000..7d0771098 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryDisplayView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.Developer.Views +{ + /// + /// Interaction logic for EmbroideryDisplayView.xaml + /// + public partial class EmbroideryDisplayView : UserControl + { + public EmbroideryDisplayView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml index 220e7d3ab..d084aabcf 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml @@ -47,7 +47,7 @@ - public partial class EmbroideryImportView : UserControl { + public byte[] EmbroideryImageBytes { get; set; } + public EmbroideryImportView() { InitializeComponent(); } + + private void OnImportClick(object sender, RoutedEventArgs e) + { + var source = UIHelper.TakeSnapshot(editor); + EmbroideryImageBytes = source.ToJpegBytes(50); + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml index 9ba41f688..1dea01de7 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml @@ -438,13 +438,13 @@ - -