Commit 6a9488ad authored by Ralf's avatar Ralf
Browse files

fake input generation

parent a59e2f57
......@@ -22,7 +22,7 @@ impl<T> RecordActor<T> {
impl<T> Actor<T> for RecordActor<T> {
fn act(&mut self, t : T) {
fn act(&mut self, t: T) {
......@@ -31,7 +31,7 @@ impl<T> Actor<T> for RecordActor<T> {
pub struct DebugActor;
impl<T: fmt::Debug> Actor<T> for DebugActor {
fn act(&mut self, t : T) {
fn act(&mut self, t: T) {
println!("{:?}", &t);
//! The acots module defines the interface for performing actions.
//! The actors module defines the interface for performing actions.
//! The core bit is of course the `Actor<T>` trait. Furthermore, there
//! are various implementations of this trait: Some for testing (fake actors),
//! and some for actual production usage.
mod fake;
/// The `Actor` trait defines the interface to act. It works for any
/// type `T` of the parameter describing the action.
pub trait Actor<T> {
......@@ -10,4 +12,5 @@ pub trait Actor<T> {
fn act(&mut self, t : T);
mod fake;
// Re-export the public tyes
pub use self::fake::*;
//! This module contains some fake input generaors, that do not actually
//! gather data from any real devices.
use std::time::Duration;
use std::thread;
use std::sync::mpsc;
use input::Event;
/// FakeInput is an event generator that produces a predetermined stream
/// of events.
struct FakeInput {
events: Vec<(Duration, Event)>,
impl FakeInput {
/// Create a new FakeInput, generting the given events. The corepsonding
/// timeouts determine how long we wait *before* sending the event.
fn new(events: Vec<(Duration, Event)>) -> FakeInput {
FakeInput { events: events }
/// Run the fake input generation.
fn run(&self, chan: mpsc::Sender<Event>) {
let e =;
thread::spawn(move || {
for (d, e) in e {
//! The input module defines the event data structure, which is used to communicate
//! events from the sensors to the brain. Furthermore, there are a few
//! types that can be sued to generate inputs from I2C bits, and for debugging.
pub enum Event { }
mod fake;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment