internal DeviceConnectionState Initialize(int Timeout) { m_ConnectionState = DeviceConnectionState.ConnectionInProcess; FireConnectionEvent(m_ConnectionState, "Adapter initializing"); if (m_IsAdapterEmulation) { m_ConnectionState = DeviceConnectionState.ConnectionSuccess; FireConnectionEvent(m_ConnectionState, "Adapter initialized"); return(m_ConnectionState); } try { if (m_Adapter != null) { if (m_Adapter.Connected) { m_Adapter.Close(); } } m_Adapter = new SCCIMasterAdapter(true); m_Adapter.Initialize(new SerialPortConfigurationMaster { PortNumber = Settings.Default.AdapterPort, BaudRate = 115200, DataBits = 8, StopBits = StopBits.One, ParityMode = Parity.None, TimeoutForSyncReceive = Timeout, TimeoutForSyncStreamReceive = Timeout, UseRetransmitsForArrays = true, RetransmitsCountOnError = 5 }); m_ConnectionState = DeviceConnectionState.ConnectionSuccess; FireConnectionEvent(m_ConnectionState, "Adapter initialized"); } catch (SerialConnectionException ex) { m_ConnectionState = DeviceConnectionState.ConnectionFailed; FireConnectionEvent(m_ConnectionState, String.Format("Adapter initialization error: {0}", ex.Message)); } return(m_ConnectionState); }
internal void Deinitialize() { m_ConnectionState = DeviceConnectionState.DisconnectionInProcess; FireConnectionEvent(DeviceConnectionState.DisconnectionInProcess, "Adapter closing"); if (m_Adapter != null && m_Adapter.Connected) { m_Adapter.Close(); m_Adapter = null; } m_ConnectionState = DeviceConnectionState.DisconnectionSuccess; FireConnectionEvent(DeviceConnectionState.DisconnectionSuccess, "Adapter closed"); }