internal void CloseConnection() { if (m_machine.connected) { Disconnect(); } m_connectionState = HeidenhainDNCLib.DNC_STATE.DNC_STATE_NOT_INITIALIZED; }
internal bool RequestConnection() { m_connectionState = HeidenhainDNCLib.DNC_STATE.DNC_STATE_HOST_IS_NOT_AVAILABLE; // Request the DNC connection and connect the OnStateChanged event handler try { connectionName = FindConnection(address); if (connectionName != null) { m_machine.Connect(connectionName); m_connectionState = HeidenhainDNCLib.DNC_STATE.DNC_STATE_MACHINE_IS_AVAILABLE; // Machine is available, so complete the connection Connect(); return(true); } else { Console.WriteLine("Error: Cannot find DNC connection to CNC machine. Please check DNC settings."); return(false); } } catch (COMException cex) { Disconnect(); m_connectionState = HeidenhainDNCLib.DNC_STATE.DNC_STATE_NOT_INITIALIZED; Console.WriteLine("Error in DNC connection"); Console.WriteLine(cex.Message); return(false); } }