forked from eclipse-basyx/basyx-java-server-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Value-Only serialization of BasicEvent (eclipse-basyx#262)
* Add serialization of basic event Signed-off-by: Zai Zhang <[email protected]> * Add unit test for value only basic event serialization Signed-off-by: Zai Zhang <[email protected]> --------- Signed-off-by: Zai Zhang <[email protected]>
- Loading branch information
1 parent
afaef43
commit 241b96e
Showing
8 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
basyx.aasenvironment/basyx.aasenvironment-http/src/test/resources/BasicEventValueOnly.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"AnnotationBottom": "", | ||
"ObserveValueUpdates": { | ||
"observed": { | ||
"keys": [{ | ||
"type": "Submodel", | ||
"value": "www.example.com/ids/sm/2222_8041_1042_8057" | ||
} | ||
], | ||
"type": "ExternalReference" | ||
} | ||
}, | ||
"ViaHTTP": [{ | ||
"L1": "291.4213289500366" | ||
}, { | ||
"L2": "296.869547091201" | ||
}, { | ||
"L3": "299.65015492058336" | ||
}, { | ||
"Active_Power_All": "109572.7967447997" | ||
} | ||
], | ||
"ViaModbus": [{ | ||
"L1": "160.26637" | ||
}, { | ||
"L2": "160.44434" | ||
}, { | ||
"L3": "163.39528" | ||
}, { | ||
"Active_Power_All": "59738.68" | ||
} | ||
], | ||
"ViaMqtt": [{ | ||
"L1": "290.6217782649107" | ||
}, { | ||
"L2": "282.4599521889145" | ||
}, { | ||
"L3": "272.2067133660983" | ||
}, { | ||
"Active_Power_All": "104308.59396737856" | ||
} | ||
], | ||
"ViaOpcUa": [{ | ||
"L1": "299.53634421194454" | ||
}, { | ||
"L2": "296.55226321871635" | ||
}, { | ||
"L3": "290.9149535087691" | ||
}, { | ||
"Active_Power_All": "109456.23941992565" | ||
} | ||
] | ||
} |
1 change: 1 addition & 0 deletions
1
...senvironment/basyx.aasenvironment-http/src/test/resources/operationalDataEnvironment.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...re/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/BasicEventValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/******************************************************************************* | ||
* Copyright (C) 2023 the Eclipse BaSyx Authors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to | ||
* the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
* | ||
* SPDX-License-Identifier: MIT | ||
******************************************************************************/ | ||
|
||
package org.eclipse.digitaltwin.basyx.submodelservice.value; | ||
|
||
public class BasicEventValue implements SubmodelElementValue { | ||
|
||
private ReferenceValue observed; | ||
|
||
@SuppressWarnings("unused") | ||
private BasicEventValue() { | ||
super(); | ||
} | ||
|
||
public BasicEventValue(ReferenceValue observed) { | ||
super(); | ||
this.observed = observed; | ||
} | ||
|
||
public ReferenceValue getObserved() { | ||
return observed; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...ava/org/eclipse/digitaltwin/basyx/submodelservice/value/mapper/BasicEventValueMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/******************************************************************************* | ||
* Copyright (C) 2023 the Eclipse BaSyx Authors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to | ||
* the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
* | ||
* SPDX-License-Identifier: MIT | ||
******************************************************************************/ | ||
|
||
package org.eclipse.digitaltwin.basyx.submodelservice.value.mapper; | ||
|
||
import org.eclipse.digitaltwin.aas4j.v3.model.BasicEventElement; | ||
import org.eclipse.digitaltwin.aas4j.v3.model.Reference; | ||
import org.eclipse.digitaltwin.basyx.submodelservice.value.BasicEventValue; | ||
import org.eclipse.digitaltwin.basyx.submodelservice.value.ReferenceValue; | ||
|
||
public class BasicEventValueMapper implements ValueMapper<BasicEventValue> { | ||
private BasicEventElement basicEvent; | ||
|
||
|
||
public BasicEventValueMapper(BasicEventElement basicEvent) { | ||
this.basicEvent = basicEvent; | ||
} | ||
|
||
@Override | ||
public void setValue(BasicEventValue basicEventValue) { | ||
|
||
} | ||
|
||
@Override | ||
public BasicEventValue getValue() { | ||
Reference referenceElement = basicEvent.getObserved(); | ||
return new BasicEventValue(new ReferenceValue(referenceElement.getType(), referenceElement.getKeys())); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters