Fabio Posted April 23, 2017 at 04:12 PM Posted April 23, 2017 at 04:12 PM Hallo zusammen, ich bin ein großer Fan des Tinkerforge Baukastensystems. Außerdem programmiere ich fast ausschließlich in C#. Leider finde ich die C# API nicht besonders komfortabel, was wie ich denke auf die vielen Methoden mit „out“-Parametren zurückzuführen ist. Microsoft bzw. das C# Team haben das erkannt und mit .net 4.7 und C# Version 7 (Windows 10 Creators Update) das Problem behoben. Daher möchte ich nun hier meine C# Plugin für .net 4.7 vorstellen. Diese Erweiterung fügt für alle Methoden aus der Tinkerfoge API für .net eine Methoden-Überschreibung hinzu. Es handelt sich um keine neue API sondern um eine API-Erweiterung. Es wird weiterhin die Basis-DLL benötigt. Beispiel für C#: var ipcon = new IPConnection(); // Create IP connection var io = new BrickletIO4("h2R", ipcon); // Create device object ipcon.Connect("localhost", 4223); // Connect to brickd //Old Style io.GetMonoflop(0, out byte value, out long time, out long timeRemaining); Console.WriteLine("Remaining time: " + timeRemaining); //New Style Console.WriteLine("Remaining time: " + io.GetMonoflop(0).TimeRemaining); ipcon.Disconnect(); Console.WriteLine("Press enter to exit..."); Console.ReadKey(); Beispiel VB.net: Dim ipcon = New IPConnection Dim io = New BrickletIO4("h2R", ipcon) ' Create device object ipcon.Connect("localhost", 4223) ' Connect to brickd 'Old Style Dim value As Byte Dim time As Long Dim timeRemaining As Long io.GetMonoflop(0, value:=value, time:=time, timeRemaining:=timeRemaining) Console.WriteLine("Remaining time: " + timeRemaining.ToString()) 'New Style Console.WriteLine("Remaining time: " + io.GetMonoflop(0).TimeRemaining.ToString()) ipcon.Disconnect() Console.WriteLine("Press enter to exit...") Console.ReadKey() Ich kenne mich leider mit Mono nicht aus, daher kann ich nicht sagen, ob das kompatibel ist. Fragen und Kommentare sind willkommen! TinkerforgeNetPlus47.zipTinkerforgeNetPlus47.dll Quote
borg Posted April 26, 2017 at 09:18 AM Posted April 26, 2017 at 09:18 AM Sieht sehr gut aus! Wir brechen nur sehr ungern die API, deswegen ist es für uns immer schwer solche Sprachverbesserungen im Nachhinein umzusetzen. Quote
Fabio Posted April 30, 2017 at 03:33 PM Author Posted April 30, 2017 at 03:33 PM Ist nun auch auf NuGet verfügbar: https://www.nuget.org/packages/Tinkerforge.Tuple/ Regelmäßige Updates, wenn es API Erweiterungen gibt, sind geplant. Quote
Fabio Posted May 14, 2017 at 05:44 PM Author Posted May 14, 2017 at 05:44 PM Version 1.1 veröffentlicht für GPS Bricklet 2.0. https://www.nuget.org/packages/Tinkerforge.Tuple/ Quote
Grimsey Posted May 23, 2017 at 01:11 PM Posted May 23, 2017 at 01:11 PM Gehe ich richtig in der Annahme, dass man dafür jetzt zwingend Visual Studio 2017 benötigt? Ich habe die 2015er Community-Version, habe auch das .net-Framework 4.7 installiert (Betriebssystem ist Windows 7) aber ich kann das Zielframework nicht auf die Version 4.7 ändern. Es wird in der Dropdownliste nicht angezeigt. Quote
Fabio Posted May 23, 2017 at 04:43 PM Author Posted May 23, 2017 at 04:43 PM Also bei mir funktioniert das auch mit VS2015 allerdings unter Windows 10. Ansonsten ist .NET 4.7 zum Download hier erhältlich: https://blogs.msdn.microsoft.com/dotnet/2017/05/02/announcing-the-net-framework-4-7-general-availability/ Quote
Grimsey Posted May 24, 2017 at 06:19 AM Posted May 24, 2017 at 06:19 AM Hallo Fabio, danke für Deine Antwort. Ich habe das .Net-Framework 4.7 ja bereits installiert, aber es steht mir für eine Auswahl dennoch nicht zur Verfügung. Danke Dir dennoch! Quote
Grimsey Posted May 24, 2017 at 07:44 AM Posted May 24, 2017 at 07:44 AM Habs auch endlich hinbekommen. Gibt für den Download nochmal eine Auswahl für welche VisualStudio Version man es herunterladen will. Da hatte ich offensichtlich nicht das richtige. Quote
Fabio Posted August 8, 2017 at 05:48 PM Author Posted August 8, 2017 at 05:48 PM Version 1.2 veröffentlicht: Unterstützung für RS485 Bricklet NuGet: https://www.nuget.org/packages/Tinkerforge.Tuple/ Quote
tatzemax Posted March 7, 2018 at 01:07 AM Posted March 7, 2018 at 01:07 AM Vielleicht kann TF einen hinweis in der Doku zu dieser Erweiterung hinterlegen Quote
Fabio Posted March 23, 2018 at 05:10 PM Author Posted March 23, 2018 at 05:10 PM Update 1.3 Unterstützung für folgende Bricklet´s wurde ergänzt: -Remote Switch Bricklet 2.0 -Motion Detector Bricklet 2.0 -Analog In Bricklet 3.0 -NFC Bricklet -Temperature IR Bricklet 2.0 -Rotary Encoder Bricklet 2.0 -Solid State Relay Bricklet 2.0 -Outdoor Weather Bricklet -DMX Bricklet, Humidity Bricklet 2.0 -Motorized Linear Poti Bricklet -RGB LED Button Bricklet -RGB LED Matrix Bricklet -Thermal Imaging Bricklet Quote
stevehayles Posted January 29, 2019 at 05:04 PM Posted January 29, 2019 at 05:04 PM Hi, Not sure if this package is being maintained. Please see https://www.tinkerunity.org/forum/index.php/topic,4748.0.html for another option with Async/Await support and other additional features Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.