Example #1
0
    static void Main()
    {
        IPConnection             ipcon = new IPConnection(); // Create IP connection
        BrickletVoltageCurrentV2 vc    =
            new BrickletVoltageCurrentV2(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
        vc.CurrentCallback += CurrentCB;

        // Set period for current callback to 1s (1000ms) without a threshold
        vc.SetCurrentCallbackConfiguration(1000, false, 'x', 0, 0);

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
Example #2
0
    static void Main()
    {
        IPConnection             ipcon = new IPConnection(); // Create IP connection
        BrickletVoltageCurrentV2 vc    =
            new BrickletVoltageCurrentV2(UID, ipcon);        // Create device object

        ipcon.Connect(HOST, PORT);                           // Connect to brickd
        // Don't use device before ipcon is connected

        // Register power callback to function PowerCB
        vc.PowerCallback += PowerCB;

        // Configure threshold for power "greater than 10 W"
        // with a debounce period of 1s (1000ms)
        vc.SetPowerCallbackConfiguration(1000, false, '>', 10 * 1000, 0);

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
    private static string UID  = "XYZ";    // Change XYZ to the UID of your Voltage/Current Bricklet 2.0

    static void Main()
    {
        IPConnection             ipcon = new IPConnection(); // Create IP connection
        BrickletVoltageCurrentV2 vc    =
            new BrickletVoltageCurrentV2(UID, ipcon);        // Create device object

        ipcon.Connect(HOST, PORT);                           // Connect to brickd
        // Don't use device before ipcon is connected

        // Get current voltage
        int voltage = vc.GetVoltage();

        Console.WriteLine("Voltage: " + voltage / 1000.0 + " V");

        // Get current current
        int current = vc.GetCurrent();

        Console.WriteLine("Current: " + current / 1000.0 + " A");

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
Example #4
0
    private static string UID  = "XYZ";    // Change XYZ to the UID of your Voltage/Current Bricklet 2.0

    // Callback function for power callback
    static void PowerCB(BrickletVoltageCurrentV2 sender, int power)
    {
        Console.WriteLine("power: " + power / 1000.0 + " W");
    }
Example #5
0
    private static string UID  = "XYZ";    // Change XYZ to the UID of your Voltage/Current Bricklet 2.0

    // Callback function for current callback
    static void CurrentCB(BrickletVoltageCurrentV2 sender, int current)
    {
        Console.WriteLine("Current: " + current / 1000.0 + " A");
    }