#pragma once #include "JsonCommandStatus.h" #include "EDeviceCommandStatus.h" #include "DeviceCommandStatusConverter.h" #include "DeviceCommandStatusInfo.h" #include #include namespace Incart::DeviceWebApi { struct JsonCommandStatusCreator { static std::shared_ptr create(Usb::DeviceCommand::EStatus status, const std::vector& answer) { if (status != Usb::DeviceCommand::EStatus::OK) { std::string errorText = Usb::DeviceCommandStatusConverter::toText(status); if (status == Usb::DeviceCommand::EStatus::WRONG_FRAME_FORMAT) { return std::make_shared>>(errorText, answer); } return std::make_shared(errorText); } return std::make_shared(); } static std::shared_ptr create(Usb::DeviceCommand::EStatus status) { if (status != Usb::DeviceCommand::EStatus::OK) { return std::make_shared(Usb::DeviceCommandStatusConverter::toText(status)); } return std::make_shared(); } static std::shared_ptr create(std::shared_ptr status) { if (status->status != Usb::DeviceCommand::EStatus::OK) { std::string errorText = Usb::DeviceCommandStatusConverter::toText(status->status); if (status->status == Usb::DeviceCommand::EStatus::WRONG_FRAME_FORMAT) { std::shared_ptr>> wrongFrameStatus = std::dynamic_pointer_cast>>(status); return std::make_shared>>(errorText, wrongFrameStatus->info); } return std::make_shared(errorText); } return std::make_shared(); } }; } // namespace Incart::DeviceWebApi