Skip to content
GitLab
Explore
Sign in
Register
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
PyPCC
Commits
3b61930f
Commit
3b61930f
authored
10 months ago
by
Paulus Kruger
Browse files
Options
Downloads
Patches
Plain Diff
unlock during wait
parent
de2ee74d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#91026
passed
10 months ago
Stage: run
Stage: image
Changes
1
Pipelines
8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pypcc/i2cserv/i2cthread.py
+27
-14
27 additions, 14 deletions
pypcc/i2cserv/i2cthread.py
with
27 additions
and
14 deletions
pypcc/i2cserv/i2cthread.py
+
27
−
14
View file @
3b61930f
...
@@ -29,7 +29,28 @@ class AttrDict(object):
...
@@ -29,7 +29,28 @@ class AttrDict(object):
except
KeyError
:
except
KeyError
:
raise
AttributeError
raise
AttributeError
def
runmethod
(
conf
,
Qout
,
methodid
,
mask
,
PQ
):
def
get_lock
(
lock
):
if
lock
is
None
:
return
True
try
:
lock
.
acquire
()
return
True
except
:
logging
.
error
(
"
I2C lock timeout!!
"
)
return
False
#continue;
# print('lock');
def
release_lock
(
lock
):
if
lock
is
None
:
return
True
try
:
lock
.
release
()
return
True
except
:
logging
.
error
(
"
I2C lock release error
"
)
return
False
def
runmethod
(
conf
,
Qout
,
methodid
,
mask
,
PQ
,
lock
=
None
):
# print("Run method",methodid,mask)
# print("Run method",methodid,mask)
var1
=
conf
.
getmethod
(
methodid
)
var1
=
conf
.
getmethod
(
methodid
)
drv
=
var1
.
get
(
'
drivercls
'
);
drv
=
var1
.
get
(
'
drivercls
'
);
...
@@ -39,7 +60,9 @@ def runmethod(conf,Qout,methodid,mask,PQ):
...
@@ -39,7 +60,9 @@ def runmethod(conf,Qout,methodid,mask,PQ):
logging
.
info
(
str
((
"
Run instruction
"
,
key
,
value
,
mask
)));
logging
.
info
(
str
((
"
Run instruction
"
,
key
,
value
,
mask
)));
if
mask
is
None
:
mask
=
[]
if
mask
is
None
:
mask
=
[]
if
(
key
==
'
WAIT
'
):
if
(
key
==
'
WAIT
'
):
release_lock
(
lock
)
sleep
(
value
[
0
]
/
1000.
)
sleep
(
value
[
0
]
/
1000.
)
get_lock
(
lock
)
continue
;
continue
;
v1
=
conf
.
getvarid
(
key
)
v1
=
conf
.
getvarid
(
key
)
if
not
(
v1
is
None
):
if
not
(
v1
is
None
):
...
@@ -147,13 +170,7 @@ def I2Cserver(Qin,Qout,name,lock=None):
...
@@ -147,13 +170,7 @@ def I2Cserver(Qin,Qout,name,lock=None):
# print("TODO: Set busy")
# print("TODO: Set busy")
# self.statevar.set_value("busy");
# self.statevar.set_value("busy");
#print("SetVar",item)#,self.conf.variables[item.id])
#print("SetVar",item)#,self.conf.variables[item.id])
if
not
(
lock
is
None
):
get_lock
(
lock
)
try
:
lock
.
acquire
()
except
:
logging
.
error
(
"
I2C lock timeout!!
"
)
#continue;
# print('lock');
try
:
try
:
if
(
item
.
type
==
InstType
.
varSet
):
if
(
item
.
type
==
InstType
.
varSet
):
setvar
(
conf
,
Qout
,
item
.
id
,
item
.
data
,
item
.
mask
)
setvar
(
conf
,
Qout
,
item
.
id
,
item
.
data
,
item
.
mask
)
...
@@ -162,14 +179,10 @@ def I2Cserver(Qin,Qout,name,lock=None):
...
@@ -162,14 +179,10 @@ def I2Cserver(Qin,Qout,name,lock=None):
getvar
(
conf
,
Qout
,
item
.
id
,
item
.
mask
)
getvar
(
conf
,
Qout
,
item
.
id
,
item
.
mask
)
# var1=self.conf.variables[item.id]
# var1=self.conf.variables[item.id]
# self.OPCUAReadVariable(item.id,var1,item.data,item.mask)
# self.OPCUAReadVariable(item.id,var1,item.data,item.mask)
elif
(
item
.
type
==
InstType
.
method
):
runmethod
(
conf
,
Qout
,
item
.
id
,
item
.
mask
,
PQ
)
elif
(
item
.
type
==
InstType
.
method
):
runmethod
(
conf
,
Qout
,
item
.
id
,
item
.
mask
,
PQ
,
lock
=
lock
)
else
:
print
(
"
OPCUA call not implemented!
"
);
else
:
print
(
"
OPCUA call not implemented!
"
);
finally
:
finally
:
if
not
(
lock
is
None
):
release_lock
(
lock
)
try
:
lock
.
release
()
except
:
logging
.
error
(
"
I2C lock release error
"
)
# print('unlock');
# print('unlock');
# print("TODO: Set ready")
# print("TODO: Set ready")
logging
.
info
(
"
End i2c process
"
+
name
)
logging
.
info
(
"
End i2c process
"
+
name
)
...
...
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