Skip to content

Commit b05b88c

Browse files
committed
Events with SubmodelElementList
1 parent 6674e3c commit b05b88c

File tree

5 files changed

+41
-15
lines changed

5 files changed

+41
-15
lines changed

src/AasxServerBlazor/Pages/TreePage.razor

+9-6
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@
337337
{
338338
var path = sme.IdShort;
339339
var parent = sme.Parent as IReferable;
340-
while (parent is not Submodel)
340+
while (parent != null && parent is not Submodel)
341341
{
342342
if (parent is ISubmodelElementList parentList)
343343
{
@@ -362,11 +362,14 @@
362362

363363
parent = (IReferable) parent.Parent;
364364
}
365-
366-
var idEncoded = Base64UrlEncoder.Encode((parent as Submodel).Id);
367-
path = Program.externalBlazor + "/submodels/" + idEncoded + "/submodel-elements/" + path;
368-
<span style="color:white;background-color:blue;">URL:</span>
369-
<a href="@path" target="_blank">@path</a>
365+
366+
if (parent != null)
367+
{
368+
var idEncoded = Base64UrlEncoder.Encode((parent as Submodel).Id);
369+
path = Program.externalBlazor + "/submodels/" + idEncoded + "/submodel-elements/" + path;
370+
<span style="color:white;background-color:blue;">URL:</span>
371+
<a href="@path" target="_blank">@path</a>
372+
}
370373
<br>
371374
}
372375

src/AasxServerBlazor/Properties/launchSettings.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
},
1111
"AasxServerBlazor": {
1212
"commandName": "Project",
13-
"commandLineArgs": "--no-security --save-temp 30 --secret-string-api 1234 --aasx-in-memory 1000 --data-path \"C:\\Development\\Olaf-Event-2\" --edit --external-blazor http://localhost:5002",
13+
"commandLineArgs": "--no-security --save-temp 30 --secret-string-api 1234 --aasx-in-memory 1000 --data-path \"C:\\Development\\Festo\" --edit --external-blazor http://localhost:5001",
1414
"launchBrowser": true,
1515
"environmentVariables": {
1616
"ASPNETCORE_ENVIRONMENT": "Development",
1717
"AASREGISTRY": "",
1818
"IFRAMEPATH": "https://dpp40-2-v2.industrialdigitaltwin.org/dashboard/submodelViewV3.html",
19-
"Kestrel__Endpoints__Http__Url": "http://localhost:5002",
19+
"Kestrel__Endpoints__Http__Url": "http://localhost:5001",
2020
"EVENT2": "http://localhost:5002/submodels/aHR0cHM6Ly9pNGQuZGUvVC8zMjA5NTEwL3N1Ym1vZGVsL05hbWVwbGF0ZS9yZWNlaXZlcg/events/EventElement1"
2121
},
2222
"applicationUrl": "http://localhost:5001",

src/AasxServerDB/Events.cs

+26-5
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,11 @@ public static int changeData(string json, EventData eventData, AdminShellPackage
488488
}
489489
if (referable is SubmodelElementList sml)
490490
{
491+
if (sml.Value == null)
492+
{
493+
sml.Value = new List<ISubmodelElement>();
494+
}
495+
data = sml.Value;
491496
children = sml.Value;
492497
}
493498
var r = referable;
@@ -726,11 +731,15 @@ public static int changeSubmodelElement(EventData eventData, EventPayloadEntry e
726731

727732
if (maxCount != 0 && eventData.dataCollection == parent)
728733
{
729-
SubmodelElementCollection data = eventData.dataCollection;
734+
SubmodelElementCollection data = null;
735+
if (eventData.dataCollection is SubmodelElementCollection dataSmc)
736+
{
737+
data = dataSmc;
738+
}
730739
// if (eventData.direction != null && eventData.direction.Value == "IN" && eventData.mode != null && (eventData.mode.Value == "PUSH" || eventData.mode.Value == "PUT"))
731-
if (eventData.direction != null && eventData.direction.Value == "IN" && eventData.mode != null)
740+
if (data != null && eventData.direction != null && eventData.direction.Value == "IN" && eventData.mode != null)
732741
{
733-
if (eventData.dataCollection.Value != null && eventData.dataCollection.Value.Count == 1 && eventData.dataCollection.Value[0] is SubmodelElementCollection smc)
742+
if (data.Value != null && data.Value.Count == 1 && data.Value[0] is SubmodelElementCollection smc)
734743
{
735744
data = smc;
736745

@@ -767,7 +776,7 @@ public class EventData
767776
public AasCore.Aas3_0.Property changes = null;
768777
public AasCore.Aas3_0.Property endPoint = null;
769778
public Submodel dataSubmodel = null;
770-
public SubmodelElementCollection dataCollection = null;
779+
public ISubmodelElement dataCollection = null;
771780
public AasCore.Aas3_0.Property dataMaxSize = null;
772781
public SubmodelElementCollection statusData = null;
773782
public AasCore.Aas3_0.Property noPayload = null;
@@ -829,12 +838,14 @@ public static Operation FindEvent(ISubmodel submodel, ISubmodelElement sme, stri
829838
public void ParseData(Operation op, AdminShellPackageEnv env)
830839
{
831840
SubmodelElementCollection smec = null;
841+
SubmodelElementList smel = null;
832842
Submodel sm = null;
833843
AasCore.Aas3_0.Property p = null;
834844

835845
foreach (var input in op.InputVariables)
836846
{
837-
smec = null;
847+
smec = null;
848+
smel = null;
838849
sm = null;
839850
p = null;
840851
var inputRef = input.Value;
@@ -851,6 +862,10 @@ public void ParseData(Operation op, AdminShellPackageEnv env)
851862
{
852863
smec = (inputRef as SubmodelElementCollection);
853864
}
865+
if (inputRef is SubmodelElementList)
866+
{
867+
smel = (inputRef as SubmodelElementList);
868+
}
854869

855870
if (inputRef is ReferenceElement)
856871
{
@@ -859,6 +874,10 @@ public void ParseData(Operation op, AdminShellPackageEnv env)
859874
{
860875
smec = refElement as SubmodelElementCollection;
861876
}
877+
if (refElement is SubmodelElementList)
878+
{
879+
smel = refElement as SubmodelElementList;
880+
}
862881
if (refElement is Submodel)
863882
{
864883
sm = refElement as Submodel;
@@ -913,6 +932,8 @@ public void ParseData(Operation op, AdminShellPackageEnv env)
913932
dataSubmodel = sm;
914933
if (smec != null)
915934
dataCollection = smec;
935+
if (smel != null)
936+
dataCollection = smel;
916937
break;
917938
case "datamaxsize":
918939
if (p != null)

src/AasxServerStandardBib/SecurityClient.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,8 @@ static void operation_get_put_events(Operation op, int envIndex, DateTime timeSt
17371737
p.IdShort = "diff" + i;
17381738
p.Value = d;
17391739
p.SetTimeStamp(dt);
1740-
eventData.diff.Value.Add(p);
1740+
eventData.diff.Value.Add(p);
1741+
p.SetAllParentsAndTimestamps(eventData.diff, dt, dt, DateTime.MinValue);
17411742
i++;
17421743
}
17431744
eventData.diff.SetTimeStamp(dt);
@@ -2050,6 +2051,7 @@ static void operation_get_put_events(Operation op, int envIndex, DateTime timeSt
20502051
p.Value = d;
20512052
p.SetTimeStamp(dt);
20522053
eventData.diff.Value.Add(p);
2054+
p.SetAllParentsAndTimestamps(eventData.diff, dt, dt, DateTime.MinValue);
20532055
i++;
20542056
}
20552057
eventData.diff.SetTimeStamp(dt);

src/IO.Swagger.Lib.V3/Controllers/SubmodelRepositoryAPIApi.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public virtual IActionResult GetEventMessages([FromRoute] [Required] string subm
161161
if (eventData.direction != null && eventData.direction.Value == "IN")
162162
{
163163
data = null;
164-
if (eventData.dataCollection.Value != null && eventData.dataCollection.Value.Count == 1 && eventData.dataCollection.Value[0] is SubmodelElementCollection smc)
164+
if (eventData.dataCollection is SubmodelElementCollection sme && sme.Value != null && sme.Value.Count == 1 && sme.Value[0] is SubmodelElementCollection smc)
165165
{
166166
data = smc;
167167
}

0 commit comments

Comments
 (0)