Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
AIDA-2020 TLU - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
AIDA-2020 TLU - Software
Commits
ba235e10
Commit
ba235e10
authored
Jun 01, 2023
by
David Cussans
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converting from Python 2 to 3
parent
7cd338b5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
1857 additions
and
1757 deletions
+1857
-1757
AIDA_testPower.py
TLU_v1e/scripts/AIDA_testPower.py
+50
-53
AIDA_testScript.py
TLU_v1e/scripts/AIDA_testScript.py
+93
-96
TLU_v1e.py
TLU_v1e/scripts/TLU_v1e.py
+534
-472
TLUconnection.xml
TLU_v1e/scripts/TLUconnection.xml
+3
-1
initTLU.py
TLU_v1e/scripts/initTLU.py
+84
-81
localConf.conf
TLU_v1e/scripts/localConf.conf
+12
-9
startTLU_v1e.py
TLU_v1e/scripts/startTLU_v1e.py
+67
-67
startTLU_v1e.sh
TLU_v1e/scripts/startTLU_v1e.sh
+1
-1
startTLU_v6.py
TLU_v1e/scripts/startTLU_v6.py
+99
-82
test.py
TLU_v1e/scripts/test.py
+13
-12
testTLU_script.py
TLU_v1e/scripts/testTLU_script.py
+48
-49
test_T0.py
TLU_v1e/scripts/test_T0.py
+35
-35
AD5665R.py
packages/AD5665R.py
+29
-28
ADN2814ACPZ.py
packages/ADN2814ACPZ.py
+69
-67
ATSHA204A.py
packages/ATSHA204A.py
+78
-78
E24AA025E48T.py
packages/E24AA025E48T.py
+8
-8
FmcTluI2c.py
packages/FmcTluI2c.py
+53
-56
I2CDISP.py
packages/I2CDISP.py
+116
-109
I2CuHal.py
packages/I2CuHal.py
+33
-36
I2CuHal2.py
packages/I2CuHal2.py
+34
-35
I2cBusProperties.py
packages/I2cBusProperties.py
+39
-34
NHDC0220Biz.py
packages/NHDC0220Biz.py
+13
-12
PCA9539PW.py
packages/PCA9539PW.py
+41
-41
PCA9548ADW.py
packages/PCA9548ADW.py
+22
-22
RawI2cAccess.py
packages/RawI2cAccess.py
+28
-34
SFPI2C.py
packages/SFPI2C.py
+43
-41
TLU_powermodule.py
packages/TLU_powermodule.py
+119
-110
si5345.py
packages/si5345.py
+93
-88
No files found.
TLU_v1e/scripts/AIDA_testPower.py
View file @
ba235e10
...
...
@@ -14,72 +14,69 @@ hw = manager.getDevice("tlu")
# hw.getNode("A").write(255)
reg
=
hw
.
getNode
(
"version"
)
.
read
()
hw
.
dispatch
()
print
"CHECK REG= "
,
hex
(
reg
)
print
(
"CHECK REG= "
,
hex
(
reg
)
)
# #First I2C core
print
(
"Instantiating master I2C core:"
)
master_I2C
=
I2CCore
(
hw
,
10
,
5
,
"i2c_master"
,
None
)
print
(
"Instantiating master I2C core:"
)
master_I2C
=
I2CCore
(
hw
,
10
,
5
,
"i2c_master"
,
None
)
master_I2C
.
state
()
#
# #######################################
enableCore
=
False
#
Only need to run this once, after power-up
enableCore
=
False
#
Only need to run this once, after power-up
if
(
enableCore
):
mystop
=
True
print
" Write RegDir to set I/O[7] to output:"
myslave
=
0x21
mycmd
=
[
0x01
,
0x7F
]
nwords
=
1
master_I2C
.
write
(
myslave
,
mycmd
,
mystop
)
mystop
=
True
print
(
" Write RegDir to set I/O[7] to output:"
)
myslave
=
0x21
mycmd
=
[
0x01
,
0x7F
]
nwords
=
1
master_I2C
.
write
(
myslave
,
mycmd
,
mystop
)
mystop
=
False
mycmd
=
[
0x01
]
master_I2C
.
write
(
myslave
,
mycmd
,
mystop
)
res
=
master_I2C
.
read
(
myslave
,
nwords
)
print
"
\t
Post RegDir: "
,
res
mystop
=
False
mycmd
=
[
0x01
]
master_I2C
.
write
(
myslave
,
mycmd
,
mystop
)
res
=
master_I2C
.
read
(
myslave
,
nwords
)
print
(
"
\t
Post RegDir: "
,
res
)
#DAC CONFIGURATION BEGIN
#
DAC CONFIGURATION BEGIN
if
(
False
):
zeDAC1
=
AD5665R
(
master_I2C
,
0x1C
)
zeDAC1
.
setIntRef
(
intRef
=
False
,
verbose
=
True
)
zeDAC1
.
writeDAC
(
0x0
,
7
,
verbose
=
True
)
#
7626
zeDAC1
=
AD5665R
(
master_I2C
,
0x1C
)
zeDAC1
.
setIntRef
(
intRef
=
False
,
verbose
=
True
)
zeDAC1
.
writeDAC
(
0x0
,
7
,
verbose
=
True
)
#
7626
if
(
True
):
# #I2C EXPANDER CONFIGURATION BEGIN
IC6
=
PCA9539PW
(
master_I2C
,
0x76
)
#BANK 0
IC6
.
setInvertReg
(
0
,
0x00
)
# 0= normal
IC6
.
setIOReg
(
0
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
IC6
.
setOutputs
(
0
,
0x00
)
res
=
IC6
.
getInputs
(
0
)
print
"IC6 read back bank 0: 0x
%
X"
%
res
[
0
]
#
#BANK 1
IC6
.
setInvertReg
(
1
,
0x00
)
# 0= normal
IC6
.
setIOReg
(
1
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
IC6
.
setOutputs
(
1
,
0x00
)
res
=
IC6
.
getInputs
(
1
)
print
"IC6 read back bank 1: 0x
%
X"
%
res
[
0
]
# # #
IC7
=
PCA9539PW
(
master_I2C
,
0x77
)
#BANK 0
IC7
.
setInvertReg
(
0
,
0x00
)
# 0= normal
IC7
.
setIOReg
(
0
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
IC7
.
setOutputs
(
0
,
0x00
)
res
=
IC7
.
getInputs
(
0
)
print
"IC7 read back bank 0: 0x
%
X"
%
res
[
0
]
#
#BANK 1
IC7
.
setInvertReg
(
1
,
0x00
)
# 0= normal
IC7
.
setIOReg
(
1
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
IC7
.
setOutputs
(
1
,
0x00
)
res
=
IC7
.
getInputs
(
1
)
print
"IC7 read back bank 1: 0x
%
X"
%
res
[
0
]
# #I2C EXPANDER CONFIGURATION END
# #I2C EXPANDER CONFIGURATION BEGIN
IC6
=
PCA9539PW
(
master_I2C
,
0x76
)
# BANK 0
IC6
.
setInvertReg
(
0
,
0x00
)
# 0= normal
IC6
.
setIOReg
(
0
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
IC6
.
setOutputs
(
0
,
0x00
)
res
=
IC6
.
getInputs
(
0
)
print
(
"IC6 read back bank 0: 0x
%
X"
%
res
[
0
])
#
# BANK 1
IC6
.
setInvertReg
(
1
,
0x00
)
# 0= normal
IC6
.
setIOReg
(
1
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
IC6
.
setOutputs
(
1
,
0x00
)
res
=
IC6
.
getInputs
(
1
)
print
(
"IC6 read back bank 1: 0x
%
X"
%
res
[
0
])
# # #
IC7
=
PCA9539PW
(
master_I2C
,
0x77
)
# BANK 0
IC7
.
setInvertReg
(
0
,
0x00
)
# 0= normal
IC7
.
setIOReg
(
0
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
IC7
.
setOutputs
(
0
,
0x00
)
res
=
IC7
.
getInputs
(
0
)
print
(
"IC7 read back bank 0: 0x
%
X"
%
res
[
0
])
#
# BANK 1
IC7
.
setInvertReg
(
1
,
0x00
)
# 0= normal
IC7
.
setIOReg
(
1
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
IC7
.
setOutputs
(
1
,
0x00
)
res
=
IC7
.
getInputs
(
1
)
print
(
"IC7 read back bank 1: 0x
%
X"
%
res
[
0
])
# #I2C EXPANDER CONFIGURATION END
TLU_v1e/scripts/AIDA_testScript.py
View file @
ba235e10
...
...
@@ -7,7 +7,7 @@ from si5345 import si5345
from
AD5665R
import
AD5665R
from
PCA9539PW
import
PCA9539PW
from
E24AA025E48T
import
E24AA025E48T
from
I2CDISP
import
LCD_ada
#
Library for display
from
I2CDISP
import
LCD_ada
#
Library for display
manager
=
uhal
.
ConnectionManager
(
"file://./TLUconnection.xml"
)
hw
=
manager
.
getDevice
(
"tlu"
)
...
...
@@ -15,34 +15,31 @@ hw = manager.getDevice("tlu")
# hw.getNode("A").write(255)
reg
=
hw
.
getNode
(
"version"
)
.
read
()
hw
.
dispatch
()
print
"CHECK REG= "
,
hex
(
reg
)
print
(
"CHECK REG= "
,
hex
(
reg
)
)
# #First I2C core
print
(
"Instantiating master I2C core:"
)
master_I2C
=
I2CCore
(
hw
,
10
,
5
,
"i2c_master"
,
None
)
print
(
"Instantiating master I2C core:"
)
master_I2C
=
I2CCore
(
hw
,
10
,
5
,
"i2c_master"
,
None
)
master_I2C
.
state
()
#
# #######################################
enableCore
=
True
#
Only need to run this once, after power-up
enableCore
=
True
#
Only need to run this once, after power-up
if
(
enableCore
):
mystop
=
True
print
" Write RegDir to set I/O[7] to output:"
myslave
=
0x21
mycmd
=
[
0x01
,
0x7F
]
nwords
=
1
master_I2C
.
write
(
myslave
,
mycmd
,
mystop
)
mystop
=
False
mycmd
=
[
0x01
]
master_I2C
.
write
(
myslave
,
mycmd
,
mystop
)
res
=
master_I2C
.
read
(
myslave
,
nwords
)
print
"
\t
Post RegDir: "
,
res
mystop
=
True
print
(
" Write RegDir to set I/O[7] to output:"
)
myslave
=
0x21
mycmd
=
[
0x01
,
0x7F
]
nwords
=
1
master_I2C
.
write
(
myslave
,
mycmd
,
mystop
)
mystop
=
False
mycmd
=
[
0x01
]
master_I2C
.
write
(
myslave
,
mycmd
,
mystop
)
res
=
master_I2C
.
read
(
myslave
,
nwords
)
print
(
"
\t
Post RegDir: "
,
res
)
# #######################################
#
# time.sleep(0.1)
...
...
@@ -62,10 +59,10 @@ if (enableCore):
# #######################################
#Second I2C core
#
Second I2C core
#print ("Instantiating SFP I2C core:")
#clock_I2C= I2CCore(hw, 10, 5, "i2c_sfp", None)
#clock_I2C.state()
#
clock_I2C.state()
# #Third I2C core
# print ("Instantiating clock I2C core:")
...
...
@@ -90,104 +87,104 @@ if (enableCore):
#
#CLOCK CONFIGURATION BEGIN
zeClock
=
si5345
(
master_I2C
,
0x68
)
res
=
zeClock
.
getDeviceVersion
()
#
CLOCK CONFIGURATION BEGIN
zeClock
=
si5345
(
master_I2C
,
0x68
)
res
=
zeClock
.
getDeviceVersion
()
zeClock
.
checkDesignID
()
#zeClock.setPage(0, True)
#zeClock.getPage(True)
doClock
=
False
#
zeClock.getPage(True)
doClock
=
False
if
(
doClock
):
clkRegList
=
zeClock
.
parse_clk
(
"./../../bitFiles/TLU_CLK_Config_v1e.txt"
)
zeClock
.
writeConfiguration
(
clkRegList
)
######
zeClock
.
writeRegister
(
0x0536
,
[
0x0A
])
#
Configures manual switch of inputs
zeClock
.
writeRegister
(
0x0949
,
[
0x0F
])
#
Enable all inputs
zeClock
.
writeRegister
(
0x052A
,
[
0x05
])
#
Configures source of input
iopower
=
zeClock
.
readRegister
(
0x0949
,
1
)
print
" Clock IO power: 0x
%
X"
%
iopower
[
0
]
lol
=
zeClock
.
readRegister
(
0x000E
,
1
)
print
" Clock LOL (0x000E): 0x
%
X"
%
lol
[
0
]
los
=
zeClock
.
readRegister
(
0x000D
,
1
)
print
" Clock LOS (0x000D): 0x
%
X"
%
los
[
0
]
#CLOCK CONFIGURATION END
#DAC CONFIGURATION BEGIN
zeDAC1
=
AD5665R
(
master_I2C
,
0x13
)
zeDAC1
.
setIntRef
(
intRef
=
False
,
verbose
=
True
)
zeDAC1
.
writeDAC
(
0x0
,
7
,
verbose
=
True
)
#
7626
zeDAC2
=
AD5665R
(
master_I2C
,
0x1F
)
zeDAC2
.
setIntRef
(
intRef
=
False
,
verbose
=
True
)
zeDAC2
.
writeDAC
(
0x2fff
,
3
,
verbose
=
True
)
#DAC CONFIGURATION END
#EEPROM BEGIN
zeEEPROM
=
E24AA025E48T
(
master_I2C
,
0x50
)
res
=
zeEEPROM
.
readEEPROM
(
0xfa
,
6
)
result
=
" EEPROM ID:
\n\t
"
clkRegList
=
zeClock
.
parse_clk
(
"./../../bitFiles/TLU_CLK_Config_v1e.txt"
)
zeClock
.
writeConfiguration
(
clkRegList
)
zeClock
.
writeRegister
(
0x0536
,
[
0x0A
])
#
Configures manual switch of inputs
zeClock
.
writeRegister
(
0x0949
,
[
0x0F
])
#
Enable all inputs
zeClock
.
writeRegister
(
0x052A
,
[
0x05
])
#
Configures source of input
iopower
=
zeClock
.
readRegister
(
0x0949
,
1
)
print
(
" Clock IO power: 0x
%
X"
%
iopower
[
0
])
lol
=
zeClock
.
readRegister
(
0x000E
,
1
)
print
(
" Clock LOL (0x000E): 0x
%
X"
%
lol
[
0
])
los
=
zeClock
.
readRegister
(
0x000D
,
1
)
print
(
" Clock LOS (0x000D): 0x
%
X"
%
los
[
0
])
#
CLOCK CONFIGURATION END
#
DAC CONFIGURATION BEGIN
zeDAC1
=
AD5665R
(
master_I2C
,
0x13
)
zeDAC1
.
setIntRef
(
intRef
=
False
,
verbose
=
True
)
zeDAC1
.
writeDAC
(
0x0
,
7
,
verbose
=
True
)
#
7626
zeDAC2
=
AD5665R
(
master_I2C
,
0x1F
)
zeDAC2
.
setIntRef
(
intRef
=
False
,
verbose
=
True
)
zeDAC2
.
writeDAC
(
0x2fff
,
3
,
verbose
=
True
)
#
DAC CONFIGURATION END
#
EEPROM BEGIN
zeEEPROM
=
E24AA025E48T
(
master_I2C
,
0x50
)
res
=
zeEEPROM
.
readEEPROM
(
0xfa
,
6
)
result
=
" EEPROM ID:
\n\t
"
for
iaddr
in
res
:
result
+=
"
%02
x "
%
(
iaddr
)
print
result
#EEPROM END
result
+=
"
%02
x "
%
(
iaddr
)
print
(
result
)
#
EEPROM END
# #I2C EXPANDER CONFIGURATION BEGIN
IC6
=
PCA9539PW
(
master_I2C
,
0x74
)
#BANK 0
IC6
.
setInvertReg
(
0
,
0x00
)
# 0= normal
IC6
.
setIOReg
(
0
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
IC6
.
setOutputs
(
0
,
0x77
)
#
77
res
=
IC6
.
getInputs
(
0
)
print
"
\t
IC6 read back bank 0: 0x
%
X"
%
res
[
0
]
IC6
=
PCA9539PW
(
master_I2C
,
0x74
)
#
BANK 0
IC6
.
setInvertReg
(
0
,
0x00
)
# 0= normal
IC6
.
setIOReg
(
0
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
IC6
.
setOutputs
(
0
,
0x77
)
#
77
res
=
IC6
.
getInputs
(
0
)
print
(
"
\t
IC6 read back bank 0: 0x
%
X"
%
res
[
0
])
#
#BANK 1
IC6
.
setInvertReg
(
1
,
0x00
)
# 0= normal
IC6
.
setIOReg
(
1
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
IC6
.
setOutputs
(
1
,
0x77
)
#
77
res
=
IC6
.
getInputs
(
1
)
print
"
\t
IC6 read back bank 1: 0x
%
X"
%
res
[
0
]
#
BANK 1
IC6
.
setInvertReg
(
1
,
0x00
)
# 0= normal
IC6
.
setIOReg
(
1
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
IC6
.
setOutputs
(
1
,
0x77
)
#
77
res
=
IC6
.
getInputs
(
1
)
print
(
"
\t
IC6 read back bank 1: 0x
%
X"
%
res
[
0
])
# # #
IC7
=
PCA9539PW
(
master_I2C
,
0x75
)
#BANK 0
IC7
.
setInvertReg
(
0
,
0x00
)
# 0= normal
IC7
.
setIOReg
(
0
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
IC7
=
PCA9539PW
(
master_I2C
,
0x75
)
#
BANK 0
IC7
.
setInvertReg
(
0
,
0x00
)
# 0= normal
IC7
.
setIOReg
(
0
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
IC7
.
setOutputs
(
0
,
0xF0
)
res
=
IC7
.
getInputs
(
0
)
print
"
\t
IC7 read back bank 0: 0x
%
X"
%
res
[
0
]
res
=
IC7
.
getInputs
(
0
)
print
(
"
\t
IC7 read back bank 0: 0x
%
X"
%
res
[
0
])
#
#BANK 1
IC7
.
setInvertReg
(
1
,
0x00
)
# 0= normal
IC7
.
setIOReg
(
1
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
#
BANK 1
IC7
.
setInvertReg
(
1
,
0x00
)
# 0= normal
IC7
.
setIOReg
(
1
,
0x00
)
# 0= output <<<<<<<<<<<<<<<<<<<
IC7
.
setOutputs
(
1
,
0xAF
)
res
=
IC7
.
getInputs
(
1
)
print
"
\t
IC7 read back bank 1: 0x
%
X"
%
res
[
0
]
res
=
IC7
.
getInputs
(
1
)
print
(
"
\t
IC7 read back bank 1: 0x
%
X"
%
res
[
0
])
# #I2C EXPANDER CONFIGURATION END
#Instantiate Display
doDisplaytest
=
False
#
Instantiate Display
doDisplaytest
=
False
if
doDisplaytest
:
DISP
=
LCD_ada
(
master_I2C
,
0x20
)
#
3A
#
self.DISP.clear()
DISP
.
test
()
DISP
=
LCD_ada
(
master_I2C
,
0x20
)
#
3A
#
self.DISP.clear()
DISP
.
test
()
# #Reset counters
#cmd = int("0x0", 16) #write 0x2 to reset
#hw.getNode("triggerInputs.SerdesRstW").write(cmd)
#
cmd = int("0x0", 16) #write 0x2 to reset
#
hw.getNode("triggerInputs.SerdesRstW").write(cmd)
#restatus= hw.getNode("triggerInputs.SerdesRstR").read()
#hw.dispatch()
#print "Trigger Reset: 0x%X" % restatus
#
# #
Read trigger inputs
#
hw.dispatch()
#
print "Trigger Reset: 0x%X" % restatus
#
Read trigger inputs
#myreg= [-1, -1, -1, -1, -1, -1]
#for inputN in range(0, 6):
#
for inputN in range(0, 6):
# regString= "triggerInputs.ThrCount%dR" % inputN
# myreg[inputN]= hw.getNode(regString).read()
# hw.dispatch()
# print regString, myreg[inputN]
#
#
Read ev formatter
# Read ev formatter
#cmd = int("0x0", 16) #
#
#
hw.getNode("Event_Formatter.Enable_Record_Data").write(cmd)
#
hw.getNode("Event_Formatter.Enable_Record_Data").write(cmd)
#efstatus= hw.getNode("Event_Formatter.CurrentTimestampLR").read()
#hw.dispatch()
#print "Event Formatter Record: 0x%X" % efstatus
#
hw.dispatch()
#
print "Event Formatter Record: 0x%X" % efstatus
TLU_v1e/scripts/TLU_v1e.py
View file @
ba235e10
This diff is collapsed.
Click to expand it.
TLU_v1e/scripts/TLUconnection.xml
View file @
ba235e10
<?xml version="1.0" encoding="UTF-8"?>
<connections>
<connection
id=
"tlu"
uri=
"ipbusudp-2.0://192.168.200.30:50001"
<!--connection id="tlu" uri="ipbusudp-2.0://192.168.200.30:50001"-->
<connection
id=
"tlu"
uri=
"chtcp-2.0://localhost:10203?target=192.168.200.30:50001"
address_table=
"file://./TLUaddrmap.xml"
/>
</connections>
TLU_v1e/scripts/initTLU.py
View file @
ba235e10
This diff is collapsed.
Click to expand it.
TLU_v1e/scripts/localConf.conf
View file @
ba235e10
[
Producer
.
fmctlu
]
verbose
=
2
confid
=
20
170626
confid
=
20
221005
delayStart
=
1000
# HDMI pin direction:
# 4-bits to determine direction of HDMI pins
# 1-bit for the clock pair
# 0= pins are not driving signals, 1 pins drive signals (outputs)
# 0 = clock pins are not driving signals,
# 1 = clock pins drive signals from FPGA
# 2 = clock pins drive signals from si5345 clock generator
HDMI1_set
=
0
x7
HDMI2_set
=
0
x7
HDMI3_set
=
0
x7
HDMI4_set
=
0
x7
HDMI1_clk
=
0
HDMI2_clk
=
0
HDMI3_clk
=
0
HDMI4_clk
=
0
HDMI1_clk
=
2
HDMI2_clk
=
2
HDMI3_clk
=
2
HDMI4_clk
=
2
# Control voltages for the PMTs
PMT1_V
=
0
.
5
...
...
@@ -51,21 +53,22 @@ DACThreshold4 = -0.12
DACThreshold5
= -
0
.
12
# Define which DUTs are ON
DUTMask
=
0
x
1
DUTMask
=
0
x
F
# Define mode of DUT (00 EUDET, 11 AIDA)
DUTMaskMode
=
0
xF
C
DUTMaskMode
=
0
xF
F
# Allow asynchronous veto
DUTMaskModeModifier
=
0
x0
# Ignore busy from a specific DUT
DUTIgnoreBusy
=
0
x
0
DUTIgnoreBusy
=
0
x
F
# Ignore the SHUTTER veto on a specific DUT
DUTIgnoreShutterVeto
=
0
x0
# Generate internal triggers (in Hz, 0= no triggers)
#InternalTriggerFreq = 10
InternalTriggerFreq
=
0
...
...
TLU_v1e/scripts/startTLU_v1e.py
View file @
ba235e10
...
...
@@ -17,7 +17,7 @@ from TLU_v1e import TLU
import
cmd
# Use to have config file parser
import
ConfigP
arser
import
configp
arser
# Use root
from
ROOT
import
TFile
,
TTree
,
gROOT
,
AddressOf
...
...
@@ -25,7 +25,7 @@ from ROOT import *
import
numpy
as
numpy
#
#
Define class that creates the command user inteface
# Define class that creates the command user inteface
class
MyPrompt
(
cmd
.
Cmd
):
# def do_initialise(self, args):
...
...
@@ -44,32 +44,31 @@ class MyPrompt(cmd.Cmd):
# print "\t Could not retrieve INI data."
# return
def
do_configure
(
self
,
args
):
"""Processes the CONF file and writes its values to the TLU. To use a specific file type:
\n
parseIni path/to/filename.conf
\n
(without quotation marks)"""
print
"==== COMMAND RECEIVED: PARSE CONFIG"
#
self.testme()
parsed_cfg
=
self
.
open_cfg_file
(
args
,
"./localConf.conf"
)
print
(
"==== COMMAND RECEIVED: PARSE CONFIG"
)
#
self.testme()
parsed_cfg
=
self
.
open_cfg_file
(
args
,
"./localConf.conf"
)
try
:
theID
=
parsed_cfg
.
getint
(
"Producer.fmctlu"
,
"confid"
)
print
"
\t
"
,
theID
print
(
"
\t
"
,
theID
)
TLU
.
configure
(
parsed_cfg
)
except
IOError
:
print
"
\t
Could not retrieve CONF data."
print
(
"
\t
Could not retrieve CONF data."
)
return
def
do_i2c
(
self
,
args
):
arglist
=
args
.
split
()
arglist
=
args
.
split
()
if
len
(
arglist
)
==
0
:
print
"
\t
no command specified"
print
(
"
\t
no command specified"
)
else
:
i2ccmd
=
arglist
[
0
]
i2ccmd
=
arglist
[
0
]
results
=
list
(
map
(
int
,
arglist
))
TLU
.
DISP
.
writeSomething
(
results
)
print
"Sending i2c command to display"
return
TLU
.
DISP
.
writeSomething
(
results
)
print
(
"Sending i2c command to display"
)
return
def
do_id
(
self
,
args
):
"""Interrogates the TLU and prints it unique ID on screen"""
...
...
@@ -85,40 +84,41 @@ class MyPrompt(cmd.Cmd):
def
do_startRun
(
self
,
args
):
"""Starts the TLU run. If a number is specified, this number will be appended to the file name as Run_#"""
print
"==== COMMAND RECEIVED: STARTING TLU RUN"
#startTLU( uhalDevice = self.hw, pychipsBoard = self.board, writeTimestamps = ( options.writeTimestamps == "True" ) )
print
(
"==== COMMAND RECEIVED: STARTING TLU RUN"
)
#startTLU( uhalDevice = self.hw, pychipsBoard = self.board, writeTimestamps = ( options.writeTimestamps == "True" ) )
arglist
=
args
.
split
()
if
len
(
arglist
)
==
0
:
print
"
\t
no run# specified, using 1"
runN
=
1
print
(
"
\t
no run# specified, using 1"
)
runN
=
1
else
:
runN
=
arglist
[
0
]
runN
=
arglist
[
0
]
logdata
=
True
logdata
=
True
#TLU.start(logdata)
if
(
TLU
.
isRunning
):
#
Prevent double start
print
" Run already in progress"
#
TLU.start(logdata)
if
(
TLU
.
isRunning
):
#
Prevent double start
print
(
" Run already in progress"
)
return
else
:
now
=
datetime
.
now
()
.
strftime
(
'
%
Y
%
m
%
d_
%
H
%
M
%
S'
)
default_filename
=
"./datafiles/"
+
now
+
"_tluData_"
+
str
(
runN
)
+
".root"
rootFname
=
default_filename
print
"OPENING ROOT FILE:"
,
rootFname
self
.
root_file
=
TFile
(
rootFname
,
'RECREATE'
)
default_filename
=
"./datafiles/"
+
\
now
+
"_tluData_"
+
str
(
runN
)
+
".root"
rootFname
=
default_filename
print
(
"OPENING ROOT FILE:"
,
rootFname
)
self
.
root_file
=
TFile
(
rootFname
,
'RECREATE'
)
# Create a root "tree"
root_tree
=
TTree
(
'T'
,
'TLU Data'
)
root_tree
=
TTree
(
'T'
,
'TLU Data'
)
#highWord =0
#lowWord =0
#evtNumber=0
#timeStamp=0
#evtType=0
#trigsFired=0
#
evtNumber=0
#
timeStamp=0
#
evtType=0
#
trigsFired=0
#bufPos = 0
#https://root-forum.cern.ch/t/long-integer/1961/2
#
https://root-forum.cern.ch/t/long-integer/1961/2
gROOT
.
ProcessLine
(
"struct MyStruct {
\
"struct MyStruct {
\
UInt_t raw0;
\
UInt_t raw1;
\
UInt_t raw2;
\
...
...
@@ -129,13 +129,13 @@ class MyPrompt(cmd.Cmd):
ULong64_t tluTimeStamp;
\
UChar_t tluEvtType;
\
UChar_t tluTrigFired;
\
};"
);
mystruct
=
MyStruct
()
};"
)
mystruct
=
MyStruct
()
# Create a branch for each piece of data
root_tree
.
Branch
(
'EVENTS'
,
mystruct
,
'raw0/i:raw1/i:raw2/i:raw3/i:raw4/i:raw5/i:evtNumber/i:tluTimeStamp/l:tluEvtType/b:tluTrigFired/b'
)
root_tree
.
Branch
(
'EVENTS'
,
mystruct
,
'raw0/i:raw1/i:raw2/i:raw3/i:raw4/i:raw5/i:evtNumber/i:tluTimeStamp/l:tluEvtType/b:tluTrigFired/b'
)
# root_tree.Branch( 'tluHighWord' , highWord , "HighWord/l")
# root_tree.Branch( 'tluLowWord' , lowWord , "LowWord/l")
# root_tree.Branch( 'tluExtWord' , extWord , "ExtWord/l")
...
...
@@ -144,36 +144,36 @@ class MyPrompt(cmd.Cmd):
# root_tree.Branch( 'tluEvtNumber' , evtNumber , "EvtNumber/i")
# root_tree.Branch( 'tluEvtType' , evtType , "EvtType/b")
# root_tree.Branch( 'tluTrigFired' , trigsFired, "TrigsFired/b")
#self.root_file.Write()
#
self.root_file.Write()
daq_thread
=
threading
.
Thread
(
target
=
TLU
.
start
,
args
=
(
logdata
,
runN
,
mystruct
,
root_tree
))
daq_thread
=
threading
.
Thread
(
target
=
TLU
.
start
,
args
=
(
logdata
,
runN
,
mystruct
,
root_tree
))
daq_thread
.
start
()
def
do_endRun
(
self
,
args
):
"""Stops the TLU run"""
print
"==== COMMAND RECEIVED: STOP TLU RUN"
"""Stops the TLU run"""
print
(
"==== COMMAND RECEIVED: STOP TLU RUN"
)
if
TLU
.
isRunning
:
TLU
.
isRunning
=
False
TLU
.
isRunning
=
False
TLU
.
stop
(
False
,
False
)
self
.
root_file
.
Write
()
self
.
root_file
.
Close
()
else
:
print
" No run to stop"
print
(
" No run to stop"
)
def
do_quit
(
self
,
args
):
"""Quits the program."""
print
"==== COMMAND RECEIVED: QUITTING TLU CONSOLE"
print
(
"==== COMMAND RECEIVED: QUITTING TLU CONSOLE"
)
if
TLU
.
isRunning
:
TLU
.
isRunning
=
False
TLU
.
isRunning
=
False
TLU
.
stop
(
False
,
False
)
self
.
root_file
.
Write
()
self
.
root_file
.
Close
()
print
"Terminating run"
return
True
print
(
"Terminating run"
)
return
True
def
testme
(
self
):
print
"This is a test"
print
(
"This is a test"
)
def
open_cfg_file
(
self
,
args
,
default_file
):
# Parse the user arguments, attempts to opent the file and performs a (minimal)
...
...
@@ -181,22 +181,22 @@ class MyPrompt(cmd.Cmd):
arglist
=
args
.
split
()
if
len
(
arglist
)
==
0
:
print
"
\t
no file specified, using default"
fileName
=
default_file
print
"
\t
"
,
fileName
print
(
"
\t
no file specified, using default"
)
fileName
=
default_file
print
(
"
\t
"
,
fileName
)
else
:
fileName
=
arglist
[
0
]
fileName
=
arglist
[
0
]
if
len
(
arglist
)
>
1
:
print
"
\t
invalid: too many arguments. Max 1."
print
(
"
\t
invalid: too many arguments. Max 1."
)
return
parsed_file
=
ConfigP
arser
.
RawConfigParser
()
parsed_file
=
configp
arser
.
RawConfigParser
()
try
:
with
open
(
fileName
)
as
f
:
parsed_file
.
readfp
(
f
)
print
"
\t
"
,
parsed_file
.
sections
(
)
print
(
"
\t
"
,
parsed_file
.
sections
()
)
except
IOError
:
print
"
\t
Error while parsing the specified file."
print
(
"
\t
Error while parsing the specified file."
)
return
return
parsed_file
...
...
@@ -226,21 +226,21 @@ class MyPrompt(cmd.Cmd):
#################################################
if
__name__
==
"__main__"
:
print
"TLU v1E MAIN"
print
(
"TLU v1E MAIN"
)
prompt
=
MyPrompt
()
prompt
.
prompt
=
'>> '
parsed_ini
=
prompt
.
open_cfg_file
(
""
,
"./localIni.ini"
)
TLU
=
TLU
(
"tlu"
,
"file://./TLUconnection.xml"
,
parsed_ini
)
parsed_ini
=
prompt
.
open_cfg_file
(
""
,
"./localIni.ini"
)
TLU
=
TLU
(
"tlu"
,
"file://./TLUconnection.xml"
,
parsed_ini
)
#
##
TLU.configure(parsed_cfg)
#
TLU.configure(parsed_cfg)
###logdata= True
#
##
TLU.start(logdata)
#
##
time.sleep(5)
#
TLU.start(logdata)
#
time.sleep(5)
###TLU.stop(False, False)
# Start interactive prompt
print
"===================================================================="
print
"==========================TLU TEST CONSOLE=========================="
print
"===================================================================="
print
(
"===================================================================="
)
print
(
"==========================TLU TEST CONSOLE=========================="
)
print
(
"===================================================================="
)
prompt
.
cmdloop
(
"Type 'help' for a list of commands."
)
TLU_v1e/scripts/startTLU_v1e.sh