#pragma once #include "GetPelCommand.h" #include "UsbDeviceManager.h" namespace Incart::DeviceComplexCommands { class MicroMonGetPelCommand : public GetPelCommand { private: Usb::UsbDeviceManager* m_usbDeviceManager; public: MicroMonGetPelCommand(uint32_t uid, Usb::UsbDeviceManager* deviceManager) : GetPelCommand(uid) , m_usbDeviceManager(deviceManager) { } public: std::shared_ptr execute() override { std::vector commandBytes; Usb::ByteCommandQueue* commandQueue = m_usbDeviceManager->getCommandQueue(); std::shared_ptr commandInfo = std::make_shared("ReadReoAndPel", commandQueue->generateUid(), std::vector()); m_usbDeviceManager->getCommandSet()->createCommandBytes(commandInfo, commandBytes); std::shared_ptr readReoPelCommand = std::make_shared(commandInfo->name, commandInfo->uid, commandBytes); connect(readReoPelCommand.get(), &Usb::ByteCommand::answerIsReady, this, &MicroMonGetPelCommand::handleReadReoPelAnswerIsReady); commandQueue->enqueue(readReoPelCommand); return std::make_shared(Usb::DeviceCommand::EStatus::OK); } private slots: void handleReadReoPelAnswerIsReady(std::shared_ptr /*command*/, std::vector answer, int32_t status) { if (status != Usb::DeviceCommand::EStatus::OK) { emit answerIsReady(this, false, Usb::DeviceCommandStatusCreator::create(answer, status)); return; } m_usbDeviceManager->setIsReoOn(answer[5] == 1); emit answerIsReady(this, answer[6] == 1, std::make_shared(Usb::DeviceCommand::EStatus::OK)); } }; } // namespace Incart::DeviceComplexCommands