Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Writing FIT decoder in vb.net

Rank

Total Posts: 4

Joined 2017-04-19

PM

Hello,

I am new to this forum and the FIT sdk.

I am trying to learn how to decode fit files using vb.net (VS2015). Although I am not really comfortable with C#, I try to figure out how DecodeDemo.cs works and recreate it in vb.net. Difference is that I use the Fit.DLL which I added to my references.

Opening, validating and closing the FIT file was easy to figure out and runs without errors.

I have difficulty understand the following C# code from DecodeDemo.cs :
Decode decodeDemo = new Decode();
MesgBroadcaster mesgBroadcaster = new MesgBroadcaster();

// Connect the Broadcaster to our event (message) source (in this case the Decoder)
decodeDemo.MesgEvent += mesgBroadcaster.OnMesg;
decodeDemo.MesgDefinitionEvent += mesgBroadcaster.OnMesgDefinition;
decodeDemo.DeveloperFieldDescriptionEvent += OnDeveloperFieldDescriptionEvent;

// Subscribe to message events of interest by connecting to the Broadcaster
mesgBroadcaster.MesgEvent += OnMesg;
mesgBroadcaster.MesgDefinitionEvent += OnMesgDefn;
mesgBroadcaster.FileIdMesgEvent += OnFileIDMesg;
mesgBroadcaster.UserProfileMesgEvent += OnUserProfileMesg;
mesgBroadcaster.MonitoringMesgEvent += OnMonitoringMessage;
mesgBroadcaster.DeviceInfoMesgEvent += OnDeviceInfoMessage;
mesgBroadcaster.RecordMesgEvent += OnRecordMessage


I set up the instances for decodeDemo and mesgBroadcaster as follows. That by itself seems okay, it generates no errors.
Dim decodeDemo As Dynastream.Fit.Decode = New Dynastream.Fit.Decode
Dim mesgBroadcaster 
As Dynastream.Fit.MesgBroadcaster = New Dynastream.Fit.MesgBroadcaster() 


But decodeDemo will not show the property MesgEvent in the member list (I can see it in the object browser). Now I kinda understand that, since MesgEvent is an event and not a property or method. I have never in vb seen an event listed in the member list and don't now about assigning values to an event. But the C# code seems to do so.

Anyone can guide me to how to translate this part to vb.net?
     
Rank

Total Posts: 4

Joined 2017-04-19

PM

So I found out that the vb.net syntax is:
'Connect the Broadcaster to our event (message) source (in this case the Decoder)
AddHandler Decoder.MesgEvent, AddressOf mesgBroadcaster.OnMesg
AddHandler Decoder.MesgDefinitionEvent, AddressOf mesgBroadcaster.OnMesgDefinition
AddHandler Decoder.DeveloperFieldDescriptionEvent, AddressOf OnDeveloperFieldDescriptionEvent

'
Subscribe to message events of interest by connecting to the Broadcaster
AddHandler mesgBroadcaster
.MesgEventAddressOf OnMesg
AddHandler mesgBroadcaster
.MesgDefinitionEventAddressOf OnMesgDefn
AddHandler mesgBroadcaster
.FileIdMesgEventAddressOf OnFileIDMesg
AddHandler mesgBroadcaster
.UserProfileMesgEventAddressOf OnUserProfileMesg
AddHandler mesgBroadcaster
.MonitoringMesgEventAddressOf OnMonitoringMessage
AddHandler mesgBroadcaster
.DeviceInfoMesgEventAddressOf OnDeviceInfoMessage
AddHandler mesgBroadcaster
.RecordMesgEventAddressOf OnRecordMessage 

I'm on a roll again. But it will probably be a while before I get it really running though.