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

Commits on Dec 4, 2020

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b54f0d6 View commit details
Showing with 98 additions and 0 deletions.
  1. +33 −0 scopehal/LeCroyOscilloscope.cpp
  2. +3 −0 scopehal/LeCroyOscilloscope.h
  3. +14 −0 scopehal/Oscilloscope.cpp
  4. +22 −0 scopehal/Oscilloscope.h
  5. +22 −0 scopehal/OscilloscopeChannel.cpp
  6. +4 −0 scopehal/OscilloscopeChannel.h
33 changes: 33 additions & 0 deletions scopehal/LeCroyOscilloscope.cpp
Original file line number Diff line number Diff line change
@@ -1232,6 +1232,10 @@ void LeCroyOscilloscope::SetChannelAttenuation(size_t i, double atten)
if(i >= m_analogChannelCount)
return;

//Get the old coupling value first.
//This ensures that m_probeIsActive[i] is valid
GetChannelCoupling(i);

//Don't allow changing attenuation on active probes
{
lock_guard<recursive_mutex> lock(m_cacheMutex);
@@ -1415,6 +1419,35 @@ void LeCroyOscilloscope::SetChannelBandwidthLimit(size_t i, unsigned int limit_m
m_transport->SendCommand(cmd);
}

bool LeCroyOscilloscope::CanInvert(size_t i)
{
//All analog channels, and only analog channels, can be inverted
return (i < m_analogChannelCount);
}

void LeCroyOscilloscope::Invert(size_t i, bool invert)
{
if(i >= m_analogChannelCount)
return;

lock_guard<recursive_mutex> lock(m_mutex);

if(invert)
m_transport->SendCommand(string("VBS 'app.Acquisition.") + m_channels[i]->GetHwname() + ".Invert = true'");
else
m_transport->SendCommand(string("VBS 'app.Acquisition.") + m_channels[i]->GetHwname() + ".Invert = false'");
}

bool LeCroyOscilloscope::IsInverted(size_t i)
{
if(i >= m_analogChannelCount)
return false;

m_transport->SendCommand(string("VBS? 'return = app.Acquisition.") + m_channels[i]->GetHwname() + ".Invert'");
auto reply = Trim(m_transport->ReadReply());
return (reply == "-1");
}

void LeCroyOscilloscope::SetChannelDisplayName(size_t i, string name)
{
auto chan = m_channels[i];
3 changes: 3 additions & 0 deletions scopehal/LeCroyOscilloscope.h
Original file line number Diff line number Diff line change
@@ -95,6 +95,9 @@ class LeCroyOscilloscope
virtual std::string GetChannelDisplayName(size_t i);
virtual void SetChannelDisplayName(size_t i, std::string name);
virtual std::vector<unsigned int> GetChannelBandwidthLimiters(size_t i);
virtual bool CanInvert(size_t i);
virtual void Invert(size_t i, bool invert);
virtual bool IsInverted(size_t i);

//Triggering
virtual Oscilloscope::TriggerMode PollTrigger();
14 changes: 14 additions & 0 deletions scopehal/Oscilloscope.cpp
Original file line number Diff line number Diff line change
@@ -505,6 +505,20 @@ void Oscilloscope::SetADCMode(size_t /*channel*/, size_t /*mode*/)
//no-op
}

bool Oscilloscope::CanInvert(size_t /*i*/)
{
return false;
}

void Oscilloscope::Invert(size_t /*i*/, bool /*invert*/)
{
}

bool Oscilloscope::IsInverted(size_t /*i*/)
{
return false;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Trigger configuration

22 changes: 22 additions & 0 deletions scopehal/Oscilloscope.h
Original file line number Diff line number Diff line change
@@ -274,6 +274,28 @@ class Oscilloscope : public virtual Instrument
*/
virtual void SetChannelOffset(size_t i, double offset) =0;

/**
@brief Checks if a channel is capable of hardware polarity inversion
@param i Zero-based index of channel
*/
virtual bool CanInvert(size_t i);

/**
@brief Enables hardware polarity inversion for a channel, if supported
@param i Zero-based index of channel
@param invert True to invert, false for normal operation
*/
virtual void Invert(size_t i, bool invert);

/**
@brief Checks if hardware polarity inversion is enabled for a channel
@param i Zero-based index of channel
*/
virtual bool IsInverted(size_t i);

//Triggering
enum TriggerMode
{
22 changes: 22 additions & 0 deletions scopehal/OscilloscopeChannel.cpp
Original file line number Diff line number Diff line change
@@ -277,6 +277,28 @@ string OscilloscopeChannel::GetDisplayName()
return m_displayname;
}

bool OscilloscopeChannel::CanInvert()
{
if(m_scope)
return m_scope->CanInvert(m_index);
else
return false;
}

void OscilloscopeChannel::Invert(bool invert)
{
if(m_scope)
m_scope->Invert(m_index, invert);
}

bool OscilloscopeChannel::IsInverted()
{
if(m_scope)
return m_scope->IsInverted(m_index);
else
return false;
}

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

4 changes: 4 additions & 0 deletions scopehal/OscilloscopeChannel.h
Original file line number Diff line number Diff line change
@@ -186,6 +186,10 @@ class OscilloscopeChannel

void SetCenterFrequency(int64_t freq);

virtual bool CanInvert();
virtual void Invert(bool invert);
virtual bool IsInverted();

void SetDefaultDisplayName();
protected:
void SharedCtorInit();