Ich habe grade mal einen kurzen Test mit der KNX.net Bibliothek von Codeplex ausprobiert und auf meinem Test-Board eine Lampe an und ausgeschaltet.
Das möchte ich euch nicht vorenthalten!
Die Verwendung ist denkbar einfach. Ein beiligendes Testprojekt veranschaulicht dies auch. Dazu musste ich nur die Objekt-Gruppenadresse anpassen und es lief sofort.
Die Events und Status-Änderungen kommen per Event rein und können dann dementsprechend auch gefiltert werden wenn man möchte.
Zusätzlich sind noch Beispiele für Temperatur und Blendensteuerung mit dabei aber auskommentiert.
Das möchte ich euch nicht vorenthalten!
Die Verwendung ist denkbar einfach. Ein beiligendes Testprojekt veranschaulicht dies auch. Dazu musste ich nur die Objekt-Gruppenadresse anpassen und es lief sofort.
Die Events und Status-Änderungen kommen per Event rein und können dann dementsprechend auch gefiltert werden wenn man möchte.
Zusätzlich sind noch Beispiele für Temperatur und Blendensteuerung mit dabei aber auskommentiert.
Code:
class TestRouting { private static KNXLib.KNXConnection connection = null; static void Main(string[] args) { connection = new KNXLib.KNXConnectionRouting(); connection.Debug = false; connection.ActionMessageCode = 0x29; connection.Connect(); connection.KNXConnectedDelegate += new KNXLib.KNXConnection.KNXConnected(Connected); connection.KNXDisconnectedDelegate += new KNXLib.KNXConnection.KNXDisconnected(Disconnected); connection.KNXEventDelegate += new KNXLib.KNXConnection.KNXEvent(Event); connection.KNXStatusDelegate += new KNXLib.KNXConnection.KNXStatus(Status); //// LIGHT ON/OFF Console.WriteLine("Lampe 1 AN senden"); Console.ReadLine(); connection.Action("0/0/1", true); Thread.Sleep(200); Console.WriteLine("Lampe 1 AUS senden"); Console.ReadLine(); connection.Action("0/0/1", false); Thread.Sleep(200); //// BLIND UP/DOWN //Console.WriteLine("Press [ENTER] to send command (2/1/1) - false"); //Console.ReadLine(); //connection.Action("2/1/1", false); //Thread.Sleep(200); //Console.WriteLine("Press [ENTER] to send command (2/1/1) - true"); //Console.ReadLine(); //connection.Action("2/1/1", true); //Thread.Sleep(200); //Console.WriteLine("Press [ENTER] to send command (2/2/1) - true"); //Console.ReadLine(); //connection.Action("2/2/1", true); //Thread.Sleep(200); //// BLIND UP/DOWN //Console.WriteLine("Press [ENTER] to send command (2/3/1) - \x00"); //Console.ReadLine(); //connection.Action("2/3/1", 0x00); //Thread.Sleep(200); //Console.WriteLine("Press [ENTER] to send command (2/3/1) - \xFF"); //Console.ReadLine(); //connection.Action("2/3/1", 0xFF); //Thread.Sleep(200); //Console.WriteLine("Press [ENTER] to send command (2/3/1) - \x80"); //Console.ReadLine(); //connection.Action("2/3/1", 0x80); //Thread.Sleep(200); //Console.WriteLine("Press [ENTER] to send command (2/2/1) - true"); //Console.ReadLine(); //connection.Action("2/2/1", true); //Thread.Sleep(200); // TEMPERATURE SETPOINT //Console.WriteLine("Press [ENTER] to send command (1/1/16) - 28ºC"); //Console.ReadLine(); //connection.Action("1/1/16", connection.toDPT("9.001", 28.0f)); //Thread.Sleep(200); //Console.WriteLine("Press [ENTER] to send command (1/1/16) - 27ºC"); //Console.ReadLine(); //connection.Action("1/1/16", connection.toDPT("9.001", 27.0f)); //Thread.Sleep(200); //Console.WriteLine("Press [ENTER] to send command (1/1/16) - 26ºC"); //Console.ReadLine(); //connection.Action("1/1/16", connection.toDPT("9.001", 26.0f)); //Thread.Sleep(200); //Console.WriteLine("Press [ENTER] to send command (1/1/16) - 25ºC"); //Console.ReadLine(); //connection.Action("1/1/16", connection.toDPT("9.001", 25.0f)); //Thread.Sleep(200); //Console.WriteLine("Press [ENTER] to send command (1/1/16) - 24ºC"); //Console.ReadLine(); //connection.Action("1/1/16", connection.toDPT("9.001", 24.0f)); //Thread.Sleep(200); // 1/1/16 // 1/1/18 feedback // 1/1/17 temp feedback Console.WriteLine("Ende. [ENTER to EXTI]"); Console.Read(); System.Environment.Exit(0); } static void Event(string address, string state) { if (address.Equals("1/1/18") || address.Equals("1/1/17")) { float temp = (float)connection.fromDPT("9.001", state); Console.WriteLine("New Event: TEMPERATURE device " + address + " has status (" + state + ")" + temp); } if (address.Equals("5/1/2")) { Console.WriteLine("New Event: LIGHT device " + address + " has status (" + state + ")" + state); } else { Console.WriteLine("New Event: device " + address + " has status " + state); } } static void Status(string address, string state) { Console.WriteLine("New Status: device " + address + " has status " + state); } static void Connected() { Console.WriteLine("Connected!"); } static void Disconnected() { Console.WriteLine("Disconnected! Reconnecting"); if (connection != null) { Thread.Sleep(1000); connection.Connect(); } }
Kommentar