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

Commits on Oct 30, 2020

  1. Copy the full SHA
    78c3176 View commit details
Showing with 212 additions and 4 deletions.
  1. +1 −0 scopehal/CMakeLists.txt
  2. +66 −0 scopehal/GlitchTrigger.cpp
  3. +76 −0 scopehal/GlitchTrigger.h
  4. +64 −4 scopehal/LeCroyOscilloscope.cpp
  5. +3 −0 scopehal/LeCroyOscilloscope.h
  6. +2 −0 scopehal/scopehal.cpp
1 change: 1 addition & 0 deletions scopehal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@ set(SCOPEHAL_SOURCES
Trigger.cpp
DropoutTrigger.cpp
EdgeTrigger.cpp
GlitchTrigger.cpp
PulseWidthTrigger.cpp
RuntTrigger.cpp
SerialTrigger.cpp
66 changes: 66 additions & 0 deletions scopehal/GlitchTrigger.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/***********************************************************************************************************************
* *
* 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 "GlitchTrigger.h"
#include "LeCroyOscilloscope.h"
#include "TektronixOscilloscope.h"

using namespace std;

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

GlitchTrigger::GlitchTrigger(Oscilloscope* scope)
: EdgeTrigger(scope)
, m_conditionname("Condition")
, m_lowername("Lower Bound")
, m_uppername("Upper Bound")
{
m_parameters[m_lowername] = FilterParameter(FilterParameter::TYPE_INT, Unit(Unit::UNIT_PS));

m_parameters[m_uppername] = FilterParameter(FilterParameter::TYPE_INT, Unit(Unit::UNIT_PS));

m_parameters[m_conditionname] = FilterParameter(FilterParameter::TYPE_ENUM, Unit(Unit::UNIT_COUNTS));
m_parameters[m_conditionname].AddEnumValue("Less than", CONDITION_LESS);
m_parameters[m_conditionname].AddEnumValue("Between", CONDITION_BETWEEN);
}

GlitchTrigger::~GlitchTrigger()
{

}

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

string GlitchTrigger::GetTriggerName()
{
return "Glitch";
}
76 changes: 76 additions & 0 deletions scopehal/GlitchTrigger.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/***********************************************************************************************************************
* *
* 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 GlitchTrigger
*/
#ifndef GlitchTrigger_h
#define GlitchTrigger_h

#include "EdgeTrigger.h"

/**
@brief Trigger on a glitch meeting certain width criteria
*/
class GlitchTrigger : public EdgeTrigger
{
public:
GlitchTrigger(Oscilloscope* scope);
virtual ~GlitchTrigger();

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

void SetCondition(Condition type)
{ m_parameters[m_conditionname].SetIntVal(type); }

Condition GetCondition()
{ return (Condition) m_parameters[m_conditionname].GetIntVal(); }

int64_t GetLowerBound()
{ return m_parameters[m_lowername].GetIntVal(); }

void SetLowerBound(int64_t bound)
{ m_parameters[m_lowername].SetIntVal(bound); }

int64_t GetUpperBound()
{ return m_parameters[m_uppername].GetIntVal(); }

void SetUpperBound(int64_t bound)
{ m_parameters[m_uppername].SetIntVal(bound); }

protected:
std::string m_conditionname;
std::string m_lowername;
std::string m_uppername;
};

#endif
68 changes: 64 additions & 4 deletions scopehal/LeCroyOscilloscope.cpp
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@

#include "DropoutTrigger.h"
#include "EdgeTrigger.h"
#include "GlitchTrigger.h"
#include "PulseWidthTrigger.h"
#include "RuntTrigger.h"
#include "SlewRateTrigger.h"
@@ -3448,6 +3449,8 @@ void LeCroyOscilloscope::PullTrigger()
PullDropoutTrigger();
else if (reply == "Edge")
PullEdgeTrigger();
else if (reply == "Glitch")
PullGlitchTrigger();
else if (reply == "Runt")
PullRuntTrigger();
else if (reply == "SlewRate")
@@ -3555,6 +3558,45 @@ void LeCroyOscilloscope::PullEdgeTrigger()
GetTriggerSlope(et, Trim(m_transport->ReadReply()));
}

/**
@brief Reads settings for a glitch trigger from the instrument
*/
void LeCroyOscilloscope::PullGlitchTrigger()
{
//Clear out any triggers of the wrong type
if( (m_trigger != NULL) && (dynamic_cast<GlitchTrigger*>(m_trigger) != NULL) )
{
delete m_trigger;
m_trigger = NULL;
}

//Create a new trigger if necessary
if(m_trigger == NULL)
m_trigger = new GlitchTrigger(this);
GlitchTrigger* gt = dynamic_cast<GlitchTrigger*>(m_trigger);

//Level
m_transport->SendCommand("VBS? 'return = app.Acquisition.Trigger.Glitch.Level'");
gt->SetLevel(stof(m_transport->ReadReply()));

//Slope
m_transport->SendCommand("VBS? 'return = app.Acquisition.Trigger.Glitch.Slope'");
GetTriggerSlope(gt, Trim(m_transport->ReadReply()));

//Condition
m_transport->SendCommand("VBS? 'return = app.Acquisition.Trigger.Glitch.Condition'");
gt->SetCondition(GetCondition(m_transport->ReadReply()));

//Min range
Unit ps(Unit::UNIT_PS);
m_transport->SendCommand("VBS? 'return = app.Acquisition.Trigger.Glitch.TimeLow'");
gt->SetLowerBound(ps.ParseString(m_transport->ReadReply()));

//Max range
m_transport->SendCommand("VBS? 'return = app.Acquisition.Trigger.Glitch.TimeHigh'");
gt->SetUpperBound(ps.ParseString(m_transport->ReadReply()));
}

/**
@brief Reads settings for an edge trigger from the instrument
*/
@@ -3883,6 +3925,7 @@ void LeCroyOscilloscope::PushTrigger()
//The rest depends on the type
auto dt = dynamic_cast<DropoutTrigger*>(m_trigger);
auto et = dynamic_cast<EdgeTrigger*>(m_trigger);
auto gt = dynamic_cast<GlitchTrigger*>(m_trigger);
auto pt = dynamic_cast<PulseWidthTrigger*>(m_trigger);
auto rt = dynamic_cast<RuntTrigger*>(m_trigger);
auto st = dynamic_cast<SlewRateTrigger*>(m_trigger);
@@ -3893,15 +3936,15 @@ void LeCroyOscilloscope::PushTrigger()
m_transport->SendCommand("VBS? 'app.Acquisition.Trigger.Type = \"Dropout\"");
PushDropoutTrigger(dt);
}
else if(pt) //must be before edge trigger
else if(pt)
{
m_transport->SendCommand("VBS? 'app.Acquisition.Trigger.Type = \"Width\"");
PushPulseWidthTrigger(pt);
}
else if(et)
else if(gt)
{
m_transport->SendCommand("VBS? 'app.Acquisition.Trigger.Type = \"Edge\"");
PushEdgeTrigger(et, "app.Acquisition.Trigger.Edge");
m_transport->SendCommand("VBS? 'app.Acquisition.Trigger.Type = \"Glitch\"");
PushGlitchTrigger(gt);
}
else if(rt)
{
@@ -3923,6 +3966,11 @@ void LeCroyOscilloscope::PushTrigger()
m_transport->SendCommand("VBS? 'app.Acquisition.Trigger.Type = \"Window\"");
PushWindowTrigger(wt);
}
else if(et) //must be last
{
m_transport->SendCommand("VBS? 'app.Acquisition.Trigger.Type = \"Edge\"");
PushEdgeTrigger(et, "app.Acquisition.Trigger.Edge");
}

else
LogWarning("Unknown trigger type (not an edge)\n");
@@ -3987,6 +4035,17 @@ void LeCroyOscilloscope::PushPulseWidthTrigger(PulseWidthTrigger* trig)
PushFloat("app.Acquisition.Trigger.Width.TimeLow", trig->GetLowerBound() * 1e-12f);
}

/**
@brief Pushes settings for a glitch trigger to the instrument
*/
void LeCroyOscilloscope::PushGlitchTrigger(GlitchTrigger* trig)
{
PushEdgeTrigger(trig, "app.Acquisition.Trigger.Glitch");
PushCondition("app.Acquisition.Trigger.Glitch.Condition", trig->GetCondition());
PushFloat("app.Acquisition.Trigger.Glitch.TimeHigh", trig->GetUpperBound() * 1e-12f);
PushFloat("app.Acquisition.Trigger.Glitch.TimeLow", trig->GetLowerBound() * 1e-12f);
}

/**
@brief Pushes settings for a runt trigger to the instrument
*/
@@ -4214,6 +4273,7 @@ vector<string> LeCroyOscilloscope::GetTriggerTypes()
vector<string> ret;
ret.push_back(DropoutTrigger::GetTriggerName());
ret.push_back(EdgeTrigger::GetTriggerName());
ret.push_back(GlitchTrigger::GetTriggerName());
ret.push_back(PulseWidthTrigger::GetTriggerName());
ret.push_back(RuntTrigger::GetTriggerName());
ret.push_back(SlewRateTrigger::GetTriggerName());
3 changes: 3 additions & 0 deletions scopehal/LeCroyOscilloscope.h
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@

class DropoutTrigger;
class EdgeTrigger;
class GlitchTrigger;
class PulseWidthTrigger;
class RuntTrigger;
class SlewRateTrigger;
@@ -209,6 +210,7 @@ class LeCroyOscilloscope
protected:
void PullDropoutTrigger();
void PullEdgeTrigger();
void PullGlitchTrigger();
void PullPulseWidthTrigger();
void PullRuntTrigger();
void PullSlewRateTrigger();
@@ -221,6 +223,7 @@ class LeCroyOscilloscope

void PushDropoutTrigger(DropoutTrigger* trig);
void PushEdgeTrigger(EdgeTrigger* trig, const std::string& tree);
void PushGlitchTrigger(GlitchTrigger* trig);
void PushCondition(const std::string& path, Trigger::Condition cond);
void PushPatternCondition(const std::string& path, Trigger::Condition cond);
void PushFloat(std::string path, float f);
2 changes: 2 additions & 0 deletions scopehal/scopehal.cpp
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@

#include "DropoutTrigger.h"
#include "EdgeTrigger.h"
#include "GlitchTrigger.h"
#include "PulseWidthTrigger.h"
#include "RuntTrigger.h"
#include "SlewRateTrigger.h"
@@ -129,6 +130,7 @@ void DriverStaticInit()

AddTriggerClass(DropoutTrigger);
AddTriggerClass(EdgeTrigger);
AddTriggerClass(GlitchTrigger);
AddTriggerClass(PulseWidthTrigger);
AddTriggerClass(RuntTrigger);
AddTriggerClass(SlewRateTrigger);