private static string UID = "XYZ"; // Change XYZ to the UID of your Temperature IR Bricklet

    #endregion Fields

    #region Methods

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

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

        // Register object temperature callback to function ObjectTemperatureCB
        tir.ObjectTemperature += ObjectTemperatureCB;

        // Set period for object temperature callback to 1s (1000ms)
        // Note: The object temperature callback is only called every second
        //       if the object temperature has changed since the last call!
        tir.SetObjectTemperatureCallbackPeriod(1000);

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

    #endregion Fields

    #region Methods

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

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

        // Get current ambient temperature (unit is °C/10)
        short ambientTemperature = tir.GetAmbientTemperature();
        Console.WriteLine("Ambient Temperature: " + ambientTemperature/10.0 + " °C");

        // Get current object temperature (unit is °C/10)
        short objectTemperature = tir.GetObjectTemperature();
        Console.WriteLine("Object Temperature: " + objectTemperature/10.0 + " °C");

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

    #endregion Fields

    #region Methods

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

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

        // Set emissivity to 0.98 (emissivity of water, 65535 * 0.98 = 64224.299)
        tir.SetEmissivity(64224);

        // Get threshold callbacks with a debounce time of 10 seconds (10000ms)
        tir.SetDebouncePeriod(10000);

        // Register object temperature reached callback to function ObjectTemperatureReachedCB
        tir.ObjectTemperatureReached += ObjectTemperatureReachedCB;

        // Configure threshold for object temperature "greater than 100 °C" (unit is °C/10)
        tir.SetObjectTemperatureCallbackThreshold('>', 100*10, 0);

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
    // Callback function for object temperature reached callback (parameter has unit °C/10)
    static void ObjectTemperatureReachedCB(BrickletTemperatureIR sender,
	                                       short temperature)
    {
        Console.WriteLine("Object Temperature: " + temperature/10.0 + " °C");
        Console.WriteLine("The water is boiling!");
    }
 // Callback function for object temperature callback (parameter has unit °C/10)
 static void ObjectTemperatureCB(BrickletTemperatureIR sender, short temperature)
 {
     Console.WriteLine("Object Temperature: " + temperature/10.0 + " °C");
 }
예제 #6
0
        public void TestConnection()
        {
            IPConnection ipcon              = new IPConnection();                 // Create IP connection
            BrickMaster  master             = new BrickMaster(_uidMaster, ipcon); // Create device object
            BrickletIndustrialQuadRelay or1 = new BrickletIndustrialQuadRelay(_uidRelay1, ipcon);
            BrickletIndustrialQuadRelay or2 = new BrickletIndustrialQuadRelay(_uidRelay2, ipcon);
            BrickletTemperatureIR       tir = new BrickletTemperatureIR(_uidTemp, ipcon);

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

            // Get current stack voltage (unit is mV)
            int stackVoltage = master.GetStackVoltage();

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

            // Get current stack current (unit is mA)
            int stackCurrent = master.GetStackCurrent();

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

            short chipTemp = tir.GetAmbientTemperature();

            Console.WriteLine("Chibi master address: " + chipTemp / 10 + "°/C");

            int delay = 50;

            while (true)
            {
                ConsoleKeyInfo insertKey = Console.ReadKey();
                int            result    = insertKey.KeyChar;
                // UP
                if (result.Equals(32))
                {
                    or1.SetValue(1 << 0);
                    Thread.Sleep(delay);
                    or1.SetValue(1 << 0);
                    Thread.Sleep(delay);
                }
                // DOWN
                if (result.Equals(32))
                {
                    or1.SetValue(1 << 0);
                    Thread.Sleep(delay);
                    or1.SetValue(1 << 0);
                    Thread.Sleep(delay);
                }
                // LEFT
                if (result.Equals(97))
                {
                    or1.SetValue(1 << 0);
                    Thread.Sleep(delay);
                    or1.SetValue(1 << 0);
                    Thread.Sleep(delay);
                }
                // RIGHT
                if (result.Equals(32))
                {
                    or1.SetValue(1 << 0);
                    Thread.Sleep(delay);
                    or1.SetValue(1 << 0);
                    Thread.Sleep(delay);
                }
                // START
                if (result.Equals(115))
                {
                    or2.SetValue(1);
                    Thread.Sleep(delay);
                    or2.SetValue(0);
                    Thread.Sleep(delay);
                }
                // SELECT
                if (result.Equals(83))
                {
                    or2.SetValue(4);
                    Thread.Sleep(delay);
                    or2.SetValue(0);
                    Thread.Sleep(delay);
                }
                // A
                if (result.Equals(97))
                {
                    or2.SetValue(2);
                    Thread.Sleep(delay);
                    or2.SetValue(0);
                    Thread.Sleep(delay);
                }
                // B
                if (result.Equals(98))
                {
                    or2.SetValue(8);
                    Thread.Sleep(delay);
                    or2.SetValue(0);
                    Thread.Sleep(delay);
                }
                Console.WriteLine(result);
                // ESC for EXIT
                if (result.Equals(27))
                {
                    break;
                }
            }
            ipcon.Disconnect();
        }