Ref T609, UI to set Tx/Receive for COM unit in emulated driver

This commit is contained in:
Klaus Basan
2019-08-02 01:04:19 +02:00
committed by Mat Sutcliffe
parent b60f84244b
commit 3275d97653
4 changed files with 337 additions and 17 deletions

View File

@@ -0,0 +1,88 @@
/* Copyright (C) 2019
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
* or distributed except according to the terms contained in the LICENSE file.
*/
#include "cockpitcomtransmissioncomponent.h"
#include "ui_cockpitcomtransmissioncomponent.h"
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Simulation;
namespace BlackGui
{
namespace Components
{
CCockpitComTransmissionComponent::CCockpitComTransmissionComponent(QWidget *parent) :
QFrame(parent),
ui(new Ui::CCockpitComTransmissionComponent)
{
ui->setupUi(this);
connect(ui->pb_Com1Save, &QPushButton::released, this, &CCockpitComTransmissionComponent::onSave);
connect(ui->pb_Com2Save, &QPushButton::released, this, &CCockpitComTransmissionComponent::onSave);
}
CCockpitComTransmissionComponent::~CCockpitComTransmissionComponent()
{
// void
}
void CCockpitComTransmissionComponent::updateComSystem(CComSystem &comSystem, CComSystem::ComUnit comUnit) const
{
switch (comUnit)
{
case CComSystem::Com1:
comSystem.setVolumeReceive(ui->sb_Com1VolumeRec->value());
comSystem.setVolumeTransmit(ui->sb_Com1VolumeTx->value());
comSystem.setTransmitEnabled(ui->cb_Com1Tx->isChecked());
comSystem.setReceiveEnabled(ui->cb_Com1Rec->isChecked());
break;
case CComSystem::Com2:
comSystem.setVolumeReceive(ui->sb_Com2VolumeRec->value());
comSystem.setVolumeTransmit(ui->sb_Com2VolumeTx->value());
comSystem.setTransmitEnabled(ui->cb_Com2Tx->isChecked());
comSystem.setReceiveEnabled(ui->cb_Com2Rec->isChecked());
break;
default:
break;
}
}
void CCockpitComTransmissionComponent::setComSystem(const CComSystem &comSystem, CComSystem::ComUnit comUnit)
{
switch (comUnit)
{
case CComSystem::Com1:
ui->sb_Com1VolumeRec->setValue(comSystem.getVolumeReceive());
ui->sb_Com1VolumeTx->setValue(comSystem.getVolumeTransmit());
ui->cb_Com1Tx->setChecked(comSystem.isTransmitEnabled());
ui->cb_Com1Rec->setChecked(comSystem.isReceiveEnabled());
break;
case CComSystem::Com2:
ui->sb_Com2VolumeRec->setValue(comSystem.getVolumeReceive());
ui->sb_Com2VolumeTx->setValue(comSystem.getVolumeTransmit());
ui->cb_Com2Tx->setChecked(comSystem.isTransmitEnabled());
ui->cb_Com2Rec->setChecked(comSystem.isReceiveEnabled());
break;
default:
break;
}
}
void CCockpitComTransmissionComponent::setComSystems(const CSimulatedAircraft &aircraft)
{
this->setComSystem(aircraft.getCom1System(), CComSystem::Com1);
this->setComSystem(aircraft.getCom2System(), CComSystem::Com2);
}
void CCockpitComTransmissionComponent::onSave()
{
const QObject *s = QObject::sender();
const CComSystem::ComUnit unit = (s == ui->pb_Com2Save) ? CComSystem::Com2 : CComSystem::Com1;
emit this->changedValues(unit);
}
} // ns
} // ns

View File

@@ -0,0 +1,59 @@
/* Copyright (C) 2019
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
* or distributed except according to the terms contained in the LICENSE file.
*/
//! \file
#ifndef BLACKGUI_COMPONENTS_COCKPITCOMPONENTTRANSMISSION_H
#define BLACKGUI_COMPONENTS_COCKPITCOMPONENTTRANSMISSION_H
#include "blackmisc/simulation/simulatedaircraft.h"
#include "blackmisc/aviation/comsystem.h"
#include "blackgui/blackguiexport.h"
#include <QFrame>
#include <QScopedPointer>
namespace Ui { class CCockpitComTransmissionComponent; }
namespace BlackGui
{
namespace Components
{
//! Transmission for COM units
class BLACKGUI_EXPORT CCockpitComTransmissionComponent : public QFrame
{
Q_OBJECT
public:
//! Constructor
explicit CCockpitComTransmissionComponent(QWidget *parent = nullptr);
//! Destructor
virtual ~CCockpitComTransmissionComponent() override;
//! Update given COM system
void updateComSystem(BlackMisc::Aviation::CComSystem &comSystem, BlackMisc::Aviation::CComSystem::ComUnit comUnit) const;
//! Set values of given COM system
void setComSystem(const BlackMisc::Aviation::CComSystem &comSystem, BlackMisc::Aviation::CComSystem::ComUnit comUnit);
//! Set botb systems
void setComSystems(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
signals:
//! Values changed for unit
void changedValues(BlackMisc::Aviation::CComSystem::ComUnit unit);
private:
//! Save clicked
void onSave();
QScopedPointer<Ui::CCockpitComTransmissionComponent> ui;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,157 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CCockpitComTransmissionComponent</class>
<widget class="QFrame" name="CCockpitComTransmissionComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>205</width>
<height>148</height>
</rect>
</property>
<property name="windowTitle">
<string>Cockpit COM transmission</string>
</property>
<layout class="QHBoxLayout" name="hl_CockpitComTransmission">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="gb_Com1">
<property name="title">
<string>COM1</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="cb_Com1Tx">
<property name="text">
<string>transmit</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_Com1Rec">
<property name="text">
<string>receive</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sb_Com1VolumeTx">
<property name="suffix">
<string> transmit</string>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>95</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sb_Com1VolumeRec">
<property name="suffix">
<string> receive</string>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>95</number>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QPushButton" name="pb_Com1Save">
<property name="text">
<string>save</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_Com2">
<property name="title">
<string>COM2</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="cb_Com2Tx">
<property name="text">
<string>transmit</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_Com2Rec">
<property name="text">
<string>receive</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sb_Com2VolumeTx">
<property name="suffix">
<string> transmit</string>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>95</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sb_Com2VolumeRec">
<property name="suffix">
<string> receive</string>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>95</number>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QPushButton" name="pb_Com2Save">
<property name="text">
<string>save</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>