Skip to content

Commit

Permalink
Fix module OD view to at least a view only usable point. Probably as …
Browse files Browse the repository at this point in the history
…far as im going with

modules
  • Loading branch information
robincornelius committed Sep 11, 2017
1 parent d387001 commit 9fed0bf
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 16 deletions.
126 changes: 112 additions & 14 deletions EDSTest/DeviceODView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private void button_save_changes_Click(object sender, EventArgs e)
}


updateselectedindexdisplay(selectedobject.index);
updateselectedindexdisplay(selectedobject.index, currentmodule);
validateanddisplaydata();

populateindexlists();
Expand All @@ -198,7 +198,7 @@ public void updatedetailslist()
if (selectedobject == null)
return;

updateselectedindexdisplay(selectedobject.index);
updateselectedindexdisplay(selectedobject.index, currentmodule);
}

public void validateanddisplaydata()
Expand All @@ -216,7 +216,15 @@ public void validateanddisplaydata()
ODentry od = (ODentry)selectedobject;


label_index.Text = string.Format("0x{0:x4}", od.index);
if (currentmodule == 0)
{
label_index.Text = string.Format("0x{0:x4}", od.index);
}
else
{
label_index.Text = string.Format("0x{0:x4} in module {1} -- {2}", od.index,currentmodule,eds.modules[currentmodule].mi.ProductName);
}

textBox_name.Text = od.parameter_name;
textBox_denotation.Text = od.denotation;

Expand Down Expand Up @@ -360,9 +368,15 @@ public void validateanddisplaydata()


ODentry selectedindexod = null;
private void updateselectedindexdisplay(UInt16 index)
UInt16 currentmodule = 0;

private void updateselectedindexdisplay(UInt16 index,UInt16 mod)
{
selectedindexod = eds.ods[index];


selectedindexod = getOD(index,mod);
currentmodule = mod;

updateselectedindexdisplay();
}

Expand Down Expand Up @@ -469,7 +483,7 @@ private void listView_mandatory_objects_MouseClick(object sender, MouseEventArgs
return;

UInt16 idx = Convert.ToUInt16(lvi.Text, 16);
updateselectedindexdisplay(idx);
updateselectedindexdisplay(idx, currentmodule);

selectedobject = eds.ods[idx];
validateanddisplaydata();
Expand All @@ -488,10 +502,30 @@ private void list_mouseclick(ListView listview, MouseEventArgs e)
return;

ListViewItem lvi = listview.SelectedItems[0];
UInt16 idx = Convert.ToUInt16(lvi.Text, 16);

currentmodule = 0;

UInt16 idx;
if (lvi.Text.Contains('('))
{
int i = 1+lvi.Text.IndexOf(' ');
string id = lvi.Text.Substring(i, lvi.Text.Length - i);
idx = Convert.ToUInt16(id, 16);

string mods = lvi.Text.Substring(1, i - 3);

currentmodule = Convert.ToUInt16(mods, 10);

}
else
{
idx = Convert.ToUInt16(lvi.Text, 16);
}

if (e.Button == MouseButtons.Right)
{
if (currentmodule != 0)
return;

if (listview.FocusedItem.Bounds.Contains(e.Location) == true)
{
Expand All @@ -513,10 +547,10 @@ private void list_mouseclick(ListView listview, MouseEventArgs e)
return;
}

updateselectedindexdisplay(idx);
updateselectedindexdisplay(idx, currentmodule);

selectedobject = getOD(idx, currentmodule);

selectedobject = eds.ods[idx];
validateanddisplaydata();

listView_mandatory_objects.HideSelection = true;
Expand Down Expand Up @@ -701,6 +735,39 @@ public void populateindexlists()

}



foreach (libEDSsharp.Module m in eds.modules.Values)
{
foreach (KeyValuePair<UInt16, ODentry> kvp in m.modulesubext)
{


UInt16 index = kvp.Value.index;
ListViewItem lvi = new ListViewItem(string.Format("({0}) 0x{1:x4}", m.moduleindex,kvp.Value.index));
lvi.SubItems.Add(kvp.Value.parameter_name);
lvi.Tag = kvp.Value;
if (selectedobject != null)
if (index == selectedobject.index)
lvi.Selected = true;

lvi.ForeColor = Color.Blue;

if (index >= 0x2000 && index < 0x6000)
{
listView_manufacture_objects.Items.Add(lvi);
}
else
{
listView_optional_objects.Items.Add(lvi);
}

}
}




listView_mandatory_objects.EndUpdate();
listView_manufacture_objects.EndUpdate();
listView_optional_objects.EndUpdate();
Expand Down Expand Up @@ -778,7 +845,7 @@ private void addNewObjectToolStripMenuItem_Click(object sender, EventArgs e)

//Now switch to it as well Bug #26

updateselectedindexdisplay(od.index);
updateselectedindexdisplay(od.index, currentmodule);
selectedobject = eds.ods[od.index];
validateanddisplaydata();

Expand Down Expand Up @@ -834,7 +901,11 @@ private void deleteObjectToolStripMenuItem_Click(object sender, EventArgs e)
if (MessageBox.Show(string.Format("Really delete index 0x{0:x4} ?", od.index), "Are you sure?", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
eds.dirty = true;
eds.ods.Remove(od.index);
if (currentmodule == 0)
{
eds.ods.Remove(od.index);
}

populateindexlists();
}

Expand Down Expand Up @@ -910,7 +981,7 @@ private void addSubItemToolStripMenuItem_Click(object sender, EventArgs e)
}

eds.dirty = true;
updateselectedindexdisplay(selectedobject.index);
updateselectedindexdisplay(selectedobject.index, currentmodule);
validateanddisplaydata();

}
Expand Down Expand Up @@ -947,7 +1018,7 @@ private void removeSubItemToolStripMenuItem_Click(object sender, EventArgs e)
od.parent.subobjects = newlist;

eds.dirty = true;
updateselectedindexdisplay(selectedobject.index);
updateselectedindexdisplay(selectedobject.index, currentmodule);
validateanddisplaydata();
}

Expand Down Expand Up @@ -986,7 +1057,7 @@ private void changeMaxSubIndexToolStripMenuItem_Click(object sender, EventArgs e
if(frm.ShowDialog()==DialogResult.OK)
{
od.defaultvalue = string.Format("0x{0:x2}",frm.maxsubindex);
updateselectedindexdisplay(selectedobject.index);
updateselectedindexdisplay(selectedobject.index, currentmodule);
validateanddisplaydata();
}
}
Expand Down Expand Up @@ -1072,6 +1143,31 @@ private void comboBox_memory_SelectedIndexChanged(object sender, EventArgs e)
}
}
}

private ODentry getOD(UInt16 index, UInt16 selectedmodule)
{
ODentry ret = null;

if (selectedmodule == 0)
{
if (eds.ods.ContainsKey(index))
{
return eds.ods[index];
}
}
else
{

if (eds.modules.ContainsKey(selectedmodule))
{
return eds.modules[selectedmodule].modulesubext[index];
}

}

return null; ;

}
}

public static class ControlExtensions
Expand All @@ -1083,4 +1179,6 @@ public static void DoubleBuffering(this Control control, bool enable)
}
}



}
13 changes: 11 additions & 2 deletions EDSTest/ModuleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,17 @@ private void listView_modules_MouseClick(object sender, MouseEventArgs e)
}
else
{
lvi = new ListViewItem(string.Format("0x{0:x4}", sindex));
lvi.SubItems.Add("** FAULT OD NOT FOUND **");
if (eds.modules[index].modulesubext.ContainsKey(sindex))
{
lvi = new ListViewItem(string.Format("0x{0:x4}", sindex));
lvi.SubItems.Add(eds.modules[index].modulesubext[sindex].parameter_name);

}
else
{
lvi = new ListViewItem(string.Format("0x{0:x4}", sindex));
lvi.SubItems.Add("** FAULT OD NOT FOUND **");
}
}

listView_extends.Items.Add(lvi);
Expand Down
5 changes: 5 additions & 0 deletions libEDSsharp/eds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,11 @@ public bool PDOMapping
}
}

//FIXME Count "If several modules are gathered to form a new Sub-Index,
//then the number is 0, followed by semicolon and the
//number of bits that are created per module to build a new
//Sub-Index"

[EdsExport]
public byte count = 0;

Expand Down

0 comments on commit 9fed0bf

Please sign in to comment.