Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions scopehal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ set(SCOPEHAL_SOURCES
UartTrigger.cpp
WindowTrigger.cpp

RSRTB2kEdgeTrigger.cpp
RSRTB2kLineTrigger.cpp
RSRTB2kRiseTimeTrigger.cpp
RSRTB2kRuntTrigger.cpp
RSRTB2kTimeoutTrigger.cpp
RSRTB2kVideoTrigger.cpp
RSRTB2kWidthTrigger.cpp

Instrument.cpp
InstrumentChannel.cpp
BERT.cpp
Expand Down Expand Up @@ -181,6 +189,7 @@ set(SCOPEHAL_SOURCES
PicoVNA.cpp
RigolFunctionGenerator.cpp
RigolOscilloscope.cpp
RSRTB2kOscilloscope.cpp
SiglentLoad.cpp
SiglentFunctionGenerator.cpp
SiglentPowerSupply.cpp
Expand Down
4 changes: 2 additions & 2 deletions scopehal/FilterParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ class FilterParameter
calculates coefficients or other configuration based on user input. The coefficients are no longer direct user
inputs, so they should be marked hidden to avoid confusing the user.
*/
void MarkHidden()
{ m_hidden = true; }
void MarkHidden(bool hidden = true)
{ m_hidden = hidden; }

/**
@brief Checks if this parameter should be hidden in the GUI.
Expand Down
126 changes: 126 additions & 0 deletions scopehal/RSRTB2kEdgeTrigger.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/***********************************************************************************************************************
* *
* libscopehal *
* *
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
* 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 Implementation of EdgeTrigger
@ingroup triggers
*/

#include "scopehal.h"
#include "RSRTB2kEdgeTrigger.h"

using namespace std;

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

/**
@brief Initialize a new edge trigger

@param scope The scope this trigger will be used on
*/
RSRTB2kEdgeTrigger::RSRTB2kEdgeTrigger(Oscilloscope* scope)
: Trigger(scope)
, m_edgetype(m_parameters["Slope"])
, m_couplingtype(m_parameters["Coupling"])
, m_hfrejectstate(m_parameters["Reject HF"])
, m_noiserejectstate(m_parameters["Reject Noise"])
, m_holdofftimestate(m_parameters["Hold Off"])
, m_holdofftime(m_parameters["Hold Off Time"])
{
CreateInput("din");

//Trigger level
m_level.MarkHidden();
m_triggerLevel.MarkHidden(false);
m_upperLevel.MarkHidden();

//Slope
m_edgetype = FilterParameter(FilterParameter::TYPE_ENUM, Unit(Unit::UNIT_COUNTS));
m_edgetype.AddEnumValue("Rising", EDGE_RISING);
m_edgetype.AddEnumValue("Falling", EDGE_FALLING);
m_edgetype.AddEnumValue("Any", EDGE_ANY);

//Trigger coupling
m_couplingtype = FilterParameter(FilterParameter::TYPE_ENUM, Unit(Unit::UNIT_COUNTS));
m_couplingtype.AddEnumValue("DC", COUPLING_DC);
m_couplingtype.AddEnumValue("AC", COUPLING_AC);
m_couplingtype.AddEnumValue("LF Reject", COUPLING_LFREJECT);

//HF and noise reject
m_hfrejectstate = FilterParameter(FilterParameter::TYPE_BOOL, Unit(Unit::UNIT_COUNTS));
m_noiserejectstate = FilterParameter(FilterParameter::TYPE_BOOL, Unit(Unit::UNIT_COUNTS));

//Hold off time
m_holdofftimestate = FilterParameter(FilterParameter::TYPE_BOOL, Unit(Unit::UNIT_COUNTS));
m_holdofftime = FilterParameter(FilterParameter::TYPE_INT, Unit(Unit::UNIT_FS));
}

RSRTB2kEdgeTrigger::~RSRTB2kEdgeTrigger()
{

}

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

///@brief Return the constant trigger name "edge"
string RSRTB2kEdgeTrigger::GetTriggerName()
{
return "Edge";
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Input validation

bool RSRTB2kEdgeTrigger::ValidateChannel(size_t i, StreamDescriptor stream)
{
//We only can take one input
if(i > 0)
return false;

//Has to be non null
if(!stream.m_channel)
return false;

//Has to be a scope or digital input / IO channel
auto schan = dynamic_cast<OscilloscopeChannel*>(stream.m_channel);
auto di = dynamic_cast<DigitalInputChannel*>(stream.m_channel);
auto dio = dynamic_cast<DigitalIOChannel*>(stream.m_channel);
if(!schan && !di && !dio)
return false;

//It has to be from the same instrument we're trying to trigger on
if(stream.m_channel->GetInstrument() != m_scope)
return false;

return true;
}
112 changes: 112 additions & 0 deletions scopehal/RSRTB2kEdgeTrigger.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/***********************************************************************************************************************
* *
* libscopehal *
* *
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
* 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 EdgeTrigger
@ingroup triggers
*/
#ifndef RSRTB2kEdgeTrigger_h
#define RSRTB2kEdgeTrigger_h

/**
@brief Simple edge trigger
@ingroup triggers
*/
class RSRTB2kEdgeTrigger : public Trigger
{
public:
RSRTB2kEdgeTrigger(Oscilloscope* scope);
virtual ~RSRTB2kEdgeTrigger();

enum EdgeType
{
EDGE_RISING,
EDGE_FALLING,
EDGE_ANY,
};

void SetType(EdgeType type)
{ m_edgetype.SetIntVal(type); }

EdgeType GetType()
{ return (EdgeType) m_edgetype.GetIntVal(); }

enum CouplingType
{
COUPLING_DC,
COUPLING_AC,
COUPLING_LFREJECT
};

void SetCouplingType(CouplingType type)
{ m_couplingtype.SetIntVal(type); }

CouplingType GetCouplingType()
{ return (CouplingType) m_couplingtype.GetIntVal(); }

void SetHfRejectState(bool state)
{ m_hfrejectstate.SetBoolVal(state); }
void SetNoiseRejectState(bool state)
{ m_noiserejectstate.SetBoolVal(state); }

bool GetHfRejectState()
{ return m_hfrejectstate.GetBoolVal(); }
bool GetNoiseRejectState()
{ return m_noiserejectstate.GetBoolVal(); }

void SetHoldoffTimeState(bool state)
{ m_holdofftimestate.SetBoolVal(state); }

bool GetHoldoffTimeState()
{ return m_holdofftimestate.GetBoolVal(); }

void SetHoldoffTime(uint64_t bound)
{ m_holdofftime.SetIntVal(bound); }

uint64_t GetHoldoffTime()
{ return m_holdofftime.GetIntVal(); }


virtual bool ValidateChannel(size_t i, StreamDescriptor stream) override;

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

protected:
FilterParameter& m_edgetype;
FilterParameter& m_couplingtype;
FilterParameter& m_hfrejectstate;
FilterParameter& m_noiserejectstate;
FilterParameter& m_holdofftimestate;
FilterParameter& m_holdofftime;
};

#endif
88 changes: 88 additions & 0 deletions scopehal/RSRTB2kLineTrigger.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/***********************************************************************************************************************
* *
* libscopehal *
* *
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
* 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 Implementation of Line trigger
@ingroup triggers
*/

#include "scopehal.h"
#include "RSRTB2kLineTrigger.h"

using namespace std;

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

/**
@brief Initialize the trigger

@param scope The scope this trigger will be used with
*/
RSRTB2kLineTrigger::RSRTB2kLineTrigger(Oscilloscope* scope)
: Trigger(scope)
, m_holdofftimestate(m_parameters["Hold Off"])
, m_holdofftime(m_parameters["Hold Off Time"])
{
CreateInput("din");

//Trigger level
m_level.MarkHidden();
m_triggerLevel.MarkHidden();
m_upperLevel.MarkHidden();

//Hold off time
m_holdofftimestate = FilterParameter(FilterParameter::TYPE_BOOL, Unit(Unit::UNIT_COUNTS));
m_holdofftime = FilterParameter(FilterParameter::TYPE_INT, Unit(Unit::UNIT_FS));
}

RSRTB2kLineTrigger::~RSRTB2kLineTrigger()
{
}

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

///@brief Returns the constant trigger name "Dropout"
string RSRTB2kLineTrigger::GetTriggerName()
{
return "Line";
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Input validation

bool RSRTB2kLineTrigger::ValidateChannel(size_t i, StreamDescriptor stream)
{
return true;
}


Loading