/// <summary> /// Connect to the remote host using the specified port. /// </summary> public KnxClientHelper Connect() { if (knxClient != null) { knxClient.Disconnect(); } if (knxEndPoint == null) { knxClient = new KnxConnectionRouting(); } else { if (knxEndPoint.RemoteIp != null && knxEndPoint.LocalIp != null) { if (knxClient == null) { knxClient = new KnxConnectionTunneling(knxEndPoint.RemoteIp, knxEndPoint.RemotePort, knxEndPoint.LocalIp, knxEndPoint.LocalPort); } } else if (knxEndPoint.LocalIp != null && knxEndPoint.LocalPort > 0) { if (knxClient == null) { knxClient = new KnxConnectionRouting(knxEndPoint.LocalIp, knxEndPoint.LocalPort); } } else if (knxEndPoint.LocalIp != null && knxEndPoint.LocalPort == 0) { if (knxClient == null) { knxClient = new KnxConnectionRouting(knxEndPoint.LocalIp); } } else if (knxEndPoint.LocalPort > 0) { if (knxClient == null) { knxClient = new KnxConnectionRouting(knxEndPoint.LocalPort); } } } if (!string.IsNullOrWhiteSpace(actionMessageCode)) { knxClient.ActionMessageCode = (byte)new ByteConverter().ConvertFromString(actionMessageCode); } knxClient.Connect(); knxClient.KnxConnectedDelegate += knxClient_Connected; knxClient.KnxDisconnectedDelegate += knxClient_Disconnected; knxClient.KnxEventDelegate += knxClient_EventReceived; knxClient.KnxStatusDelegate += knxClient_StatusReceived; return(this); }
public static void Main(string[] args) { /*test output werte richtig anzeigen * testen knx connection unten abschalten * auf nas probiren*/ _connection = new KnxConnectionTunneling("192.168.100.250", 3671, "192.168.100.194", 3671) { Debug = false }; //_connection = new KnxConnectionTunneling("192.168.100.250", 3671, "172.17.0.2", 3672) { Debug = true }; //_connection = new KnxConnectionTunneling("192.168.100.250", 3671, "192.168.100.90", 3672) { Debug = false }; /*DOCKER NAS*/ //_connection = new KnxConnectionTunneling("192.168.100.250", 3671, "192.168.100.172", 3671) { Debug = false }; _connection.KnxConnectedDelegate += Connected; _connection.KnxDisconnectedDelegate += Disconnected; _connection.KnxEventDelegate += Event; _connection.KnxStatusDelegate += Status; _connection.Connect(); Console.WriteLine("Done. Press [ENTER] to finish"); //Console.ReadLine(); //Console.WriteLine("send"); //_connection.Action("2/1/3", true); //Console.ReadLine(); //_connection.Action("2/1/3", false); Console.ReadLine(); _connection.KnxDisconnectedDelegate -= Disconnected; _connection.Disconnect(); Environment.Exit(0); }
public void Disconnect() { if (_connection != null) { _connection.Disconnect(); _connection.KnxConnectedDelegate -= Connected; _connection.KnxDisconnectedDelegate -= Disconnected; _connection.KnxEventDelegate -= Event; _connection.KnxStatusDelegate -= Status; _connected = false; } }
/// <summary> /// Connect to the remote host using the specified port. /// </summary> /// <param name="port">Port number.</param> public KnxClientHelper Connect() { if (knxClient != null) { knxClient.Disconnect(); } if (knxEndPoint == null) { knxClient = new KnxConnectionRouting(); } else { if (knxEndPoint.RemoteIp != null && knxEndPoint.LocalIp != null) { knxClient = new KnxConnectionTunneling(knxEndPoint.RemoteIp, knxEndPoint.RemotePort, knxEndPoint.LocalIp, knxEndPoint.LocalPort); } else if (knxEndPoint.LocalIp != null && knxEndPoint.LocalPort > 0) { knxClient = new KnxConnectionRouting(knxEndPoint.LocalIp, knxEndPoint.LocalPort); } else if (knxEndPoint.LocalIp != null && knxEndPoint.LocalPort == 0) { knxClient = new KnxConnectionRouting(knxEndPoint.LocalIp); } else if (knxEndPoint.LocalPort > 0) { knxClient = new KnxConnectionRouting(knxEndPoint.LocalPort); } } knxClient.Connect(); knxClient.KnxConnectedDelegate += knxClient_Connected; knxClient.KnxDisconnectedDelegate += knxClient_Disconnected; knxClient.KnxEventDelegate += knxClient_EventReceived; knxClient.KnxStatusDelegate += knxClient_StatusReceived; return(this); }
public void Shutdown() { lock (_runLock) { if (!_run) { return; } _run = false; } _connection.Disconnect(); Task.Delay(10000).GetAwaiter().GetResult(); _connection.KnxDisconnectedDelegate -= Disconnected; _connection.KnxConnectedDelegate -= Connected; _connection.KnxStatusDelegate -= Status; _connection.KnxEventDelegate -= Event; _connection = null; }
private static void Main() { _connection = new KnxConnectionTunneling("10.0.250.20", 3671, "10.0.253.5", 3671) { Debug = false }; _connection.KnxConnectedDelegate += Connected; _connection.KnxDisconnectedDelegate += Disconnected; _connection.KnxEventDelegate += Event; _connection.KnxStatusDelegate += Status; _connection.Connect(); Console.WriteLine("Done. Press [ENTER] to finish"); Console.Read(); _connection.KnxDisconnectedDelegate -= Disconnected; _connection.Disconnect(); Environment.Exit(0); }
public void Test() { KNXLib.Log._logger.DebugEventEndpoint += Log; KNXLib.Log._logger.InfoEventEndpoint += Log; KNXLib.Log._logger.WarnEventEndpoint += Log; KNXLib.Log._logger.ErrorEventEndpoint += Log; //var connection = new KnxConnectionRouting("192.128.1.100"); _connection = new KnxConnectionTunneling("192.128.1.100", 3671, "192.128.1.1", 3671); _connection.Debug = true; _connection.KnxConnectedDelegate += Connected; _connection.KnxDisconnectedDelegate += Disconnected; _connection.KnxStatusDelegate += Status; _connection.KnxEventDelegate += Event; _connection.Connect(); //Task.Run(() => //{ // Thread.Sleep(10000); //}).Wait(); //_connection.Action("0/0/6", false); //Task.Run(() => //{ // Thread.Sleep(10000); //}).Wait(); //_connection.Action("0/0/6", true); //Task.Run(() => //{ // Thread.Sleep(10000); //}).Wait(); //_connection.RequestStatus("1.1.50"); //Task.Run(() => //{ // Thread.Sleep(10000); //}).Wait(); //_connection.RequestStatus("1.1.51"); //Task.Run(() => //{ // Thread.Sleep(10000); //}).Wait(); //_connection.RequestStatus("1.1.30"); //Task.Run(() => //{ // Thread.Sleep(10000); //}).Wait(); //_connection.RequestStatus("1.1.31"); //Task.Run(() => //{ // Thread.Sleep(10000); //}).Wait(); //_connection.RequestStatus("1.1.32"); //Task.Run(() => //{ // Thread.Sleep(10000); //}).Wait(); Task.Run(() => { var _run = true; while (_run) { Thread.Sleep(100); } }).Wait(); _connection.Disconnect(); Task.Run(() => { Thread.Sleep(10000); }).Wait(); //connection.KnxEventDelegate += Event; //connection.Action("1/1/50", false); //Task.Delay(5000).Wait(); //connection.Action("1/1/50", true); //Task.Delay(5000).Wait(); }