#pragma once #include "ComplexCommand.h" #include "ByteCommandQueue.h" #include "ReadEcgModeCommand.h" #include "ByteArrayProvider.h" #include "MicroMonEcgModeConverter.h" namespace Incart::DeviceComplexCommands { class MicroMonReadEcgModeCommand : public Usb::ReadEcgModeCommand { private: Usb::ByteCommandQueue* m_commandQueue; public: MicroMonReadEcgModeCommand(uint32_t uid, Usb::ByteCommandQueue* commandQueue) : Usb::ReadEcgModeCommand(uid) , m_commandQueue(commandQueue) { } public: std::shared_ptr execute() override { //JTerminal() << __PRETTY_FUNCTION__; std::shared_ptr command = std::make_shared("ReadEcgMode", m_commandQueue->generateUid(), std::vector{ 0x7e, 0x02, 0x00, 0x10, 0x00, 0x00, 0xff, 0xff, 0xbd }); connect(command.get(), &Usb::ByteCommand::answerIsReady, this, &MicroMonReadEcgModeCommand::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) { Usb::UsbDevice::EEcgMode cableMode = Usb::UsbDevice::EEcgMode::NoEcg; std::shared_ptr statusInfo; if (status != Usb::DeviceCommand::EStatus::OK) { statusInfo = Usb::DeviceCommandStatusCreator::create(answer, status); } else if (answer.size() != 8) { statusInfo = std::make_shared>>(Usb::DeviceCommand::EStatus::WRONG_FRAME_FORMAT, answer); } else { cableMode = MicroMonEcgModeConverter::toCableMode((uint8_t)answer[4]); statusInfo = std::make_shared(Usb::DeviceCommand::EStatus::OK); } emit answerIsReady(this, cableMode, statusInfo); } }; } // namespace Incart::DeviceComplexCommands