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: 2c3163a0e553
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4f83855fb15a
Choose a head ref
  • 1 commit
  • 5 files changed
  • 1 contributor

Commits on Sep 16, 2020

  1. Refactoring: WindowTrigger now derives from TwoLevelTrigger, which ca…

    …n be used for UI event handling
    azonenberg committed Sep 16, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    4f83855 View commit details
Showing with 124 additions and 27 deletions.
  1. +1 −0 scopehal/CMakeLists.txt
  2. +54 −0 scopehal/TwoLevelTrigger.cpp
  3. +65 −0 scopehal/TwoLevelTrigger.h
  4. +1 −9 scopehal/WindowTrigger.cpp
  5. +3 −18 scopehal/WindowTrigger.h
1 change: 1 addition & 0 deletions scopehal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@ set(SCOPEHAL_SOURCES
Trigger.cpp
EdgeTrigger.cpp
PulseWidthTrigger.cpp
TwoLevelTrigger.cpp
WindowTrigger.cpp

Instrument.cpp
54 changes: 54 additions & 0 deletions scopehal/TwoLevelTrigger.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2020 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. *
* *
***********************************************************************************************************************/

#include "scopehal.h"
#include "TwoLevelTrigger.h"

using namespace std;

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

TwoLevelTrigger::TwoLevelTrigger(Oscilloscope* scope)
: Trigger(scope)
{
//Redefine the upper level signal name
m_parameters.clear();
m_levelname = "Upper Bound";
m_parameters[m_levelname] = FilterParameter(FilterParameter::TYPE_FLOAT, Unit(Unit::UNIT_VOLTS));

m_lowername = "Lower Bound";
m_parameters[m_lowername] = FilterParameter(FilterParameter::TYPE_FLOAT, Unit(Unit::UNIT_VOLTS));
}

TwoLevelTrigger::~TwoLevelTrigger()
{

}

65 changes: 65 additions & 0 deletions scopehal/TwoLevelTrigger.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2020 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 TwoLevelTrigger
*/
#ifndef TwoLevelTrigger_h
#define TwoLevelTrigger_h

/**
@brief Base class for all triggers that have two thresholds rather than one
*/
class TwoLevelTrigger : public Trigger
{
public:
TwoLevelTrigger(Oscilloscope* scope);
virtual ~TwoLevelTrigger();

//Upper bound of range is the base class "trigger level"
float GetUpperBound()
{ return GetLevel(); }

void SetUpperBound(float f)
{ SetLevel(f); }

//Lower bound
float GetLowerBound()
{ return m_parameters[m_lowername].GetFloatVal(); }

void SetLowerBound(float level)
{ m_parameters[m_lowername].SetFloatVal(level); }

protected:
std::string m_lowername;
};

#endif
10 changes: 1 addition & 9 deletions scopehal/WindowTrigger.cpp
Original file line number Diff line number Diff line change
@@ -36,17 +36,9 @@ using namespace std;
// Construction / destruction

WindowTrigger::WindowTrigger(Oscilloscope* scope)
: Trigger(scope)
: TwoLevelTrigger(scope)
{
CreateInput("din");

//Redefine the upper level signal name
m_parameters.clear();
m_levelname = "Upper Bound";
m_parameters[m_levelname] = FilterParameter(FilterParameter::TYPE_FLOAT, Unit(Unit::UNIT_VOLTS));

m_lowername = "Lower Bound";
m_parameters[m_lowername] = FilterParameter(FilterParameter::TYPE_FLOAT, Unit(Unit::UNIT_VOLTS));
}

WindowTrigger::~WindowTrigger()
21 changes: 3 additions & 18 deletions scopehal/WindowTrigger.h
Original file line number Diff line number Diff line change
@@ -35,10 +35,12 @@
#ifndef WindowTrigger_h
#define WindowTrigger_h

#include "TwoLevelTrigger.h"

/**
@brief Window trigger - detect when the signal leaves a specified range
*/
class WindowTrigger : public Trigger
class WindowTrigger : public TwoLevelTrigger
{
public:
WindowTrigger(Oscilloscope* scope);
@@ -48,23 +50,6 @@ class WindowTrigger : public Trigger

static std::string GetTriggerName();
TRIGGER_INITPROC(WindowTrigger);

//Upper bound of range is the base class "trigger level"
float GetUpperBound()
{ return GetLevel(); }

void SetUpperBound(float f)
{ SetLevel(f); }

//Lower bound
float GetLowerBound()
{ return m_parameters[m_lowername].GetFloatVal(); }

void SetLowerBound(float level)
{ m_parameters[m_lowername].SetFloatVal(level); }

protected:
std::string m_lowername;
};

#endif