public override void Run() { var masterStack = new MasterStackConfig(); masterStack.link.localAddr = 1; masterStack.link.remoteAddr = 10; master = GetMaster(masterStack); var integrityPoll = master.AddClassScan(ClassField.AllEventClasses, TimeSpan.FromMilliseconds(500), TaskConfig.Default); master.Enable(); }
/// <summary> /// Attempts to connect to data input source. /// </summary> /// <remarks> /// Derived classes should attempt connection to data input source here. Any exceptions thrown /// by this implementation will result in restart of the connection cycle. /// </remarks> protected override void AttemptConnection() { TcpClientConfig tcpConfig = m_masterConfig.client; string portName = tcpConfig.address + ":" + tcpConfig.port; TimeSpan minRetry = TimeSpan.FromMilliseconds(tcpConfig.minRetryMs); TimeSpan maxRetry = TimeSpan.FromMilliseconds(tcpConfig.maxRetryMs); ChannelRetry channelRetry = new ChannelRetry(minRetry, maxRetry); IChannelListener channelListener = new ChannelListener(state => OnStatusMessage(MessageLevel.Info, portName + " - Channel state change: " + state)); IChannel channel = s_manager.AddTCPClient(portName, tcpConfig.level, channelRetry, tcpConfig.address, tcpConfig.port, channelListener); m_channel = channel; IMaster master = channel.AddMaster(portName, m_soeHandler, DefaultMasterApplication.Instance, m_masterConfig.master); if (m_pollingInterval > TimeSpan.Zero) { master.AddClassScan(ClassField.AllClasses, m_pollingInterval, TaskConfig.Default); } master.Enable(); m_active = true; }