#include "realman_hw_test_common.hpp"

#include <cstring>

int main() {
    using namespace realman_hw_test;

    TestSuite suite("realman_hw_connection");
    RobotSession session(&suite);
    if (!session.connect()) {
        return suite.finish();
    }

    suite.info("api_version", rm_api_version());

    rm_robot_info_t info = {};
    if (readRobotInfo(session.handle(), &info, &suite)) {
        validateDof(static_cast<int>(info.arm_dof), &suite);
        suite.expect(info.force_type == RM_MODEL_RM_ISF_E,
                     "expected_integrated_6d_force",
                     std::string("actual=") + forceTypeName(info.force_type));
        suite.expect(info.robot_controller_version == 3 || info.robot_controller_version == 4,
                     "controller_generation_valid",
                     "actual=" + std::to_string(static_cast<int>(info.robot_controller_version)));
    }

    rm_arm_software_version_t software = {};
    const int software_result = rm_get_arm_software_info(session.handle(), &software);
    suite.expect(software_result == 0, "rm_get_arm_software_info", "error=" + std::to_string(software_result));
    if (software_result == 0) {
        suite.info("product_version", software.product_version);
        suite.expect(std::strlen(software.product_version) > 0,
                     "product_version_not_empty",
                     software.product_version);
    }

    return suite.finish();
}
