Skip to content
Snippets Groups Projects
Commit 6b29320f authored by David Hammer's avatar David Hammer
Browse files

Fix queue length counting, change name

parent 6d26c1e3
No related branches found
No related tags found
2 merge requests!59Interface CrystFEL with Karabo and allow automatic parameter tunning with rcrystfel,!53Train picker arbiter kernel
...@@ -136,11 +136,11 @@ class CrystfelRunner(PythonDevice): ...@@ -136,11 +136,11 @@ class CrystfelRunner(PythonDevice):
.commit(), .commit(),
NODE_ELEMENT(expected) NODE_ELEMENT(expected)
.key("trainQueue") .key("frameQueue")
.commit(), .commit(),
UINT64_ELEMENT(expected) UINT64_ELEMENT(expected)
.key("trainQueue.capacity") .key("frameQueue.capacity")
.assignmentOptional() .assignmentOptional()
.defaultValue(100) .defaultValue(100)
.commit(), .commit(),
...@@ -149,7 +149,7 @@ class CrystfelRunner(PythonDevice): ...@@ -149,7 +149,7 @@ class CrystfelRunner(PythonDevice):
# TODO: set this value # TODO: set this value
DOUBLE_ELEMENT(expected) DOUBLE_ELEMENT(expected)
.key("trainQueue.fullness") .key("frameQueue.fullness")
.description( .description(
"This device maintains a queue of frames to send to CrystFEL. If " "This device maintains a queue of frames to send to CrystFEL. If "
"CrystFEL cannot keep up, this queue can get full and some frames will " "CrystFEL cannot keep up, this queue can get full and some frames will "
...@@ -163,7 +163,7 @@ class CrystfelRunner(PythonDevice): ...@@ -163,7 +163,7 @@ class CrystfelRunner(PythonDevice):
.commit(), .commit(),
SLOT_ELEMENT(expected) SLOT_ELEMENT(expected)
.key("trainQueue.reset") .key("frameQueue.reset")
.commit(), .commit(),
INPUT_CHANNEL(expected) INPUT_CHANNEL(expected)
...@@ -286,7 +286,7 @@ class CrystfelRunner(PythonDevice): ...@@ -286,7 +286,7 @@ class CrystfelRunner(PythonDevice):
self.KARABO_SLOT(self.startCrystfel) self.KARABO_SLOT(self.startCrystfel)
self.KARABO_SLOT(self.stopCrystfel) self.KARABO_SLOT(self.stopCrystfel)
self.KARABO_SLOT(self.trainQueue_reset) self.KARABO_SLOT(self.frameQueue_reset)
self.registerInitialFunction(self._initialization) self.registerInitialFunction(self._initialization)
def _initialization(self): def _initialization(self):
...@@ -298,7 +298,7 @@ class CrystfelRunner(PythonDevice): ...@@ -298,7 +298,7 @@ class CrystfelRunner(PythonDevice):
self._crystfel_socket.bind( self._crystfel_socket.bind(
f"tcp://*:{self.get('crystfelArgs.zmqPort')}" f"tcp://*:{self.get('crystfelArgs.zmqPort')}"
) )
self.trainQueue_reset() self.frameQueue_reset()
self.KARABO_ON_INPUT("input", self.input_handler) self.KARABO_ON_INPUT("input", self.input_handler)
# note: loading with cfelpyutils.geometry does not tell us peak_list value # note: loading with cfelpyutils.geometry does not tell us peak_list value
...@@ -338,9 +338,9 @@ class CrystfelRunner(PythonDevice): ...@@ -338,9 +338,9 @@ class CrystfelRunner(PythonDevice):
self._crystfel_proc.terminate() self._crystfel_proc.terminate()
self.updateState(State.STOPPED) self.updateState(State.STOPPED)
def trainQueue_reset(self): def frameQueue_reset(self):
self._crystfel_queue = queue.Queue(maxsize=self.get("trainQueue.capacity")) self._crystfel_queue = queue.Queue(maxsize=self.get("frameQueue.capacity"))
self.set("trainQueue.fullness", 0) self.set("frameQueue.fullness", 0)
def input_handler(self, input_channel): def input_handler(self, input_channel):
all_metadata = input_channel.getMetaData() all_metadata = input_channel.getMetaData()
...@@ -437,8 +437,8 @@ class CrystfelRunner(PythonDevice): ...@@ -437,8 +437,8 @@ class CrystfelRunner(PythonDevice):
self._crystfel_queue.get(block=True) self._crystfel_queue.get(block=True)
) )
self.set( self.set(
"trainQueue.fullness", "frameQueue.fullness",
len(self._crystfel_queue) / self._crystfel_queue.maxsize * 100 self._crystfel_queue.qsize() / self._crystfel_queue.maxsize * 100
) )
threading.Thread(target=server, daemon=True).start() threading.Thread(target=server, daemon=True).start()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment