Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tempus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
karaboDevices
tempus
Commits
5ae48f33
You need to sign in or sign up before continuing.
Commit
5ae48f33
authored
3 months ago
by
Andrea Parenti
Committed by
Jonathan Correa Magdalena
3 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Refactor / 1
parent
9fb30dec
No related branches found
No related tags found
2 merge requests
!2
Draft: Feat/p8003
,
!1
First version
Pipeline
#162659
failed
3 months ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/karabo_init.py
+0
-19
0 additions, 19 deletions
scripts/karabo_init.py
src/tempus/Tempus.py
+86
-8
86 additions, 8 deletions
src/tempus/Tempus.py
with
86 additions
and
27 deletions
scripts/karabo_init.py
deleted
100644 → 0
+
0
−
19
View file @
9fb30dec
import
os
from
control
import
Timepix4control
APP_DIR
=
"
/home/timepix4/application
"
os
.
system
(
'
devmem2 0x80010004 w 0x2
'
)
os
.
system
(
'
devmem2 0x80010004 w 0x0
'
)
os
.
system
(
'
devmem2 0x80010004 w 0x2
'
)
mytpx4
=
Timepix4control
(
1
)
os
.
system
(
APP_DIR
+
"
/Timepix4_Init.py
"
)
mytpx4
.
initialisechip
()
mytpx4
.
configureGWT
()
os
.
system
(
APP_DIR
+
"
/sc_set_gwt_link_up.py -i 0x0 -l 0x0 -s 0x2
"
)
os
.
system
(
APP_DIR
+
"
/sc_set_gwt_link_up.py -i 0x1 -l 0x0 -s 0x2
"
)
os
.
system
(
'
devmem2 0x80050000 w 0x2
'
)
This diff is collapsed.
Click to expand it.
src/tempus/Tempus.py
+
86
−
8
View file @
5ae48f33
...
...
@@ -15,6 +15,7 @@
from
asyncio
import
create_subprocess_exec
,
subprocess
# CancelledError
from
time
import
time
from
paramiko.client
import
SSHClient
from
psutil
import
net_io_counters
from
karabo.middlelayer
import
(
...
...
@@ -65,6 +66,7 @@ class Tempus(Device):
__version__
=
deviceVersion
COMMAND
=
"
ssh
"
APP_DIR
=
"
/home/timepix4/application
"
SCRIPT_DIR
=
"
/home/timepix4/master
"
def
__init__
(
self
,
configuration
):
...
...
@@ -72,8 +74,9 @@ class Tempus(Device):
self
.
background_task
=
None
self
.
monitor_task
=
background
(
self
.
_monitor
())
self
.
ARGS
=
[
f
"
root@
{
self
.
controllerIp
}
"
,
"
python3
"
]
self
.
client
=
None
self
.
channel
=
None
self
.
do_acquire
=
False
self
.
state
=
State
.
INIT
async
def
_monitor
(
self
):
last_time
=
None
...
...
@@ -204,18 +207,52 @@ class Tempus(Device):
@Slot
(
displayedName
=
"
Initialize
"
,
description
=
"
Run the initialization sequence. This
can
take about
"
"
30
s
"
,
description
=
"
Run the initialization sequence. This
will
take about
"
"
45
s
"
,
allowedStates
=
{
State
.
INIT
,
State
.
ON
})
async
def
initialize
(
self
):
self
.
state
=
State
.
CHANGING
self
.
status
=
"
Initializing TEMPUS
"
cmnd
=
[
self
.
COMMAND
,
*
self
.
ARGS
,
f
"
{
self
.
SCRIPT_DIR
}
/karabo_init.py
"
]
self
.
commandLog
=
(
f
"
Initializing TEMPUS:
\n
{
'
'
.
join
(
cmnd
)
}
\n
This can take about 30
"
"
s
"
)
self
.
background_task
=
background
(
self
.
_execute_command
(
cmnd
,
State
.
ON
,
"
Initialized
"
))
"
Initializing TEMPUS:
\n
This will take about 45 s.
\n\n
"
)
self
.
background_task
=
background
(
self
.
_initialize
())
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
(
"
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
)
await
self
.
send_command
(
"
mytpx4.configureGWT()
"
,
sleep_time
=
1
)
await
self
.
send_command
(
f
"
os.system(
'
{
self
.
APP_DIR
}
/sc_set_gwt_link_up.py -i 0x0
"
"
-l 0x0 -s 0x2
'
)
"
,
sleep_time
=
15
)
await
self
.
send_command
(
f
"
os.system(
'
{
self
.
APP_DIR
}
/sc_set_gwt_link_up.py -i 0x1
"
"
-l 0x0 -s 0x2
'
)
"
,
sleep_time
=
15
)
await
self
.
send_command
(
"
os.system(
'
devmem2 0x80050000 w 0x2
'
)
"
)
self
.
status
=
"
Initialized
"
self
.
state
=
State
.
ON
except
Exception
as
e
:
self
.
logger
.
error
(
e
)
self
.
state
=
State
.
ERROR
self
.
status
=
str
(
e
)
self
.
commandLog
=
str
(
e
)
@Slot
(
displayedName
=
"
Reset Fast-Links
"
,
...
...
@@ -341,8 +378,49 @@ class Tempus(Device):
defaultValue
=
0.0001
,
allowedStates
=
{
State
.
INIT
,
State
.
ON
,
State
.
ACTIVE
})
async
def
onInitialization
(
self
):
try
:
self
.
client
=
SSHClient
()
self
.
client
.
load_system_host_keys
()
self
.
client
.
connect
(
self
.
controllerIp
,
username
=
"
root
"
,
password
=
""
)
self
.
channel
=
self
.
client
.
invoke_shell
()
msg
=
f
"
Connected to
{
self
.
controllerIp
}
"
self
.
logger
.
info
(
msg
)
self
.
status
=
msg
self
.
state
=
State
.
INIT
except
Exception
as
e
:
self
.
client
=
None
self
.
channel
=
None
msg
=
f
"
Cannot connect to
{
self
.
controllerIp
}
"
self
.
status
=
msg
self
.
logger
.
error
(
f
"
{
msg
}
:
{
e
}
"
)
async
def
onDestruction
(
self
):
if
self
.
channel
:
self
.
channel
.
close
()
if
self
.
client
:
self
.
client
.
close
()
# De-initialize
cmnd
=
[
self
.
COMMAND
,
*
self
.
ARGS
,
f
"
{
self
.
SCRIPT_DIR
}
/karabo_deinit.py
"
]
await
self
.
_execute_command
(
cmnd
,
State
.
INIT
,
""
)
async
def
send_command
(
self
,
cmnd
,
sleep_time
=
0.1
):
self
.
logger
.
info
(
f
"
Executing:
{
cmnd
}
"
)
# XXX debug
self
.
channel
.
send
(
cmnd
+
"
\n
"
)
await
sleep
(
sleep_time
)
recv_stderr
=
b
""
while
self
.
channel
.
recv_stderr_ready
():
recv_stderr
+=
self
.
channel
.
recv_stderr
(
1024
)
if
recv_stderr
:
raise
RuntimeError
(
recv_stderr
.
decode
())
recv
=
b
""
while
self
.
channel
.
recv_ready
():
recv
+=
self
.
channel
.
recv
(
1024
)
self
.
logger
.
info
(
recv
)
# XXX debug
self
.
commandLog
=
recv
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment