summaryrefslogtreecommitdiffstats
path: root/tests/roof.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/roof.py')
-rw-r--r--tests/roof.py81
1 files changed, 8 insertions, 73 deletions
diff --git a/tests/roof.py b/tests/roof.py
index 1941aa8..71b4465 100644
--- a/tests/roof.py
+++ b/tests/roof.py
@@ -1,79 +1,14 @@
-import gi
-import re
+#import gi
import sys
-import json
-import argparse
+from roof.graph import RoofGraph
-gi.require_version('Ufo', '0.0')
-from gi.repository import Ufo
-from gi.repository import GObject
+#gi.require_version('Ufo', '0.0')
+#from gi.repository import Ufo
+#from gi.repository import GObject
-class RoofConfig:
- def __init__(self, args, config="roof.json"):
- self.streams = 1
- self.bit_depth = 8
- self.convert = False if ((not args.output) or (re.compile('\.raw$').search(args.output))) else True
- self.build = "raw" if args.noroof else "ufo" if self.convert else "sino"
- with open(config) as json_file:
- cfg = json.load(json_file)
- if cfg.get("network", {}).get("streams") != None:
- self.streams = cfg["network"]["streams"]
- elif cfg.get("hardware", {}).get("modules") != None:
- self.streams = cfg["setup"]["modules"]
+roof = RoofGraph()
+graph = roof.get()
- if cfg.get("hardware", {}).get("bit_depth") != None:
- self.bit_depth = cfg["hardware"]["bit_depth"]
-
-parser = argparse.ArgumentParser()
-parser.add_argument('-c', '--config', dest="config", default="roof.json", help="ROOF configuration (JSON)")
-parser.add_argument('-o', '--output', dest="output", default=None, help="Output file")
-parser.add_argument('-n', '--number', dest="number", default=None, type=int, help="Specify number of frames to capture (limits number of captured frames irrespective of further filtering)")
-parser.add_argument('-p', '--plane', dest="plane", default=None, type=int, help="Only process the specified detector plane (indexed from 1)")
-parser.add_argument( '--no-roof', dest="noroof", default=False, type=bool, help="Disable ROOF, only network testing (no sinogram building, store linearly)")
-#parser.add_argument('-r', '--raw', dest="raw", default=False, type=bool, help="Store raw data, ignore processed")
-#parser.add_argument('-v', '--visualize', dest='visualize', default=False, type=bool, help="Visualize data")
-args = parser.parse_args()
-
-
-cfg = RoofConfig(args, args.config)
-
-pm = Ufo.PluginManager()
-graph = Ufo.TaskGraph()
-scheduler = Ufo.Scheduler()
-
-if args.output is None:
- print ("Starting ROOF using NULL writter")
- write = pm.get_task('null')
- if args.number is None: args.number = 0
-else:
- print ("Starting ROOF streaming to {}".format(args.output))
- write = pm.get_task('write')
- write.set_properties(filename=args.output)
- if args.number is None: args.number = 5
-
-build = pm.get_task('roof-build')
-build.set_properties(config=args.config, number=args.number, build=cfg.build)
-
-plane = pm.get_task('roof-plane') if args.plane else None
-if plane: plane.set_properties(plane=args.plane)
-
-for id in range(cfg.streams):
- read = pm.get_task('roof-read')
- read.set_properties(config=args.config, id=id)
- graph.connect_nodes(read, build)
- build.bind_property('stop', read, 'stop', GObject.BindingFlags.DEFAULT)
-
-#read_task.set_properties(path='/home/data/*.tif', start=10, number=100)
-#graph.connect_nodes_full(read, write, 0)
-
-if plane:
- graph.connect_nodes(build, plane)
- graph.connect_nodes(plane, write)
-else:
- graph.connect_nodes(build, write)
-
-
-
-scheduler.run(graph)
+roof.run()