Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Try to read an activity with MonitoringReader

Rank

Total Posts: 3

Joined 2014-06-17

PM

Hello,

I want to read a .fit file with Java. I adopted the code from DecodeExample.java but ca't get it running;
I have the following code:
public class GCListener implements MonitoringMesgListener
{
 
public GCListener()
 
{
  
try
  
{
   Decode decode 
= new Decode();
   
MesgBroadcaster mesgBroadcaster = new MesgBroadcaster(decode);
   
FileInputStream in = new FileInputStream("act.fit");
   
mesgBroadcaster.addListener((MonitoringMesgListenerthis);
   
mesgBroadcaster.run(in);

   
in.close();
  
}
  
catch (Exception e)
  
{
   e
.printStackTrace();
  
}
 }

 
@Override
 
public void onMesg(MonitoringMesg mesg)
 
{
  System
.out.println("monitoring");
  
System.out.println(mesg.getActiveTime());
 
}


I really do not get any output on my console. The same happens if I try to run the FitDecodeExample.jar from the examples in the SDK. If I try other Listener like ActivityMesgListener everything works perfectly fine.
I also found the class MonitoringReader but also can't get it to work. Also the examples won't work:
foobar:testFitSDk andijava -jar FitMonitoringReaderExample.jar act.fit 86000
Decoded monitoring data from act
.fit to at 86000s intervals

This is not really the expected output (after looking into the code).
I tried several .fit files but with everyone the same happens.

I really have no idea what is wrong in my code (or with my .fit files). Can you please help me with this?

Thank you in advance grin      
RankRankRank

Total Posts: 91

Joined 2012-10-12

PM

Hi t4deon,

It seems like your source files do not contain any monitoring mesgs. Also I don't see any sample monitoring files included in the SDK. I will try and find an example that can be added to the package.

To be clear is your interest in activity files or monitoring files (they have different formats and contain different data)? Where does your act.fit come from?      
Rank

Total Posts: 3

Joined 2014-06-17

PM

Hi ShaneP,

thanks for your answer.
My act.fit file comes from a garmin 910xt device, so i want to get some informationen out of the act.fit file like time spent on activity or length or burned calories.
It seems obvious that is doesn't contain any monitoring data but what for a listener do i need then?

Thank you grin      
RankRankRank

Total Posts: 91

Joined 2012-10-12

PM

Hi t4deon,

The 910 will generate activity files. I think record, lap and session messages will be most interesting to you. Try adding those listeners. See the File Types Description Document for more details about the content of Activity files (its included in the FITSDK). There is also a sample file (\examples\activity.fit).

HTH      
Rank

Total Posts: 3

Joined 2014-06-17

PM

This works perfect grin
Thank you very much for your help!