Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b1ce3deef134
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d401cc8cde02
Choose a head ref
  • 1 commit
  • 9 files changed
  • 1 contributor

Commits on Dec 16, 2019

  1. Copy the full SHA
    d401cc8 View commit details
5 changes: 5 additions & 0 deletions scopehal/Measurement.cpp
Original file line number Diff line number Diff line change
@@ -514,12 +514,17 @@ string FloatMeasurement::GetValueAsString()

switch(m_type)
{
case TYPE_PERCENTAGE:
snprintf(tmp, sizeof(tmp), "%.2f %%", m_value * 100);
break;

case TYPE_VOLTAGE:
if(fabs(m_value) > 1)
snprintf(tmp, sizeof(tmp), "%.3f V", m_value);
else
snprintf(tmp, sizeof(tmp), "%.2f mV", m_value * 1000);
break;

case TYPE_TIME:
if(fabs(m_value) < 1e-9)
snprintf(tmp, sizeof(tmp), "%.3f ps", m_value * 1e12);
3 changes: 2 additions & 1 deletion scopehal/Measurement.h
Original file line number Diff line number Diff line change
@@ -114,7 +114,8 @@ class FloatMeasurement : public Measurement
TYPE_VOLTAGE,
TYPE_TIME,
TYPE_FREQUENCY,
TYPE_BAUD
TYPE_BAUD,
TYPE_PERCENTAGE
};

FloatMeasurement(FloatMeasurementType type);
2 changes: 2 additions & 0 deletions scopemeasurements/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -14,11 +14,13 @@ set(SCOPEMEASUREMENTS_SOURCES
FrequencyMeasurement.cpp
MaxVoltageMeasurement.cpp
MinVoltageMeasurement.cpp
OvershootMeasurement.cpp
PeriodMeasurement.cpp
PkPkVoltageMeasurement.cpp
Rise1090Measurement.cpp
Rise2080Measurement.cpp
TopMeasurement.cpp
UndershootMeasurement.cpp

scopemeasurements.cpp
)
94 changes: 94 additions & 0 deletions scopemeasurements/OvershootMeasurement.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2019 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of OvershootMeasurement
*/

#include "scopemeasurements.h"
#include "OvershootMeasurement.h"

using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction/destruction

OvershootMeasurement::OvershootMeasurement()
: FloatMeasurement(TYPE_PERCENTAGE)
{
//Configure for a single input
m_signalNames.push_back("Vin");
m_channels.push_back(NULL);
}

OvershootMeasurement::~OvershootMeasurement()
{
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Accessors

Measurement::MeasurementType OvershootMeasurement::GetMeasurementType()
{
return Measurement::MEAS_VERT;
}

string OvershootMeasurement::GetMeasurementName()
{
return "Overshoot";
}

bool OvershootMeasurement::ValidateChannel(size_t i, OscilloscopeChannel* channel)
{
if( (i == 0) && (channel->GetType() == OscilloscopeChannel::CHANNEL_TYPE_ANALOG) )
return true;
return false;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Measurement processing

bool OvershootMeasurement::Refresh()
{
//Get the input data
if(m_channels[0] == NULL)
return false;
AnalogCapture* din = dynamic_cast<AnalogCapture*>(m_channels[0]->GetData());
if(din == NULL || (din->GetDepth() == 0))
return false;

//Calculate the worst case overshoot
float max = GetMaxVoltage(din);
float top = GetTopVoltage(din);
float base = GetBaseVoltage(din);
m_value = (max-top) / (top-base);
return true;
}
56 changes: 56 additions & 0 deletions scopemeasurements/OvershootMeasurement.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2019 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of OvershootMeasurement
*/
#ifndef OvershootMeasurement_h
#define OvershootMeasurement_h

#include "../scopehal/Measurement.h"

class OvershootMeasurement : public FloatMeasurement
{
public:
OvershootMeasurement();
virtual ~OvershootMeasurement();

virtual bool Refresh();

static std::string GetMeasurementName();
virtual bool ValidateChannel(size_t i, OscilloscopeChannel* channel);

virtual MeasurementType GetMeasurementType();

MEASUREMENT_INITPROC(OvershootMeasurement)
};

#endif
94 changes: 94 additions & 0 deletions scopemeasurements/UndershootMeasurement.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2019 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of UndershootMeasurement
*/

#include "scopemeasurements.h"
#include "UndershootMeasurement.h"

using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction/destruction

UndershootMeasurement::UndershootMeasurement()
: FloatMeasurement(TYPE_PERCENTAGE)
{
//Configure for a single input
m_signalNames.push_back("Vin");
m_channels.push_back(NULL);
}

UndershootMeasurement::~UndershootMeasurement()
{
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Accessors

Measurement::MeasurementType UndershootMeasurement::GetMeasurementType()
{
return Measurement::MEAS_VERT;
}

string UndershootMeasurement::GetMeasurementName()
{
return "Undershoot";
}

bool UndershootMeasurement::ValidateChannel(size_t i, OscilloscopeChannel* channel)
{
if( (i == 0) && (channel->GetType() == OscilloscopeChannel::CHANNEL_TYPE_ANALOG) )
return true;
return false;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Measurement processing

bool UndershootMeasurement::Refresh()
{
//Get the input data
if(m_channels[0] == NULL)
return false;
AnalogCapture* din = dynamic_cast<AnalogCapture*>(m_channels[0]->GetData());
if(din == NULL || (din->GetDepth() == 0))
return false;

//Calculate the worst case undershoot
float min = GetMinVoltage(din);
float top = GetTopVoltage(din);
float base = GetBaseVoltage(din);
m_value = (base-min) / (top-base);
return true;
}
56 changes: 56 additions & 0 deletions scopemeasurements/UndershootMeasurement.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2019 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of UndershootMeasurement
*/
#ifndef UndershootMeasurement_h
#define UndershootMeasurement_h

#include "../scopehal/Measurement.h"

class UndershootMeasurement : public FloatMeasurement
{
public:
UndershootMeasurement();
virtual ~UndershootMeasurement();

virtual bool Refresh();

static std::string GetMeasurementName();
virtual bool ValidateChannel(size_t i, OscilloscopeChannel* channel);

virtual MeasurementType GetMeasurementType();

MEASUREMENT_INITPROC(UndershootMeasurement)
};

#endif
2 changes: 2 additions & 0 deletions scopemeasurements/scopemeasurements.cpp
Original file line number Diff line number Diff line change
@@ -54,9 +54,11 @@ void ScopeMeasurementStaticInit()
AddMeasurementClass(FrequencyMeasurement);
AddMeasurementClass(MaxVoltageMeasurement);
AddMeasurementClass(MinVoltageMeasurement);
AddMeasurementClass(OvershootMeasurement);
AddMeasurementClass(PeriodMeasurement);
AddMeasurementClass(PkPkVoltageMeasurement);
AddMeasurementClass(Rise1090Measurement);
AddMeasurementClass(Rise2080Measurement);
AddMeasurementClass(TopMeasurement);
AddMeasurementClass(UndershootMeasurement);
}
3 changes: 3 additions & 0 deletions scopemeasurements/scopemeasurements.h
Original file line number Diff line number Diff line change
@@ -51,11 +51,14 @@
#include "FrequencyMeasurement.h"
#include "MaxVoltageMeasurement.h"
#include "MinVoltageMeasurement.h"
#include "OvershootMeasurement.h"
#include "PeriodMeasurement.h"
#include "PeriodMeasurement.h"
#include "PkPkVoltageMeasurement.h"
#include "Rise1090Measurement.h"
#include "Rise2080Measurement.h"
#include "TopMeasurement.h"
#include "UndershootMeasurement.h"

void ScopeMeasurementStaticInit();