-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(agents): refactor agents.py into a package agents with the m…
…odules base_agents and signal_agents
- Loading branch information
1 parent
67fc99e
commit c7bdfae
Showing
3 changed files
with
41 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from base_agents import AgentMET4FOF, AgentNetwork, MonitorAgent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from agentMET4FOF.agents.base_agents import AgentMET4FOF | ||
from agentMET4FOF.streams import SineGenerator | ||
|
||
|
||
class SineGeneratorAgent(AgentMET4FOF): | ||
"""An agent streaming a sine signal | ||
Takes samples from the :py:mod:`SineGenerator` and pushes them sample by sample | ||
to connected agents via its output channel. | ||
""" | ||
|
||
def init_parameters(self, sfreq=500, sine_freq=5): | ||
"""Initialize the input data | ||
Initialize the input data stream as an instance of the :class:`SineGenerator` | ||
class. | ||
Parameters | ||
---------- | ||
sfreq : int | ||
sampling frequency for the underlying signal | ||
sine_freq : float | ||
frequency of the generated sine wave | ||
""" | ||
self._sine_stream = SineGenerator(sfreq=sfreq, sine_freq=sine_freq) | ||
|
||
def agent_loop(self): | ||
"""Model the agent's behaviour | ||
On state *Running* the agent will extract sample by sample the input data | ||
streams content and push it via invoking :meth:`AgentMET4FOF.send_output`. | ||
""" | ||
if self.current_state == "Running": | ||
sine_data = self._sine_stream.next_sample() # dictionary | ||
self.send_output(sine_data["quantities"]) |