#pragma once #include "ComplexCommand.h" #include "ByteCommandQueue.h" #include "CheckSpecialFirmwareExistCommand.h" namespace Incart::DeviceComplexCommands { class MicroMonCheckSpecialFirmwareExistCommand final : public CheckSpecialFirmwareExistCommand { private: Usb::ByteCommandQueue* const m_commandQueue; public: MicroMonCheckSpecialFirmwareExistCommand(uint32_t uid, Usb::ByteCommandQueue* const commandQueue) : CheckSpecialFirmwareExistCommand(uid), m_commandQueue(commandQueue) { } public: std::shared_ptr execute() override { //JTerminal() << __PRETTY_FUNCTION__; std::shared_ptr command = std::make_shared("CheckSpecialFirmwareExist", m_commandQueue->generateUid(), std::vector{ 0x7e, 0x01, 0x00, 0x1e, 0x01, 0xff, 0xff, 0xbd }); connect(command.get(), &Usb::ByteCommand::answerIsReady, this, &MicroMonCheckSpecialFirmwareExistCommand::handleAnswerIsReady); m_commandQueue->enqueue(command); return std::make_shared(Usb::DeviceCommand::EStatus::OK); } private slots: void handleAnswerIsReady(std::shared_ptr /*command*/, std::vector answer, int32_t status) { bool isExist = false; std::shared_ptr statusInfo; if (status != Usb::DeviceCommand::EStatus::OK) { statusInfo = Usb::DeviceCommandStatusCreator::create(answer, status); } else if (answer.size() != 9) { statusInfo = std::make_shared>>(Usb::DeviceCommand::EStatus::WRONG_FRAME_FORMAT, answer); } else { isExist = (uint32_t)answer[5] == 1; statusInfo = std::make_shared(Usb::DeviceCommand::EStatus::OK); } emit answerIsReady(this, isExist, statusInfo); } }; } // namespace Incart::DeviceComplexCommands