public void Initialize(bool _BurstMessages, byte _StationNumDevice, CStationBase.Protocol _FrameProtocol, CStationBase.Protocol _CommandProtocol) { if (_BurstMessages) { m_flowControlMethod = EnumFrameFlowControl.BURST; m_frameWindow = MAX_FRAME_WINDOW; } else { m_flowControlMethod = EnumFrameFlowControl.ONE_TO_ONE; } if (m_mode == SearchMode.USB) { m_StackDll = new Stack_dll(ref m_pSerialPort, m_sourceAddress, _FrameProtocol, m_flowControlMethod, m_frameWindow); m_StackDll.DataReceived += DataReceived; m_StackDll.DataReceivedMessages += DataReceived_Burst; m_StackDll.ErrorConnect += Event_ConnectionError; #if LibraryTest m_StackDll.DataSentFrame += StackDll_DataSentFrame; m_StackDll.DataReceivedFrame += StackDll_DataReceivedFrame; m_StackDll.DataReceivedFrameMessages += StackDll_DataReceivedFrame_Burst; m_StackDll.DataSentRawData += StackDll_DataSentRawData; m_StackDll.DataReceivedRawData += StackDll_DataReceivedRawData; #endif } else if (m_mode == SearchMode.ETH) { m_StackDll = new Stack_dll(ref m_pWinSock, m_sourceAddress, _FrameProtocol, m_flowControlMethod, m_frameWindow); m_StackDll.DataReceived += DataReceived; m_StackDll.DataReceivedMessages += DataReceived_Burst; m_StackDll.ErrorConnect += Event_ConnectionError; #if LibraryTest m_StackDll.DataSentFrame += StackDll_DataSentFrame; m_StackDll.DataReceivedFrame += StackDll_DataReceivedFrame; m_StackDll.DataReceivedFrameMessages += StackDll_DataReceivedFrame_Burst; m_StackDll.DataSentRawData += StackDll_DataSentRawData; m_StackDll.DataReceivedRawData += StackDll_DataReceivedRawData; #endif } }
public void Dispose() { m_mutexStackAddressMessages.WaitOne(); if (m_htStackAddressMessages != null) { foreach (DictionaryEntry stack in m_htStackAddressMessages) { ((CStackMessages)stack.Value).Dispose(); } m_htStackAddressMessages.Clear(); m_htStackAddressMessages = null; } m_mutexStackAddressMessages.Release(); m_pSerialPort = null; m_pWinSock = null; m_mutexStackDll.WaitOne(); if (m_StackDll != null) { #if LibraryTest m_StackDll.DataSentFrame -= StackDll_DataSentFrame; m_StackDll.DataReceivedFrame -= StackDll_DataReceivedFrame; m_StackDll.DataReceivedFrameMessages -= StackDll_DataReceivedFrame_Burst; m_StackDll.DataSentRawData -= StackDll_DataSentRawData; m_StackDll.DataReceivedRawData -= StackDll_DataReceivedRawData; #endif m_StackDll.Eraser(); m_StackDll = null; //m_StackDll.DataReceived += DataReceived; //m_StackDll.DataReceivedMessages += DataReceived_Burst; //m_StackDll.ErrorConnect += Event_ConnectionError; } m_mutexStackDll.Release(); }