#pragma once #include "UsbDeviceManager.h" #include "SetProgIdCommand.h" #include "SetDataToEepromCommand.h" #include "EepromDataRecord.h" #include "EEeramVersion9Address.h" #include "ComplexCommandCreateMultidata.h" namespace Incart::DeviceComplexCommands { class MicroMonSetProgIdCommand final : public SetProgIdCommand { private: uint8_t m_progId; Usb::UsbDeviceCommandSet* const m_deviceCommands; Usb::ByteCommandQueue* const m_commandQueue; public: MicroMonSetProgIdCommand(uint32_t uid, uint8_t progId_, Usb::UsbDeviceManager* const deviceManager) : SetProgIdCommand(uid) , m_progId(progId_), m_deviceCommands(deviceManager->getCommandSet()), m_commandQueue(deviceManager->getCommandQueue()) { } public: std::shared_ptr execute() override { std::vector commandDataBytes = { m_progId, static_cast(~m_progId) }; std::shared_ptr commandData = std::make_shared>(m_commandQueue->generateUid(), EepromDataRecord{ static_cast(EEeramVersion9Address::ProgId), commandDataBytes }); std::shared_ptr command = std::dynamic_pointer_cast(m_deviceCommands->createComplexCommand("SetDataToEeprom", commandData)); addExecutedInnerCommand(command); connect(command.get(), &SetDataToEepromCommand::answerIsReady, this, &MicroMonSetProgIdCommand::handleSetDataToEepromIsReady); return executeCommand(command); } private slots: void handleSetDataToEepromIsReady(Usb::ComplexCommand* command_, std::shared_ptr status_) { removeExecutedInnerCommand(command_); emit answerIsReady(this, status_); } }; } // namespace Incart::DeviceComplexCommands