private static string UID = "XYZ"; // Change XYZ to the UID of your Current25 Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletCurrent25 c = new BrickletCurrent25(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current current (unit is mA) short current = c.GetCurrent(); Console.WriteLine("Current: " + current/1000.0 + " A"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletCurrent25 c = new BrickletCurrent25(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Register current callback to function CurrentCB c.Current += CurrentCB; // Set period for current callback to 1s (1000ms) // Note: The current callback is only called every second // if the current has changed since the last call! c.SetCurrentCallbackPeriod(1000); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletCurrent25 c = new BrickletCurrent25(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get threshold callbacks with a debounce time of 10 seconds (10000ms) c.SetDebouncePeriod(10000); // Register current reached callback to function CurrentReachedCB c.CurrentReached += CurrentReachedCB; // Configure threshold for current "greater than 5 A" (unit is mA) c.SetCurrentCallbackThreshold('>', 5*1000, 0); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Current25 Bricklet #endregion Fields #region Methods // Callback function for current reached callback (parameter has unit mA) static void CurrentReachedCB(BrickletCurrent25 sender, short current) { Console.WriteLine("Current: " + current/1000.0 + " A"); }