Skip to content

Commit

Permalink
Added frames offset into frame ID
Browse files Browse the repository at this point in the history
Use fp_adapter to grab message that contains the offset to be used and pass it on to the frames after a pause.
  • Loading branch information
Luis Segalla authored and LuisFSegalla committed Sep 4, 2024
1 parent 2948c7d commit d0c2052
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
3 changes: 3 additions & 0 deletions cpp/data/frameProcessor/include/XspressProcessPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class XspressMemoryBlock
uint32_t current_block_start_;
uint32_t concurrent_processes_;
uint32_t concurrent_rank_;
uint32_t offset;
std::string acq_id_;
std::string live_view_name_;

Expand Down Expand Up @@ -116,6 +117,8 @@ class XspressMemoryBlock

static const std::string CONFIG_CHUNK;

static const std::string CONFIG_OFFSET;

/** Pointer to logger */
LoggerPtr logger_;
};
Expand Down
29 changes: 19 additions & 10 deletions cpp/data/frameProcessor/src/XspressProcessPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ const std::string XspressProcessPlugin::CONFIG_FRAMES = "frames";
const std::string XspressProcessPlugin::CONFIG_DTC_FLAGS = "dtc/flags";
const std::string XspressProcessPlugin::CONFIG_DTC_PARAMS = "dtc/params";

const std::string XspressProcessPlugin::CONFIG_CHUNK = "chunks";
const std::string XspressProcessPlugin::CONFIG_CHUNK = "chunks";

const std::string XspressProcessPlugin::CONFIG_OFFSET = "offset";

const std::string META_NAME = "xspress";
const std::string META_XSPRESS_CHUNK = "xspress_meta_chunk";
Expand Down Expand Up @@ -138,7 +140,8 @@ XspressProcessPlugin::XspressProcessPlugin() :
scalar_memblock_(0),
dtc_memblock_(0),
inp_est_memblock_(0),
num_scalars_recorded_(0)
num_scalars_recorded_(0),
offset(0)
{
// Setup logging for the class
logger_ = Logger::getLogger("FP.XspressProcessPlugin");
Expand Down Expand Up @@ -220,8 +223,14 @@ void XspressProcessPlugin::configure(OdinData::IpcMessage& config, OdinData::Ipc
boost::to_string(this->frames_per_block_),
buffer.GetString());

LOG4CXX_INFO(logger_, "Number of frames per block set to " << this->frames_per_block_);
}
LOG4CXX_INFO(logger_, "Number of frames per block set to " << this->frames_per_block_);
}

if(config.has_param(XspressProcessPlugin::CONFIG_OFFSET))
{
this->offset = config.get_param<uint32_t>(XspressProcessPlugin::CONFIG_OFFSET);
LOG4CXX_INFO(logger_,"\n\nconfigured offset: " << offset << "\n\n");
}

// Check for the live view plugin name
if (config.has_param(XspressProcessPlugin::CONFIG_LIVE_VIEW_NAME)) {
Expand Down Expand Up @@ -501,12 +510,12 @@ void XspressProcessPlugin::process_frame(boost::shared_ptr <Frame> frame)
}
}

void XspressProcessPlugin::send_scalars(uint32_t last_frame_id, uint32_t num_scalars, uint32_t first_channel, uint32_t num_channels)
{
uint32_t num_scalar_values = num_scalars * num_channels;
uint32_t num_dtc_factors = num_channels;
uint32_t num_inp_est = num_channels;
uint32_t frame_id = last_frame_id - num_scalars_recorded_ + 1;
void XspressProcessPlugin::send_scalars(uint32_t last_frame_id, uint32_t num_scalars, uint32_t first_channel, uint32_t num_channels)
{
uint32_t num_scalar_values = num_scalars * num_channels;
uint32_t num_dtc_factors = num_channels;
uint32_t num_inp_est = num_channels;
uint32_t frame_id = (last_frame_id - num_scalars_recorded_ + 1) + (this->offset * this->frames_per_block_); //Acquisition frame ID + Offset

rapidjson::Document meta_document;
meta_document.SetObject();
Expand Down
17 changes: 17 additions & 0 deletions python/src/xspress_detector/control/fp_xspress_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ def initialize(self, adapters):
def put(self, path, request): # pylint: disable=W0613
if path.startswith("config/hdf/dataset/data"):
self.configure_data_datasets(path,request)
if path.startswith("config/offset/offset_adjustment"):
value = json_decode(request.body)
self.configure_dataset_offset(value)
if path == self._command:
# Check the mode we are running in (mca or list)
mode = self._xsp_adapter.detector.mode
Expand Down Expand Up @@ -177,6 +180,20 @@ def setup_rank(self):
logging.debug(OdinDataAdapter.ERROR_FAILED_TO_SEND)
logging.error("Error: %s", err)

def configure_dataset_offset(self, offset):
for client in self._clients:
try:
parameters = {
"xspress": {
"offset": int(offset),
},
}
logging.warning("Sending: {}".format(parameters))
client.send_configuration(parameters)
except Exception as err:
logging.debug(OdinDataAdapter.ERROR_FAILED_TO_SEND)
logging.error("Error: %s", err)

def configure_data_datasets(self, path, request):
if "chunks" in str(escape.url_unescape(request.body)):
value = json_decode(request.body)
Expand Down

0 comments on commit d0c2052

Please sign in to comment.