Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
bcfe0682
"models/vision/vscode:/vscode.git/clone" did not exist on "f09defd3f595cae1c6b36f8db8431c1f4cd5e06b"
Unverified
Commit
bcfe0682
authored
Aug 30, 2024
by
Jakob Görgen
Browse files
add funciton to determine if sim shall listen or connect on socket
parent
26511db0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
4 deletions
+24
-4
experiments/simbricks/orchestration/instantiation/base.py
experiments/simbricks/orchestration/instantiation/base.py
+24
-4
No files found.
experiments/simbricks/orchestration/instantiation/base.py
View file @
bcfe0682
...
...
@@ -61,7 +61,7 @@ class Instantiation:
):
self
.
_simulation
=
simulation
self
.
_env
:
InstantiationEnvironment
=
env
self
.
_socket_tracker
:
set
[
tuple
[
simulation
.
channel
.
Channel
,
SockType
]
]
=
set
()
self
.
_socket_tracker
:
dict
[
simulation
.
channel
.
Channel
,
SockType
]
=
{}
@
staticmethod
def
is_absolute_exists
(
path
:
str
)
->
bool
:
...
...
@@ -108,12 +108,32 @@ class Instantiation:
case
_
:
raise
Exception
(
"cannot create socket path for given interface type"
)
def
_is_liste_nor_connect
(
self
,
interface
:
system
.
base
.
Interface
)
->
SockType
:
# We use the channel to determine if the socket is a listening or connecting socket.
# We perform lookup by using the channel as the channel is unique for both
# interfaces connected to it.
if
not
interface
.
is_connected
():
raise
Exception
(
"cannot determine the socket type to use for an interface that isn't connected to a channel"
)
chan
=
interface
.
channel
if
not
chan
in
self
.
_socket_tracker
:
self
.
_socket_tracker
[
chan
]
=
SockType
.
LISTEN
return
SockType
.
LISTEN
ty
=
self
.
_socket_tracker
[
chan
]
if
ty
==
SockType
.
LISTEN
:
return
SockType
.
CONNECT
else
:
return
SockType
.
LISTEN
def
get_socket
(
self
,
interface
:
system
.
base
.
Interface
)
->
Socket
:
#
TODO: use self._socket_tracker to
determine socket type that is needed
sock_type
=
SockType
.
LISTEN
# determine socket type that is needed
sock_type
=
self
.
_is_liste_nor_connect
(
interface
=
interface
)
#
TODO:
generate socket path
# generate socket path
sock_path
=
self
.
_interface_to_sock_path
(
interface
=
interface
)
return
Socket
(
sock_path
,
sock_type
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment