Skip to content
Snippets Groups Projects
Commit d8b30372 authored by FrankR's avatar FrankR
Browse files

datamodel: configWrapper-Feldnamen geändert

SimpleSceneIntegration: ConfigWrapper-Protobuf kann empfangen werden
parent 347fbfa7
No related branches found
No related tags found
No related merge requests found
...@@ -43,11 +43,12 @@ public class SimpleSceneIntegration { ...@@ -43,11 +43,12 @@ public class SimpleSceneIntegration {
// LOG.info("obtained protobuf-positionEvent:" + posEvent_proto.toString()); // LOG.info("obtained protobuf-positionEvent:" + posEvent_proto.toString());
MqttMessage mqttMessage = mqttService.createMqttMsg(posEvent_proto, 0, false); MqttMessage mqttMessage = mqttService.createMqttMsg(posEvent_proto, 0, false);
// Protobuf-Versand: LOG.info("publishing mqttMessage:" + mqttMessage.toString() + " on topic: " + monitoringTaskId); // LOG.info("publishing mqttMessage:" + mqttMessage.toString() + " on topic: " + monitoringTaskId);
// mqttService.publish(monitoringTaskId, mqttMessage); mqttService.publish(monitoringTaskId, mqttMessage);
LOG.info("publishing protobuf mqttMessage. JSON-representation:" + ProtoJsonMap.toJson(posEvent_proto) + " on topic: " + monitoringTaskId);
LOG.info("publishing mqttMessage:" + ProtoJsonMap.toJson(posEvent_proto) + " on topic: " + monitoringTaskId); //LOG.info("publishing mqttMessage:" + ProtoJsonMap.toJson(posEvent_proto) + " on topic: " + monitoringTaskId);
mqttService.publish(monitoringTaskId, ProtoJsonMap.toJson(posEvent_proto), 0, false); // mqttService.publish(monitoringTaskId, ProtoJsonMap.toJson(posEvent_proto), 0, false);
}else{ }else{
LOG.warn("Warning: SimpleScene: Received empty PositionEvent"); LOG.warn("Warning: SimpleScene: Received empty PositionEvent");
} }
......
package ipos.project.DataModellntegration.SimpleSceneIntegration.api; package ipos.project.DataModellntegration.SimpleSceneIntegration.api;
import com.google.protobuf.InvalidProtocolBufferException; import com.google.protobuf.InvalidProtocolBufferException;
import ipos.models.GenericSensor;
import ipos.models.SimpleScene;
import ipos.models.SimpleScene.IposMonitoringRequest; import ipos.models.SimpleScene.IposMonitoringRequest;
import ipos.project.DataModellntegration.SimpleSceneIntegration.SimpleSceneIntegration;
import ipos.project.DataModellntegration.SimpleSceneIntegration.service.SimpleSceneTransformer; import ipos.project.DataModellntegration.SimpleSceneIntegration.service.SimpleSceneTransformer;
import ipos.project.DataModellntegration.iPos_Datamodel.MonitoringRequest; import ipos.project.DataModellntegration.iPos_Datamodel.MonitoringRequest;
import ipos.project.UseCaseController.PositionMonitoring;
import ipos.project.config.mqtt.Handler; import ipos.project.config.mqtt.Handler;
import ipos.project.config.mqtt.MqttListener; import ipos.project.config.mqtt.MqttListener;
import ipos.project.mapper.ProtoJsonMap;
import org.apache.logging.log4j.LogManager;
import org.eclipse.paho.client.mqttv3.MqttMessage; import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -14,10 +20,10 @@ import org.springframework.jms.core.JmsTemplate; ...@@ -14,10 +20,10 @@ import org.springframework.jms.core.JmsTemplate;
// subscribe to the topic. It's example // subscribe to the topic. It's example
@MqttListener("usertopic/IposMonitoringRequest") @MqttListener("usertopic/IposConfigWrapper")
public class MqttRequestHandler implements Handler { public class MqttRequestHandler implements Handler {
private final Logger LOG = LoggerFactory.getLogger(getClass()); private static org.apache.logging.log4j.Logger LOG = LogManager.getLogger();
JmsTemplate jmsTemplate; JmsTemplate jmsTemplate;
@Autowired @Autowired
...@@ -28,13 +34,17 @@ public class MqttRequestHandler implements Handler { ...@@ -28,13 +34,17 @@ public class MqttRequestHandler implements Handler {
// method that handle new message from the topic // method that handle new message from the topic
public void handle(MqttMessage message) { public void handle(MqttMessage message) {
try { try {
IposMonitoringRequest monReqProto = IposMonitoringRequest.parseFrom(message.getPayload()); SimpleScene.IposConfigWrapper iposConfigWrapper = ProtoJsonMap.fromJson(message.toString(), SimpleScene.IposConfigWrapper.class);
LOG.info("IposMonitoringRequest received: \n" // IposMonitoringRequest monReqProto = IposMonitoringRequest.parseFrom(message.getPayload());
+ monReqProto.toString()); LOG.info("IposConfigWrapper received: \n"
MonitoringRequest monReqInternal = SimpleSceneTransformer.monReq_SScene2Internal(monReqProto); + iposConfigWrapper.toString());
for (IposMonitoringRequest monReq : iposConfigWrapper.getMonitoringRequestsList()){
MonitoringRequest monReqInternal = SimpleSceneTransformer.monReq_SScene2Internal(monReq);
PositionMonitoring.receiveMessage(monReqInternal);
// TODO: send request via JMS to MonitoringController // TODO: send request via JMS to MonitoringController
}
this.jmsTemplate.convertAndSend("/request123", monReqInternal); // submit request to the internal broker // this.jmsTemplate.convertAndSend("/request123", monReqInternal); // submit request to the internal broker
} catch (InvalidProtocolBufferException e) { } catch (InvalidProtocolBufferException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -22,20 +22,20 @@ public class PositionMonitoring { ...@@ -22,20 +22,20 @@ public class PositionMonitoring {
private static WorldModel wm; private static WorldModel wm;
private static List<eventFilter> eventFilters = new ArrayList<eventFilter>(); private static List<eventFilter> eventFilters = new ArrayList<eventFilter>();
private static Map<String, List<String>> zonePopulation = new HashMap<String, List<String>>(); private static Map<String, List<String>> zonePopulation = new HashMap<String, List<String>>();
private IPos_DatamodelFactory modelFactory = IPos_DatamodelFactory.eINSTANCE; private static IPos_DatamodelFactory modelFactory = IPos_DatamodelFactory.eINSTANCE;
public static final String EXIT_NOTIFICATION_TYPE = "ExitNotification"; public static final String EXIT_NOTIFICATION_TYPE = "ExitNotification";
public static final String ENTRY_NOTIFICATION_TYPE = "EntryNotification"; public static final String ENTRY_NOTIFICATION_TYPE = "EntryNotification";
public static final String UNDEFINED_TYPE = "undefined"; 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 TOPIC_DOOR = "Human_at_Door_Side";
public static final String TOPIC_WINDOW = "Human_at_Window_Side";
public static final String ZONE_ID_DOOR = "cobot1_door_zone"; public static final String ZONE_ID_DOOR = "cobot1_door_zone";
public static final String ZONE_ID_WINDOW = "cobot1_window_zone"; public static final String ZONE_ID_WINDOW = "cobot1_window_zone";
public PositionMonitoring(){ public PositionMonitoring(){
ReferenceSystem rootRefSystem = createReferenceSystem("ROOT", "ROOT", null); 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> doorSpaces = new LinkedList<Space>(Arrays.asList(createSpace(2.0f, 2.0f, 6.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))))); List<Space> windowSpaces = new LinkedList<Space>(Arrays.asList(createSpace(2.0f, 2.0f, 6.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 doorZone = createZone(ZONE_ID_DOOR, ZONE_ID_DOOR, doorSpaces);
Zone windowZone = createZone(ZONE_ID_WINDOW, ZONE_ID_WINDOW,windowSpaces); Zone windowZone = createZone(ZONE_ID_WINDOW, ZONE_ID_WINDOW,windowSpaces);
wm = modelFactory.createWorldModel(); wm = modelFactory.createWorldModel();
...@@ -164,8 +164,8 @@ public class PositionMonitoring { ...@@ -164,8 +164,8 @@ public class PositionMonitoring {
} }
@JmsListener(destination = "/monitoringRequest", containerFactory = "jmsListenFactory") @JmsListener(destination = "/monitoringRequest", containerFactory = "jmsListenFactory")
public void receiveMessage(MonitoringRequest monReq) { public static void receiveMessage(MonitoringRequest monReq) {
LOG.info("Received <" + monReq + ">"); LOG.info("Received MonitoringRequest <" + monReq + ">");
eventFilter filter = new eventFilter(monReq.getMonitoringTaskId()); eventFilter filter = new eventFilter(monReq.getMonitoringTaskId());
filter.setWM(wm); filter.setWM(wm);
EventFilterCondition config = modelFactory.createEventFilterCondition(); EventFilterCondition config = modelFactory.createEventFilterCondition();
...@@ -175,7 +175,7 @@ public class PositionMonitoring { ...@@ -175,7 +175,7 @@ public class PositionMonitoring {
} }
filter.init(config); filter.init(config);
eventFilters.add(filter); eventFilters.add(filter);
LOG.info("EventFilter was created"); LOG.info("EventFilter was created: " + filter.toString() + "; monitoringTaskId: " + filter.getMonitoringTaskId() + "; zone-id:" + filter.getFilterConditionConfig().getPositionConditionCellId());
} }
private static boolean isDoor = false; private static boolean isDoor = false;
......
...@@ -3,11 +3,12 @@ syntax = "proto3"; ...@@ -3,11 +3,12 @@ syntax = "proto3";
package ipos.models; package ipos.models;
message IposConfigWrapper { // wrapper-message for configuration-topic message IposConfigWrapper { // wrapper-message for configuration-topic
repeated IposFrameConfig frame = 1; repeated IposFrameConfig frames = 1;
repeated IposObject object = 2; // an object must be either in this list repeated IposObject objects = 2; // an object must be either in this list
repeated IposObjectConfig objectConfig = 3; // or in this list, not in both repeated IposObjectConfig objectConfigs = 3; // or in this list, not in both
repeated POI poi = 4; repeated POI pois = 4;
repeated RefSystem refsystem = 5; repeated RefSystem refsystems = 5;
repeated IposMonitoringRequest monitoringRequests = 6;
} }
message IposObjectConfig { message IposObjectConfig {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment