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

Commits on Mar 15, 2020

  1. Copy the full SHA
    a002044 View commit details
Showing with 446 additions and 2 deletions.
  1. +1 −1 scopehal/AntikernelLogicAnalyzer.h
  2. +2 −1 scopehal/CMakeLists.txt
  3. +325 −0 scopehal/MockOscilloscope.cpp
  4. +118 −0 scopehal/MockOscilloscope.h
2 changes: 1 addition & 1 deletion scopehal/AntikernelLogicAnalyzer.h
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@
/**
@file
@author Andrew D. Zonenberg
@brief Declaration of RedTinLogicAnalyzer
@brief Declaration of AntikernelLogicAnalyzer
*/

#ifndef AntikernelLogicAnalyzer_h
3 changes: 2 additions & 1 deletion scopehal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -21,11 +21,12 @@ set(SCOPEHAL_SOURCES
Instrument.cpp
FunctionGenerator.cpp
Oscilloscope.cpp
SCPIOscilloscope.cpp
OscilloscopeChannel.cpp
SCPIOscilloscope.cpp
AgilentOscilloscope.cpp
AntikernelLogicAnalyzer.cpp
LeCroyOscilloscope.cpp
MockOscilloscope.cpp
SiglentSCPIOscilloscope.cpp
RigolOscilloscope.cpp
RohdeSchwarzOscilloscope.cpp
325 changes: 325 additions & 0 deletions scopehal/MockOscilloscope.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,325 @@
/***********************************************************************************************************************
* *
* 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 Implementation of MockOscilloscope
*/

#include "scopehal.h"
#include "OscilloscopeChannel.h"
#include "MockOscilloscope.h"

using namespace std;

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

MockOscilloscope::MockOscilloscope(string name, string vendor, string serial)
: m_name(name)
, m_vendor(vendor)
, m_serial(serial)
, m_extTrigger(NULL)
{
}

MockOscilloscope::~MockOscilloscope()
{

}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Information queries

string MockOscilloscope::GetTransportName()
{
return "null";
}

string MockOscilloscope::GetTransportConnectionString()
{
return "";
}

string MockOscilloscope::GetDriverNameInternal()
{
return "mock";
}

unsigned int MockOscilloscope::GetInstrumentTypes()
{
return INST_OSCILLOSCOPE;
}

string MockOscilloscope::GetName()
{
return m_name;
}

string MockOscilloscope::GetVendor()
{
return m_vendor;
}

string MockOscilloscope::GetSerial()
{
return m_serial;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Triggering

Oscilloscope::TriggerType MockOscilloscope::GetTriggerType()
{
return TRIGGER_TYPE_RISING;
}

void MockOscilloscope::SetTriggerType(Oscilloscope::TriggerType /*type*/)
{
//no-op, we never trigger
}

Oscilloscope::TriggerMode MockOscilloscope::PollTrigger()
{
//we never trigger
return TRIGGER_MODE_STOP;
}

bool MockOscilloscope::AcquireData(bool /*toQueue*/)
{
//no new data possible
return false;
}

void MockOscilloscope::ArmTrigger()
{
//no-op, we never trigger
}

void MockOscilloscope::StartSingleTrigger()
{
//no-op, we never trigger
}

void MockOscilloscope::Start()
{
//no-op, we never trigger
}

void MockOscilloscope::Stop()
{
//no-op, we never trigger
}

bool MockOscilloscope::IsTriggerArmed()
{
return false;
}

void MockOscilloscope::ResetTriggerConditions()
{
//no-op, we never trigger
}

void MockOscilloscope::SetTriggerForChannel(OscilloscopeChannel* /*channel*/, vector<TriggerType> /*triggerbits*/)
{
//no-op, we never trigger
}

size_t MockOscilloscope::GetTriggerChannelIndex()
{
return 0;
}

void MockOscilloscope::SetTriggerChannelIndex(size_t /*i*/)
{
//no-op, we never trigger
}

float MockOscilloscope::GetTriggerVoltage()
{
return 0;
}

void MockOscilloscope::SetTriggerVoltage(float /*v*/)
{
//no-op, we never trigger
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Serialization

void MockOscilloscope::LoadConfiguration(const YAML::Node& node, IDTable& table)
{
//Load the channels
auto& chans = node["channels"];
for(auto it : chans)
{
auto& cnode = it.second;

//Allocate channel space if we didn't have it yet
size_t index = cnode["index"].as<int>();
if(m_channels.size() < (index+1))
m_channels.resize(index+1);

//Configure the channel
OscilloscopeChannel::ChannelType type = OscilloscopeChannel::CHANNEL_TYPE_COMPLEX;
string stype = cnode["type"].as<string>();
if(stype == "analog")
type = OscilloscopeChannel::CHANNEL_TYPE_ANALOG;
else if(stype == "digital")
type = OscilloscopeChannel::CHANNEL_TYPE_DIGITAL;
else if(stype == "trigger")
type = OscilloscopeChannel::CHANNEL_TYPE_TRIGGER;
auto chan = new OscilloscopeChannel(
this,
cnode["name"].as<string>(),
type,
cnode["color"].as<string>(),
1,
index,
true);
m_channels[index] = chan;

//Create the channel ID
table.emplace(cnode["id"].as<int>(), chan);
}

//Call the base class to configure everything
Oscilloscope::LoadConfiguration(node, table);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Channel configuration. Mostly trivial stubs.

bool MockOscilloscope::IsChannelEnabled(size_t i)
{
return m_channelsEnabled[i];
}

void MockOscilloscope::EnableChannel(size_t i)
{
m_channelsEnabled[i] = true;
}

void MockOscilloscope::DisableChannel(size_t i)
{
m_channelsEnabled[i] = false;
}

OscilloscopeChannel::CouplingType MockOscilloscope::GetChannelCoupling(size_t i)
{
return m_channelCoupling[i];
}

void MockOscilloscope::SetChannelCoupling(size_t i, OscilloscopeChannel::CouplingType type)
{
m_channelCoupling[i] = type;
}

double MockOscilloscope::GetChannelAttenuation(size_t i)
{
return m_channelAttenuation[i];
}

void MockOscilloscope::SetChannelAttenuation(size_t i, double atten)
{
m_channelAttenuation[i] = atten;
}

int MockOscilloscope::GetChannelBandwidthLimit(size_t i)
{
return m_channelBandwidth[i];
}

void MockOscilloscope::SetChannelBandwidthLimit(size_t i, unsigned int limit_mhz)
{
m_channelBandwidth[i] = limit_mhz;
}

double MockOscilloscope::GetChannelVoltageRange(size_t i)
{
return m_channelVoltageRange[i];
}

void MockOscilloscope::SetChannelVoltageRange(size_t i, double range)
{
m_channelVoltageRange[i] = range;
}

OscilloscopeChannel* MockOscilloscope::GetExternalTrigger()
{
return m_extTrigger;
}

double MockOscilloscope::GetChannelOffset(size_t i)
{
return m_channelOffset[i];
}

void MockOscilloscope::SetChannelOffset(size_t i, double offset)
{
m_channelOffset[i] = offset;
}

vector<uint64_t> MockOscilloscope::GetSampleRatesNonInterleaved()
{
//no-op
vector<uint64_t> ret;
return ret;
}

vector<uint64_t> MockOscilloscope::GetSampleRatesInterleaved()
{
//no-op
vector<uint64_t> ret;
return ret;
}

set<Oscilloscope::InterleaveConflict> MockOscilloscope::GetInterleaveConflicts()
{
//no-op
set<Oscilloscope::InterleaveConflict> ret;
return ret;
}

vector<uint64_t> MockOscilloscope::GetSampleDepthsNonInterleaved()
{
//no-op
vector<uint64_t> ret;
return ret;
}

vector<uint64_t> MockOscilloscope::GetSampleDepthsInterleaved()
{
//no-op
vector<uint64_t> ret;
return ret;
}
Loading