Skip to content

Commit faf928b

Browse files
committed
Set Submodel/Kind as per action
1 parent 423f03f commit faf928b

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/AasxPackageLogic/DispEditHelperEntities.cs

+12
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,14 @@ public void DisplayOrEditAasEntityAasEnv(
511511
sm.Id = AdminShellUtil.GenerateIdAccordingTemplate(
512512
(buttonNdx == 2) ? Options.Curr.TemplateIdSubmodelInstance
513513
: Options.Curr.TemplateIdSubmodelTemplate);
514+
if(buttonNdx == 2)
515+
{
516+
sm.Kind = ModellingKind.Instance;
517+
}
518+
else
519+
{
520+
sm.Kind = ModellingKind.Template;
521+
}
514522
env.Add(sm);
515523
this.AddDiaryEntry(sm, new DiaryEntryStructChange(
516524
StructuralChangeReason.Create));
@@ -1350,8 +1358,12 @@ public void DisplayOrEditAasEntityAas(
13501358
submodel.Kind = Aas.ModellingKind.Template;
13511359
}
13521360
else
1361+
{
13531362
submodel.Id = AdminShellUtil.GenerateIdAccordingTemplate(
13541363
Options.Curr.TemplateIdSubmodelInstance);
1364+
submodel.Kind = ModellingKind.Instance;
1365+
}
1366+
13551367

13561368
// create ref
13571369
var smr = new Aas.Reference(Aas.ReferenceTypes.ModelReference, new List<Aas.IKey>() { new Aas.Key(Aas.KeyTypes.Submodel, submodel.Id) });

src/AasxPackageLogic/DispEditHelperModules.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,15 @@ public void DisplayOrEditEntityIdentifiable(AnyUiStackPanel stack,
348348
new HintCheck(
349349
() => {
350350
int count = 0;
351-
foreach(var aas in env.AssetAdministrationShells)
351+
if(env != null && !env.AssetAdministrationShells.IsNullOrEmpty())
352352
{
353-
if(aas.Id == identifiable.Id)
354-
count++;
353+
foreach(var aas in env.AssetAdministrationShells)
354+
{
355+
if(aas.Id == identifiable.Id)
356+
count++;
357+
}
355358
}
359+
356360
return (count >= 2?true:false);
357361
},
358362
"It is not allowed to have duplicate Ids in AAS of the same file. This will break functionality and we strongly encoure to make the Id unique!",

0 commit comments

Comments
 (0)