private static void TemperatureSetpoint(KnxConnectionRouting connection) { Console.WriteLine("Press [ENTER] to send command (1/1/16) - 28ºC"); Console.ReadLine(); connection.Action(new KnxThreeLevelGroupAddress(1, 1, 16), connection.ToDataPoint("9.001", 28.0f)); Thread.Sleep(200); Console.WriteLine("Press [ENTER] to send command (1/1/16) - 27ºC"); Console.ReadLine(); connection.Action(new KnxThreeLevelGroupAddress(1, 1, 16), connection.ToDataPoint("9.001", 27.0f)); Thread.Sleep(200); Console.WriteLine("Press [ENTER] to send command (1/1/16) - 26ºC"); Console.ReadLine(); connection.Action(new KnxThreeLevelGroupAddress(1, 1, 16), connection.ToDataPoint("9.001", 26.0f)); Thread.Sleep(200); Console.WriteLine("Press [ENTER] to send command (1/1/16) - 25ºC"); Console.ReadLine(); connection.Action(new KnxThreeLevelGroupAddress(1, 1, 16), connection.ToDataPoint("9.001", 25.0f)); Thread.Sleep(200); Console.WriteLine("Press [ENTER] to send command (1/1/16) - 24ºC"); Console.ReadLine(); connection.Action(new KnxThreeLevelGroupAddress(1, 1, 16), connection.ToDataPoint("9.001", 24.0f)); Thread.Sleep(200); }
private static void Main() { _logFile = new StreamWriter("telegrams.txt"); using (var connection = new KnxConnectionRouting { Debug = false, ActionMessageCode = 0x29 }) { connection.SetLockIntervalMs(20); connection.KnxConnectedDelegate += Connected; connection.KnxDisconnectedDelegate += () => Disconnected(connection); connection.KnxEventDelegate += (sender, args) => Event(connection, args.DestinationAddress, args.State); connection.KnxStatusDelegate += (sender, args) => Status(connection, args.DestinationAddress, args.State); connection.Connect(); //LightOnOff(connection); //BlindUpDown1(connection); //BlindUpDown2(connection); //TemperatureSetpoint(connection); Console.WriteLine("Done. Press [ENTER] to finish"); Console.Read(); } _logFile.Dispose(); Environment.Exit(0); }
private static void BlindUpDown1(KnxConnectionRouting connection) { Console.WriteLine("Press [ENTER] to send command (2/1/1) - false"); Console.ReadLine(); connection.Action(new KnxThreeLevelGroupAddress(2, 1, 1), false); Thread.Sleep(200); Console.WriteLine("Press [ENTER] to send command (2/1/1) - true"); Console.ReadLine(); connection.Action(new KnxThreeLevelGroupAddress(2, 1, 1), true); Thread.Sleep(200); Console.WriteLine("Press [ENTER] to send command (2/2/1) - true"); Console.ReadLine(); connection.Action(new KnxThreeLevelGroupAddress(2, 2, 1), true); Thread.Sleep(200); }
private static void BlindUpDown2(KnxConnectionRouting connection) { Console.WriteLine("Press [ENTER] to send command (2/3/1) - \x00"); Console.ReadLine(); connection.Action(new KnxThreeLevelGroupAddress(2, 3, 1), 0x00); Thread.Sleep(200); Console.WriteLine("Press [ENTER] to send command (2/3/1) - \xFF"); Console.ReadLine(); connection.Action(new KnxThreeLevelGroupAddress(2, 3, 1), 0xFF); Thread.Sleep(200); Console.WriteLine("Press [ENTER] to send command (2/3/1) - \x80"); Console.ReadLine(); connection.Action(new KnxThreeLevelGroupAddress(2, 3, 1), 0x80); Thread.Sleep(200); Console.WriteLine("Press [ENTER] to send command (2/2/1) - true"); Console.ReadLine(); connection.Action(new KnxThreeLevelGroupAddress(2, 2, 1), true); Thread.Sleep(200); }
public bool Execute(string connectionMode, IEnumerable <Actor> actors, ActorAction action, bool verbose) { if (actors == null) { throw new ArgumentNullException(nameof(actors)); } if (action == null) { throw new ArgumentNullException(nameof(action)); } var finalConnectionMode = CheckAndGetConnectionMode(connectionMode); var hostName = Dns.GetHostName(); var localIPs = Dns.GetHostAddresses(Dns.GetHostName()); var myIPs = localIPs .Where(address => address.AddressFamily == AddressFamily.InterNetwork) .Select(l => l.ToString()); foreach (var myIP in myIPs) { try { KnxConnection connection = null; if (finalConnectionMode == 1) { connection = new KnxConnectionTunneling( settings.KnxGatewayIP, settings.KnxGatewayPort, myIP, settings.KnxLocalPort) { Debug = verbose }; } else if (finalConnectionMode == 2) { connection = new KnxConnectionRouting( settings.KnxGatewayIP, settings.KnxGatewayPort) { Debug = verbose }; } else { throw new ArgumentException("Unknown mode."); } connection.Connect(); //connection.KnxEventDelegate += Event; foreach (var actor in actors) { if (actor.Action.Type.Equals("Switch", StringComparison.InvariantCultureIgnoreCase)) { var val = (bool)action.Value; connection.Action(actor.Address, val); } else { Console.Error.WriteLine("Unknown actor action type"); return(false); } } connection.Disconnect(); return(true); } catch (Exception ex) { if (verbose) { Console.Error.WriteLine($"Can't use local IP '{myIP}'."); Console.Error.WriteLine(ex.Message); } } } return(false); }