Skip to content

Commit

Permalink
hide not yet implemented feature 'NewDeviceModelFromExisting'; clean …
Browse files Browse the repository at this point in the history
…up 'cppcheck' findings

Signed-off-by: Martin <Ho-Ro@users.noreply.github.com>
  • Loading branch information
Ho-Ro committed Dec 6, 2019
1 parent ed3839d commit a7c9eb6
Show file tree
Hide file tree
Showing 30 changed files with 223 additions and 233 deletions.
2 changes: 1 addition & 1 deletion openhantek/src/OH_BUILD.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Do not edit, will be re-created at each commit!
#define OH_BUILD "20191204 build 567"
#define OH_BUILD "20191206 build 568"
2 changes: 1 addition & 1 deletion openhantek/src/exporting/exporterprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ExporterRegistry;
class ExporterProcessor : public Processor
{
public:
ExporterProcessor(ExporterRegistry* registry);
explicit ExporterProcessor(ExporterRegistry* registry);
void process(PPresult *) override;
private:
ExporterRegistry* registry;
Expand Down
2 changes: 1 addition & 1 deletion openhantek/src/glscopegraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void Graph::writeData(PPresult *data, QOpenGLShaderProgram *program, int vertexL
int offset = 0;
vaoVoltage.resize(data->vaChannelVoltage.size());
vaoSpectrum.resize(data->vaChannelSpectrum.size());
for (ChannelID channel = 0; channel < vaoVoltage.size(); ++channel) {
for (ChannelID channel = 0; channel < std::max( vaoVoltage.size(), vaoSpectrum.size() ); ++channel) {
int dataSize;

// Voltage channel
Expand Down
2 changes: 2 additions & 0 deletions openhantek/src/hantekdso/controlsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ struct ControlSettingsVoltage {
struct ControlSettings {
ControlSettings(const ControlSamplerateLimits *limits, size_t channelCount);
~ControlSettings();
ControlSettings( const ControlSettings& ) = delete;
ControlSettings operator=( const ControlSettings& ) = delete;
ControlSettingsSamplerate samplerate; ///< The samplerate settings
std::vector<ControlSettingsVoltage> voltage; ///< The amplification settings
ControlSettingsTrigger trigger; ///< The trigger settings
Expand Down
2 changes: 1 addition & 1 deletion openhantek/src/hantekdso/controlspecification.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct FixedSampleRate {

/// \brief Stores the specifications of the currently connected device.
struct ControlSpecification {
ControlSpecification(unsigned channels);
explicit ControlSpecification( unsigned channels );
const ChannelID channels;

// Limits
Expand Down
5 changes: 5 additions & 0 deletions openhantek/src/hantekdso/enums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Dso {
Enum<Dso::Slope, Dso::Slope::Positive, Dso::Slope::Both> SlopeEnum;
Enum<Dso::GraphFormat, Dso::GraphFormat::TY, Dso::GraphFormat::XY> GraphFormatEnum;

#if 0
/// \brief Return string representation of the given channel mode.
/// \param mode The ::ChannelMode that should be returned as string.
/// \return The string that should be used in labels etc., empty when invalid.
Expand All @@ -18,6 +19,7 @@ namespace Dso {
}
return QString();
}
#endif

/// \brief Return string representation of the given graph format.
/// \param format The ::GraphFormat that should be returned as string.
Expand Down Expand Up @@ -88,6 +90,7 @@ namespace Dso {
}
}

#if 0
/// \brief Return string representation of the given graph interpolation mode.
/// \param interpolation The ::InterpolationMode that should be returned as
/// string.
Expand All @@ -104,4 +107,6 @@ namespace Dso {
return QString();
}
}
#endif

}
4 changes: 2 additions & 2 deletions openhantek/src/hantekdso/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ enum InterpolationMode {
INTERPOLATION_COUNT ///< Total number of interpolation modes
};

QString channelModeString(ChannelMode mode);
// QString channelModeString(ChannelMode mode);
QString graphFormatString(GraphFormat format);
QString couplingString(Coupling coupling);
QString triggerModeString(TriggerMode mode);
QString slopeString(Slope slope);
QString interpolationModeString(InterpolationMode interpolation);
// QString interpolationModeString(InterpolationMode interpolation);
}

Q_DECLARE_METATYPE(Dso::TriggerMode)
Expand Down
7 changes: 5 additions & 2 deletions openhantek/src/hantekdso/hantekdsocontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void HantekDsoControl::enableSampling(bool enabled) {

const USBDevice *HantekDsoControl::getDevice() const { return device; }

const DSOsamples &HantekDsoControl::getLastSamples() { return result; }
// const DSOsamples &HantekDsoControl::getLastSamples() { return result; }


HantekDsoControl::HantekDsoControl(USBDevice *device)
Expand All @@ -69,7 +69,7 @@ HantekDsoControl::~HantekDsoControl() {
}
}


#if 0
unsigned HantekDsoControl::getChannelCount() const { return specification->channels; }


Expand All @@ -95,6 +95,7 @@ double HantekDsoControl::getMaxSamplerate() const {
return specification->samplerate.single.max;
}
}
#endif


bool HantekDsoControl::isSampling() const { return sampling; }
Expand Down Expand Up @@ -832,6 +833,7 @@ void HantekDsoControl::run() {
}


#if 0
int HantekDsoControl::getConnectionSpeed() const {
int errorCode;
ControlGetSpeed response;
Expand All @@ -855,3 +857,4 @@ int HantekDsoControl::getPacketSize() const {
return s;
return 0;
}
#endif
6 changes: 5 additions & 1 deletion openhantek/src/hantekdso/hantekdsocontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class HantekDsoControl : public QObject {
* if run() is called.
* @param device The usb device. This object does not take ownership.
*/
HantekDsoControl(USBDevice *device);
explicit HantekDsoControl( USBDevice *device );

/// \brief Cleans up
~HantekDsoControl();
Expand All @@ -49,6 +49,7 @@ class HantekDsoControl : public QObject {
/// there.
void run();

#if 0
/// \brief Gets the physical channel count for this oscilloscope.
/// \return The number of physical channels.
unsigned getChannelCount() const;
Expand All @@ -68,6 +69,7 @@ class HantekDsoControl : public QObject {
/// \brief Get maximum samplerate for this oscilloscope.
/// \return The maximum samplerate for the current configuration in S/s.
double getMaxSamplerate() const;
#endif

double getSamplerate() const;

Expand All @@ -78,6 +80,7 @@ class HantekDsoControl : public QObject {
/// Return the associated usb device.
const USBDevice *getDevice() const;

#if 0
/// \brief Gets the speed of the connection.
/// \return The ::ConnectionSpeed of the USB connection.
int getConnectionSpeed() const;
Expand All @@ -88,6 +91,7 @@ class HantekDsoControl : public QObject {

/// Return the last sample set
const DSOsamples &getLastSamples();
#endif

/// \brief Sends control commands directly.
/// <p>
Expand Down
2 changes: 1 addition & 1 deletion openhantek/src/hantekprotocol/controlStructs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ControlBeginCommand::ControlBeginCommand(CommandIndex index)

ControlGetSpeed::ControlGetSpeed() : ControlCommand(Hantek::ControlCode::CONTROL_GETSPEED, 10) { }

ConnectionSpeed ControlGetSpeed::getSpeed() { return (ConnectionSpeed)data()[0]; }
// ConnectionSpeed ControlGetSpeed::getSpeed() { return (ConnectionSpeed)data()[0]; }


ControlSetVoltDIV_CH1::ControlSetVoltDIV_CH1() : ControlCommand(ControlCode::CONTROL_SETVOLTDIV_CH1, 1) {
Expand Down
4 changes: 2 additions & 2 deletions openhantek/src/hantekprotocol/controlStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ControlBeginCommand : public ControlCommand {
public:
/// \brief Sets the command index to the given value.
/// \param index The CommandIndex for the command.
ControlBeginCommand(CommandIndex index = COMMANDINDEX_0);
explicit ControlBeginCommand( CommandIndex index = COMMANDINDEX_0 );
};

/// \brief The CONTROL_GETSPEED parser.
Expand All @@ -37,7 +37,7 @@ class ControlGetSpeed : public ControlCommand {
ControlGetSpeed();
/// \brief Gets the speed of the connection.
/// \return The speed level of the USB connection.
ConnectionSpeed getSpeed();
// ConnectionSpeed getSpeed();
};

struct ControlSetVoltDIV_CH1 : public ControlCommand {
Expand Down
2 changes: 1 addition & 1 deletion openhantek/src/post/mathchannelgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ void MathChannelGenerator::process(PPresult *result) {
DataChannel *const channelData = result->modifyData(physicalChannels);
std::vector<double> &resultData = channelData->voltage.sample;

unsigned src = 0;
const double sign = scope->voltage[physicalChannels].inverted ? -1.0 : 1.0;

if ( Dso::getMathMode( scope->voltage[physicalChannels] ) < Dso::MathMode::AC_CH1 ) { // binary operations
Expand Down Expand Up @@ -56,6 +55,7 @@ void MathChannelGenerator::process(PPresult *result) {
*it = sign * calculate( *ch1Iterator++, *ch2Iterator++ );
}
} else { // unary operators (calculate "AC coupling")
unsigned src = 0;
if ( Dso::getMathMode( scope->voltage[physicalChannels] ) == Dso::MathMode::AC_CH1 )
src = 0;
else if ( Dso::getMathMode( scope->voltage[physicalChannels] ) == Dso::MathMode::AC_CH2 )
Expand Down
2 changes: 1 addition & 1 deletion openhantek/src/post/postprocessing.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PostProcessing : public QObject {
Q_OBJECT

public:
PostProcessing(unsigned channelCount);
explicit PostProcessing( unsigned channelCount );
/**
* Adds a new processor that is called when a new input arrived. The order of the processors is
* imporant. The first added processor will be called first. This class does not take ownership
Expand Down
4 changes: 4 additions & 0 deletions openhantek/src/post/postprocessingsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ QString mathModeString(MathMode mode) {
}
return QString();
}

#if 0
/// \brief Return string representation of the given dft window function.
/// \param window The ::WindowFunction that should be returned as string.
/// \return The string that should be used in labels etc.
Expand Down Expand Up @@ -66,4 +68,6 @@ QString windowFunctionString(WindowFunction window) {
}
return QString();
}
#endif

}
2 changes: 1 addition & 1 deletion openhantek/src/post/postprocessingsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ enum class WindowFunction : int {
extern Enum<Dso::WindowFunction, Dso::WindowFunction::RECTANGULAR, Dso::WindowFunction::FLATTOP> WindowFunctionEnum;

QString mathModeString(MathMode mode);
QString windowFunctionString(WindowFunction window);
// QString windowFunctionString(WindowFunction window);
}

Q_DECLARE_METATYPE(Dso::MathMode)
Expand Down
2 changes: 1 addition & 1 deletion openhantek/src/post/ppresult.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ typedef std::vector<ChannelGraph> ChannelsGraphs;
/// Post processing results
class PPresult {
public:
PPresult(unsigned int channelCount);
explicit PPresult(unsigned int channelCount);

/// \brief Returns the analyzed data.
/// \param channel Channel, whose data should be returned.
Expand Down
3 changes: 1 addition & 2 deletions openhantek/src/post/spectrumgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ void SpectrumGenerator::process(PPresult *result) {
break;
case Dso::WindowFunction::GAUSS: {
const double sigma = 0.5;
double w;
for (unsigned int windowPosition = 0; windowPosition < lastRecordLength; ++windowPosition) {
w = ( (double)windowPosition - lastRecordLength / 2.0 ) / ( sigma * lastRecordLength / 2.0 );
double w = ( (double)windowPosition - lastRecordLength / 2.0 ) / ( sigma * lastRecordLength / 2.0 );
w *= w;
weight += *(lastWindowBuffer + windowPosition) = exp( -w );
}
Expand Down
4 changes: 2 additions & 2 deletions openhantek/src/selectdevice/devicelistentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
struct DeviceListEntry {
UniqueUSBid id;
QString name;
bool canConnect;
bool needFirmware;
bool canConnect = false;
bool needFirmware = false;
QString errorMessage;
QString getStatus() const {
return errorMessage.size()? errorMessage : (canConnect?"Ready":(needFirmware?"Firmware upload":"Cannot connect"));
Expand Down
2 changes: 1 addition & 1 deletion openhantek/src/selectdevice/deviceslistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class FindDevices;
*/
class DevicesListModel: public QAbstractTableModel {
public:
DevicesListModel(FindDevices* findDevices);
explicit DevicesListModel( FindDevices* findDevices );
// QAbstractItemModel interface
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
Expand Down
2 changes: 2 additions & 0 deletions openhantek/src/selectdevice/newdevicemodelfromexisting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ NewDeviceModelFromExisting::NewDeviceModelFromExisting(QWidget *parent) :
}
}

#if 0
void NewDeviceModelFromExisting::setUSBcontext(libusb_context *context)
{
this->context = context;
Expand All @@ -70,6 +71,7 @@ RawDeviceListEntry *NewDeviceModelFromExisting::getSelectedEntry()
{
return (RawDeviceListEntry*) ui->cmbUSBdevices->currentData(RawDevicesListModel::EntryPointerRole).value<void*>();
}
#endif

void NewDeviceModelFromExisting::accept()
{
Expand Down
4 changes: 2 additions & 2 deletions openhantek/src/selectdevice/newdevicemodelfromexisting.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class NewDeviceModelFromExisting : public QDialog

public:
explicit NewDeviceModelFromExisting(QWidget *parent = 0);
void setUSBcontext(libusb_context* context);
RawDeviceListEntry* getSelectedEntry();
// void setUSBcontext(libusb_context* context);
// RawDeviceListEntry* getSelectedEntry();
private:
std::unique_ptr<Ui::NewDeviceModelFromExisting> ui;
libusb_context* context = nullptr;
Expand Down
9 changes: 8 additions & 1 deletion openhantek/src/selectdevice/selectsupporteddevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ SelectSupportedDevice::SelectSupportedDevice( QWidget *parent ) :
QDialog( parent ), ui( new Ui::SelectSupportedDevice )
{
ui->setupUi(this);
#ifdef NEW_DEVICE_FROM_EXISTING_DIALOG
newDeviceFromExistingDialog = new NewDeviceModelFromExisting(this);
#endif
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
qRegisterMetaType<UniqueUSBid>("UniqueUSBid");
connect(ui->buttonBox, &QDialogButtonBox::accepted, [this]() {
Expand All @@ -29,15 +31,18 @@ SelectSupportedDevice::SelectSupportedDevice( QWidget *parent ) :
connect(ui->buttonBox, &QDialogButtonBox::helpRequested, [this]() {
QDesktopServices::openUrl(QUrl("https://github.com/OpenHantek/OpenHantek6022"));
});
#ifdef NEW_DEVICE_FROM_EXISTING_DIALOG
connect(ui->btnAddDevice, &QPushButton::clicked, [this]() {
newDeviceFromExistingDialog->setModal(true);
newDeviceFromExistingDialog->show();
});
#endif

}

std::unique_ptr<USBDevice> SelectSupportedDevice::showSelectDeviceModal(libusb_context *context)
{
newDeviceFromExistingDialog->setUSBcontext(context);
// newDeviceFromExistingDialog->setUSBcontext(context);
std::unique_ptr<FindDevices> findDevices = std::unique_ptr<FindDevices>(new FindDevices(context));
std::unique_ptr<DevicesListModel> model = std::unique_ptr<DevicesListModel>(new DevicesListModel(findDevices.get()));
ui->cmbDevices->setModel(model.get());
Expand Down Expand Up @@ -114,7 +119,9 @@ std::unique_ptr<USBDevice> SelectSupportedDevice::showSelectDeviceModal(libusb_c
void SelectSupportedDevice::showLibUSBFailedDialogModel(int error)
{
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
#ifdef NEW_DEVICE_FROM_EXISTING_DIALOG
ui->btnAddDevice->setEnabled(false);
#endif
ui->labelReadyState->setText(tr("Can't initalize USB: %1").arg(libUsbErrorString(error)));
show();
QCoreApplication::instance()->exec();
Expand Down
5 changes: 5 additions & 0 deletions openhantek/src/selectdevice/selectsupporteddevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
struct libusb_context;
class NewDeviceModelFromExisting;

// define if this tab is also designed in "selectsupporteddevice.ui"
// #define NEW_DEVICE_FROM_EXISTING_DIALOG

/**
* Offers the user a device selection dialog. If you call any of the -Modal methods,
* the method will block and show a dialog for selection or for a usb error
Expand All @@ -32,5 +35,7 @@ class SelectSupportedDevice : public QDialog
void updateSupportedDevices();
std::unique_ptr<Ui::SelectSupportedDevice> ui;
UniqueUSBid selectedDevice = 0;
#ifdef NEW_DEVICE_FROM_EXISTING_DIALOG
NewDeviceModelFromExisting* newDeviceFromExistingDialog;
#endif
};

0 comments on commit a7c9eb6

Please sign in to comment.