Emotiv EPOC and the Event Store – Streams of Consciousness

I’ve found a way to combine two of my interests; the Emotiv EPOC headset and the Event Store. The EPOC is “a revolutionary personal interface for human computer interacton”. Couple this with “The awesome, rock-solid, super-fast persistence engine for event-sourced applications” that is the Event Store and you have:

Streams of Consciousness

The project is just a way to learn both of these technologies whilst creating something that, I think, is pretty cool.

The idea? To send the stream of events from the EPOC headset into the Event Store! I then re-use (steal) the event stores health chart graphs to display real-time data of the events measuring my current level of engagement, excitement/boredom, frustration and meditation as they are being read by the EPOC headset – all in JavaScript!!!

ouroepoc

I’ve essentially just reverse engineered the example chat room and charts to build the charts. It’s quite simple to consume the event store using the projections.js javascript that powers the chat room.

After digging into the way the chat works, I mashed up this javascript that will build the stats for the graphs and publish that to the onStateUpdated callback.

function emoProjection(options) {
    var streamName = options.streamName || "";
    var onStateUpdated = options.onStateUpdated || function () { };

    return es.projection({
        body: function () {
            fromStream(streamName).when({
                'AffectivEmoStateUpdated': function (state, event) {
                    var body = event.body;
                    return {
                        "StateEvent" : "AffectiveEmoStateUpdated",
                        "Excitement Short Term Score": body.ExcitementShortTermScore,
                        "Excitement Long Term Score": body.ExcitementLongTermScore,
                        "Frustration Score": body.FrustrationScore,
                        "Engagement Boredom Score": body.EngagementBoredomScore,
                        "Meditation Score": body.MeditationScore

                    };
                }
            });
        },
        onStateUpdate: function (state) {
            onStateUpdated(state);
        },
        showError: function (err) {
            $('.error').text(err);
        },
        hideError: function () {
            $('.error').hide().text("");
        }
    });
}

To consume this projection, new it up and assign the function that updates the charts to the onStateUpdated callback.

  var projection = new emoProjection({
            streamName: streamName,
            onStateUpdated: function (state) { updateCharts(state);}
        });

        projection.start();

Bob’s your uncle!

Below are screen prints of the charts capturing my current state while I’m wearing the EPOC headset and writing this post!

Event Charts

Excitement Short Term Score

Next steps: I’ll get these charts up on a live server soon and then stream my consciousness into the interwebs for all to see! Hopefully I’ll get the chance to blog about it too.