Getting real-time data

Post questions and issues with Concept2 PM3 SDK

Getting real-time data

Postby bcardarella » December 15th, 2016, 6:24 am

I have an idea I'd like to spike out with my Concept2. However, I cannot find any information if I can get real-time rowing data. Is this possible? Everything I see indicates you can only download logs after the fact.
bcardarella
Paddler
 
Posts: 3
Joined: December 15th, 2016, 6:22 am

Re: Getting real-time data

Postby Citroen » December 15th, 2016, 6:58 am

That's precisely what the CSAFE protocol gives you. You can get stroke by stroke data.
User avatar
Citroen
SpamTeam
 
Posts: 4984
Joined: March 16th, 2006, 3:28 pm
Location: Basingstoke, UK

Re: Getting real-time data

Postby bcardarella » December 15th, 2016, 10:30 am

Fantastic, thank you!
bcardarella
Paddler
 
Posts: 3
Joined: December 15th, 2016, 6:22 am

Re: Getting real-time data

Postby Citroen » December 15th, 2016, 11:14 am

There's even a Visual Basic ActiveX plugin that lets you read C2 data directly into a VB macro (which can run in an Excel spreadsheet). It's been a while since I played with that piece.
User avatar
Citroen
SpamTeam
 
Posts: 4984
Joined: March 16th, 2006, 3:28 pm
Location: Basingstoke, UK

Re: Getting real-time data

Postby tijmenvangulik » December 16th, 2016, 2:32 pm

Most data updates on every stroke. The state changes are a bit more accurate, you can spot the beginning and ending of a stroke. The power curve can be updated live while your doing the stroke. You can see this if you enable the live power chart on my website:

http://ergometer-space.org/#

If you want to experiment with this. you can change the code behind the plugins within the website, (so no development environment required)

Tijmen
User avatar
tijmenvangulik
Paddler
 
Posts: 39
Joined: November 25th, 2012, 10:24 am

Re: Getting real-time data

Postby gmngueko » December 24th, 2016, 1:47 pm

Hi tijmenvangulik,

is it possible to export to a file the data your data server records and sends to the web page ?

thanks
gmngueko
Paddler
 
Posts: 5
Joined: December 24th, 2016, 1:44 pm

Re: Getting real-time data

Postby tijmenvangulik » December 25th, 2016, 5:46 am

The monitor already files some history data. This data can be viewed in the history chart widget. I have not yet made an export of the data like the power chart does do. You can alter the History widget and add an export to it. You can alter the history widget example and add an export to it.

However the history functionality stores a limited set of data:

export interface HistoryStroke {
splitTime : Date;
power : number;
strokesPerMinute : number;
workTime : Date;
workDistance : number;
}

it is possible make a widgets which stores its own history data (this way you can store more properties). If you look at the examples a widgets subscribes it selves to the data ergometer stream and then display's / stores the data when it is changed.

public visibleChanged() {

if (this.visible)
pm3.monitor.pubsubs.subStrokeDataUpdate(this, this.strokeDataUpdate)
else
pm3.monitor.pubsubs.unsubStrokeDataUpdate(this.strokeDataUpdate);

}
}
You can write your own plugins / widgets from the plugin menu (it provides a typescript/javascript based development environment for you) The easiest way to start is to install one of the example plugins and modify the code.

I have placed some documentation here:
https://ergometerspace.codeplex.com/documentation

Tijmen
User avatar
tijmenvangulik
Paddler
 
Posts: 39
Joined: November 25th, 2012, 10:24 am

Re: Getting real-time data

Postby tijmenvangulik » December 26th, 2016, 4:18 am

Since it was only a view lines of code, I have added an simple export for you in the history widget.

The code is as simple as this:
Code: Select all
      public exportData() {
         if (pm3.monitor.historyCount>0) {
            let exportData = [];
            for(let i =0; i<pm3.monitor.historyCount;i++ ) {
               let c=pm3.monitor.getHistory(i);
               exportData.push(
                     { "workTime": utilities.formatRelativeTime(c.workTime),
                        "power": c.power,
                        "strokesPerMinute":c.strokesPerMinute ,
                        "workDistance":c.workDistance,
                        "splitTime":utilities.formatRelativeTime(c.splitTime)
                     })
            }
            let blob = new Blob([JSON.stringify(exportData)], {type: "data:application/json;charset=utf-8"});

            saveAs(blob, "History.JSON");
         }
         else app.showTopError("No data to export.")
      }

You can convert JSON to csv using this website.

https://konklone.io/json/

It would be nice to have a direct csv export but I do not yet have time for this
User avatar
tijmenvangulik
Paddler
 
Posts: 39
Joined: November 25th, 2012, 10:24 am

Re: Getting real-time data

Postby tijmenvangulik » December 27th, 2016, 1:02 pm

Just found a simple javascript json exporter. The history and the power curve widget now export in csv.

Tijmen
User avatar
tijmenvangulik
Paddler
 
Posts: 39
Joined: November 25th, 2012, 10:24 am


Return to SDK Questions

Who is online

Users browsing this forum: No registered users and 1 guest