#include "minimcswidget.h"
#include "ui_minimcswidget.h"

#include "qg1553overudp.h"
#include "qgscopedevice.h"

#include "th_b1553_icd.h"

static Qg1553OverUdp* b1553;

MiniMcsWidget::MiniMcsWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MiniMcsWidget)
{
    ui->setupUi(this);

    b1553=new Qg1553OverUdp;

    connect(ui->tbSTBY, &QToolButton::toggled, ui->actionSTBY,
            [this](bool checked)
            {
                ui->actionSTBY->setChecked(checked);
            }
        );
/*
    connect(ui->actionSTBY, &QAction::toggled, ui->tbSTBY,
            [this](bool checked)
            {
                ui->tbSTBY->setChecked(checked);
            }
        );
*/
    connect(ui->actionSTBY, &QAction::toggled, this,
            [this](bool checked)
            {
                ui->tbSTBY->setChecked(checked);

                icd1553::msg_rdr_operation_command_t* msg=reinterpret_cast<icd1553::msg_rdr_operation_command_t*>(b1553->getBuffer(2));
                msg->rdr_mode_command.master_mode.set(icd1553::RWS);
            }
        );
}

MiniMcsWidget::~MiniMcsWidget()
{
    delete ui;
}

QgScopeDevice* MiniMcsWidget::scopeDevice()
{
    return b1553;
}
