Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simuDAtor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computer Engineering
simuDAtor
Commits
3e84e4eb
Commit
3e84e4eb
authored
11 months ago
by
Johannes Kung
Browse files
Options
Downloads
Patches
Plain Diff
Refactor signal
parent
ddb95637
No related branches found
No related tags found
1 merge request
!27
Docstring refactor of core
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/simudator/core/signal.py
+56
-33
56 additions, 33 deletions
src/simudator/core/signal.py
with
56 additions
and
33 deletions
src/simudator/core/signal.py
+
56
−
33
View file @
3e84e4eb
...
@@ -5,54 +5,77 @@ from typing import Any
...
@@ -5,54 +5,77 @@ from typing import Any
class
Signal
:
class
Signal
:
"""
"""
Handles datatransportation between modules in the processor.
Signal class to send data between modules in a processor.
Each signal has one source module and can have multiple
destination modules.
Parameters
----------
processor : Processor
Processor that the signal belongs to. Needed to queue processor modules
for update.
name : str
Name of the signal.
value : Any
Initial value of the signal.
"""
"""
def
__init__
(
self
,
processor
:
Processor
,
name
:
str
=
"
Signal
"
,
value
=
None
):
self
.
processor
=
processor
def
__init__
(
self
,
processor
:
Processor
,
name
:
str
=
"
Signal
"
,
value
=
None
):
self
.
name
=
name
self
.
_processor
=
processor
self
.
source
=
None
self
.
_name
=
name
self
.
destinations
=
set
()
self
.
_source
=
None
self
.
value
=
value
self
.
_destinations
=
set
()
self
.
_value
=
value
def
add_destination
(
self
,
module
:
Module
)
->
None
:
def
add_destination
(
self
,
module
:
Module
)
->
None
:
"""
"""
Add a module as a destination that the signal will send new
Add a destination module that the signal will send new
values to.
values to.
"""
"""
self
.
destinations
.
add
(
module
)
self
.
_destinations
.
add
(
module
)
def
set_source
(
self
,
module
:
Module
)
->
None
:
"""
Set source module that will send values through the signal.
"""
self
.
source
=
module
def
update_value
(
self
,
value
)
->
None
:
def
update_value
(
self
,
value
)
->
None
:
"""
"""
Sets value in signal and queues destination moduels for update.
Set the value of the signal and queue destination modules for update.
Parameters
----------
value : Any
Value to set the signal to.
"""
"""
if
value
!=
self
.
value
:
if
value
!=
self
.
_
value
:
self
.
value
=
value
self
.
_
value
=
value
# Inform the processor on what modules have been given
# Inform the processor on what modules have been given
# signal so they can update
# signal so they can update
for
destination
in
self
.
destinations
:
for
destination
in
self
.
_
destinations
:
self
.
processor
.
add_modules_to_update
(
destination
)
self
.
_
processor
.
add_modules_to_update
(
destination
)
def
get_value
(
self
)
->
Any
:
def
get_value
(
self
)
->
Any
:
"""
"""
Get the current value of the signal.
Get the signals current value.
"""
return
self
.
value
def
set_value
(
self
,
value
)
->
None
:
Returns
-------
Any
Value of the signal.
"""
"""
Set the value of the signal without queuing the destination
return
self
.
_value
modules of the signal for update. This method should not
be called by a module.
def
set_value
(
self
,
value
:
Any
)
->
None
:
"""
Set the value of the signal without queuing the destination
modules of the signal for update.
This method should not be called by a module.
Parameters
----------
value : any
Value to set the signal to.
"""
"""
self
.
value
=
value
self
.
_
value
=
value
def
get_name
(
self
)
->
str
:
def
get_name
(
self
)
->
str
:
return
self
.
name
"""
Return the name of the signal.
Returns
-------
str
Name of the signal.
"""
return
self
.
_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