Page 1 of 7

BCS 4.0 .NET API and BCS Temperature Logger

Posted: Wed Jul 15, 2015 6:20 pm
by MikeRussell
Too long; didn't read? Just download the BCSTempLogger attachment

Unzip and run the executable. If your BCS has the older v3 firmware, use the v3 temp logger below.


While writing the temperature logger found near the end of this thread viewtopic.php?f=13&t=257 I found the need to make my code a little more modular.

To make my life easier, I wrote a quick .net api for dealing with the interactions with the BCS. Well, the theoretical BCS anyways, as I don't actually have a BCS to test with.

Essentially what this library will help you do is create a connection to your BCS and then provide methods to get or set specific pieces of data from it.

For example you can do:

BCSWebConnection connection = new BCSWebConnection(address, port);
BCSWrapper wrapper = new BCSWrapper(connection);

and then you can do

wrapper.GetCurrentTemperatures() which will give you an array of temperatures from the BCS or you can do wrapper.GetTemperatureProbe(probeIndex) which will give you all of the details from a probe (setpoint, etc)

Anyways, here is a zip with the API (BCSNet.Core.dll) as well as an example front end. I would really appreciate anyone's time testing it out. You can reference the BCSNet.Core.dll in your .net project and leverage the work i've done.

I've also added version 1.1.0 to the attachments which includes some customizations requested by a friend - it also saves output and DIN status to the log. You can use the existing version if this isn't useful for you

Re: BCS 4.0 .NET API

Posted: Thu Jul 16, 2015 9:58 am
by brahn
Mike, this is awesome, and you don't even have a BCS! Thanks for putting this together.

I'm on a Mac, but I may have to see if this works with the .Net Core preview that MS put out earlier this year.

Re: BCS 4.0 .NET API

Posted: Thu Jul 16, 2015 10:42 am
by MikeRussell
Thanks, brahn! I love to brew and I love to code - things like this just happen to come together sometime.

You and another forum user have talked about Mac compatibility. Are there a large number of BCS users on Macs?

I analyzed my other app (BCSTempLogger) with the Mono Migration Analyzer (MoMA) tool and it told me that the stock WebRequest.DefaultCredentials (no username/password when connecting to the BCS) is marked as TODO in Mono 2.8. This means it could potentially still work fine using Mono, or it might not connect at all.

If you could give this a try via .net Core or Wine or Mono and let me know how it works I would be eternally grateful. I think other users would benefit as well. Of course since I don't have access to a mac, there is little I can do on that front as well. I hate having my hands tied like that.

Let me know if you get error messages when using the .net core - I may have to target a different framework to make things work OK with that.

Re: BCS 4.0 .NET API

Posted: Thu Jul 16, 2015 11:23 am
by JonW
Mike,
I need to see what's wrong with our demo BCS unit and I'll get it back online. Once that's working, you can test your utilities against demo.embeddedcc.com .

Great work on the API.

Re: BCS 4.0 .NET API

Posted: Thu Jul 16, 2015 11:48 am
by MikeRussell
Oh awesome, that will make life (and code) a lot easier!

Thanks for the reply JonW!

Re: BCS 4.0 .NET API

Posted: Thu Jul 16, 2015 11:58 am
by SamIam
Mike, I created a VS2012 project a while back that does the same thing. It generates a bsc_library.dll that can be used in any other .NET project. I've tested it against a very early alpha version of the 4.0 firmware and it worked at the time. If your interested, I can send you the what I've done.

Re: BCS 4.0 .NET API

Posted: Thu Jul 16, 2015 12:22 pm
by MikeRussell
Awesome!

Glad to hear others are interested in the same type of thing. I didn't spend any time looking around to see if anyone had started a similar api. I just wanted a quick and easy way of helping a buddy log temperatures from his BCS but it turned into this already.

You can find the source for what I've done so far here: https://bitbucket.org/ransidmeat/bcsnet/ It should be flexible enough that the rest of the commands can be implemented with minimal effort. Feel free to post/host what you've got as well. I wouldn't mind taking a look at what you have done.

Oh also, how did you handle the json? I decided to try json.net since it appeared to be straightforward - I don't have much experience with parsing this stuff so maybe there is a better way.

Re: BCS 4.0 .NET API

Posted: Thu Jul 16, 2015 6:33 pm
by SamIam
I can't remember I think I just used the Javascript deserializer within .NET. I don't have it hosted anywhere and it's been over a year since I've done anything with it. Let me dig it up and I'll just shoot it to you in a PM. Do with it as you wish.

Re: BCS 4.0 .NET API

Posted: Thu Jul 16, 2015 8:28 pm
by SamIam
Project is pretty small so I thought I would just post it up here. It just builds a dll that can be used in other projects for making calls the BCS. Let me know if anyone has any questions.
NET_BCS_Library.zip
(79.68 KiB) Downloaded 687 times

Re: BCS 4.0 .NET API

Posted: Thu Jul 16, 2015 9:25 pm
by JonW
Sam, is that for BCS 3.x or 4.x?