diff --git a/emf_datamodel/model/iPos_Datamodel.aird b/emf_datamodel/model/iPos_Datamodel.aird index e5e7e447aab40361ae0d003270d4eaa1e43a5fb7..3b55cb5b7e207f87639f402db7e6486ef46de5a2 100644 --- a/emf_datamodel/model/iPos_Datamodel.aird +++ b/emf_datamodel/model/iPos_Datamodel.aird @@ -5,7 +5,7 @@ <semanticResources>iPos_Datamodel.genmodel</semanticResources> <ownedViews xmi:type="viewpoint:DView" uid="_EpwecAQNEey-kNQ7esRa_g"> <viewpoint xmi:type="description:Viewpoint" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']"/> - <ownedRepresentationDescriptors xmi:type="viewpoint:DRepresentationDescriptor" uid="_Et4wgAQNEey-kNQ7esRa_g" name="iPos_Datamodel" repPath="#_Es-xkAQNEey-kNQ7esRa_g" changeId="97e64d49-5157-4ee8-a1f0-01117933234c"> + <ownedRepresentationDescriptors xmi:type="viewpoint:DRepresentationDescriptor" uid="_Et4wgAQNEey-kNQ7esRa_g" name="iPos_Datamodel" repPath="#_Es-xkAQNEey-kNQ7esRa_g" changeId="9e1b7476-c4ed-4af9-bf42-c1e58844c8c1"> <description xmi:type="description_1:DiagramDescription" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']"/> <target xmi:type="ecore:EPackage" href="iPos_Datamodel.ecore#/"/> </ownedRepresentationDescriptors> @@ -709,6 +709,10 @@ <styles xmi:type="notation:FontStyle" xmi:id="_iWqJIR_NEeyaJIyxidrtuQ" fontColor="2697711" fontName="Segoe UI" fontHeight="8"/> <layoutConstraint xmi:type="notation:Location" xmi:id="_iWqJIh_NEeyaJIyxidrtuQ"/> </children> + <children xmi:type="notation:Node" xmi:id="_uoVVkCHPEeynrdmghnL28w" type="3010" element="_umtk8CHPEeynrdmghnL28w"> + <styles xmi:type="notation:FontStyle" xmi:id="_uoVVkSHPEeynrdmghnL28w" fontColor="2697711" fontName="Segoe UI" fontHeight="8"/> + <layoutConstraint xmi:type="notation:Location" xmi:id="_uoVVkiHPEeynrdmghnL28w"/> + </children> <styles xmi:type="notation:SortingStyle" xmi:id="_D9ZrhQc-Eey-kNQ7esRa_g"/> <styles xmi:type="notation:FilteringStyle" xmi:id="_D9Zrhgc-Eey-kNQ7esRa_g"/> </children> @@ -2800,7 +2804,7 @@ <arrangeConstraints>KEEP_LOCATION</arrangeConstraints> <arrangeConstraints>KEEP_SIZE</arrangeConstraints> <arrangeConstraints>KEEP_RATIO</arrangeConstraints> - <ownedStyle xmi:type="diagram:FlatContainerStyle" uid="_l8_WqR_NEeyaJIyxidrtuQ" borderSize="1" borderSizeComputationExpression="1" backgroundStyle="Liquid" foregroundColor="255,252,216"> + <ownedStyle xmi:type="diagram:FlatContainerStyle" uid="_yc1iBSHPEeynrdmghnL28w" borderSize="1" borderSizeComputationExpression="1" backgroundStyle="Liquid" foregroundColor="255,252,216"> <description xmi:type="style:FlatContainerStyleDescription" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@style"/> </ownedStyle> <actualMapping xmi:type="description_1:ContainerMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']"/> @@ -2884,6 +2888,14 @@ </ownedStyle> <actualMapping xmi:type="description_1:NodeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@subNodeMappings[name='EC%20EAttribute']"/> </ownedElements> + <ownedElements xmi:type="diagram:DNodeListElement" uid="_umtk8CHPEeynrdmghnL28w" name="positionConditionCellId : String" tooltipText=""> + <target xmi:type="ecore:EAttribute" href="iPos_Datamodel.ecore#//EventFilterCondition/positionConditionCellId"/> + <semanticElements xmi:type="ecore:EAttribute" href="iPos_Datamodel.ecore#//EventFilterCondition/positionConditionCellId"/> + <ownedStyle xmi:type="diagram:BundledImage" uid="_yc8PpCHPEeynrdmghnL28w" labelAlignment="LEFT"> + <description xmi:type="style:BundledImageDescription" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@subNodeMappings[name='EC%20EAttribute']/@style"/> + </ownedStyle> + <actualMapping xmi:type="description_1:NodeMapping" href="platform:/plugin/org.eclipse.emf.ecoretools.design/description/ecore.odesign#//@ownedViewpoints[name='Design']/@ownedRepresentations[name='Entities']/@defaultLayer/@containerMappings[name='EC%20EClass']/@subNodeMappings[name='EC%20EAttribute']"/> + </ownedElements> </ownedDiagramElements> <ownedDiagramElements xmi:type="diagram:DEdge" uid="_JkOxSgc-Eey-kNQ7esRa_g" name="[0..*] eventfiltercondition" sourceNode="_IOFwkAZtEey-kNQ7esRa_g" targetNode="_D9Ka8Ac-Eey-kNQ7esRa_g"> <target xmi:type="ecore:EReference" href="iPos_Datamodel.ecore#//EventFilterConfiguration/eventfiltercondition"/> diff --git a/emf_datamodel/model/iPos_Datamodel.ecore b/emf_datamodel/model/iPos_Datamodel.ecore index 481804d45bec65fbcf64adef69bcfb1ae62838a2..c52f2a43b1630c4f375980c943bd145a8503d1a6 100644 --- a/emf_datamodel/model/iPos_Datamodel.ecore +++ b/emf_datamodel/model/iPos_Datamodel.ecore @@ -235,6 +235,8 @@ eType="#//FloatArray3d"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="idCondition" eType="#//StringList"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="categoryCondition" eType="#//StringList"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="positionConditionCellId" + eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String"/> </eClassifiers> <eClassifiers xsi:type="ecore:EDataType" name="StringList" instanceClassName="java.util.List<java.lang.String>"/> <eClassifiers xsi:type="ecore:EDataType" name="StringArray" instanceClassName="java.util.ArrayList<java.lang.String[]>"/> diff --git a/emf_datamodel/model/iPos_Datamodel.genmodel b/emf_datamodel/model/iPos_Datamodel.genmodel index 5a12659432eeb11ab1b3e78ebc5913b3969b063b..18b60791953fd6f6a293ba85eba4b38515dae812 100644 --- a/emf_datamodel/model/iPos_Datamodel.genmodel +++ b/emf_datamodel/model/iPos_Datamodel.genmodel @@ -179,6 +179,7 @@ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute iPos_Datamodel.ecore#//EventFilterCondition/positionConditionCell"/> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute iPos_Datamodel.ecore#//EventFilterCondition/idCondition"/> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute iPos_Datamodel.ecore#//EventFilterCondition/categoryCondition"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute iPos_Datamodel.ecore#//EventFilterCondition/positionConditionCellId"/> </genClasses> </genPackages> </genmodel:GenModel> diff --git a/src/main/java/ipos/project/DataModellntegration/SimpleSceneIntegration/SimpleSceneIntegration.java b/src/main/java/ipos/project/DataModellntegration/SimpleSceneIntegration/SimpleSceneIntegration.java index d03f4b301c2efe365e2bb7cb822d7cbd8d6e1f53..bd3fb8a634c9c7b42301a63e8a0428275146d0bb 100644 --- a/src/main/java/ipos/project/DataModellntegration/SimpleSceneIntegration/SimpleSceneIntegration.java +++ b/src/main/java/ipos/project/DataModellntegration/SimpleSceneIntegration/SimpleSceneIntegration.java @@ -35,20 +35,21 @@ public class SimpleSceneIntegration { }*/ public static void receiveMessage(PositionEvent positionEvent, String monitoringTaskId, String type) { - LOG.info("receiveMessage get: " + positionEvent); + // LOG.info("receiveMessage get: " + positionEvent); //String jsonPos = ProtoJsonMap.toJson(positionEvent); // we can translate a class into a string using several methods: 1) `.toString()` 2) `JsonFormat` in `ProtoJsonMap` if (positionEvent != null) { - LOG.info("received internal-positionEvent: monitoringTaskId: " + monitoringTaskId + " positionEvent: " + positionEvent.toString()); + // LOG.info("received internal-positionEvent: monitoringTaskId: " + monitoringTaskId + " positionEvent: " + positionEvent.toString()); SimpleScene.IposPositionEvent posEvent_proto = SimpleSceneTransformer.posEvent_internal2Proto(positionEvent, type); - LOG.info("obtained protobuf-positionEvent:" + posEvent_proto.toString()); + // LOG.info("obtained protobuf-positionEvent:" + posEvent_proto.toString()); MqttMessage mqttMessage = mqttService.createMqttMsg(posEvent_proto, 0, false); - LOG.info("publishing mqttMessage:" + mqttMessage.toString() + " on topic: " + monitoringTaskId); - mqttService.publish(monitoringTaskId, mqttMessage); - // JSON-Versand... LOG.info("publishing mqttMessage:" + ProtoJsonMap.toJson(posEvent_proto) + " on topic: " + monitoringTaskId); - // mqttService.publish(monitoringTaskId, ProtoJsonMap.toJson(posEvent_proto), 0, false); + // Protobuf-Versand: LOG.info("publishing mqttMessage:" + mqttMessage.toString() + " on topic: " + monitoringTaskId); + // mqttService.publish(monitoringTaskId, mqttMessage); + + LOG.info("publishing mqttMessage:" + ProtoJsonMap.toJson(posEvent_proto) + " on topic: " + monitoringTaskId); + mqttService.publish(monitoringTaskId, ProtoJsonMap.toJson(posEvent_proto), 0, false); }else{ - LOG.debug("Warning: SimpleScene: Received empty PositionEvent"); + LOG.warn("Warning: SimpleScene: Received empty PositionEvent"); } } diff --git a/src/main/java/ipos/project/DataModellntegration/SimpleSceneIntegration/service/SimpleSceneTransformer.java b/src/main/java/ipos/project/DataModellntegration/SimpleSceneIntegration/service/SimpleSceneTransformer.java index 46ea341338d849c91b328179d5c7e69484404c30..1003df2905c5a6fdfdc0e6446754817d099d83e6 100644 --- a/src/main/java/ipos/project/DataModellntegration/SimpleSceneIntegration/service/SimpleSceneTransformer.java +++ b/src/main/java/ipos/project/DataModellntegration/SimpleSceneIntegration/service/SimpleSceneTransformer.java @@ -41,7 +41,7 @@ public class SimpleSceneTransformer { } public static SimpleScene.IposPositionEvent posEvent_internal2Proto(PositionEvent internalPosEvent, String type){ - LocalizableObject lObject = PositionMonitoring.getLObjectByIdOrNull(internalPosEvent.getSensorId()); + LocalizableObject lObject = PositionMonitoring.getLObjectByIdOrNull(internalPosEvent.getLObjectId()); if (null == lObject || null == lObject.getAgent()) { LOG.error("Internal-PositionEvent could not be transformed into protobuf-format. " + "No LocalizableObject with the provided sensor-id could be found, or no agent " + @@ -58,7 +58,7 @@ public class SimpleSceneTransformer { private static SimpleScene.IposPositionEvent.Builder transformIntoProtoIposPosEvent(String type, SimpleScene.IposObject.Builder protoIposObject) { SimpleScene.IposPositionEvent.Builder protoIposPosEvent = SimpleScene.IposPositionEvent.newBuilder(); - if (!"undefined".equals(type)) { + if (!PositionMonitoring.UNDEFINED_TYPE.equals(type)) { // if undefined, protobuf-object will be created without explicit type-information protoIposPosEvent.setType(type); } protoIposPosEvent.addObject(protoIposObject); diff --git a/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/EventFilterCondition.java b/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/EventFilterCondition.java index 873e353f53a3c20815d13640638dad094b88628c..46e45613301030759a01d78e3f3c833a210b1422 100644 --- a/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/EventFilterCondition.java +++ b/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/EventFilterCondition.java @@ -26,6 +26,7 @@ import org.eclipse.emf.ecore.EObject; * <li>{@link ipos.project.DataModellntegration.iPos_Datamodel.EventFilterCondition#getPositionConditionCell <em>Position Condition Cell</em>}</li> * <li>{@link ipos.project.DataModellntegration.iPos_Datamodel.EventFilterCondition#getIdCondition <em>Id Condition</em>}</li> * <li>{@link ipos.project.DataModellntegration.iPos_Datamodel.EventFilterCondition#getCategoryCondition <em>Category Condition</em>}</li> + * <li>{@link ipos.project.DataModellntegration.iPos_Datamodel.EventFilterCondition#getPositionConditionCellId <em>Position Condition Cell Id</em>}</li> * </ul> * * @see ipos.project.DataModellntegration.iPos_Datamodel.IPos_DatamodelPackage#getEventFilterCondition() @@ -253,4 +254,26 @@ public interface EventFilterCondition extends EObject { */ void setCategoryCondition(List<String> value); + /** + * Returns the value of the '<em><b>Position Condition Cell Id</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the value of the '<em>Position Condition Cell Id</em>' attribute. + * @see #setPositionConditionCellId(String) + * @see ipos.project.DataModellntegration.iPos_Datamodel.IPos_DatamodelPackage#getEventFilterCondition_PositionConditionCellId() + * @model dataType="org.eclipse.emf.ecore.xml.type.String" + * @generated + */ + String getPositionConditionCellId(); + + /** + * Sets the value of the '{@link ipos.project.DataModellntegration.iPos_Datamodel.EventFilterCondition#getPositionConditionCellId <em>Position Condition Cell Id</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Position Condition Cell Id</em>' attribute. + * @see #getPositionConditionCellId() + * @generated + */ + void setPositionConditionCellId(String value); + } // EventFilterCondition diff --git a/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/IPos_DatamodelPackage.java b/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/IPos_DatamodelPackage.java index f3913e5bc6e45073c062644fddc7c06291151196..9584236628340a4d6f02cfca00454e7ffc68c09c 100644 --- a/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/IPos_DatamodelPackage.java +++ b/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/IPos_DatamodelPackage.java @@ -1346,13 +1346,13 @@ public interface IPos_DatamodelPackage extends EPackage { int POSITION_EVENT__TIME_STAMP = 1; /** - * The feature id for the '<em><b>Sensor Id</b></em>' attribute. + * The feature id for the '<em><b>LObject Id</b></em>' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated * @ordered */ - int POSITION_EVENT__SENSOR_ID = 2; + int POSITION_EVENT__LOBJECT_ID = 2; /** * The number of structural features of the '<em>Position Event</em>' class. @@ -2400,6 +2400,15 @@ public interface IPos_DatamodelPackage extends EPackage { */ int EVENT_FILTER_CONDITION__CATEGORY_CONDITION = 9; + /** + * The feature id for the '<em><b>Position Condition Cell Id</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int EVENT_FILTER_CONDITION__POSITION_CONDITION_CELL_ID = 10; + /** * The number of structural features of the '<em>Event Filter Condition</em>' class. * <!-- begin-user-doc --> @@ -2407,7 +2416,7 @@ public interface IPos_DatamodelPackage extends EPackage { * @generated * @ordered */ - int EVENT_FILTER_CONDITION_FEATURE_COUNT = 10; + int EVENT_FILTER_CONDITION_FEATURE_COUNT = 11; /** * The number of operations of the '<em>Event Filter Condition</em>' class. @@ -3263,15 +3272,15 @@ public interface IPos_DatamodelPackage extends EPackage { EAttribute getPositionEvent_TimeStamp(); /** - * Returns the meta object for the attribute '{@link ipos.project.DataModellntegration.iPos_Datamodel.PositionEvent#getSensorId <em>Sensor Id</em>}'. + * Returns the meta object for the attribute '{@link ipos.project.DataModellntegration.iPos_Datamodel.PositionEvent#getLObjectId <em>LObject Id</em>}'. * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Sensor Id</em>'. - * @see ipos.project.DataModellntegration.iPos_Datamodel.PositionEvent#getSensorId() + * @return the meta object for the attribute '<em>LObject Id</em>'. + * @see ipos.project.DataModellntegration.iPos_Datamodel.PositionEvent#getLObjectId() * @see #getPositionEvent() * @generated */ - EAttribute getPositionEvent_SensorId(); + EAttribute getPositionEvent_LObjectId(); /** * Returns the meta object for class '{@link ipos.project.DataModellntegration.iPos_Datamodel.RawdataEvent <em>Rawdata Event</em>}'. @@ -3880,6 +3889,17 @@ public interface IPos_DatamodelPackage extends EPackage { */ EAttribute getEventFilterCondition_CategoryCondition(); + /** + * Returns the meta object for the attribute '{@link ipos.project.DataModellntegration.iPos_Datamodel.EventFilterCondition#getPositionConditionCellId <em>Position Condition Cell Id</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Position Condition Cell Id</em>'. + * @see ipos.project.DataModellntegration.iPos_Datamodel.EventFilterCondition#getPositionConditionCellId() + * @see #getEventFilterCondition() + * @generated + */ + EAttribute getEventFilterCondition_PositionConditionCellId(); + /** * Returns the meta object for data type '{@link java.util.List <em>String List</em>}'. * <!-- begin-user-doc --> @@ -4609,12 +4629,12 @@ public interface IPos_DatamodelPackage extends EPackage { EAttribute POSITION_EVENT__TIME_STAMP = eINSTANCE.getPositionEvent_TimeStamp(); /** - * The meta object literal for the '<em><b>Sensor Id</b></em>' attribute feature. + * The meta object literal for the '<em><b>LObject Id</b></em>' attribute feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ - EAttribute POSITION_EVENT__SENSOR_ID = eINSTANCE.getPositionEvent_SensorId(); + EAttribute POSITION_EVENT__LOBJECT_ID = eINSTANCE.getPositionEvent_LObjectId(); /** * The meta object literal for the '{@link ipos.project.DataModellntegration.iPos_Datamodel.impl.RawdataEventImpl <em>Rawdata Event</em>}' class. @@ -5116,6 +5136,15 @@ public interface IPos_DatamodelPackage extends EPackage { */ EAttribute EVENT_FILTER_CONDITION__CATEGORY_CONDITION = eINSTANCE.getEventFilterCondition_CategoryCondition(); + /** + * The meta object literal for the '<em><b>Position Condition Cell Id</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EAttribute EVENT_FILTER_CONDITION__POSITION_CONDITION_CELL_ID = eINSTANCE + .getEventFilterCondition_PositionConditionCellId(); + /** * The meta object literal for the '<em>String List</em>' data type. * <!-- begin-user-doc --> diff --git a/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/PositionEvent.java b/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/PositionEvent.java index b57f1c722fdd51f7173b7b260f1b51c66a6d21c2..1df2c2abfb76bdac48e4c289d81f48ed8bbbb436 100644 --- a/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/PositionEvent.java +++ b/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/PositionEvent.java @@ -15,7 +15,7 @@ import org.eclipse.emf.ecore.EObject; * <ul> * <li>{@link ipos.project.DataModellntegration.iPos_Datamodel.PositionEvent#getPlacing <em>Placing</em>}</li> * <li>{@link ipos.project.DataModellntegration.iPos_Datamodel.PositionEvent#getTimeStamp <em>Time Stamp</em>}</li> - * <li>{@link ipos.project.DataModellntegration.iPos_Datamodel.PositionEvent#getSensorId <em>Sensor Id</em>}</li> + * <li>{@link ipos.project.DataModellntegration.iPos_Datamodel.PositionEvent#getLObjectId <em>LObject Id</em>}</li> * </ul> * * @see ipos.project.DataModellntegration.iPos_Datamodel.IPos_DatamodelPackage#getPositionEvent() @@ -68,25 +68,25 @@ public interface PositionEvent extends EObject { void setTimeStamp(String value); /** - * Returns the value of the '<em><b>Sensor Id</b></em>' attribute. + * Returns the value of the '<em><b>LObject Id</b></em>' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @return the value of the '<em>Sensor Id</em>' attribute. - * @see #setSensorId(String) - * @see ipos.project.DataModellntegration.iPos_Datamodel.IPos_DatamodelPackage#getPositionEvent_SensorId() + * @return the value of the '<em>LObject Id</em>' attribute. + * @see #setLObjectId(String) + * @see ipos.project.DataModellntegration.iPos_Datamodel.IPos_DatamodelPackage#getPositionEvent_LObjectId() * @model * @generated */ - String getSensorId(); + String getLObjectId(); /** - * Sets the value of the '{@link ipos.project.DataModellntegration.iPos_Datamodel.PositionEvent#getSensorId <em>Sensor Id</em>}' attribute. + * Sets the value of the '{@link ipos.project.DataModellntegration.iPos_Datamodel.PositionEvent#getLObjectId <em>LObject Id</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @param value the new value of the '<em>Sensor Id</em>' attribute. - * @see #getSensorId() + * @param value the new value of the '<em>LObject Id</em>' attribute. + * @see #getLObjectId() * @generated */ - void setSensorId(String value); + void setLObjectId(String value); } // PositionEvent diff --git a/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/impl/EventFilterConditionImpl.java b/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/impl/EventFilterConditionImpl.java index 28bae6c07777838ddece605b19e99e8e782666ff..7d28c6e1e1fe608c77d104f4114fb6489aca288f 100644 --- a/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/impl/EventFilterConditionImpl.java +++ b/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/impl/EventFilterConditionImpl.java @@ -33,6 +33,7 @@ import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; * <li>{@link ipos.project.DataModellntegration.iPos_Datamodel.impl.EventFilterConditionImpl#getPositionConditionCell <em>Position Condition Cell</em>}</li> * <li>{@link ipos.project.DataModellntegration.iPos_Datamodel.impl.EventFilterConditionImpl#getIdCondition <em>Id Condition</em>}</li> * <li>{@link ipos.project.DataModellntegration.iPos_Datamodel.impl.EventFilterConditionImpl#getCategoryCondition <em>Category Condition</em>}</li> + * <li>{@link ipos.project.DataModellntegration.iPos_Datamodel.impl.EventFilterConditionImpl#getPositionConditionCellId <em>Position Condition Cell Id</em>}</li> * </ul> * * @generated @@ -238,6 +239,26 @@ public class EventFilterConditionImpl extends MinimalEObjectImpl.Container imple */ protected List<String> categoryCondition = CATEGORY_CONDITION_EDEFAULT; + /** + * The default value of the '{@link #getPositionConditionCellId() <em>Position Condition Cell Id</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getPositionConditionCellId() + * @generated + * @ordered + */ + protected static final String POSITION_CONDITION_CELL_ID_EDEFAULT = null; + + /** + * The cached value of the '{@link #getPositionConditionCellId() <em>Position Condition Cell Id</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getPositionConditionCellId() + * @generated + * @ordered + */ + protected String positionConditionCellId = POSITION_CONDITION_CELL_ID_EDEFAULT; + /** * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -484,6 +505,29 @@ public class EventFilterConditionImpl extends MinimalEObjectImpl.Container imple categoryCondition)); } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getPositionConditionCellId() { + return positionConditionCellId; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setPositionConditionCellId(String newPositionConditionCellId) { + String oldPositionConditionCellId = positionConditionCellId; + positionConditionCellId = newPositionConditionCellId; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, + IPos_DatamodelPackage.EVENT_FILTER_CONDITION__POSITION_CONDITION_CELL_ID, + oldPositionConditionCellId, positionConditionCellId)); + } + /** * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -512,6 +556,8 @@ public class EventFilterConditionImpl extends MinimalEObjectImpl.Container imple return getIdCondition(); case IPos_DatamodelPackage.EVENT_FILTER_CONDITION__CATEGORY_CONDITION: return getCategoryCondition(); + case IPos_DatamodelPackage.EVENT_FILTER_CONDITION__POSITION_CONDITION_CELL_ID: + return getPositionConditionCellId(); } return super.eGet(featureID, resolve, coreType); } @@ -555,6 +601,9 @@ public class EventFilterConditionImpl extends MinimalEObjectImpl.Container imple case IPos_DatamodelPackage.EVENT_FILTER_CONDITION__CATEGORY_CONDITION: setCategoryCondition((List<String>) newValue); return; + case IPos_DatamodelPackage.EVENT_FILTER_CONDITION__POSITION_CONDITION_CELL_ID: + setPositionConditionCellId((String) newValue); + return; } super.eSet(featureID, newValue); } @@ -597,6 +646,9 @@ public class EventFilterConditionImpl extends MinimalEObjectImpl.Container imple case IPos_DatamodelPackage.EVENT_FILTER_CONDITION__CATEGORY_CONDITION: setCategoryCondition(CATEGORY_CONDITION_EDEFAULT); return; + case IPos_DatamodelPackage.EVENT_FILTER_CONDITION__POSITION_CONDITION_CELL_ID: + setPositionConditionCellId(POSITION_CONDITION_CELL_ID_EDEFAULT); + return; } super.eUnset(featureID); } @@ -635,6 +687,9 @@ public class EventFilterConditionImpl extends MinimalEObjectImpl.Container imple case IPos_DatamodelPackage.EVENT_FILTER_CONDITION__CATEGORY_CONDITION: return CATEGORY_CONDITION_EDEFAULT == null ? categoryCondition != null : !CATEGORY_CONDITION_EDEFAULT.equals(categoryCondition); + case IPos_DatamodelPackage.EVENT_FILTER_CONDITION__POSITION_CONDITION_CELL_ID: + return POSITION_CONDITION_CELL_ID_EDEFAULT == null ? positionConditionCellId != null + : !POSITION_CONDITION_CELL_ID_EDEFAULT.equals(positionConditionCellId); } return super.eIsSet(featureID); } @@ -670,6 +725,8 @@ public class EventFilterConditionImpl extends MinimalEObjectImpl.Container imple result.append(idCondition); result.append(", categoryCondition: "); result.append(categoryCondition); + result.append(", positionConditionCellId: "); + result.append(positionConditionCellId); result.append(')'); return result.toString(); } diff --git a/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/impl/IPos_DatamodelPackageImpl.java b/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/impl/IPos_DatamodelPackageImpl.java index 5d8b8e12511982bfdd736e45f59a8a7811271473..ff856f8b09db1811b63ca6be2afe9566b6c9d48e 100644 --- a/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/impl/IPos_DatamodelPackageImpl.java +++ b/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/impl/IPos_DatamodelPackageImpl.java @@ -1179,7 +1179,7 @@ public class IPos_DatamodelPackageImpl extends EPackageImpl implements IPos_Data * <!-- end-user-doc --> * @generated */ - public EAttribute getPositionEvent_SensorId() { + public EAttribute getPositionEvent_LObjectId() { return (EAttribute) positionEventEClass.getEStructuralFeatures().get(2); } @@ -1696,6 +1696,15 @@ public class IPos_DatamodelPackageImpl extends EPackageImpl implements IPos_Data return (EAttribute) eventFilterConditionEClass.getEStructuralFeatures().get(9); } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getEventFilterCondition_PositionConditionCellId() { + return (EAttribute) eventFilterConditionEClass.getEStructuralFeatures().get(10); + } + /** * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -1871,7 +1880,7 @@ public class IPos_DatamodelPackageImpl extends EPackageImpl implements IPos_Data positionEventEClass = createEClass(POSITION_EVENT); createEReference(positionEventEClass, POSITION_EVENT__PLACING); createEAttribute(positionEventEClass, POSITION_EVENT__TIME_STAMP); - createEAttribute(positionEventEClass, POSITION_EVENT__SENSOR_ID); + createEAttribute(positionEventEClass, POSITION_EVENT__LOBJECT_ID); rawdataEventEClass = createEClass(RAWDATA_EVENT); createEReference(rawdataEventEClass, RAWDATA_EVENT__RAWDATA); @@ -1949,6 +1958,7 @@ public class IPos_DatamodelPackageImpl extends EPackageImpl implements IPos_Data createEAttribute(eventFilterConditionEClass, EVENT_FILTER_CONDITION__POSITION_CONDITION_CELL); createEAttribute(eventFilterConditionEClass, EVENT_FILTER_CONDITION__ID_CONDITION); createEAttribute(eventFilterConditionEClass, EVENT_FILTER_CONDITION__CATEGORY_CONDITION); + createEAttribute(eventFilterConditionEClass, EVENT_FILTER_CONDITION__POSITION_CONDITION_CELL_ID); // Create data types stringListEDataType = createEDataType(STRING_LIST); @@ -2209,7 +2219,7 @@ public class IPos_DatamodelPackageImpl extends EPackageImpl implements IPos_Data initEAttribute(getPositionEvent_TimeStamp(), theXMLTypePackage.getString(), "timeStamp", null, 0, 1, PositionEvent.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getPositionEvent_SensorId(), ecorePackage.getEString(), "sensorId", null, 0, 1, + initEAttribute(getPositionEvent_LObjectId(), ecorePackage.getEString(), "lObjectId", null, 0, 1, PositionEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); @@ -2407,6 +2417,9 @@ public class IPos_DatamodelPackageImpl extends EPackageImpl implements IPos_Data initEAttribute(getEventFilterCondition_CategoryCondition(), this.getStringList(), "categoryCondition", null, 0, 1, EventFilterCondition.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getEventFilterCondition_PositionConditionCellId(), theXMLTypePackage.getString(), + "positionConditionCellId", null, 0, 1, EventFilterCondition.class, !IS_TRANSIENT, !IS_VOLATILE, + IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); // Initialize data types initEDataType(stringListEDataType, List.class, "StringList", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS, diff --git a/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/impl/PositionEventImpl.java b/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/impl/PositionEventImpl.java index e837053b1e58191a683842eae7ed997f1495192e..9d25ef8f3cf84fd84cf35c801f9eb6f1a32ed879 100644 --- a/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/impl/PositionEventImpl.java +++ b/src/main/java/ipos/project/DataModellntegration/iPos_Datamodel/impl/PositionEventImpl.java @@ -24,7 +24,7 @@ import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; * <ul> * <li>{@link ipos.project.DataModellntegration.iPos_Datamodel.impl.PositionEventImpl#getPlacing <em>Placing</em>}</li> * <li>{@link ipos.project.DataModellntegration.iPos_Datamodel.impl.PositionEventImpl#getTimeStamp <em>Time Stamp</em>}</li> - * <li>{@link ipos.project.DataModellntegration.iPos_Datamodel.impl.PositionEventImpl#getSensorId <em>Sensor Id</em>}</li> + * <li>{@link ipos.project.DataModellntegration.iPos_Datamodel.impl.PositionEventImpl#getLObjectId <em>LObject Id</em>}</li> * </ul> * * @generated @@ -61,24 +61,24 @@ public class PositionEventImpl extends MinimalEObjectImpl.Container implements P protected String timeStamp = TIME_STAMP_EDEFAULT; /** - * The default value of the '{@link #getSensorId() <em>Sensor Id</em>}' attribute. + * The default value of the '{@link #getLObjectId() <em>LObject Id</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @see #getSensorId() + * @see #getLObjectId() * @generated * @ordered */ - protected static final String SENSOR_ID_EDEFAULT = null; + protected static final String LOBJECT_ID_EDEFAULT = null; /** - * The cached value of the '{@link #getSensorId() <em>Sensor Id</em>}' attribute. + * The cached value of the '{@link #getLObjectId() <em>LObject Id</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @see #getSensorId() + * @see #getLObjectId() * @generated * @ordered */ - protected String sensorId = SENSOR_ID_EDEFAULT; + protected String lObjectId = LOBJECT_ID_EDEFAULT; /** * <!-- begin-user-doc --> @@ -166,8 +166,8 @@ public class PositionEventImpl extends MinimalEObjectImpl.Container implements P * <!-- end-user-doc --> * @generated */ - public String getSensorId() { - return sensorId; + public String getLObjectId() { + return lObjectId; } /** @@ -175,12 +175,12 @@ public class PositionEventImpl extends MinimalEObjectImpl.Container implements P * <!-- end-user-doc --> * @generated */ - public void setSensorId(String newSensorId) { - String oldSensorId = sensorId; - sensorId = newSensorId; + public void setLObjectId(String newLObjectId) { + String oldLObjectId = lObjectId; + lObjectId = newLObjectId; if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, IPos_DatamodelPackage.POSITION_EVENT__SENSOR_ID, - oldSensorId, sensorId)); + eNotify(new ENotificationImpl(this, Notification.SET, IPos_DatamodelPackage.POSITION_EVENT__LOBJECT_ID, + oldLObjectId, lObjectId)); } /** @@ -197,8 +197,8 @@ public class PositionEventImpl extends MinimalEObjectImpl.Container implements P return basicGetPlacing(); case IPos_DatamodelPackage.POSITION_EVENT__TIME_STAMP: return getTimeStamp(); - case IPos_DatamodelPackage.POSITION_EVENT__SENSOR_ID: - return getSensorId(); + case IPos_DatamodelPackage.POSITION_EVENT__LOBJECT_ID: + return getLObjectId(); } return super.eGet(featureID, resolve, coreType); } @@ -217,8 +217,8 @@ public class PositionEventImpl extends MinimalEObjectImpl.Container implements P case IPos_DatamodelPackage.POSITION_EVENT__TIME_STAMP: setTimeStamp((String) newValue); return; - case IPos_DatamodelPackage.POSITION_EVENT__SENSOR_ID: - setSensorId((String) newValue); + case IPos_DatamodelPackage.POSITION_EVENT__LOBJECT_ID: + setLObjectId((String) newValue); return; } super.eSet(featureID, newValue); @@ -238,8 +238,8 @@ public class PositionEventImpl extends MinimalEObjectImpl.Container implements P case IPos_DatamodelPackage.POSITION_EVENT__TIME_STAMP: setTimeStamp(TIME_STAMP_EDEFAULT); return; - case IPos_DatamodelPackage.POSITION_EVENT__SENSOR_ID: - setSensorId(SENSOR_ID_EDEFAULT); + case IPos_DatamodelPackage.POSITION_EVENT__LOBJECT_ID: + setLObjectId(LOBJECT_ID_EDEFAULT); return; } super.eUnset(featureID); @@ -257,8 +257,8 @@ public class PositionEventImpl extends MinimalEObjectImpl.Container implements P return placing != null; case IPos_DatamodelPackage.POSITION_EVENT__TIME_STAMP: return TIME_STAMP_EDEFAULT == null ? timeStamp != null : !TIME_STAMP_EDEFAULT.equals(timeStamp); - case IPos_DatamodelPackage.POSITION_EVENT__SENSOR_ID: - return SENSOR_ID_EDEFAULT == null ? sensorId != null : !SENSOR_ID_EDEFAULT.equals(sensorId); + case IPos_DatamodelPackage.POSITION_EVENT__LOBJECT_ID: + return LOBJECT_ID_EDEFAULT == null ? lObjectId != null : !LOBJECT_ID_EDEFAULT.equals(lObjectId); } return super.eIsSet(featureID); } @@ -276,8 +276,8 @@ public class PositionEventImpl extends MinimalEObjectImpl.Container implements P StringBuilder result = new StringBuilder(super.toString()); result.append(" (timeStamp: "); result.append(timeStamp); - result.append(", sensorId: "); - result.append(sensorId); + result.append(", lObjectId: "); + result.append(lObjectId); result.append(')'); return result.toString(); } diff --git a/src/main/java/ipos/project/Functionality/eventfilter/eventFilter.java b/src/main/java/ipos/project/Functionality/eventfilter/eventFilter.java index 164eb42106d0589e19b355f2d41a8f1d9ed3e444..6a3f15585faeb7eca785199f1e23a628c02eb777 100644 --- a/src/main/java/ipos/project/Functionality/eventfilter/eventFilter.java +++ b/src/main/java/ipos/project/Functionality/eventfilter/eventFilter.java @@ -46,6 +46,10 @@ public class eventFilter { //Conditions: unique conditions are defined as single values, Parallel conditions are defined in lists. //initial value: 0 (for float and int) and empty (for arrays), it's not always possible to determine the status of the filter with just the condition value, so a filterStructure is defined to register which conditions are active. + public EventFilterCondition getFilterConditionConfig() { + return filterConditionConfig; + } + private ArrayList<String[]> timeCondition; private List<String> categoryCondition; private List<String> sensorIdCondition; @@ -55,6 +59,7 @@ public class eventFilter { private int timeMinInterval; private float positionDelta; private ArrayList<Float[][]> positionConditionCell; + private EventFilterCondition filterConditionConfig; public void init(EventFilterCondition conf) { filterStructure = conf.getFilterStructure(); @@ -67,6 +72,7 @@ public class eventFilter { timeMinInterval = conf.getTimeMinInterval(); positionDelta = conf.getPositionDelta(); positionConditionCell = conf.getPositionConditionCell(); + this.filterConditionConfig = conf; } private static String createRegexFromGlob(String glob) { @@ -103,14 +109,14 @@ public class eventFilter { public boolean process(PositionEvent event) throws ParseException { IPos_DatamodelFactory dataModelFactory = IPos_DatamodelFactory.eINSTANCE; - LocalizableObject lObject = getLObjectBySensorIdOrNull(event.getSensorId()); + LocalizableObject lObject = getLObjectBySensorIdOrNull(event.getLObjectId()); boolean flag = false; //false for pass, true for block if (null == event.getPlacing() || null == event.getPlacing().getPosition() || null == event.getPlacing().getPosition().getPoint()){ - System.out.println("EventFilter: Warning: Received event with unknown Position. Sensor-id: " + event.getSensorId()); + System.out.println("EventFilter: Warning: Received event with unknown Position. Sensor-id: " + event.getLObjectId()); return true; } if (null == lObject){ - System.out.println("EventFilter: Warning: Received event from sensor with unknown sensor-id: " + event.getSensorId()); + System.out.println("EventFilter: Warning: Received event from sensor with unknown sensor-id: " + event.getLObjectId()); return true; } Agent agent = lObject.getAgent(); diff --git a/src/main/java/ipos/project/Functionality/eventfilter/readConfig.java b/src/main/java/ipos/project/Functionality/eventfilter/readConfig.java index 027151fb9b9c4e9cc635c09648ee991db76062f7..d93a535ccfed1f0226f1e7c1ff73af3b0bb70fc0 100644 --- a/src/main/java/ipos/project/Functionality/eventfilter/readConfig.java +++ b/src/main/java/ipos/project/Functionality/eventfilter/readConfig.java @@ -1,9 +1,9 @@ package ipos.project.Functionality.eventfilter; import ipos.project.DataModellntegration.iPos_Datamodel.*; +import org.apache.logging.log4j.LogManager; import org.json.JSONArray; import org.json.JSONObject; -import javax.xml.stream.EventFilter; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; @@ -13,15 +13,28 @@ public class readConfig { // kommt später raus, Zugriff auf Weltmodell erfolgt eigentlich über Komponente DataRetrieval private static WorldModel wm; + private static org.apache.logging.log4j.Logger LOG = LogManager.getLogger(); - public static void readFilterConfigFromMonitoringRequest (MonitoringRequest monReq, EventFilterCondition config){ - // TODO: support other criteria than "position_delta" and "position_condition_cell" aus config-file - float delta_monReq = monReq.getDelta(); + /** + * Returns false if MonitoringRequest could not be read successfully. + * @param monReq + * @param config + * @return + */ + public static boolean readFilterConfigFromMonitoringRequest (MonitoringRequest monReq, EventFilterCondition config){ + // TODO: support other criteria than "position_condition_cell" + //float delta_monReq = monReq.getDelta(); String frameId_monReq = monReq.getFrameId(); - Zone zone_monReq = retrieveZone(frameId_monReq); - config.setFilterStructure(new boolean[] {false, false, false, false, false, false, false, true, true}); - config.setPositionDelta(delta_monReq); + Zone zone_monReq = retrieveZoneOrNull(frameId_monReq); + if (null == zone_monReq){ + LOG.warn("MonitoringRequest contained an invalid Zone-id"); + return false; + } + config.setFilterStructure(new boolean[] {false, false, false, false, false, false, false, false, true}); + //config.setPositionDelta(delta_monReq); config.setPositionConditionCell(transformZone2PositionConditionCell(zone_monReq)); + config.setPositionConditionCellId(zone_monReq.getId()); + return true; } public static ArrayList<Float[][]> transformZone2PositionConditionCell(Zone zone) { @@ -39,7 +52,7 @@ public class readConfig { return position_condition_cell; } - private static Zone retrieveZone(String zoneId){ + private static Zone retrieveZoneOrNull(String zoneId){ List<Zone> knownZones = wm.getZoneMap().get(0).getZone(); for (var zone : knownZones){ if(zone.getId().equals(zoneId)){ diff --git a/src/main/java/ipos/project/SensorValueIntegration/Service/GenericSensorTransformer.java b/src/main/java/ipos/project/SensorValueIntegration/Service/GenericSensorTransformer.java index f3c87c964fbb4498fef17a81c618cb64f896b463..b2179657ea1b1e8f6259d171f0ac2586ab85107f 100644 --- a/src/main/java/ipos/project/SensorValueIntegration/Service/GenericSensorTransformer.java +++ b/src/main/java/ipos/project/SensorValueIntegration/Service/GenericSensorTransformer.java @@ -27,7 +27,7 @@ public class GenericSensorTransformer { public static PositionEvent posEvent_GSensor2Internal(GenericSensor.SensorPositionEvent protoSensPosEvent) { PositionEvent positionEvent = modelFactory.createPositionEvent(); positionEvent.setTimeStamp(protoSensPosEvent.getLastPosUpdate()); - positionEvent.setSensorId(protoSensPosEvent.getSensorId()); + positionEvent.setLObjectId(protoSensPosEvent.getSensorId()); // TODO: Zugriff auf Weltmodell ermöglichen um Bezugssystem-Objekt beschaffen zu können positionEvent.setPlacing( diff --git a/src/main/java/ipos/project/UseCaseController/PositionMonitoring.java b/src/main/java/ipos/project/UseCaseController/PositionMonitoring.java index b79d981ee1a4f138c3aa60b4455baa1128617f17..b6f56efd9b2fb550edd20c1571d0e03dd380a275 100644 --- a/src/main/java/ipos/project/UseCaseController/PositionMonitoring.java +++ b/src/main/java/ipos/project/UseCaseController/PositionMonitoring.java @@ -8,6 +8,10 @@ import org.apache.logging.log4j.LogManager; import org.springframework.jms.annotation.JmsListener; import org.springframework.stereotype.Component; import ipos.models.SimpleScene.IposPosition; +import reactor.util.function.Tuple3; +import reactor.util.function.Tuples; + +import java.text.ParseException; import java.util.*; @@ -17,20 +21,45 @@ public class PositionMonitoring { private static WorldModel wm; private static List<eventFilter> eventFilters = new ArrayList<eventFilter>(); + private static Map<String, List<String>> zonePopulation = new HashMap<String, List<String>>(); private IPos_DatamodelFactory modelFactory = IPos_DatamodelFactory.eINSTANCE; + public static final String EXIT_NOTIFICATION_TYPE = "ExitNotification"; + public static final String ENTRY_NOTIFICATION_TYPE = "EntryNotification"; + public static final String UNDEFINED_TYPE = "undefined"; + public static final String TOPIC_WINDOW = "Human_at_Window_Side"; + public static final String TOPIC_DOOR = "Human_at_Door_Side"; + public static final String ZONE_ID_DOOR = "cobot1_door_zone"; + public static final String ZONE_ID_WINDOW = "cobot1_window_zone"; + public PositionMonitoring(){ + ReferenceSystem rootRefSystem = createReferenceSystem("ROOT", "ROOT", null); + List<Space> doorSpaces = new LinkedList<Space>(Arrays.asList(createSpace(2.0f, 2.0f, 2.0f, createPlacing(createPosition(createPoint3D(2.0f, 0.0f, 0f), 1f, rootRefSystem), createOrientation(0f, 0f, 0f, 0f))))); + List<Space> windowSpaces = new LinkedList<Space>(Arrays.asList(createSpace(2.0f, 2.0f, 2.0f, createPlacing(createPosition(createPoint3D(2.0f, 4.0f, 0f), 1f, rootRefSystem), createOrientation(0f, 0f, 0f, 0f))))); + Zone doorZone = createZone(ZONE_ID_DOOR, ZONE_ID_DOOR, doorSpaces); + Zone windowZone = createZone(ZONE_ID_WINDOW, ZONE_ID_WINDOW,windowSpaces); wm = modelFactory.createWorldModel(); - wm.getReferenceSystem().add(createReferenceSystem("ROOT", "ROOT", null)); + wm.getReferenceSystem().add(rootRefSystem); wm.getPois().add(createPOI(createPosition(createPoint3D(1.4f, 2.0f, 0f), 1f, wm.getReferenceSystem().get(0)), "UWBToken1", new HashMap<String,String>())); wm.getPois().add(createPOI(createPosition(createPoint3D(3.7f, -2.0f, 0f), 1f, wm.getReferenceSystem().get(0)), "UWBToken2", new HashMap<String,String>())); wm.getPois().add(createPOI(createPosition(createPoint3D(-2.4f, -0.5f, 0f), 1f, wm.getReferenceSystem().get(0)), "UWBToken3", new HashMap<String,String>())); wm.getZoneMap().add(modelFactory.createZoneMap()); - List<Space> spaces = Arrays.asList(createSpace(3.0f, 3.0f, 3.0f, createPlacing(createPosition(createPoint3D(1.1f, 0.9f, 0f), 1f, wm.getReferenceSystem().get(0)), createOrientation(0f, 0f, 0f, 0f)))); - wm.getZoneMap().get(0).getZone().add(createZone("cobot1_warning_zone", "cobot1_warning_zone", spaces)); + wm.getZoneMap().get(0).getZone().add(doorZone); + wm.getZoneMap().get(0).getZone().add(windowZone); wm.getAgent().add(createAgent("Employee1", "HUMAN")); wm.getAgent().get(0).getLObject().add(createLobject("UWB_1", "UWB", wm.getAgent().get(0), null)); - initEventFiltersForDemo(); + + MonitoringRequest doorMonReq = createMonitoringRequest(ZONE_ID_DOOR, TOPIC_DOOR); + MonitoringRequest windowMonReq = createMonitoringRequest(ZONE_ID_WINDOW, TOPIC_WINDOW); + receiveMessage(doorMonReq); + receiveMessage(windowMonReq); + } + + private MonitoringRequest createMonitoringRequest(String frameId, String monitoringTaskId) { + MonitoringRequest monReq = modelFactory.createMonitoringRequest(); + monReq.setFrameId(frameId); + monReq.setMonitoringTaskId(monitoringTaskId); + return monReq; } public static LocalizableObject getLObjectByIdOrNull(String lObjectId){ @@ -44,41 +73,6 @@ public class PositionMonitoring { return null; } - private void initEventFiltersForDemo(){ - String taskIdWindow = "Human_at_Window_Side"; - String taskIdDoor = "Human_at_Door_Side"; - ReferenceSystem rootRefSystem = createReferenceSystem("ROOT", "ROOT", null); - eventFilter filterWindow = createWindowZoneEventFilter(taskIdWindow, rootRefSystem); - eventFilter filterDoor = createDoorZoneEventFilter(taskIdDoor, rootRefSystem); - eventFilters.add(filterDoor); - eventFilters.add(filterWindow); - } - - private eventFilter createWindowZoneEventFilter(String monitoringTaskId, ReferenceSystem rootRefSystem){ - Space windowSpace = createSpace(2.0f, 2.0f, 2.0f, createPlacing(createPosition(createPoint3D(2.0f, 4.0f, 0f), 1f, rootRefSystem), createOrientation(0f, 0f, 0f, 0f))); - Zone windowZone = createZone("cobot1_window_zone", "cobot1_window_zone", Arrays.asList(windowSpace)); - return createEventFilter(monitoringTaskId, windowZone); - } - - private eventFilter createDoorZoneEventFilter(String monitoringTaskId, ReferenceSystem rootRefSystem){ - Space windowSpace = createSpace(2.0f, 2.0f, 2.0f, createPlacing(createPosition(createPoint3D(2.0f, 0.0f, 0f), 1f, rootRefSystem), createOrientation(0f, 0f, 0f, 0f))); - Zone windowZone = createZone("cobot1_door_zone", "cobot1_door_zone", Arrays.asList(windowSpace)); - return createEventFilter(monitoringTaskId, windowZone); - } - - private eventFilter createEventFilter(String monitoringTaskId, Zone zone){ - eventFilter filter = new eventFilter(monitoringTaskId); - filter.setWM(wm); - EventFilterCondition config = modelFactory.createEventFilterCondition(); - readConfig.setWM(wm); - config.setFilterStructure(new boolean[] {false, false, false, false, false, false, false, false, true}); - config.setPositionConditionCell(readConfig.transformZone2PositionConditionCell(zone)); - - //readConfig.readFilterConfigFromMonitoringRequest(monReq, config); - filter.init(config); - return filter; - } - private POI createPOI(Position position, String description, Map<String, String> data){ POI poi = modelFactory.createPOI(); poi.setPosition(position); @@ -176,9 +170,12 @@ public class PositionMonitoring { filter.setWM(wm); EventFilterCondition config = modelFactory.createEventFilterCondition(); readConfig.setWM(wm); - readConfig.readFilterConfigFromMonitoringRequest(monReq, config); + if (! readConfig.readFilterConfigFromMonitoringRequest(monReq, config)){ + return; // monitoringRequest could not be read + } filter.init(config); eventFilters.add(filter); + LOG.info("EventFilter was created"); } private static boolean isDoor = false; @@ -189,72 +186,102 @@ public class PositionMonitoring { // @JmsListener(destination = "/PositionEvent", containerFactory = "jmsListenFactory") public static void receiveMessage(PositionEvent posEvent) { LOG.info("Received <" + posEvent + ">"); - String taskIdWindow = "Human_at_Window_Side"; - String taskIdDoor = "Human_at_Door_Side"; - String type = "undefined"; // definition: if undefined, type-attribute in protobuf-message will not be set - float y_coordinate = ((Point3D) posEvent.getPlacing().getPosition().getPoint()).getY(); - // Achtung, Entry- und Exit-Notification müssten eigentlich Personengebunden sein - if (y_coordinate <= 2.08f){ - isDoor = true; - if (isCentre == true){ - isCentre = false; - type = "EntryNotification"; - } else - if (isWindow == true){ - isWindow = false; - type = "SwitchNotification"; // note: Event will be sent to the topic of the zone that the agent switched into - } else - if (firstMessage){ - firstMessage = false; - type = "EntryNotification"; + List<Tuple3<PositionEvent, String, String>> entryNotifications = new LinkedList<>(); + for (eventFilter eFilter : eventFilters){ + try { + boolean posEventMeetsFilterConditions = !eFilter.process(posEvent); + if(posEventMeetsFilterConditions){ + LOG.info(eFilter.getMonitoringTaskId() + "-EventFilter accepted the position"); + if (isEntryNotification(posEvent, eFilter)) { + entryNotifications.add(Tuples.of(posEvent, eFilter.getMonitoringTaskId(), ENTRY_NOTIFICATION_TYPE)); // note: EntryNotifications are sent after that all ExitNotifications have been sent + associateLObjectWithZone(eFilter.getFilterConditionConfig().getPositionConditionCellId(), posEvent.getLObjectId()); + }else { + SimpleSceneIntegration.receiveMessage(posEvent, eFilter.getMonitoringTaskId(), UNDEFINED_TYPE); + } + }else if (isExitNotification(posEvent, eFilter)){ + disassociateLObjectFromZone(eFilter.getFilterConditionConfig().getPositionConditionCellId(), posEvent.getLObjectId()); + SimpleSceneIntegration.receiveMessage(posEvent, eFilter.getMonitoringTaskId(), EXIT_NOTIFICATION_TYPE); // note: ExitNotifications are sent immediately + } + + } catch (ParseException e) { + sendEntryNotifications(entryNotifications); + e.printStackTrace(); + return; } - SimpleSceneIntegration.receiveMessage(posEvent, taskIdDoor, type); } - else if (y_coordinate > 2.08f && y_coordinate <= 2.5f){ - isCentre = true; - if (isDoor == true){ - isDoor = false; - type = "ExitNotification"; - SimpleSceneIntegration.receiveMessage(posEvent, taskIdDoor, type); // previous zone was door: ExitNotification is sent for this zone - } else - if (isWindow == true){ - isWindow = false; - type = "ExitNotification"; - SimpleSceneIntegration.receiveMessage(posEvent, taskIdWindow, type); - } else - if (firstMessage){ - firstMessage = false; - } + sendEntryNotifications(entryNotifications); + } + /** + * assumption: An object has been found to be located outside of a zone. + * This function determines whether it just exited from that zone + * Function has a side-effect: lObjectIds are removed from the map zonePopulation + * @param posEvent + * @param eFilter + * @return + */ + private static boolean isExitNotification(PositionEvent posEvent, eventFilter eFilter) { + String zoneId = eFilter.getFilterConditionConfig().getPositionConditionCellId(); + String lObjectId = posEvent.getLObjectId(); + if(null == zoneId) return false; + if (isLocatedInsideZone(zoneId, lObjectId)){ + disassociateLObjectFromZone(zoneId, lObjectId); + return true; }else{ - isWindow = true; - if (isCentre == true){ - isCentre = false; - type = "EntryNotification"; - } else - if (isDoor == true){ - isDoor = false; - type = "SwitchNotification"; - } else - if (firstMessage){ - firstMessage = false; - type = "EntryNotification"; - } - SimpleSceneIntegration.receiveMessage(posEvent, taskIdWindow, type); + return false; } + } - /* - for (eventFilter eFilter : eventFilters){ - try { - if(eFilter.process(posEvent)){ - String monitoringTaskId = eFilter.getMonitoringTaskId(); + /** + * Assumption: posEvent contains a position which is located within the zone associated to eFilter. + * Function has a side-effect: lObjectIds are added to the map zonePopulation + * @param posEvent + * @param eFilter + * @return + */ + private static boolean isEntryNotification(PositionEvent posEvent, eventFilter eFilter) { + String zoneId = eFilter.getFilterConditionConfig().getPositionConditionCellId(); + String lObjectId = posEvent.getLObjectId(); + LOG.info("zoneId: " + zoneId + "; lObjectId: " + lObjectId); + if(null == zoneId) return false; + if (isLocatedInsideZone(zoneId, lObjectId)){ + return false; + }else{ + associateLObjectWithZone(zoneId, lObjectId); + return true; + } + } - // posEvent und mqtt-topic (monitoringTaskId) per JMS an SimpleSceneIntegration-Komponente zum Aussenden weiterleiten - } - } catch (ParseException e) { - e.printStackTrace(); + private static boolean isLocatedInsideZone(String zoneId, String lObjectId) { + List<String> lObjectsInsideZone = zonePopulation.get(zoneId); + if (null == lObjectsInsideZone) { + return false; + } + return lObjectsInsideZone.contains(lObjectId); + } + + private static void associateLObjectWithZone(String zoneId, String lObjectId) { + if(zonePopulation.keySet().contains(zoneId)){ + zonePopulation.get(zoneId).add(lObjectId); + }else{ + zonePopulation.put(zoneId, new LinkedList<String>(Arrays.asList(lObjectId))); + } + } + + private static void disassociateLObjectFromZone(String zoneId, String lObjectId) { + if(zonePopulation.keySet().contains(zoneId)){ + List<String> objList = zonePopulation.get(zoneId); + if (!zonePopulation.get(zoneId).remove(lObjectId)){ + LOG.warn("LocalizableObjectId cannot be removed as it is currently not associated with the given zone"); } + }else{ + LOG.warn("LocalizableObjectId cannot be removed as there are currently no LocalizableObjectIds associated to the zone"); + } + } + + private static void sendEntryNotifications(List<Tuple3<PositionEvent, String, String>> entryNotifications) { + for (Tuple3<PositionEvent, String, String> entryNotification : entryNotifications){ + SimpleSceneIntegration.receiveMessage(entryNotification.getT1(), entryNotification.getT2(), entryNotification.getT3()); } - */ } }