Skip to content

Commit

Permalink
add comments and begin restructuring
Browse files Browse the repository at this point in the history
  • Loading branch information
ghbyrkit committed Jan 16, 2023
1 parent 7b3ecf3 commit a90477f
Show file tree
Hide file tree
Showing 12 changed files with 3,796 additions and 2,625 deletions.
41 changes: 41 additions & 0 deletions TM742ApplicationCSharp/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/TM742RadioProgrammingApp/TM742RadioProgrammingApp.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/TM742RadioProgrammingApp/TM742RadioProgrammingApp.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/TM742RadioProgrammingApp/TM742RadioProgrammingApp.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
6,146 changes: 3,605 additions & 2,541 deletions TM742ApplicationCSharp/TM742RadioProgrammingApp/Form1.Designer.cs

Large diffs are not rendered by default.

101 changes: 43 additions & 58 deletions TM742ApplicationCSharp/TM742RadioProgrammingApp/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ private bool openSerialPort()
return false;
}

private void SetChannelButtone_Click(object sender, EventArgs e)
private void SetChannelButton_Click(object sender, EventArgs e)
{
ListView ChannelListViewObj;
ComboBox MHzComboBoxObj;
Expand Down Expand Up @@ -718,10 +718,10 @@ private void MHzComboBox_SelectedIndexChanged(object sender, EventArgs e)
}
}

private int repeaterAryIndex;
private int repeaterModeCurrentIndex;
private int repeaterElements;

private readonly string[] _getRepeaterIncrement_repeaterAry = new string[] { "SIMPLEX", "PLUS", "MINUS", "DBL MINUS" };
private readonly string[] _getRepeaterModeList = new string[] { "SIMPLEX", "PLUS", "MINUS", "DBL MINUS" };

/// <summary>
///
Expand All @@ -732,12 +732,12 @@ public int getRepeaterIncrement(string str)
{
int count = 0;

while ((str.ToUpper() ?? "") != (_getRepeaterIncrement_repeaterAry[repeaterAryIndex] ?? ""))
while ((str.ToUpper() ?? "") != (_getRepeaterModeList[repeaterModeCurrentIndex] ?? ""))
{
repeaterAryIndex++;
if (repeaterAryIndex >= repeaterElements)
repeaterModeCurrentIndex++;
if (repeaterModeCurrentIndex >= repeaterElements)
{
repeaterAryIndex = 0;
repeaterModeCurrentIndex = 0;
}
count++;
// todo check for overflow
Expand All @@ -747,29 +747,29 @@ public int getRepeaterIncrement(string str)

}

private int ctcssAryIndex;
private int ctcssModeCurrentIndex;

private readonly string[] _getCtcssIncrement_ctcssAry = new string[] { "OFF", "XMIT", "XMIT/REC" };
private int _getCtcssIncrement_ctcssElements = 2;
private readonly string[] _getCtcssModeList = new string[] { "OFF", "XMIT", "XMIT/REC" };
private int _getCtcssModeList_Elements = 2;

public int getCtcssIncrement(string str)
public int getCtcssModeIndex(string str)
{
int count = 0;
if (My.MyProject.Forms.Form2.Tsu7CheckBox.Checked)
{
_getCtcssIncrement_ctcssElements = 3;
_getCtcssModeList_Elements = 3;
}
else
{
_getCtcssIncrement_ctcssElements = 2;
_getCtcssModeList_Elements = 2;
}

while ((str.ToUpper() ?? "") != (_getCtcssIncrement_ctcssAry[ctcssAryIndex] ?? ""))
while ((str.ToUpper() ?? "") != (_getCtcssModeList[ctcssModeCurrentIndex] ?? ""))
{
ctcssAryIndex++;
if (ctcssAryIndex > _getCtcssIncrement_ctcssElements - 1)
ctcssModeCurrentIndex++;
if (ctcssModeCurrentIndex > _getCtcssModeList_Elements - 1)
{
ctcssAryIndex = 0;
ctcssModeCurrentIndex = 0;
}
count++;
// todo check for overflow
Expand All @@ -779,21 +779,21 @@ public int getCtcssIncrement(string str)

}

private int toneAryIndex;
private int CTCSSToneFrequencyIndex;

private readonly double[] _getToneIncrement_toneAry = new double[] { 67.0d, 71.9d, 74.4d, 77.0d, 79.7d, 82.5d, 85.4d, 88.5d, 91.5d, 94.8d, 97.4d, 100.0d, 103.5d, 107.2d, 110.9d, 114.8d, 118.8d, 123.0d, 127.3d, 131.8d, 136.5d, 141.3d, 146.2d, 151.4d, 156.7d, 162.2d, 167.9d, 173.8d, 179.9d, 186.2d, 192.8d, 203.5d, 210.7d, 218.1d, 225.7d, 233.6d, 241.8d, 250.3d };
private readonly double[] _getCTCSSToneFrequencyList = new double[] { 67.0d, 71.9d, 74.4d, 77.0d, 79.7d, 82.5d, 85.4d, 88.5d, 91.5d, 94.8d, 97.4d, 100.0d, 103.5d, 107.2d, 110.9d, 114.8d, 118.8d, 123.0d, 127.3d, 131.8d, 136.5d, 141.3d, 146.2d, 151.4d, 156.7d, 162.2d, 167.9d, 173.8d, 179.9d, 186.2d, 192.8d, 203.5d, 210.7d, 218.1d, 225.7d, 233.6d, 241.8d, 250.3d };

public int getToneIncrement(string str, ref string command)
public int getCTCSSToneFrequencyIndex(string str, ref string command)
{
int count = 0;

if (Convert.ToDouble(fixDecimalSeparator(str)) <= _getToneIncrement_toneAry[toneAryIndex])
if (Convert.ToDouble(fixDecimalSeparator(str)) <= _getCTCSSToneFrequencyList[CTCSSToneFrequencyIndex])
{
command = "DOWN";
while (Convert.ToDouble(fixDecimalSeparator(str)) != _getToneIncrement_toneAry[toneAryIndex])
while (Convert.ToDouble(fixDecimalSeparator(str)) != _getCTCSSToneFrequencyList[CTCSSToneFrequencyIndex])
{
toneAryIndex--;
if (toneAryIndex == -1)
CTCSSToneFrequencyIndex--;
if (CTCSSToneFrequencyIndex == -1)
{
// publish an error
}
Expand All @@ -804,10 +804,10 @@ public int getToneIncrement(string str, ref string command)
else
{
command = "UP";
while (Convert.ToDouble(fixDecimalSeparator(str)) != _getToneIncrement_toneAry[toneAryIndex])
while (Convert.ToDouble(fixDecimalSeparator(str)) != _getCTCSSToneFrequencyList[CTCSSToneFrequencyIndex])
{
toneAryIndex++;
if (toneAryIndex == _getToneIncrement_toneAry.Length)
CTCSSToneFrequencyIndex++;
if (CTCSSToneFrequencyIndex == _getCTCSSToneFrequencyList.Length)
{
// publish an error
}
Expand All @@ -817,7 +817,7 @@ public int getToneIncrement(string str, ref string command)
return count;
}

private void Button2_Click(object sender, EventArgs e)
private void ButtonProgramBandModule_Click(object sender, EventArgs e)
{
ProgressBar ProgressBarObj;
ListView ChannelListViewObj;
Expand Down Expand Up @@ -866,9 +866,9 @@ private void Button2_Click(object sender, EventArgs e)
commandLabel = Tab3UsbCmdLabel;
}

repeaterAryIndex = 0;
toneAryIndex = 7;
ctcssAryIndex = 0;
repeaterModeCurrentIndex = 0;
CTCSSToneFrequencyIndex = 7;
ctcssModeCurrentIndex = 0;
repeaterElements = 3;

ToolStripStatusLabel.Text = "";
Expand All @@ -889,9 +889,6 @@ private void Button2_Click(object sender, EventArgs e)
string mhzLabel = TabControl.SelectedTab.Text;
var msgResult = Interaction.MsgBox("1. Reset Band in radio." + Constants.vbCrLf + " " + Strings.Chr(149) + " Hold 'F' and Band select while turning on radio." + Constants.vbCrLf + "2. Put radio in 'RC' mode." + Constants.vbCrLf + "3. Select " + Strings.Mid(mhzLabel, 3, mhzLabel.Length - 2) + " MHz band on radio." + Constants.vbCrLf + "4. Ensure that both the radio and the tabbed channel list frequency step size are correct." + Constants.vbCrLf + " " + Strings.Chr(149) + " Step size is selectable per tab under the Options menu", (MsgBoxStyle)((int)MsgBoxStyle.OkCancel + (int)MsgBoxStyle.Critical + (int)MsgBoxStyle.DefaultButton2), "Programming setup message");




if (msgResult == MsgBoxResult.Cancel)
{
return;
Expand Down Expand Up @@ -976,7 +973,7 @@ private void Button2_Click(object sender, EventArgs e)
numOfKhzChars = 2;
}

SendString("A");
SendString("A"); // ENTER key. See page 61 of User Manual.

if (My.MyProject.Forms.Form2.wideBandCheckBox.Checked && TabControl.SelectedTab.Text.Contains("1200"))
{
Expand All @@ -998,8 +995,9 @@ private void Button2_Click(object sender, EventArgs e)

if (My.MyProject.Forms.Form2.AROcheckBox.Checked)
{
if (TabControl.SelectedIndex == 0 & My.MyProject.Forms.Form2.Mod1UT144.Checked | TabControl.SelectedIndex == 1 & My.MyProject.Forms.Form2.Mod2UT144.Checked | TabControl.SelectedIndex == 2 & My.MyProject.Forms.Form2.Mod3UT144.Checked)

if ((TabControl.SelectedIndex == 0 && My.MyProject.Forms.Form2.Mod1UT144.Checked)
|| (TabControl.SelectedIndex == 1 && My.MyProject.Forms.Form2.Mod2UT144.Checked)
|| (TabControl.SelectedIndex == 2 && My.MyProject.Forms.Form2.Mod3UT144.Checked))
{
if (!My.MyProject.Forms.Form2.eTypeRadioCheckBox.Checked)
{
Expand Down Expand Up @@ -1057,7 +1055,9 @@ private void Button2_Click(object sender, EventArgs e)
getRepeaterIncrement("SIMPLEX");
}
}
else if (TabControl.SelectedIndex == 0 & My.MyProject.Forms.Form2.Mod1UT220.Checked & !My.MyProject.Forms.Form2.eTypeRadioCheckBox.Checked | TabControl.SelectedIndex == 1 & My.MyProject.Forms.Form2.Mod2UT220.Checked & !My.MyProject.Forms.Form2.eTypeRadioCheckBox.Checked | TabControl.SelectedIndex == 2 & My.MyProject.Forms.Form2.Mod3UT220.Checked & !My.MyProject.Forms.Form2.eTypeRadioCheckBox.Checked)
else if ((TabControl.SelectedIndex == 0 && My.MyProject.Forms.Form2.Mod1UT220.Checked && !My.MyProject.Forms.Form2.eTypeRadioCheckBox.Checked)
|| (TabControl.SelectedIndex == 1 && My.MyProject.Forms.Form2.Mod2UT220.Checked && !My.MyProject.Forms.Form2.eTypeRadioCheckBox.Checked)
|| (TabControl.SelectedIndex == 2 && My.MyProject.Forms.Form2.Mod3UT220.Checked && !My.MyProject.Forms.Form2.eTypeRadioCheckBox.Checked))

{
if (Convert.ToDouble(fixDecimalSeparator(freq)) < 223.92d)
Expand All @@ -1082,8 +1082,8 @@ private void Button2_Click(object sender, EventArgs e)
SendString("1");
}

// send ctcss mode
int ctcssCount = getCtcssIncrement(ChannelListViewObj.Items[channelIndex].SubItems[4].Text);
// send CTCSS mode
int ctcssCount = getCtcssModeIndex(ChannelListViewObj.Items[channelIndex].SubItems[4].Text);
if (ctcssCount > 0)
{
for (int loopVar = 0, loopTo3 = ctcssCount - 1; loopVar <= loopTo3; loopVar++)
Expand All @@ -1094,7 +1094,7 @@ private void Button2_Click(object sender, EventArgs e)
if (ChannelListViewObj.Items[channelIndex].SubItems[4].Text.ToUpper() != "OFF")
{
string direction = "";
int toneCount = getToneIncrement(ChannelListViewObj.Items[channelIndex].SubItems[3].Text, ref direction);
int toneCount = getCTCSSToneFrequencyIndex(ChannelListViewObj.Items[channelIndex].SubItems[3].Text, ref direction);
if (toneCount > 0)
{
SendString("D");
Expand All @@ -1107,7 +1107,7 @@ private void Button2_Click(object sender, EventArgs e)
}

// send memory store and increment
SendString("D");
SendString("D"); // F key. See page 61 of User Manual.
if (!firstChannelComplete)
{
for (int y = 0, loopTo5 = blankChannelCount - 1; y <= loopTo5; y++)
Expand Down Expand Up @@ -1143,8 +1143,8 @@ private void Button2_Click(object sender, EventArgs e)
Tab1UsbRcvdLabel.Text = "";
Tab2UsbRcvdLabel.Text = "";
Tab3UsbRcvdLabel.Text = "";

}

private int _Timer1_Tick_cntr = 0;

private void Timer1_Tick(object sender, EventArgs e)
Expand Down Expand Up @@ -1197,7 +1197,6 @@ private void KHzStepSizeToolStripMenuItem_Click(object sender, EventArgs e)
KhzToolStripComboBoxObj.DroppedDown = true;
}


private void Tab1KHzToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
MenuStrip MenuStripObj;
Expand Down Expand Up @@ -1479,20 +1478,6 @@ private void Tab1SaveChannelFileToolStripMenuItem_Click(object sender, EventArgs
SaveFileDialog1.AddExtension = true;
SaveFileDialog1.DefaultExt = "csv";

// If TabControl.SelectedIndex = 0 Then
// If Not tab1ChannelFileName.Equals("") Then
// SaveFileDialog1.FileName = tab1ChannelFileName.Text
// End If
// ElseIf TabControl.SelectedIndex = 1 Then
// If Not tab2ChannelFileName.Equals("") Then
// SaveFileDialog1.FileName = tab2ChannelFileName.Text
// End If
// ElseIf TabControl.SelectedIndex = 2 Then
// If Not tab3ChannelFileName.Equals("") Then
// SaveFileDialog1.FileName = tab3ChannelFileName.Text
// End If
// End If

SaveFileDialog1.ShowDialog();
}

Expand Down
Loading

0 comments on commit a90477f

Please sign in to comment.