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

Commits on Sep 10, 2020

  1. Copy the full SHA
    2e7d707 View commit details
Showing with 328 additions and 210 deletions.
  1. +1 −0 scopehal/CMakeLists.txt
  2. +0 −156 scopehal/Filter.cpp
  3. +0 −54 scopehal/Filter.h
  4. +215 −0 scopehal/FilterParameter.cpp
  5. +111 −0 scopehal/FilterParameter.h
  6. +1 −0 scopehal/scopehal.h
1 change: 1 addition & 0 deletions scopehal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -55,6 +55,7 @@ set(SCOPEHAL_SOURCES
PowerSupply.cpp

Filter.cpp
FilterParameter.cpp
PacketDecoder.cpp
Statistic.cpp
)
156 changes: 0 additions & 156 deletions scopehal/Filter.cpp
Original file line number Diff line number Diff line change
@@ -64,162 +64,6 @@ string StreamDescriptor::GetName()
return name;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FilterParameter

FilterParameter::FilterParameter(ParameterTypes type, Unit unit)
: m_type(type)
, m_unit(unit)
, m_intval(0)
, m_floatval(0)
, m_filename("")
{
}

void FilterParameter::ParseString(string str)
{
switch(m_type)
{
case TYPE_BOOL:
m_filename = "";
if( (str == "1") || (str == "true") )
m_intval = 1;
else
m_intval = 0;

m_floatval = m_intval;
break;

//Parse both int and float as float
//so e.g. 1.5M parses correctly
case TYPE_FLOAT:
case TYPE_INT:
m_floatval = m_unit.ParseString(str);
m_intval = m_floatval;
break;

case TYPE_FILENAME:
m_intval = 0;
m_floatval = 0;
m_filename = str;
m_filenames.push_back(str);
break;

case TYPE_FILENAMES:
{
m_intval = 0;
m_floatval = 0;
m_filename = "";

//Split out semicolon-delimited filenames
string tmp;
str += ';';
for(size_t i=0; i<str.length(); i++)
{
if(str[i] ==';')
{
if(tmp.empty())
continue;

if(m_filename == "")
m_filename = tmp;
m_filenames.push_back(tmp);
tmp = "";
continue;
}

tmp += str[i];
}
}
break;
}
}

string FilterParameter::ToString()
{
string ret;
switch(m_type)
{
case TYPE_FLOAT:
return m_unit.PrettyPrint(m_floatval);

case TYPE_BOOL:
case TYPE_INT:
return m_unit.PrettyPrint(m_intval);

case TYPE_FILENAME:
return m_filename;

case TYPE_FILENAMES:
for(auto f : m_filenames)
{
if(ret != "")
ret += ";";
ret += f;
}
return ret;

default:
return "unimplemented";
}
}

int64_t FilterParameter::GetIntVal()
{
return m_intval;
}

float FilterParameter::GetFloatVal()
{
return m_floatval;
}

string FilterParameter::GetFileName()
{
return m_filename;
}

vector<string> FilterParameter::GetFileNames()
{
return m_filenames;
}

void FilterParameter::SetIntVal(int64_t i)
{
m_intval = i;
m_floatval = i;
m_filename = "";
m_filenames.clear();
}

void FilterParameter::SetFloatVal(float f)
{
m_intval = f;
m_floatval = f;
m_filename = "";
m_filenames.clear();
}

void FilterParameter::SetFileName(string f)
{
m_intval = 0;
m_floatval = 0;
m_filename = f;
m_filenames.clear();
m_filenames.push_back(f);
}

void FilterParameter::SetFileNames(vector<string> names)
{
m_intval = 0;
m_floatval = 0;
if(names.empty())
m_filename = "";
else
m_filename = names[0];
m_filenames = names;
}

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

54 changes: 0 additions & 54 deletions scopehal/Filter.h
Original file line number Diff line number Diff line change
@@ -38,60 +38,6 @@

#include "OscilloscopeChannel.h"

class FilterParameter
{
public:
enum ParameterTypes
{
TYPE_FLOAT,
TYPE_INT,
TYPE_BOOL,
TYPE_FILENAME, //one file
TYPE_FILENAMES //multiple files
};

FilterParameter()
: m_unit(Unit::UNIT_PS)
{}

FilterParameter(ParameterTypes type, Unit unit);

void ParseString(std::string str);
std::string ToString();

bool GetBoolVal()
{ return (m_intval != 0); }

int64_t GetIntVal();
float GetFloatVal();
std::string GetFileName();
std::vector<std::string> GetFileNames();

void SetBoolVal(bool b)
{ m_intval = b; }
void SetIntVal(int64_t i);
void SetFloatVal(float f);
void SetFileName(std::string f);
void SetFileNames(std::vector<std::string> names);

ParameterTypes GetType()
{ return m_type; }

//File filters for TYPE_FILENAME / TYPE_FILENAMES(otherwise ignored)
std::string m_fileFilterMask;
std::string m_fileFilterName;

protected:
ParameterTypes m_type;

Unit m_unit;

int64_t m_intval;
float m_floatval;
std::string m_filename;
std::vector<std::string> m_filenames;
};

/**
@brief Descriptor for a single stream coming off a channel
*/
Loading