Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix defaultvalue: Do not ask to take new default value to all sub if new default is the same #144

Merged
merged 7 commits into from
Nov 9, 2024
41 changes: 40 additions & 1 deletion EDSEditorGUI/DeviceODView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,46 @@ private void ObjectSave()
od.prop.CO_accessSRDO = AccessSRDO.no;
}

od.defaultvalue = textBox_defaultValue.Text;
// Default value
if (listView_subObjects.SelectedItems.Count > 1) {
for (ushort i = 0; i < listView_subObjects.SelectedItems.Count; i++)
{
od.parent.subobjects[(ushort) Convert.ToInt32(listView_subObjects.SelectedItems[i].Text,16)].defaultvalue = textBox_defaultValue.Text;
}
}


bool setDefaultValueToAll = false;
bool identicalDefaultValues = true;

if (od.parent != null && od.parent.Nosubindexes > 2)
{

for (int i = 2; i < od.parent.Nosubindexes; i++)
{
identicalDefaultValues &= ((od.parent.subobjects[(ushort)i].defaultvalue == od.parent.subobjects[(ushort)(i - 1)].defaultvalue) && (od.parent.subobjects[(ushort)i].defaultvalue != textBox_defaultValue.Text));
}

if (identicalDefaultValues) {
DialogResult confirm = MessageBox.Show("Do you want to set all identical default values in subobjects to this default value?", "Set to all?", MessageBoxButtons.YesNo);
if (confirm == DialogResult.Yes)
{
setDefaultValueToAll = true;
}
}
}
if (setDefaultValueToAll)
{
for (ushort i = 1; i < od.parent.Nosubindexes; i++)
{
od.parent.subobjects[i].defaultvalue = textBox_defaultValue.Text;
}
}
else
{
od.defaultvalue = textBox_defaultValue.Text;
}

od.actualvalue = textBox_actualValue.Text;
od.HighLimit = textBox_highLimit.Text;
od.LowLimit = textBox_lowLimit.Text;
Expand Down
12 changes: 6 additions & 6 deletions EDSEditorGUI/DevicePDOView2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,12 @@ public void UpdatePDOinfo(bool updatechoices = true)
int ordinal = 0;
foreach (ODentry entry in slot.Mapping)
{
if ((bitoff + entry.Sizeofdatatype()) > 64)
{
string toDisplay = string.Join(Environment.NewLine, slot.Mapping);
MessageBox.Show(string.Format("Invalid TXPDO mapping parameters in 0x{0:X}!\r\nTrying to map more than the maximum lenght of a CAN message (8 bytes).\r\n\r\nMembers are:\r\n{1}", slot.ConfigurationIndex,toDisplay));
break;
}
string target = slot.getTargetName(entry);
grid1[row + 2, bitoff + 3] = new SourceGrid.Cells.Cell(target, comboStandard);
grid1[row + 2, bitoff + 3].ColumnSpan = entry.Sizeofdatatype();
Expand All @@ -480,14 +485,9 @@ public void UpdatePDOinfo(bool updatechoices = true)

grid1[row + 2, bitoff + 3].AddController(vcc);
bitoff += entry.Sizeofdatatype();
}

ordinal++;

if (bitoff > 64) {
MessageBox.Show(string.Format("Invalid TXPDO mapping parameters in 0x{0:X}. Trying to map more than 64 bit (8 Bytes). CAN message maximum lenght is 8 Byte", slot.ConfigurationIndex));
break;
}
ordinal++;

}

Expand Down
Loading