Ejemplo n.º 1
0
    private static string UID  = "XYZ";    // Change XYZ to the UID of your Industrial Quad Relay Bricklet 2.0

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

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

        // Turn relays alternating on/off 10 times with 100 ms delay
        for (int i = 0; i < 10; i++)
        {
            Thread.Sleep(100);
            iqr.SetValue(new bool[] { true, false, false, false });
            Thread.Sleep(100);
            iqr.SetValue(new bool[] { false, true, false, false });
            Thread.Sleep(100);
            iqr.SetValue(new bool[] { false, false, true, false });
            Thread.Sleep(100);
            iqr.SetValue(new bool[] { false, false, false, true });
        }

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
Ejemplo n.º 2
0
    static void Main()
    {
        IPConnection ipcon = new IPConnection();                                           // Create IP connection
        BrickletIndustrialQuadRelayV2 iqr = new BrickletIndustrialQuadRelayV2(UID, ipcon); // Create device object

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

        AOn(iqr);

        ipcon.Disconnect();
    }
 private void EnumerateCB(IPConnection sender, string UID, string connectedUID, char position,
                          short[] hardwareVersion, short[] firmwareVersion,
                          int deviceIdentifier, short enumerationType)
 {
     if (enumerationType == IPConnection.ENUMERATION_TYPE_CONNECTED ||
         enumerationType == IPConnection.ENUMERATION_TYPE_AVAILABLE)
     {
         if (deviceIdentifier == BrickletIndustrialQuadRelayV2.DEVICE_IDENTIFIER)
         {
             try
             {
                 brickletIndustrialQuadRelayV2 = new BrickletIndustrialQuadRelayV2(UID, ipcon);
                 Log("Industrial Quad Relay V2 initialized");
             }
             catch (TinkerforgeException e)
             {
                 Log("Industrial Quad Relay V2 init failed: " + e.Message);
                 brickletIndustrialQuadRelayV2 = null;
             }
         }
     }
 }
Ejemplo n.º 4
0
    private static string UID  = "2g2gRs";    // Change to your UID

    static void AOn(BrickletIndustrialQuadRelayV2 iqr)
    {
        // Close channels 0 and 2 for 1.5 seconds
        iqr.SetMonoflop(0, true, 1500);
        iqr.SetMonoflop(2, true, 1500);
    }
Ejemplo n.º 5
0
 static void BOff(BrickletIndustrialQuadRelayV2 iqr)
 {
     // Close channels 1 and 3 for 1.5 seconds
     iqr.SetMonoflop(1, true, 1500);
     iqr.SetMonoflop(3, true, 1500);
 }