Skip to content

Commit

Permalink
Make display of efficiency optional. Add option to show gain.
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornekelund committed Sep 29, 2023
1 parent 7b37264 commit 017cf3b
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 19 deletions.
14 changes: 8 additions & 6 deletions ACOM Controller/Config.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ACOM_Controller"
mc:Ignorable="d"
Title="Config" Height="146.188" Width="291.864" ResizeMode="NoResize" ShowInTaskbar="False" WindowStartupLocation="Manual" WindowStyle="None" Topmost="True">
Title="Config" Height="178.167" Width="291.864" ResizeMode="NoResize" ShowInTaskbar="False" WindowStartupLocation="Manual" WindowStyle="None" Topmost="True">
<Grid x:Name="Panel" Margin="10">
<GroupBox x:Name="GroupBox" Header="Configuration" HorizontalAlignment="Left" Height="106" Margin="-4,-9,0,0" VerticalAlignment="Top" Width="277">
<CheckBox x:Name="onTopCheckBox" Content="On top" HorizontalAlignment="Left" Height="18" Margin="5,97,0,-32" VerticalAlignment="Top"/>
<GroupBox x:Name="GroupBox" Header="Configuration" HorizontalAlignment="Left" Height="167" Margin="-4,-9,-1,0" VerticalAlignment="Top" Width="277">
<CheckBox x:Name="onTopCheckBox" Content="On top" HorizontalAlignment="Left" Height="18" Margin="5,89,0,0" VerticalAlignment="Top"/>
</GroupBox>

<ComboBox x:Name="modelComboBox" HorizontalAlignment="Left" Margin="7,36,0,0" VerticalAlignment="Top" Width="120"/>
<ComboBox x:Name="portComboBox" HorizontalAlignment="Left" Margin="144,36,0,0" VerticalAlignment="Top" Width="120" RenderTransformOrigin="1.747,-1.152"/>
<Label Content="PA model" HorizontalAlignment="Left" VerticalAlignment="Top" Width="68" Margin="4,10,0,0"/>
<Label Content="COM port" HorizontalAlignment="Left" Margin="138,10,0,0" VerticalAlignment="Top" Width="79"/>
<Button x:Name="CancelButton" Content="Cancel" HorizontalAlignment="Left" Margin="101,68,0,0" VerticalAlignment="Top" Width="75" Click="CancelButton_Click"/>
<Button x:Name="okButton" Content="OK" HorizontalAlignment="Left" Margin="189,68,0,0" VerticalAlignment="Top" Width="75" Click="OkButton_Click"/>
<CheckBox x:Name="silentCheckBox" Content="Do nothing if already running" HorizontalAlignment="Left" Height="18" Margin="86,105,0,0" VerticalAlignment="Top"/>
<Button x:Name="CancelButton" Content="Cancel" HorizontalAlignment="Left" Margin="101,128,0,0" VerticalAlignment="Top" Width="75" Click="CancelButton_Click"/>
<Button x:Name="okButton" Content="OK" HorizontalAlignment="Left" Margin="189,128,0,0" VerticalAlignment="Top" Width="75" Click="OkButton_Click"/>
<CheckBox x:Name="silentCheckBox" Content="Do nothing if already running" HorizontalAlignment="Left" Height="18" Margin="86,97,0,0" VerticalAlignment="Top"/>
<CheckBox x:Name="showEfficiencyCheckBox" Content="Show efficiency" HorizontalAlignment="Left" Height="18" Margin="7,68,0,0" VerticalAlignment="Top"/>
<CheckBox x:Name="showGainCheckBox" Content="Show gain" HorizontalAlignment="Left" Height="18" Margin="138,68,0,0" VerticalAlignment="Top"/>

</Grid>
</Window>
6 changes: 4 additions & 2 deletions ACOM Controller/Config.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public partial class Config : Window
{
MainWindow mainwindow;

public Config(MainWindow mw, string model, string port, bool ontop, bool nopopup)
public Config(MainWindow mw, string model, string port, bool ontop, bool nopopup, bool showEff, bool showGain)
{
InitializeComponent();

Expand All @@ -30,6 +30,8 @@ public Config(MainWindow mw, string model, string port, bool ontop, bool nopopup

onTopCheckBox.IsChecked = ontop;
silentCheckBox.IsChecked = nopopup;
showEfficiencyCheckBox.IsChecked = showEff;
showGainCheckBox.IsChecked = showGain;
}

private void CancelButton_Click(object sender, RoutedEventArgs e)
Expand All @@ -39,7 +41,7 @@ private void CancelButton_Click(object sender, RoutedEventArgs e)

private void OkButton_Click(object sender, RoutedEventArgs e)
{
mainwindow.Configuration(portComboBox.Text, modelComboBox.Text, (bool)onTopCheckBox.IsChecked, (bool)silentCheckBox.IsChecked);
mainwindow.Configuration(portComboBox.Text, modelComboBox.Text, (bool)onTopCheckBox.IsChecked, (bool)silentCheckBox.IsChecked, (bool)showEfficiencyCheckBox.IsChecked, (bool)showGainCheckBox.IsChecked);
Close();
}
}
Expand Down
1 change: 1 addition & 0 deletions ACOM Controller/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<Button x:Name="errorTextButton" Content="Drive power at wrong time" HorizontalAlignment="Left" Margin="263,27,0,0" VerticalAlignment="Top" Width="206" ClickMode="Press" Click="OperateClick" Height="40" BorderBrush="Black" Foreground="#FF303030" Background="Yellow" BorderThickness="2" FontWeight="Bold" FontSize="14" Visibility="Visible"/>
<Label x:Name="fanLabel" Content="" HorizontalAlignment="Left" Height="19" Margin="395,67,0,0" VerticalAlignment="Top" Width="55" FontSize="11" Padding="1" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" HorizontalContentAlignment="Right" VerticalContentAlignment="Center" FontWeight="Bold"/>
<Label x:Name="effLabel" Content="" HorizontalAlignment="Left" Height="19" Margin="294,67,0,0" VerticalAlignment="Top" Width="28" FontSize="11" Padding="1" HorizontalContentAlignment="Right" VerticalContentAlignment="Center" Foreground="#FFF3F3F3"/>
<Label x:Name="gainLabel" Content="" HorizontalAlignment="Left" Height="25" Margin="294,8,0,0" VerticalAlignment="Top" Width="28" FontSize="11" Padding="1" HorizontalContentAlignment="Right" VerticalContentAlignment="Center" Foreground="#FFF3F3F3"/>

</Grid>
</Window>
34 changes: 24 additions & 10 deletions ACOM Controller/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public partial class MainWindow : Window
double ReflectedPowerCurrent = 0.0; // Current reflected power
double ReflectedPowerDisplay = 0.0; // Filtered reflected power

const int swrPeakMemory = 10;
int swrPeakIndex = 0;
double[] swrValue = new double[swrPeakMemory]; // Array for filtering SWR reports
const int swrMemory = 10;
int swrIndex = 0;
double[] swrValue = new double[swrMemory]; // Array for filtering SWR reports
double swrCurrent = 0.0; // Current SWR
double swrDisplay = 0.0; // Filtered SWR

Expand Down Expand Up @@ -100,7 +100,7 @@ public MainWindow()
// Hide error pop up
errorTextButton.Visibility = Visibility.Hidden;

Configuration(Settings.Default.ComPort, Settings.Default.AmplifierModel, Settings.Default.AlwaysOnTop, Settings.Default.NoPopup);
Configuration(Settings.Default.ComPort, Settings.Default.AmplifierModel, Settings.Default.AlwaysOnTop, Settings.Default.NoPopup, Settings.Default.ShowEfficiency, Settings.Default.ShowGain);

// Fetch window location from saved settings
Top = Settings.Default.Top;
Expand Down Expand Up @@ -135,7 +135,7 @@ private void MainWindow_Closed(object sender, EventArgs e)
}
}

public void Configuration(string comPort, string ampModel, bool alwaysontop, bool nopopup)
public void Configuration(string comPort, string ampModel, bool alwaysontop, bool nopopup, bool showEfficiency, bool showGain)
{
try
{
Expand Down Expand Up @@ -221,8 +221,12 @@ public void Configuration(string comPort, string ampModel, bool alwaysontop, boo
Settings.Default.ComPort = comPort;
Settings.Default.AlwaysOnTop = alwaysontop;
Settings.Default.NoPopup = nopopup;
Settings.Default.ShowEfficiency = showEfficiency;
Settings.Default.ShowGain = showGain;
Settings.Default.Save();

effLabel.Visibility = showEfficiency ? Visibility.Visible : Visibility.Hidden;

programTitle = "ACOM " + ampModel + " Controller" + Release + "("
+ comPort + (portIsOpen ? ")" : " - failed to open)");

Expand Down Expand Up @@ -430,8 +434,8 @@ private void Port_OnReceiveData(object sender, SerialDataReceivedEventArgs e)

// Filter and display SWR data
swrCurrent = (messageBytes[26] + messageBytes[27] * 256) / 100.0;
swrValue[swrPeakIndex] = swrCurrent;
swrPeakIndex = (swrPeakIndex + 1) % swrPeakMemory;
swrValue[swrIndex] = swrCurrent;
swrIndex = (swrIndex + 1) % swrMemory;

// Filter output power data
PApowerCurrent = messageBytes[22] + messageBytes[23] * 256;
Expand Down Expand Up @@ -460,13 +464,22 @@ private void Port_OnReceiveData(object sender, SerialDataReceivedEventArgs e)
}
else
{
effLabel.Content = "";
effLabel.Content = string.Empty;
}

if (PApowerDisplay > 100.0)
{
gainLabel.Content = (10.0 * Math.Log10(PApowerDisplay / DrivePowerDisplay)).ToString("0") + "dB";
}
else
{
gainLabel.Content = string.Empty;
}

// Calculate average of recent non-zero SWR reports
double swrAverageSum = 0.0;
int swrNonZeroCount = 0;
for (int i = 0; i < swrPeakMemory; i++)
for (int i = 0; i < swrMemory; i++)
{
if (swrValue[i] > 0)
{
Expand Down Expand Up @@ -643,7 +656,8 @@ private void DismissErrorClick(object sender, RoutedEventArgs e)

private void StandbyButton_MouseRightButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
Config configPanel = new Config(this, Settings.Default.AmplifierModel, Settings.Default.ComPort, Settings.Default.AlwaysOnTop, Settings.Default.NoPopup);
Config configPanel = new Config(this, Settings.Default.AmplifierModel, Settings.Default.ComPort, Settings.Default.AlwaysOnTop,
Settings.Default.NoPopup, Settings.Default.ShowEfficiency, Settings.Default.ShowGain);
configPanel.ShowDialog();
}
}
Expand Down
24 changes: 24 additions & 0 deletions ACOM Controller/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ACOM Controller/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,11 @@
<Setting Name="NoPopup" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="ShowEfficiency" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="ShowGain" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
6 changes: 6 additions & 0 deletions ACOM Controller/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<setting name="NoPopup" serializeAs="String">
<value>False</value>
</setting>
<setting name="ShowEfficiency" serializeAs="String">
<value>False</value>
</setting>
<setting name="ShowGain" serializeAs="String">
<value>False</value>
</setting>
</ACOM_Controller.Properties.Settings>
</userSettings>
</configuration>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ application like `com2tcp` it can also be used for geographically remote operati
Right-click the *Standby* button to access the configuration panel.
Default configuration is for ACOM 700S with communication on COM1.

Can optionally always stay on top of other apps to e.g. allow use with a full
By default it stays on top of other apps to e.g. allow use with a full
screen logger on a single screen.

The "Do nothing if already running" option silently stops the program at
Expand Down

0 comments on commit 017cf3b

Please sign in to comment.