ISimulatorNode CreateMaster(ISimulatorNodeCallbacks callbacks) { using (var dialog = new Components.MasterDialog()) { dialog.ShowDialog(); if (dialog.DialogResult == DialogResult.OK) { var cache = new MeasurementCache(); var masterConfig = dialog.Configuration; var alias = dialog.SelectedAlias; var master = channel.AddMaster(alias, cache, DefaultMasterApplication.Instance, masterConfig); if (master == null) { return(null); } else { master.Enable(); return(new MasterNode(cache, master, callbacks, alias)); } } else { return(null); } } }
/// <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); IChannel channel = s_manager.AddTCPClient(portName, tcpConfig.level, minRetry, maxRetry, tcpConfig.address, tcpConfig.port); channel.AddStateListener(state => OnStatusMessage(portName + " - Channel state change: " + state)); m_channel = channel; IMaster master = channel.AddMaster(portName, m_soeHandler, m_masterConfig.master); master.Enable(); m_active = true; }
/// <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; }