diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-01-01 17:28:19 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-01-01 17:28:19 +0200 |
| commit | 25f5e6ddef7ef2fa0a747305847eeb4ceee5a2c9 (patch) | |
| tree | 600a6623f866d48a522406b4d93e5f213d290c61 /Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressForm.h | |
| parent | 9a3114908dd0a4f61fc959ef0f352b2b6255a652 (diff) | |
| download | Tango-25f5e6ddef7ef2fa0a747305847eeb4ceee5a2c9.tar.gz Tango-25f5e6ddef7ef2fa0a747305847eeb4ceee5a2c9.zip | |
Added tango firmware update lib.
Diffstat (limited to 'Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressForm.h')
| -rw-r--r-- | Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressForm.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressForm.h b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressForm.h new file mode 100644 index 000000000..4953b7b15 --- /dev/null +++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressForm.h @@ -0,0 +1,88 @@ +#include "DFUMode.h" +#include <stdio.h> +#include "stdafx.h" +#include <stdlib.h> +#include <conio.h> +#include <windows.h> +#include "lmdfu.h" +#include "lmdfuwrap.h" +#include "DFUDevice.h" +#include "ProgressMode.h" + +#pragma once + +using namespace System::Windows::Forms; + +namespace Tango +{ + namespace FirmwareUpdateLib + { + ref class ProgressForm : + public Form + { + private: + ProgressMode _mode; + int _currentTotal; + bool _verified; + bool _verifiable; + ProgressCallbackDelegate^ _callback; + + void RaiseCallback(ProgressMode mode, int current, int total) + { + if (_callback != nullptr) + { + _callback(mode, current, total); + } + } + public: + ProgressForm(ProgressCallbackDelegate^ callback, bool verifiable) + { + _verifiable = verifiable; + _callback = callback; + }; + protected: virtual void WndProc(System::Windows::Forms::Message% m) override + { + switch (m.Msg) + { + case WM_DFU_DOWNLOAD: + _verified = !_verifiable; + _mode = ProgressMode::Uploading; + _currentTotal = (int)m.WParam; + RaiseCallback(_mode, 0, _currentTotal); + break; + case WM_DFU_UPLOAD: + _verified = true; + _mode = ProgressMode::Downloading; + _currentTotal = (int)m.WParam; + RaiseCallback(_mode, 0, _currentTotal); + break; + case WM_DFU_VERIFY: + _verified = true; + _mode = ProgressMode::Verifying; + _currentTotal = (int)m.WParam; + RaiseCallback(_mode, 0, _currentTotal); + break; + case WM_DFU_COMPLETE: + if (_verified) + { + _mode = ProgressMode::Completed; + _currentTotal = (int)m.WParam; + RaiseCallback(_mode, 0, _currentTotal); + } + break; + case WM_DFU_ERROR: + _mode = ProgressMode::Error; + _currentTotal = (int)m.WParam; + RaiseCallback(_mode, 0, _currentTotal); + break; + case WM_DFU_PROGRESS: + RaiseCallback(_mode, (int)m.WParam, _currentTotal); + break; + } + + Form::WndProc(m); + } + }; + } +} + |
