Skip to content
Snippets Groups Projects
Commit 8b1de211 authored by Andrea Parenti's avatar Andrea Parenti Committed by Jonathan Correa Magdalena
Browse files

Refactor / 3

parent 4421661f
No related branches found
No related tags found
2 merge requests!2Draft: Feat/p8003,!1First version
Pipeline #162676 passed
......@@ -20,5 +20,4 @@ authors = [
]
description = ""
readme = "README.md"
dependencies = [
]
dependencies = ['paramiko']
import argparse
from control import Timepix4control
parser = argparse.ArgumentParser()
parser.add_argument("--shutter_time", type=int, default=20000)
parser.add_argument("--t0_time", type=float, default=0.0001)
parser.add_argument("--extratime", type=int, default=100000)
parser.add_argument("--pad", type=bool, default=False)
args = parser.parse_args()
mytpx4 = Timepix4control(1)
mytpx4.external_shutter(delay=False, shutter_time=args.shutter_time)
if args.pad:
mytpx4.external_t0_sync(delay=False, t0_time=args.t0_time)
mytpx4.slowtakeevents(extratime=args.extratime, pad=args.pad)
......@@ -220,19 +220,10 @@ class Tempus(Device):
async def _initialize(self):
try:
await self.send_command(f"cd {self.SCRIPT_DIR}")
await self.send_command("python3")
await self.send_command("import os")
await self.send_command("import numpy as np")
await self.send_command(
"from control import Timepix4control", sleep_time=2)
await self.send_command("os.system('devmem2 0x80010004 w 0x2')")
await self.send_command("os.system('devmem2 0x80010004 w 0x0')")
await self.send_command("os.system('devmem2 0x80010004 w 0x2')")
await self.send_command(
"mytpx4 = Timepix4control(1)", sleep_time=5)
await self.send_command(
f"os.system('{self.APP_DIR}/Timepix4_Init.py')", sleep_time=3)
await self.send_command("mytpx4.initialisechip()", sleep_time=1)
......@@ -323,18 +314,24 @@ class Tempus(Device):
self.state = State.ACQUIRING
self.background_task = background(self._acquire())
async def _acquire(self):
cmnd = [
self.COMMAND, *self.ARGS, f"{self.SCRIPT_DIR}/karabo_acquire.py",
f"--shutter_time={self.shutterTime.value}",
f"--t0_time={self.t0Time.value}",
f"--pad={self.externalSync}"]
self.commandLog = f"Starting acquisition:\n{' '.join(cmnd)}"
async def _acquire(self): # XXX test
await self.send_command(
"mytpx4.external_shutter(delay=False, "
f"shutter_time={self.shutterTime.value})") # XXX sleep_time
if self.externalSync:
await self.send_command(
"mytpx4.external_t0_sync(delay=False, "
f"t0_time={self.t0Time.value})") # XXX sleep_time
for i in range(self.nAcquisitions.value):
self.status = f"Acquisition #{i}"
await self.send_command(
"mytpx4.slowtakeevents(extratime=100000, "
f"pad={self.externalSync})", sleep_time=self.shutterTime.value)
if not self.do_acquire:
break
await self._execute_command(
cmnd, State.ACQUIRING, f"Acquisition #{i}")
self.state = State.ACTIVE
self.status = "Acquisition done"
......@@ -414,6 +411,16 @@ class Tempus(Device):
msg = f"Connected to {self.controllerIp}"
self.logger.info(msg)
self.status = msg
await self.send_command(f"cd {self.SCRIPT_DIR}")
await self.send_command("python3")
await self.send_command("import os")
await self.send_command("import numpy as np")
await self.send_command(
"from control import Timepix4control", sleep_time=2)
await self.send_command(
"mytpx4 = Timepix4control(1)", sleep_time=5)
self.state = State.INIT
except Exception as e:
self.client = None
......
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