Skip to content

Commit

Permalink
Enhance parameter succesfully saved confirmation box to display chang…
Browse files Browse the repository at this point in the history
…ed parameters with previous and new value and count of total changed parameters
  • Loading branch information
prathamEndu committed Sep 18, 2024
1 parent 4db6497 commit 5cc57b0
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions GCSViews/ConfigurationView/ConfigRawParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ private void BUT_writePIDS_Click(object sender, EventArgs e)
int error = 0;
bool reboot = false;

// List to track successfully saved parameters
List<string> savedParams = new List<string>();

foreach (string value in temp)
{
try
Expand All @@ -276,7 +279,18 @@ private void BUT_writePIDS_Click(object sender, EventArgs e)
return;
}

MainV2.comPort.setParam(value, (double)_changes[value]);
// Get the previous value of the param to display in 'param change info'
// (a better way would be to get the value somewhere from inside the code, insted of demanding it from mavlink)
string previousValue = MainV2.comPort.MAV.param[value].ToString();
// new value of param
double newValue = (double)_changes[value];

MainV2.comPort.setParam(value, newValue);

// Add the parameter, previous and new values to the list for 'param change info'
// remember, the 'value' here is key of param, while prev and new are actual values of param
savedParams.Add($"{savedParams.Count + 1}) {value} : {previousValue} -> {newValue}");

//check if reboot required
if (ParameterMetaDataRepository.GetParameterRebootRequired(value, MainV2.comPort.MAV.cs.firmware.ToString()))
{
Expand Down Expand Up @@ -322,7 +336,15 @@ private void BUT_writePIDS_Click(object sender, EventArgs e)
if (error > 0)
CustomMessageBox.Show("Not all parameters successfully saved.", "Saved");
else
CustomMessageBox.Show("Parameters successfully saved.", "Saved");
{
// Join the saved parameters list to a string
string savedParamsMessage = string.Join(Environment.NewLine, savedParams);

if (savedParams.Count > 0)
CustomMessageBox.Show($"{savedParams.Count} parameters successfully saved : \n\n{savedParamsMessage}", "Saved");
else
CustomMessageBox.Show($"No parameter saved.", "Saved");
}

//Check if reboot is required
if (reboot)
Expand Down

0 comments on commit 5cc57b0

Please sign in to comment.