Frequency Display Plugin
The source code of this plugin is available
here
.
This plugin monitors the changes of the receive and transmit frequencies, T/R switch
and Split mode, and shows these settings on a standard panel. The panel makes use of the
FrequencyDisplayPanel
control from the
Shared Controls library.
The IPlugin.CreatePanel
method creates an instance of
FrequencyDisplayPanel
and sets its properties:
public UserControl CreatePanel()
{
panel = new FrequencyDisplayPanel();
panel.Name = "Main Receiver";
panel.bandplan = BandPlan;
panel.pipeline = host.DspPipeline;
return panel;
}
To receive notifications when any of the settings of interest change, the plugin
subscribes to a number of events available in DSP Pipeline.
To access DspPipeline
, it imports the
IPluginHost interface from the host application.
The MEF framework
used in Ham Cockpit to manage the plugins supports several
ways of importing an interface. One of them is the
ImportingConstructor
attribute. The constructor of the plugin, decorated with
this attribute, looks like this:
[ImportingConstructor]
FrequencyDisplay([Import(typeof(IPluginHost))] IPluginHost host)
{
this.host = host;
host.DspPipeline.Tuner.Tuned += TunedEventHandler;
host.DspPipeline.StatusChanged += TunedEventHandler;
host.DspPipeline.Transmitter.Tuned += TunedEventHandler;
host.DspPipeline.Transmitter.SettingsChanged += TunedEventHandler;
}
The same event handler is used for all events, this handler simply updates information on the display panel:
private void TunedEventHandler(object sender, EventArgs e)
{
panel?.UpdateDisplayedInfo();
}