Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyPCC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
LOFAR2.0
PyPCC
Commits
a74e0b3b
Commit
a74e0b3b
authored
4 years ago
by
Paulus Kruger
Browse files
Options
Downloads
Patches
Plain Diff
UNB2 OPC-UA variables
parent
0f8682af
No related branches found
Branches containing commit
No related tags found
1 merge request
!11
Pypcc2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
config/UNB2.yaml
+3
-3
3 additions, 3 deletions
config/UNB2.yaml
opcuaserv/yamlconfig.py
+42
-0
42 additions, 0 deletions
opcuaserv/yamlconfig.py
opcuaserv/yamlreader.py
+3
-11
3 additions, 11 deletions
opcuaserv/yamlreader.py
pypcc2.py
+5
-4
5 additions, 4 deletions
pypcc2.py
with
53 additions
and
18 deletions
config/UNB2.yaml
+
3
−
3
View file @
a74e0b3b
...
@@ -111,7 +111,7 @@ variables:
...
@@ -111,7 +111,7 @@ variables:
driver
:
GPIO
driver
:
GPIO
mask
:
UNB2_mask
mask
:
UNB2_mask
width
:
1
width
:
1
rw
:
r
w
rw
:
r
o
dtype
:
boolean
dtype
:
boolean
dim
:
2
dim
:
2
...
@@ -195,7 +195,7 @@ variables:
...
@@ -195,7 +195,7 @@ variables:
scale
:
0.0625
scale
:
0.0625
dim
:
16
dim
:
16
-
name
:
UNB2_FPGA_DDR4_SLOT
0
_PART_NUMBER
-
name
:
UNB2_FPGA_DDR4_SLOT_PART_NUMBER
driver
:
switch_DDR4
driver
:
switch_DDR4
mask
:
UNB2_I2C_bus_DDR4_OK
mask
:
UNB2_I2C_bus_DDR4_OK
devreg
:
[
0x18.0x149
,
0x19.0x149
]
devreg
:
[
0x18.0x149
,
0x19.0x149
]
...
@@ -214,7 +214,7 @@ variables:
...
@@ -214,7 +214,7 @@ variables:
scale
:
1.2207e-4
#2^-13
scale
:
1.2207e-4
#2^-13
dim
:
8
dim
:
8
-
name
:
[
UNB2_FPGA_POL_RXGXB_VOUT
,
UNB2_FPGA_POL_RXGXB_IOUT
,
UNB2_FPGA_POL_RXGXB_TEMP
,
UNB2_FPGA_POL_TXGXB_VOUT
,
UNB2_FPGA_POL_TXGXB_IOUT
,
P
UNB2_OL_FPGA_TXGXB_TEMP
]
-
name
:
[
UNB2_FPGA_POL_RXGXB_VOUT
,
UNB2_FPGA_POL_RXGXB_IOUT
,
UNB2_FPGA_POL_RXGXB_TEMP
,
UNB2_FPGA_POL_TXGXB_VOUT
,
UNB2_FPGA_POL_TXGXB_IOUT
,
UNB2_
P
OL_FPGA_TXGXB_TEMP
]
driver
:
switch_FPGA_PS
driver
:
switch_FPGA_PS
mask
:
UNB2_I2C_bus_FGPA_PS_OK
mask
:
UNB2_I2C_bus_FGPA_PS_OK
devreg
:
[
0xE.0x8B
,
0xE.0x8C
,
0xE.0x8D
,
0xF.0x8B
,
0xF.0x8C
,
0xF.0x8D
]
devreg
:
[
0xE.0x8B
,
0xE.0x8C
,
0xE.0x8D
,
0xF.0x8B
,
0xF.0x8C
,
0xF.0x8D
]
...
...
This diff is collapsed.
Click to expand it.
opcuaserv/yamlconfig.py
0 → 100644
+
42
−
0
View file @
a74e0b3b
import
yaml
import
struct
import
time
def
Find
(
L
,
name
,
value
):
for
x
in
L
:
if
x
[
name
]
==
value
:
return
x
;
return
False
;
def
GetField
(
D
,
name
,
dev_number
,
default
=
None
):
X
=
D
.
get
(
name
,
default
)
return
X
[
dev_number
]
if
isinstance
(
X
,
list
)
else
X
;
class
yamlconfig
():
def
__init__
(
self
,
yamlfile
=
'
RCU
'
):
self
.
conf
=
yaml
.
load
(
open
(
"
config/
"
+
yamlfile
+
'
.yaml
'
))
var1
=
self
.
conf
[
'
variables
'
]
N
=
len
(
var1
)
# print([v['name'] for v in self.conf['variables']])
for
i
in
range
(
N
-
1
,
-
1
,
-
1
):
#print(var1[i])
if
isinstance
(
var1
[
i
][
'
name
'
],
list
):
for
x
,
name
in
enumerate
(
var1
[
i
][
'
name
'
]):
var2
=
var1
[
i
].
copy
()
var2
[
'
name
'
]
=
name
var2
[
'
devreg
'
]
=
GetField
(
var1
[
i
],
'
devreg
'
,
x
)
var2
[
'
scale
'
]
=
GetField
(
var1
[
i
],
'
scale
'
,
x
,
1
)
var1
.
append
(
var2
)
N
+=
1
;
var1
.
remove
(
var1
[
i
])
N
-=
1
;
# print([[v['name'],v.get('devreg')] for v in var1])
# print(len(self.conf['variables']),N)
for
i
,
v
in
enumerate
(
self
.
conf
[
'
variables
'
]):
v
[
'
id
'
]
=
i
for
i
,
v
in
enumerate
(
self
.
conf
[
'
methods
'
]):
v
[
'
id
'
]
=
i
This diff is collapsed.
Click to expand it.
opcuaserv/yamlreader.py
+
3
−
11
View file @
a74e0b3b
import
yaml
import
yaml
import
struct
import
struct
import
time
import
time
def
Find
(
L
,
name
,
value
):
from
opcuaserv.yamlconfig
import
*
for
x
in
L
:
if
x
[
name
]
==
value
:
return
x
;
return
False
;
def
bytes2int
(
bts
):
def
bytes2int
(
bts
):
x
=
0
;
x
=
0
;
...
@@ -21,13 +17,9 @@ def int2bytes(i):
...
@@ -21,13 +17,9 @@ def int2bytes(i):
return
[
i
]
+
b
;
return
[
i
]
+
b
;
class
yamlreader
():
class
yamlreader
(
yamlconfig
):
def
__init__
(
self
,
i2cserver
,
yamlfile
=
'
RCU
'
):
def
__init__
(
self
,
i2cserver
,
yamlfile
=
'
RCU
'
):
self
.
conf
=
yaml
.
load
(
open
(
"
config/
"
+
yamlfile
+
'
.yaml
'
))
yamlconfig
.
__init__
(
self
,
yamlfile
)
for
i
,
v
in
enumerate
(
self
.
conf
[
'
variables
'
]):
v
[
'
id
'
]
=
i
for
i
,
v
in
enumerate
(
self
.
conf
[
'
methods
'
]):
v
[
'
id
'
]
=
i
self
.
server
=
i2cserver
;
self
.
server
=
i2cserver
;
...
...
This diff is collapsed.
Click to expand it.
pypcc2.py
+
5
−
4
View file @
a74e0b3b
...
@@ -14,6 +14,7 @@ parser = argparse.ArgumentParser()
...
@@ -14,6 +14,7 @@ parser = argparse.ArgumentParser()
parser
.
add_argument
(
"
-s
"
,
"
--simulator
"
,
help
=
"
Do not connect to I2c, but simulate behaviour.
"
,
action
=
"
store_true
"
)
parser
.
add_argument
(
"
-s
"
,
"
--simulator
"
,
help
=
"
Do not connect to I2c, but simulate behaviour.
"
,
action
=
"
store_true
"
)
parser
.
add_argument
(
"
-p
"
,
"
--port
"
,
help
=
"
Port number to listen on [%(default)s].
"
,
type
=
int
,
default
=
4842
)
parser
.
add_argument
(
"
-p
"
,
"
--port
"
,
help
=
"
Port number to listen on [%(default)s].
"
,
type
=
int
,
default
=
4842
)
parser
.
add_argument
(
"
-l
"
,
"
--loglevel
"
,
help
=
"
Log level [%(default)s].
"
,
type
=
str
,
choices
=
[
"
DEBUG
"
,
"
INFO
"
,
"
WARNING
"
,
"
ERROR
"
],
default
=
"
INFO
"
)
parser
.
add_argument
(
"
-l
"
,
"
--loglevel
"
,
help
=
"
Log level [%(default)s].
"
,
type
=
str
,
choices
=
[
"
DEBUG
"
,
"
INFO
"
,
"
WARNING
"
,
"
ERROR
"
],
default
=
"
INFO
"
)
#parser.add_argument("-c", "--config", help="YAML config file.",type=str, action="store_true",default='RCU')
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
# set log level
# set log level
...
@@ -33,16 +34,16 @@ signal.signal(signal.SIGINT, signal_handler)
...
@@ -33,16 +34,16 @@ signal.signal(signal.SIGINT, signal_handler)
#Start i2c processes as soon as possible to have minimum duplication
#Start i2c processes as soon as possible to have minimum duplication
logging
.
info
(
"
Start I2C processes
"
)
logging
.
info
(
"
Start I2C processes
"
)
I2Cports
=
[
'
RCU
'
]
I2Cports
=
[
'
UNB2
'
]
#I2Cports=[]
#I2Cports=[]
threads
=
[]
threads
=
[]
I2Cclients
=
[]
I2Cclients
=
[]
for
name
in
I2Cports
:
for
name
in
I2Cports
:
RCU_I2C
=
i2client
.
i2client
(
name
=
name
)
RCU_I2C
=
i2client
.
i2client
(
name
=
name
)
thread1
=
i2cthread
.
start
(
*
RCU_I2C
.
GetInfo
())
if
not
(
args
.
simulator
):
threads
.
append
(
thread1
)
thread1
=
i2cthread
.
start
(
*
RCU_I2C
.
GetInfo
())
threads
.
append
(
thread1
)
I2Cclients
.
append
(
RCU_I2C
)
I2Cclients
.
append
(
RCU_I2C
)
#Initialise OPCUA server
#Initialise OPCUA server
logging
.
info
(
"
Initialised OPC-UA Server
"
)
logging
.
info
(
"
Initialised OPC-UA Server
"
)
opcuaserv
.
InitServer
(
port
=
args
.
port
)
opcuaserv
.
InitServer
(
port
=
args
.
port
)
...
...
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