Skip to content

Commit

Permalink
Merge pull request #146 from slaclab/ESCRYODET-433
Browse files Browse the repository at this point in the history
Add command to reset the unwrapper and filter from pyrogue
  • Loading branch information
jesusvasquez333 authored Nov 1, 2019
2 parents e91f38b + 4675110 commit 69f4a0d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/smurf/core/processors/SmurfProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ namespace smurf
void setGain(double g); // Set the filter gain
const double getGain() const; // Get the filter gain
void resetFilter(); // Reset the filter
void resetFilterWithMutex(); // Reset the filter, but holding the mutex.

//** DOWNSAMLER METHODS **//
void setDownsamplerDisable(bool d); // Disable the processing block. The data
Expand Down
12 changes: 12 additions & 0 deletions python/pysmurf/core/devices/_SmurfProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ def __init__(self, name, device, **kwargs):
localSet=lambda value: self.device.setUnwrapperDisable(value),
localGet=self.device.getUnwrapperDisable))

# Command to reset the unwrapper
self.add(pyrogue.LocalCommand(
name='reset',
description='Reset the unwrapper',
function=self.device.resetUnwrapper))

class Downsampler(pyrogue.Device):
"""
SMuRF Data Downsampler Python Wrapper.
Expand Down Expand Up @@ -175,6 +181,12 @@ def __init__(self, name, device, **kwargs):
localSet=lambda value: self.device.setB(value),
localGet=self.device.getB))

# Command to reset the filter
self.add(pyrogue.LocalCommand(
name='reset',
description='Reset the unwrapper',
function=self.device.resetFilter))


class SmurfProcessor(pyrogue.Device):
"""
Expand Down
18 changes: 16 additions & 2 deletions src/smurf/core/processors/SmurfProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ void scp::SmurfProcessor::setup_python()
boost::noncopyable >
("SmurfProcessor",bp::init<>())
// Channel mapping variables
.def("setUnwrapperDisable", &SmurfProcessor::setUnwrapperDisable)
.def("getUnwrapperDisable", &SmurfProcessor::getUnwrapperDisable)
.def("getNumCh", &SmurfProcessor::getNumCh)
.def("setPayloadSize", &SmurfProcessor::setPayloadSize)
.def("getPayloadSize", &SmurfProcessor::getPayloadSize)
.def("setMask", &SmurfProcessor::setMask)
.def("getMask", &SmurfProcessor::getMask)
// Unwrapper variables
.def("setUnwrapperDisable", &SmurfProcessor::setUnwrapperDisable)
.def("getUnwrapperDisable", &SmurfProcessor::getUnwrapperDisable)
.def("resetUnwrapper", &SmurfProcessor::resetUnwrapper)
// Filter variables
.def("setFilterDisable", &SmurfProcessor::setFilterDisable)
.def("getFilterDisable", &SmurfProcessor::getFilterDisable)
Expand All @@ -88,6 +90,7 @@ void scp::SmurfProcessor::setup_python()
.def("getB", &SmurfProcessor::getB)
.def("setGain", &SmurfProcessor::setGain)
.def("getGain", &SmurfProcessor::getGain)
.def("resetFilter", &SmurfProcessor::resetFilterWithMutex)
// Downsampler variables
.def("setDownsamplerDisable", &SmurfProcessor::setDownsamplerDisable)
.def("getDownsamplerDisable", &SmurfProcessor::getDownsamplerDisable)
Expand Down Expand Up @@ -423,6 +426,17 @@ void scp::SmurfProcessor::resetFilter()
currentBlockIndex = 0;
}

// Reset the filter but holding the mutex. This is need when reseting the
// filter from python
void scp::SmurfProcessor::resetFilterWithMutex()
{
// Take the mutex before changing the filter parameters
// This make sure that the new order value is not used before
// the a and b array are resized.
std::lock_guard<std::mutex> lockFilter(mutFilter);
resetFilter();
}

void scp::SmurfProcessor::setDownsamplerDisable(bool d)
{
disableDownsampler = d;
Expand Down

0 comments on commit 69f4a0d

Please sign in to comment.