The Raspberry Pi Application
Installation
Architecture
In the sketch, this is the node labeled “Raspi”. A “generic” component-based application that can be configured to act as …
… a datalogger with various data sources and sinks. There are components available that read and write data from and to MQTT topics, for example. Likewise, CAN bus sources and sinks are available, and of course there are ways to read data from sensors connected locally on Linux.
… a control application with the usual set of sensors and actors.
A Simple Example
The following example application paints a sine wave on the screen. Note that this is not a typical application because there are less overengineered ways out there to paint sine waves - but you get the point. The application uses only two components,
A mocked data source (Mocked Data Source), configured to emit samples that form a sine wave
A data sink that animates the samples on the screen.
# -*- python -*-
from endless.framework.source_mock import MockSource
from endless.framework.sink_stdout import StdoutSink
from endless.framework.sink_animation import AnimationSink
from endless.framework import async_util
import datetime
import functools
import math
sink = AnimationSink(label='ENDLESS Proof Of Concept', xlabel='Timestamp', ylabel='Value', ymin=10, ymax=70)
source = MockSource(
tag='sinewave',
timestamps=async_util.wallclock_timestamps_sleep(interval=datetime.timedelta(seconds=0.1)),
data=functools.partial(async_util.yet_another_sin, amplitude=20, hz=5, phase_shift=math.pi/2, vertical_shift=36.5),
)
source.sample_out.connect(sink.sample_in)
COMPONENTS = (source, sink)
Running the plot:
$ run-components --configfile sine-plot.conf
A More Involved Example
See Setting Up A Distributed Simulation (Sensors And Actors)