Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open 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
tango
Commits
25a05c06
Commit
25a05c06
authored
3 years ago
by
Taya Snijder
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into
L2SS-334
_2021-10-21_replace_streams_with_logger
parents
00257761
ea573fcb
No related branches found
No related tags found
1 merge request
!164
Resolve L2SS-334 "2021 10 21 replace streams with logger"
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
devices/clients/comms_client.py
+8
-14
8 additions, 14 deletions
devices/clients/comms_client.py
devices/clients/opcua_client.py
+0
-1
0 additions, 1 deletion
devices/clients/opcua_client.py
devices/test/clients/test_client.py
+1
-5
1 addition, 5 deletions
devices/test/clients/test_client.py
with
9 additions
and
20 deletions
devices/clients/comms_client.py
+
8
−
14
View file @
25a05c06
...
@@ -62,9 +62,10 @@ class CommClient(AbstractCommClient, Thread):
...
@@ -62,9 +62,10 @@ class CommClient(AbstractCommClient, Thread):
def
connect
(
self
):
def
connect
(
self
):
"""
"""
Function used to connect to the client.
Function used to connect to the client.
Throws an Exception if the connection cannot be established.
"""
"""
self
.
connected
=
True
self
.
connected
=
True
return
True
def
disconnect
(
self
):
def
disconnect
(
self
):
"""
"""
...
@@ -73,22 +74,15 @@ class CommClient(AbstractCommClient, Thread):
...
@@ -73,22 +74,15 @@ class CommClient(AbstractCommClient, Thread):
self
.
connected
=
False
self
.
connected
=
False
def
run
(
self
):
def
run
(
self
):
# Explicitly connect
if
not
self
.
connect
():
# hardware or infra is down -- needs fixing first
self
.
fault_func
()
return
self
.
stopping
=
False
self
.
stopping
=
False
while
not
self
.
stopping
:
while
not
self
.
stopping
:
# keep trying to connect
if
not
self
.
connected
:
if
not
self
.
connected
:
if
self
.
connect
():
# we (re)try only once, to catch exotic network issues. if the infra or hardware is down,
pass
else
:
# we retry only once, to catch exotic network issues. if the infra or hardware is down,
# our device cannot help, and must be reinitialised after the infra or hardware is fixed.
# our device cannot help, and must be reinitialised after the infra or hardware is fixed.
try
:
self
.
connect
()
except
Exception
as
e
:
self
.
streams
.
error_stream
(
"
Fault condition in communication detected.
"
,
e
)
self
.
fault_func
()
self
.
fault_func
()
return
return
...
...
This diff is collapsed.
Click to expand it.
devices/clients/opcua_client.py
+
0
−
1
View file @
25a05c06
...
@@ -59,7 +59,6 @@ class OPCUAConnection(AsyncCommClient):
...
@@ -59,7 +59,6 @@ class OPCUAConnection(AsyncCommClient):
try
:
try
:
await
self
.
client
.
connect
()
await
self
.
client
.
connect
()
self
.
connected
=
True
except
(
socket
.
error
,
IOError
,
OSError
)
as
e
:
except
(
socket
.
error
,
IOError
,
OSError
)
as
e
:
raise
IOError
(
f
"
Could not connect to OPC-UA server
{
self
.
_servername
()
}
"
)
from
e
raise
IOError
(
f
"
Could not connect to OPC-UA server
{
self
.
_servername
()
}
"
)
from
e
...
...
This diff is collapsed.
Click to expand it.
devices/test/clients/test_client.py
+
1
−
5
View file @
25a05c06
...
@@ -24,10 +24,7 @@ class test_client(CommClient):
...
@@ -24,10 +24,7 @@ class test_client(CommClient):
super
().
__init__
(
fault_func
,
try_interval
)
super
().
__init__
(
fault_func
,
try_interval
)
# Explicitly connect
# Explicitly connect
if
not
self
.
connect
():
self
.
connect
()
# hardware or infra is down -- needs fixing first
fault_func
()
return
def
connect
(
self
):
def
connect
(
self
):
"""
"""
...
@@ -36,7 +33,6 @@ class test_client(CommClient):
...
@@ -36,7 +33,6 @@ class test_client(CommClient):
logger
.
debug
(
"
the example client doesn
'
t actually connect to anything silly
"
)
logger
.
debug
(
"
the example client doesn
'
t actually connect to anything silly
"
)
self
.
connected
=
True
# set connected to true
self
.
connected
=
True
# set connected to true
return
True
# if succesfull, return true. otherwise return false
def
disconnect
(
self
):
def
disconnect
(
self
):
self
.
connected
=
False
# always force a reconnect, regardless of a successful disconnect
self
.
connected
=
False
# always force a reconnect, regardless of a successful disconnect
...
...
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