BCS 4.0 .NET API and BCS Temperature Logger

Applications that run on PC/Mac.
MikeRussell
Posts: 30
Joined: Thu Jun 18, 2015 7:58 pm
Bot?: No

BCS 4.0 .NET API and BCS Temperature Logger

Post by MikeRussell » Wed Jul 15, 2015 6:20 pm

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
Attachments
BCSTempLogger1.1.0.zip
(241.64 KiB) Downloaded 19 times
BCSTempLogger (v3).zip
(7.77 KiB) Downloaded 168 times
BCSTempLogger (v4).zip
(250.83 KiB) Downloaded 214 times
Last edited by MikeRussell on Thu Aug 15, 2019 7:48 am, edited 4 times in total.

brahn
Posts: 543
Joined: Thu Dec 13, 2012 11:01 am
Bot?: No

Re: BCS 4.0 .NET API

Post by brahn » Thu Jul 16, 2015 9:58 am

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.

MikeRussell
Posts: 30
Joined: Thu Jun 18, 2015 7:58 pm
Bot?: No

Re: BCS 4.0 .NET API

Post by MikeRussell » Thu Jul 16, 2015 10:42 am

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.

User avatar
JonW
Site Admin
Posts: 1705
Joined: Sun Jul 18, 2010 7:51 am
Bot?: No
Location: Huntington Beach, CA
Contact:

Re: BCS 4.0 .NET API

Post by JonW » Thu Jul 16, 2015 11:23 am

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.

MikeRussell
Posts: 30
Joined: Thu Jun 18, 2015 7:58 pm
Bot?: No

Re: BCS 4.0 .NET API

Post by MikeRussell » Thu Jul 16, 2015 11:48 am

Oh awesome, that will make life (and code) a lot easier!

Thanks for the reply JonW!

User avatar
SamIam
Posts: 51
Joined: Fri Aug 19, 2011 1:34 pm
Bot?: No

Re: BCS 4.0 .NET API

Post by SamIam » Thu Jul 16, 2015 11:58 am

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.

MikeRussell
Posts: 30
Joined: Thu Jun 18, 2015 7:58 pm
Bot?: No

Re: BCS 4.0 .NET API

Post by MikeRussell » Thu Jul 16, 2015 12:22 pm

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.

User avatar
SamIam
Posts: 51
Joined: Fri Aug 19, 2011 1:34 pm
Bot?: No

Re: BCS 4.0 .NET API

Post by SamIam » Thu Jul 16, 2015 6:33 pm

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.

User avatar
SamIam
Posts: 51
Joined: Fri Aug 19, 2011 1:34 pm
Bot?: No

Re: BCS 4.0 .NET API

Post by SamIam » Thu Jul 16, 2015 8:28 pm

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 231 times

User avatar
JonW
Site Admin
Posts: 1705
Joined: Sun Jul 18, 2010 7:51 am
Bot?: No
Location: Huntington Beach, CA
Contact:

Re: BCS 4.0 .NET API

Post by JonW » Thu Jul 16, 2015 9:25 pm

Sam, is that for BCS 3.x or 4.x?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest