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 {
// LOG.info("obtained protobuf-positionEvent:" + posEvent_proto.toString());
MqttMessage mqttMessage = mqttService.createMqttMsg(posEvent_proto, 0, false);
// Protobuf-Versand: LOG.info("publishing mqttMessage:" + mqttMessage.toString() + " on topic: " + monitoringTaskId);
// mqttService.publish(monitoringTaskId, mqttMessage);
// LOG.info("publishing mqttMessage:" + mqttMessage.toString() + " on topic: " + monitoringTaskId);
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);
mqttService.publish(monitoringTaskId, ProtoJsonMap.toJson(posEvent_proto), 0, false);
//LOG.info("publishing mqttMessage:" + ProtoJsonMap.toJson(posEvent_proto) + " on topic: " + monitoringTaskId);
// mqttService.publish(monitoringTaskId, ProtoJsonMap.toJson(posEvent_proto), 0, false);
}else{
LOG.warn("Warning: SimpleScene: Received empty PositionEvent");
}
......
package ipos.project.DataModellntegration.SimpleSceneIntegration.api;
import com.google.protobuf.InvalidProtocolBufferException;
import ipos.models.GenericSensor;
import ipos.models.SimpleScene;
import ipos.models.SimpleScene.IposMonitoringRequest;
import ipos.project.DataModellntegration.SimpleSceneIntegration.SimpleSceneIntegration;
import ipos.project.DataModellntegration.SimpleSceneIntegration.service.SimpleSceneTransformer;
import ipos.project.DataModellntegration.iPos_Datamodel.MonitoringRequest;
import ipos.project.UseCaseController.PositionMonitoring;
import ipos.project.config.mqtt.Handler;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -14,10 +20,10 @@ import org.springframework.jms.core.JmsTemplate;
// subscribe to the topic. It's example
@MqttListener("usertopic/IposMonitoringRequest")
@MqttListener("usertopic/IposConfigWrapper")
public class MqttRequestHandler implements Handler {
private final Logger LOG = LoggerFactory.getLogger(getClass());
private static org.apache.logging.log4j.Logger LOG = LogManager.getLogger();
JmsTemplate jmsTemplate;
@Autowired
......@@ -28,13 +34,17 @@ public class MqttRequestHandler implements Handler {
// method that handle new message from the topic
public void handle(MqttMessage message) {
try {
IposMonitoringRequest monReqProto = IposMonitoringRequest.parseFrom(message.getPayload());
LOG.info("IposMonitoringRequest received: \n"
+ monReqProto.toString());
MonitoringRequest monReqInternal = SimpleSceneTransformer.monReq_SScene2Internal(monReqProto);
SimpleScene.IposConfigWrapper iposConfigWrapper = ProtoJsonMap.fromJson(message.toString(), SimpleScene.IposConfigWrapper.class);
// IposMonitoringRequest monReqProto = IposMonitoringRequest.parseFrom(message.getPayload());
LOG.info("IposConfigWrapper received: \n"
+ iposConfigWrapper.toString());
for (IposMonitoringRequest monReq : iposConfigWrapper.getMonitoringRequestsList()){
MonitoringRequest monReqInternal = SimpleSceneTransformer.monReq_SScene2Internal(monReq);
PositionMonitoring.receiveMessage(monReqInternal);
// 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) {
e.printStackTrace();
}
......
......@@ -22,20 +22,20 @@ 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;
private static 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 TOPIC_WINDOW = "Human_at_Window_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)))));
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, 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 windowZone = createZone(ZONE_ID_WINDOW, ZONE_ID_WINDOW,windowSpaces);
wm = modelFactory.createWorldModel();
......@@ -164,8 +164,8 @@ public class PositionMonitoring {
}
@JmsListener(destination = "/monitoringRequest", containerFactory = "jmsListenFactory")
public void receiveMessage(MonitoringRequest monReq) {
LOG.info("Received <" + monReq + ">");
public static void receiveMessage(MonitoringRequest monReq) {
LOG.info("Received MonitoringRequest <" + monReq + ">");
eventFilter filter = new eventFilter(monReq.getMonitoringTaskId());
filter.setWM(wm);
EventFilterCondition config = modelFactory.createEventFilterCondition();
......@@ -175,7 +175,7 @@ public class PositionMonitoring {
}
filter.init(config);
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;
......
......@@ -3,11 +3,12 @@ syntax = "proto3";
package ipos.models;
message IposConfigWrapper { // wrapper-message for configuration-topic
repeated IposFrameConfig frame = 1;
repeated IposObject object = 2; // an object must be either in this list
repeated IposObjectConfig objectConfig = 3; // or in this list, not in both
repeated POI poi = 4;
repeated RefSystem refsystem = 5;
repeated IposFrameConfig frames = 1;
repeated IposObject objects = 2; // an object must be either in this list
repeated IposObjectConfig objectConfigs = 3; // or in this list, not in both
repeated POI pois = 4;
repeated RefSystem refsystems = 5;
repeated IposMonitoringRequest monitoringRequests = 6;
}
message IposObjectConfig {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment