Skip to content

Commit

Permalink
* finalize BOM editing
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHoffmeisterFesto committed Jul 22, 2024
1 parent c08bef2 commit 5cfce2c
Show file tree
Hide file tree
Showing 2 changed files with 155 additions and 14 deletions.
76 changes: 75 additions & 1 deletion src/AasxPluginBomStructure/AasxPluginBomStructure.Options.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,81 @@
}
],
"NodeSupplSemIds": [
""
"http://admin-shell.io/sandbox/CompositeComponent/General/EntityOfBOM/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/General/FeatureOfEntity/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/EntityOfPhysicalBreakdown/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/EntityOfFunctionalBreakdown/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/EntityOfElectricalEngineering/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/Potential/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/JunctionPoint/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/PhysicalCable/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/PhysicalWire/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/EntityOfFluidicEngineering/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/Potential/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/JunctionPoint/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/Tube/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/ConnectorTubePipe/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/EquipmentEntity/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/Valve/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/Sensor/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/Drive/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/PIDCtrl/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/TerminationSource/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/TerminationSink/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/EquipmentEntity/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/InstrumentationEntity/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/TerminationSource/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/TerminationSink/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/ProgrammableLogicControl/PouEntity/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/ProgrammableLogicControl/InstanceOfPou/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/ProgrammableLogicControl/PinOfInstance/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/ProgrammableLogicControl/InformationInput/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/ProgrammableLogicControl/InformationOutput/1/0"
],
"EdgeSupplSemIds": [
"http://admin-shell.io/sandbox/CompositeComponent/General/FileToNavigateElement/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/General/FileToEntity/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/General/IsPartOfForBOM/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/General/IsIdenticalForBOM/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/IsPartOfPhysicalBreakdown/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/IsPartOfFunctionalBreakdown/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/FunctionalDirectlyConnected/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/PermanentJoint/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/DetachableJoint/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/PrismaticJoint/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/RevoluteJoint/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/CylindricalJoint/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Mechanical/ShericalJoint/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/IsPartOfCable/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/SinglePoleConnection/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/MultiPoleConnection/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/BusConnection/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/ConnectionOfPotential/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Electrical/TerminalConnection/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/TubePipeConnection/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/TubePipeConnectionPneumatic/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/TubePipeConnectionHydraulic/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/FittingConnection/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/Fluidic/ManifoldConnection/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/PipeConnection/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/MeasurementLine/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/FunctionalLine/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/PipeConnection/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/ProcessConnectionLine/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/PipeAndInstrumentation/SignalLine/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/ProgrammableLogicControl/ParameterConnection/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/ProgrammableLogicControl/DataConnection/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/ProgrammableLogicControl/EventConnection/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/ClassEntity/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/ObjectEntity/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/ComponentEntity/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/ExecutionEnvironmentEntity/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/InheritanceRelationship/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/AggregateRelationship/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/ComposeRelationship/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/IsInstanceOfRelationship/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/IsInstanceOfRelationship/1/0",
"http://admin-shell.io/sandbox/CompositeComponent/SoftwareEngineering/IsExecutedInRelationship/1/0"
]
}
]
Expand Down
93 changes: 80 additions & 13 deletions src/AasxPluginBomStructure/GenericBomControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public object FillWithWpfControls(
dp.ContextMenu = new ContextMenu();
dp.ContextMenu.Items.Add(new MenuItem() { Header = "Jump to selected ..", Tag = "JUMP" });
dp.ContextMenu.Items.Add(new Separator());
dp.ContextMenu.Items.Add(new MenuItem() { Header = "Edit Node ..", Tag = "EDIT" });
dp.ContextMenu.Items.Add(new MenuItem() { Header = "Edit Node / Edge ..", Tag = "EDIT" });
dp.ContextMenu.Items.Add(new MenuItem() { Header = "Create Node (to selected) ..", Tag = "CREATE" });
dp.ContextMenu.Items.Add(new MenuItem() { Header = "Delete (selected) Node(s) ..", Tag = "DELETE" });

Expand Down Expand Up @@ -507,6 +507,33 @@ protected void AdjustNodeInBom(
});
}

protected void AdjustEdgeInBom(
Aas.ISubmodelElement edgeSme,
string edgeIdShort,
string edgeSemId,
string edgeSuppSemId)
{
// access
if (_submodel == null || edgeSme == null)
return;

// write back new values
edgeSme.IdShort = edgeIdShort;
if (edgeSemId?.HasContent() == true)
edgeSme.SemanticId = new Aas.Reference(Aas.ReferenceTypes.ExternalReference,
(new Aas.IKey[] { new Aas.Key(Aas.KeyTypes.GlobalReference, edgeSemId) }).ToList());
else
edgeSme.SemanticId = null;

if (edgeSuppSemId?.HasContent() == true)
edgeSme.SupplementalSemanticIds = (new Aas.IReference[] {
new Aas.Reference(Aas.ReferenceTypes.ExternalReference,
(new Aas.IKey[] { new Aas.Key(Aas.KeyTypes.GlobalReference, edgeSuppSemId) }).ToList())
}).ToList();
else
edgeSme.SupplementalSemanticIds = null;
}

#if cdscsd
///// <summary>
/////
Expand Down Expand Up @@ -609,12 +636,12 @@ protected void ContextMenu_Click(object sender, RoutedEventArgs e)
if (action != "OK" || !(st.AasElem is Aas.ISubmodelElement nodeSme))
return;
// modidfy
// modify
AdjustNodeInBom(
nodeSme,
nodeIdShort: st.TextBoxIdShort.Text,
nodeSuppSemId: st.ComboBoxNodeSupplSemId.Text,
nodeSemId: st.ComboBoxNodeSemId.Text);
nodeSemId: st.ComboBoxNodeSemId.Text,
nodeSuppSemId: st.ComboBoxNodeSupplSemId.Text);
// refresh
SetNeedsFinalize(true);
Expand All @@ -629,7 +656,9 @@ protected void ContextMenu_Click(object sender, RoutedEventArgs e)
&& edge.Edge?.UserData is Aas.ISubmodelElement edgeSme)
{
// create job
var stat = new DialogueStatus() { Type = DialogueType.EditEdge, AasElem = edgeSme };
var stat = new DialogueStatus() {
Type = DialogueType.EditEdge, AasElem = edgeSme
};

// set the action
stat.Action = (st, action) =>
Expand All @@ -638,8 +667,12 @@ protected void ContextMenu_Click(object sender, RoutedEventArgs e)
if (action != "OK" || !(st.AasElem is Aas.ISubmodelElement esme))
return;
// modidfy
esme.IdShort = st.TextBoxIdShort.Text;
// modify
AdjustEdgeInBom(
esme,
edgeIdShort: st.TextBoxIdShort.Text,
edgeSemId: st.ComboBoxRelSemId.Text,
edgeSuppSemId: st.ComboBoxRelSupplSemId.Text);
// refresh
SetNeedsFinalize(true);
Expand Down Expand Up @@ -1263,7 +1296,7 @@ protected Panel CreateDialoguePanel(DialogueStatus stat)
Content = editEdge ? "Rel.idShort:" : "Node.idShort:"
});
AddToGrid(grid, 0, 1, colSpan:1, fe: stat.TextBoxIdShort = new TextBox() {
Text = editNode ? stat.AasElem?.IdShort : "",
Text = (editNode || editEdge) ? stat.AasElem?.IdShort : "",
VerticalContentAlignment = VerticalAlignment.Center,
Padding = new Thickness(0, -1, 0, -1),
Margin = new Thickness(0, 2, 0, 2),
Expand Down Expand Up @@ -1294,7 +1327,8 @@ protected Panel CreateDialoguePanel(DialogueStatus stat)
}
else
{
stat.ComboBoxNodeSemId.Text = "" + (stat.AasElem as Aas.IHasSemantics).SemanticId.Keys?.FirstOrDefault()?.Value;
stat.ComboBoxNodeSemId.Text = "" + (stat.AasElem as Aas.IHasSemantics).
SemanticId.Keys?.FirstOrDefault()?.Value;
}

AddToGrid(grid, 1, 1, colSpan: 3, fe: stat.ComboBoxNodeSemId);
Expand All @@ -1309,6 +1343,13 @@ protected Panel CreateDialoguePanel(DialogueStatus stat)
VerticalContentAlignment = VerticalAlignment.Center
};

if (_bomRecords != null)
foreach (var br in _bomRecords)
if (br.NodeSupplSemIds != null)
foreach (var nss in br.NodeSupplSemIds)
if (!stat.ComboBoxNodeSupplSemId.Items.Contains(nss))
stat.ComboBoxNodeSupplSemId.Items.Add(nss);

if (!editNode)
{
stat.ComboBoxNodeSupplSemId.Text = "";
Expand Down Expand Up @@ -1338,10 +1379,18 @@ protected Panel CreateDialoguePanel(DialogueStatus stat)

stat.ComboBoxRelSemId.Items.Add(prefHS.CD_HasPart?.GetSingleKey()?.Value);
stat.ComboBoxRelSemId.Items.Add(prefHS.CD_IsPartOf?.GetSingleKey()?.Value);
if (stat.ReverseDir)
stat.ComboBoxRelSemId.Text = stat.ComboBoxRelSemId.Items[1].ToString();
else
stat.ComboBoxRelSemId.Text = stat.ComboBoxRelSemId.Items[0].ToString();

if (!editEdge)
{
if (stat.ReverseDir)
stat.ComboBoxRelSemId.Text = stat.ComboBoxRelSemId.Items[1].ToString();
else
stat.ComboBoxRelSemId.Text = stat.ComboBoxRelSemId.Items[0].ToString();
} else
{
stat.ComboBoxRelSemId.Text = "" + (stat.AasElem as Aas.IHasSemantics)
.SemanticId.Keys?.FirstOrDefault()?.Value;
}

AddToGrid(grid, 3, 1, colSpan: 3, fe: stat.ComboBoxRelSemId);

Expand All @@ -1355,6 +1404,24 @@ protected Panel CreateDialoguePanel(DialogueStatus stat)
VerticalContentAlignment = VerticalAlignment.Center
};

if (_bomRecords != null)
foreach (var br in _bomRecords)
if (br.EdgeSupplSemIds != null)
foreach (var nss in br.EdgeSupplSemIds)
if (!stat.ComboBoxRelSupplSemId.Items.Contains(nss))
stat.ComboBoxRelSupplSemId.Items.Add(nss);

if (!editEdge)
{
stat.ComboBoxRelSupplSemId.Text = "";
}
else
{
stat.ComboBoxRelSupplSemId.Text =
"" + (stat.AasElem as Aas.IHasSemantics)?.SupplementalSemanticIds?
.FirstOrDefault()?.Keys?.FirstOrDefault()?.Value;
}

AddToGrid(grid, 4, 1, colSpan: 3, fe: stat.ComboBoxRelSupplSemId);
}

Expand Down

0 comments on commit 5cfce2c

Please sign in to comment.