Projet-Fini
This commit is contained in:
commit
be99e1497b
425 changed files with 36607 additions and 0 deletions
14280
.metadata/.bak_0.log
Normal file
14280
.metadata/.bak_0.log
Normal file
File diff suppressed because it is too large
Load diff
0
.metadata/.lock
Normal file
0
.metadata/.lock
Normal file
58
.metadata/.log
Normal file
58
.metadata/.log
Normal file
|
@ -0,0 +1,58 @@
|
|||
!SESSION 2020-12-28 09:58:41.980 -----------------------------------------------
|
||||
eclipse.buildId=4.17.0.I20200902-1800
|
||||
java.version=13.0.2
|
||||
java.vendor=Oracle Corporation
|
||||
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=fr_FR
|
||||
Framework arguments: -product org.eclipse.epp.package.rcp.product
|
||||
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.rcp.product
|
||||
|
||||
This is a continuation of log file C:\Users\nunes\OneDrive\Bureau\WorkDay\INSA\TP_NAWAL\Services_package\.metadata\.bak_0.log
|
||||
Created Time: 2020-12-28 12:06:08.591
|
||||
|
||||
!ENTRY org.eclipse.ui.monitoring 2 0 2020-12-28 12:06:08.592
|
||||
!MESSAGE UI freeze of 0,66s at 12:06:07.932
|
||||
!SUBENTRY 1 org.eclipse.ui.monitoring 1 0 2020-12-28 12:06:08.592
|
||||
!MESSAGE Sample at 12:06:08.268 (+0,336s)
|
||||
Thread 'main' tid=1 (TIMED_WAITING)
|
||||
!STACK 0
|
||||
Stack Trace
|
||||
at java.base@13.0.2/java.lang.Object.wait(Native Method)
|
||||
at org.eclipse.jdt.core.manipulation.CoreASTProvider.getAST(CoreASTProvider.java:174)
|
||||
at org.eclipse.jdt.core.manipulation.SharedASTProviderCore.getAST(SharedASTProviderCore.java:138)
|
||||
at org.eclipse.jdt.internal.ui.text.correction.AssistContext.getASTRoot(AssistContext.java:128)
|
||||
at org.eclipse.jdt.internal.ui.text.java.hover.ProblemHover$ProblemInfo.getJavaAnnotationFixes(ProblemHover.java:101)
|
||||
at org.eclipse.jdt.internal.ui.text.java.hover.ProblemHover$ProblemInfo.getCompletionProposals(ProblemHover.java:79)
|
||||
at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.deferredCreateContent(AbstractAnnotationHover.java:304)
|
||||
at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.setInput(AbstractAnnotationHover.java:190)
|
||||
at org.eclipse.jface.text.AbstractInformationControlManager.internalShowInformationControl(AbstractInformationControlManager.java:1151)
|
||||
at org.eclipse.jface.text.AbstractInformationControlManager.presentInformation(AbstractInformationControlManager.java:1120)
|
||||
at org.eclipse.jface.text.AbstractHoverInformationControlManager.presentInformation(AbstractHoverInformationControlManager.java:884)
|
||||
at org.eclipse.jface.text.TextViewerHoverManager.doPresentInformation(TextViewerHoverManager.java:237)
|
||||
at org.eclipse.jface.text.TextViewerHoverManager.lambda$3(TextViewerHoverManager.java:227)
|
||||
at org.eclipse.jface.text.TextViewerHoverManager$$Lambda$888/0x0000000801a48440.run(Unknown Source)
|
||||
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
|
||||
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:185)
|
||||
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3987)
|
||||
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3615)
|
||||
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1157)
|
||||
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
|
||||
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
|
||||
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
|
||||
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644)
|
||||
at org.eclipse.ui.internal.Workbench$$Lambda$216/0x0000000800ec6c40.run(Unknown Source)
|
||||
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
|
||||
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551)
|
||||
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:153)
|
||||
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:150)
|
||||
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
|
||||
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
|
||||
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
|
||||
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
|
||||
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
|
||||
at java.base@13.0.2/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base@13.0.2/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
|
||||
at java.base@13.0.2/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base@13.0.2/java.lang.reflect.Method.invoke(Method.java:567)
|
||||
at app//org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:657)
|
||||
at app//org.eclipse.equinox.launcher.Main.basicRun(Main.java:594)
|
||||
at app//org.eclipse.equinox.launcher.Main.run(Main.java:1465)
|
|
@ -0,0 +1,334 @@
|
|||
package Services.Controller;
|
||||
import java.awt.Color;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.web.client.*;
|
||||
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/controller/")
|
||||
public class ControllerApplication {
|
||||
|
||||
private final String captMouvURI = "http://localhost:8081/CaptMouv/";
|
||||
private final String captTempURI = "http://localhost:8082/CaptTemp/";
|
||||
private final String captCO2URI = "http://localhost:8083/CaptCO2/";
|
||||
private final String captHumURI = "http://localhost:8084/CaptHum/";
|
||||
private final String automPorteURI = "http://localhost:8085/AutomPorteApplication/";
|
||||
private final String automFenetreURI = "http://localhost:8086/AutomFenetreApplication/";
|
||||
private final String automLumiereURI = "http://localhost:8087/AutomLumiereApplication/";
|
||||
private final String automChauffageURI = "http://localhost:8088/AutomChauffageApplication/";
|
||||
private final String simulationURI = "http://localhost:8089/Simulation/";
|
||||
|
||||
|
||||
boolean ControlLumiereAutomatique = false;
|
||||
boolean PorteFenetreAutomatique_TemperatureCO2 = false;
|
||||
boolean PorteFenetreAutomatique_CO2 = false;
|
||||
boolean MouvementAlarmActivated = false;
|
||||
boolean TemperatureAlarmActivated = false;
|
||||
boolean CO2AlarmActivated = false;
|
||||
|
||||
|
||||
//Controle de la lumiere automatique
|
||||
//Controle en fonction du mouvement
|
||||
@GetMapping("isControlLumiereAutomatiqueActivated/")
|
||||
private final boolean isControlLumiereAutomatique() {
|
||||
return ControlLumiereAutomatique;
|
||||
}
|
||||
@GetMapping("setControlLumiereAutomatique/")
|
||||
private final void setControlLumiereAutomatique(boolean controlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique = controlLumiereAutomatique;
|
||||
}
|
||||
|
||||
//Control de l'ouverture de la porte et fenetre
|
||||
//Control en fonction de la temperature et CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_TemperatureCO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_TemperatureCO2() {
|
||||
return PorteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_TemperatureCO2/")
|
||||
private final void setPorteFenetreAutomatique_TemperatureCO2(boolean porteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2 = porteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
//Controle en fonction du CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_CO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_CO2() {
|
||||
return PorteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_CO2/")
|
||||
private final void setPorteFenetreAutomatique_CO2(boolean porteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2 = porteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ControlLumiereAutomatique() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
String url_allumerLumiere = automLumiereURI + "setON/?oN=true";
|
||||
String url_eteindreLumiere = automLumiereURI + "setON/?oN=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
//return restTemplate.getForObject(test, String.class);
|
||||
|
||||
|
||||
if (restTemplate.getForObject(url_getDetection,boolean.class)) {
|
||||
restTemplate.getForObject(url_allumerLumiere,boolean.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_eteindreLumiere,boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_TemperatureCO2() {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getTemp,double.class)) > 30) | ((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_CO2() {
|
||||
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("getSalleOccupee/")
|
||||
public String SalleOccupe() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
boolean salle_occupe = restTemplate.getForObject(url_getDetection,boolean.class);
|
||||
|
||||
|
||||
return ("La salle est:" + String.valueOf(salle_occupe)) ;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureHeatingSystem/")
|
||||
public void setTemperatureHeatingSystem(int temp) {
|
||||
String url_setTemp = automChauffageURI + "setTemperatureSet/?temperatureSet=" + String.valueOf(temp);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject(url_setTemp,void.class);
|
||||
}
|
||||
|
||||
@GetMapping("getHeatingSystemONOFF/")
|
||||
public boolean getHeatingSystemONOFF() {
|
||||
String url_getONOFF = automChauffageURI + "isActive/";
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
return (restTemplate.getForObject(url_getONOFF,boolean.class));
|
||||
}
|
||||
|
||||
public boolean getMovementDetection() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
boolean resultat = false;
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
return (restTemplate.getForObject(url_getDetection, boolean.class));
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("getTemperatureAlarm/")
|
||||
public boolean getTemperatureAlarm() {
|
||||
return (TemperatureAlarmActivated);
|
||||
}
|
||||
@GetMapping("setTemperatureAlarm/")
|
||||
public void setTemperatureAlarm(boolean active) {
|
||||
TemperatureAlarmActivated = active;
|
||||
}
|
||||
|
||||
@GetMapping("setMouvementAlarm/")
|
||||
public void setMouvementAlarm(boolean active) {
|
||||
MouvementAlarmActivated = active;
|
||||
}
|
||||
|
||||
@GetMapping("setCO2Alarm/")
|
||||
public void setCO2Alarm(boolean active) {
|
||||
CO2AlarmActivated = active;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("run")
|
||||
public int run() throws Exception {
|
||||
|
||||
if (ControlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2();
|
||||
}
|
||||
|
||||
//Notification de mouvement Alarm
|
||||
if (MouvementAlarmActivated & (getMovementDetection())) {
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="data" val="Mouvement_GEI213"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Notification/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
|
||||
}
|
||||
|
||||
//Notification temperature elevée
|
||||
if (TemperatureAlarmActivated) {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
int temp;
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
temp = restTemplate.getForObject(url_getTemp,int.class);
|
||||
if ((temp > 35) | (temp<15)) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="location" val="GEI213"/>\n"
|
||||
+ " <str name="data" val="" + String.valueOf(temp) +""/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Temperature/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
}
|
||||
}
|
||||
|
||||
//Notification CO2 elevée
|
||||
if (CO2AlarmActivated) {
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
double CO2;
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
CO2 = restTemplate.getForObject(url_getCO2,double.class);
|
||||
if (CO2 > 1000) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="location" val="GEI213"/>\n"
|
||||
+ " <str name="data" val="" + String.valueOf(CO2) +""/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_CO2/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ControllerApplication.class, args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,274 @@
|
|||
package Services.Controller;
|
||||
import java.awt.Color;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.web.client.*;
|
||||
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/controller/")
|
||||
public class ControllerApplication {
|
||||
|
||||
private final String captMouvURI = "http://localhost:8081/CaptMouv/";
|
||||
private final String captTempURI = "http://localhost:8082/CaptTemp/";
|
||||
private final String captCO2URI = "http://localhost:8083/CaptCO2/";
|
||||
private final String captHumURI = "http://localhost:8084/";
|
||||
private final String automPorteURI = "http://localhost:8085/AutomPorteApplication/";
|
||||
private final String automFenetreURI = "http://localhost:8086/AutomFenetreApplication/";
|
||||
private final String automLumiereURI = "http://localhost:8087/AutomLumiereApplication/";
|
||||
private final String automChauffageURI = "http://localhost:8088/AutomChauffageApplication/";
|
||||
private final String simulationURI = "http://localhost:8089/Simulation/";
|
||||
|
||||
|
||||
boolean ControlLumiereAutomatique = false;
|
||||
boolean PorteFenetreAutomatique_TemperatureCO2 = false;
|
||||
boolean PorteFenetreAutomatique_CO2 = false;
|
||||
boolean AlarmActivated = false;
|
||||
|
||||
|
||||
//Controle de la lumiere automatique
|
||||
//Controle en fonction du mouvement
|
||||
@GetMapping("isControlLumiereAutomatiqueActivated/")
|
||||
private final boolean isControlLumiereAutomatique() {
|
||||
return ControlLumiereAutomatique;
|
||||
}
|
||||
@GetMapping("setControlLumiereAutomatique/")
|
||||
private final void setControlLumiereAutomatique(boolean controlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique = controlLumiereAutomatique;
|
||||
}
|
||||
|
||||
//Control de l'ouverture de la porte et fenetre
|
||||
//Control en fonction de la temperature et CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_TemperatureCO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_TemperatureCO2() {
|
||||
return PorteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_TemperatureCO2/")
|
||||
private final void setPorteFenetreAutomatique_TemperatureCO2(boolean porteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2 = porteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
//Controle en fonction du CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_CO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_CO2() {
|
||||
return PorteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_CO2/")
|
||||
private final void setPorteFenetreAutomatique_CO2(boolean porteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2 = porteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ControlLumiereAutomatique() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
String url_allumerLumiere = automLumiereURI + "setON/?oN=true";
|
||||
String url_eteindreLumiere = automLumiereURI + "setON/?oN=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
//return restTemplate.getForObject(test, String.class);
|
||||
|
||||
|
||||
if (restTemplate.getForObject(url_getDetection,boolean.class)) {
|
||||
restTemplate.getForObject(url_allumerLumiere,boolean.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_eteindreLumiere,boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_TemperatureCO2() {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getTemp,double.class)) > 30) | ((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_CO2() {
|
||||
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("getSalleOccupee/")
|
||||
public String SalleOccupe() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
boolean salle_occupe = restTemplate.getForObject(url_getDetection,boolean.class);
|
||||
|
||||
|
||||
return ("La salle est:" + String.valueOf(salle_occupe)) ;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureHeatingSystem/")
|
||||
public void setTemperatureHeatingSystem(int temp) {
|
||||
String url_setTemp = automChauffageURI + "setTemperatureSet/?temperatureSet=" + String.valueOf(temp);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject(url_setTemp,void.class);
|
||||
}
|
||||
|
||||
@GetMapping("getHeatingSystemONOFF/")
|
||||
public boolean getHeatingSystemONOFF() {
|
||||
String url_getONOFF = automChauffageURI + "isActive/";
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
return (restTemplate.getForObject(url_getONOFF,boolean.class));
|
||||
}
|
||||
|
||||
public boolean getMovementDetection() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
boolean resultat = false;
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
return (restTemplate.getForObject(url_getDetection, boolean.class));
|
||||
|
||||
}
|
||||
@GetMapping("setAlarm/")
|
||||
public void setAlarm(boolean active) {
|
||||
AlarmActivated = active;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("run")
|
||||
public int run() throws Exception {
|
||||
|
||||
if (ControlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2();
|
||||
}
|
||||
if (AlarmActivated & (getMovementDetection())) {
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="data" val="Mouvement_GEI213"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Notification/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
|
||||
return 3;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
//Communication avec OneM2M
|
||||
/*
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="presence" val="1"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Capteur_Mouvement/DATA/";
|
||||
|
||||
ResponseEntity respEntity = restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
String resp = (String) respEntity.getBody();
|
||||
return resp;
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ControllerApplication.class, args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,234 @@
|
|||
package Services.Controller;
|
||||
import java.awt.Color;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.web.client.*;
|
||||
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/controller/")
|
||||
public class ControllerApplication {
|
||||
|
||||
private final String captMouvURI = "http://localhost:8081/CaptMouv/";
|
||||
private final String captTempURI = "http://localhost:8082/CaptTemp/";
|
||||
private final String captCO2URI = "http://localhost:8083/CaptCO2/";
|
||||
private final String captHumURI = "http://localhost:8084/";
|
||||
private final String automPorteURI = "http://localhost:8085/AutomPorteApplication/";
|
||||
private final String automFenetreURI = "http://localhost:8086/AutomFenetreApplication/";
|
||||
private final String automLumiereURI = "http://localhost:8087/AutomLumiereApplication/";
|
||||
private final String automChauffageURI = "http://localhost:8088/AutomChauffageApplication/";
|
||||
private final String simulationURI = "http://localhost:8089/Simulation/";
|
||||
|
||||
|
||||
boolean ControlLumiereAutomatique = false;
|
||||
boolean PorteFenetreAutomatique_TemperatureCO2 = false;
|
||||
boolean PorteFenetreAutomatique_CO2 = false;
|
||||
|
||||
|
||||
|
||||
//Controle de la lumiere automatique
|
||||
//Controle en fonction du mouvement
|
||||
@GetMapping("isControlLumiereAutomatiqueActivated/")
|
||||
private final boolean isControlLumiereAutomatique() {
|
||||
return ControlLumiereAutomatique;
|
||||
}
|
||||
@GetMapping("setControlLumiereAutomatique/")
|
||||
private final void setControlLumiereAutomatique(boolean controlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique = controlLumiereAutomatique;
|
||||
}
|
||||
|
||||
//Control de l'ouverture de la porte et fenetre
|
||||
//Control en fonction de la temperature et CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_TemperatureCO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_TemperatureCO2() {
|
||||
return PorteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_TemperatureCO2/")
|
||||
private final void setPorteFenetreAutomatique_TemperatureCO2(boolean porteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2 = porteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
//Controle en fonction du CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_CO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_CO2() {
|
||||
return PorteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_CO2/")
|
||||
private final void setPorteFenetreAutomatique_CO2(boolean porteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2 = porteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ControlLumiereAutomatique() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
String url_allumerLumiere = automLumiereURI + "setON/?oN=true";
|
||||
String url_eteindreLumiere = automLumiereURI + "setON/?oN=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
//return restTemplate.getForObject(test, String.class);
|
||||
|
||||
|
||||
if (restTemplate.getForObject(url_getDetection,boolean.class)) {
|
||||
restTemplate.getForObject(url_allumerLumiere,boolean.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_eteindreLumiere,boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_TemperatureCO2() {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getTemp,double.class)) > 30) | ((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_CO2() {
|
||||
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("getSalleOccupee/")
|
||||
public String SalleOccupe() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
boolean salle_occupe = restTemplate.getForObject(url_getDetection,boolean.class);
|
||||
|
||||
|
||||
return ("La salle est:" + String.valueOf(salle_occupe)) ;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureHeatingSystem/")
|
||||
public void setTemperatureHeatingSystem(int temp) {
|
||||
String url_setTemp = automChauffageURI + "setTemperatureSet/?temperatureSet=" + String.valueOf(temp);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject(url_setTemp,void.class);
|
||||
}
|
||||
|
||||
@GetMapping("getHeatingSystemONOFF/")
|
||||
public boolean getHeatingSystemONOFF() {
|
||||
String url_getONOFF = automChauffageURI + "isActive/";
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
return (restTemplate.getForObject(url_getONOFF,boolean.class));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("run")
|
||||
public int run() throws Exception {
|
||||
/*
|
||||
if (ControlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
return 0;
|
||||
//Communication avec OneM2M
|
||||
/*
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="presence" val="1"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Capteur_Mouvement/DATA/";
|
||||
|
||||
ResponseEntity respEntity = restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
String resp = (String) respEntity.getBody();
|
||||
return resp;
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ControllerApplication.class, args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,271 @@
|
|||
package Services.Controller;
|
||||
import java.awt.Color;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.web.client.*;
|
||||
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/controller/")
|
||||
public class ControllerApplication {
|
||||
|
||||
private final String captMouvURI = "http://localhost:8081/CaptMouv/";
|
||||
private final String captTempURI = "http://localhost:8082/CaptTemp/";
|
||||
private final String captCO2URI = "http://localhost:8083/CaptCO2/";
|
||||
private final String captHumURI = "http://localhost:8084/";
|
||||
private final String automPorteURI = "http://localhost:8085/AutomPorteApplication/";
|
||||
private final String automFenetreURI = "http://localhost:8086/AutomFenetreApplication/";
|
||||
private final String automLumiereURI = "http://localhost:8087/AutomLumiereApplication/";
|
||||
private final String automChauffageURI = "http://localhost:8088/AutomChauffageApplication/";
|
||||
private final String simulationURI = "http://localhost:8089/Simulation/";
|
||||
|
||||
|
||||
boolean ControlLumiereAutomatique = false;
|
||||
boolean PorteFenetreAutomatique_TemperatureCO2 = false;
|
||||
boolean PorteFenetreAutomatique_CO2 = false;
|
||||
boolean AlarmActivated = false;
|
||||
|
||||
|
||||
//Controle de la lumiere automatique
|
||||
//Controle en fonction du mouvement
|
||||
@GetMapping("isControlLumiereAutomatiqueActivated/")
|
||||
private final boolean isControlLumiereAutomatique() {
|
||||
return ControlLumiereAutomatique;
|
||||
}
|
||||
@GetMapping("setControlLumiereAutomatique/")
|
||||
private final void setControlLumiereAutomatique(boolean controlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique = controlLumiereAutomatique;
|
||||
}
|
||||
|
||||
//Control de l'ouverture de la porte et fenetre
|
||||
//Control en fonction de la temperature et CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_TemperatureCO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_TemperatureCO2() {
|
||||
return PorteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_TemperatureCO2/")
|
||||
private final void setPorteFenetreAutomatique_TemperatureCO2(boolean porteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2 = porteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
//Controle en fonction du CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_CO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_CO2() {
|
||||
return PorteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_CO2/")
|
||||
private final void setPorteFenetreAutomatique_CO2(boolean porteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2 = porteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ControlLumiereAutomatique() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
String url_allumerLumiere = automLumiereURI + "setON/?oN=true";
|
||||
String url_eteindreLumiere = automLumiereURI + "setON/?oN=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
//return restTemplate.getForObject(test, String.class);
|
||||
|
||||
|
||||
if (restTemplate.getForObject(url_getDetection,boolean.class)) {
|
||||
restTemplate.getForObject(url_allumerLumiere,boolean.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_eteindreLumiere,boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_TemperatureCO2() {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getTemp,double.class)) > 30) | ((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_CO2() {
|
||||
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("getSalleOccupee/")
|
||||
public String SalleOccupe() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
boolean salle_occupe = restTemplate.getForObject(url_getDetection,boolean.class);
|
||||
|
||||
|
||||
return ("La salle est:" + String.valueOf(salle_occupe)) ;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureHeatingSystem/")
|
||||
public void setTemperatureHeatingSystem(int temp) {
|
||||
String url_setTemp = automChauffageURI + "setTemperatureSet/?temperatureSet=" + String.valueOf(temp);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject(url_setTemp,void.class);
|
||||
}
|
||||
|
||||
@GetMapping("getHeatingSystemONOFF/")
|
||||
public boolean getHeatingSystemONOFF() {
|
||||
String url_getONOFF = automChauffageURI + "isActive/";
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
return (restTemplate.getForObject(url_getONOFF,boolean.class));
|
||||
}
|
||||
|
||||
public boolean getMovementDetection() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
boolean resultat = false;
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
return (restTemplate.getForObject(url_getDetection, boolean.class));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("run")
|
||||
public int run() throws Exception {
|
||||
|
||||
if (ControlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2();
|
||||
}
|
||||
if (AlarmActivated & (getMovementDetection())) {
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="data" val="Mouvement_GEI213"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Notification/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
|
||||
return 3;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
//Communication avec OneM2M
|
||||
/*
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="presence" val="1"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Capteur_Mouvement/DATA/";
|
||||
|
||||
ResponseEntity respEntity = restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
String resp = (String) respEntity.getBody();
|
||||
return resp;
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ControllerApplication.class, args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,342 @@
|
|||
package Services.Controller;
|
||||
import java.awt.Color;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.web.client.*;
|
||||
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/controller/")
|
||||
public class ControllerApplication {
|
||||
|
||||
private final String captMouvURI = "http://localhost:8081/CaptMouv/";
|
||||
private final String captTempURI = "http://localhost:8082/CaptTemp/";
|
||||
private final String captCO2URI = "http://localhost:8083/CaptCO2/";
|
||||
private final String captHumURI = "http://localhost:8084/CaptHum/";
|
||||
private final String automPorteURI = "http://localhost:8085/AutomPorteApplication/";
|
||||
private final String automFenetreURI = "http://localhost:8086/AutomFenetreApplication/";
|
||||
private final String automLumiereURI = "http://localhost:8087/AutomLumiereApplication/";
|
||||
private final String automChauffageURI = "http://localhost:8088/AutomChauffageApplication/";
|
||||
private final String simulationURI = "http://localhost:8089/Simulation/";
|
||||
|
||||
|
||||
boolean ControlLumiereAutomatique = false;
|
||||
boolean PorteFenetreAutomatique_TemperatureCO2 = false;
|
||||
boolean PorteFenetreAutomatique_CO2 = false;
|
||||
boolean MouvementAlarmActivated = false;
|
||||
boolean TemperatureAlarmActivated = false;
|
||||
boolean CO2AlarmActivated = false;
|
||||
|
||||
|
||||
//Controle de la lumiere automatique
|
||||
//Controle en fonction du mouvement
|
||||
@GetMapping("isControlLumiereAutomatiqueActivated/")
|
||||
private final boolean isControlLumiereAutomatique() {
|
||||
return ControlLumiereAutomatique;
|
||||
}
|
||||
@GetMapping("setControlLumiereAutomatique/")
|
||||
private final void setControlLumiereAutomatique(boolean controlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique = controlLumiereAutomatique;
|
||||
}
|
||||
|
||||
//Control de l'ouverture de la porte et fenetre
|
||||
//Control en fonction de la temperature et CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_TemperatureCO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_TemperatureCO2() {
|
||||
return PorteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_TemperatureCO2/")
|
||||
private final void setPorteFenetreAutomatique_TemperatureCO2(boolean porteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2 = porteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
//Controle en fonction du CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_CO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_CO2() {
|
||||
return PorteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_CO2/")
|
||||
private final void setPorteFenetreAutomatique_CO2(boolean porteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2 = porteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ControlLumiereAutomatique() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
String url_allumerLumiere = automLumiereURI + "setON/?oN=true";
|
||||
String url_eteindreLumiere = automLumiereURI + "setON/?oN=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
//return restTemplate.getForObject(test, String.class);
|
||||
|
||||
|
||||
if (restTemplate.getForObject(url_getDetection,boolean.class)) {
|
||||
restTemplate.getForObject(url_allumerLumiere,boolean.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_eteindreLumiere,boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_TemperatureCO2() {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getTemp,double.class)) > 30) | ((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_CO2() {
|
||||
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("getSalleOccupee/")
|
||||
public String SalleOccupe() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
boolean salle_occupe = restTemplate.getForObject(url_getDetection,boolean.class);
|
||||
|
||||
|
||||
return ("La salle est:" + String.valueOf(salle_occupe)) ;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureHeatingSystem/")
|
||||
public void setTemperatureHeatingSystem(int temp) {
|
||||
String url_setTemp = automChauffageURI + "setTemperatureSet/?temperatureSet=" + String.valueOf(temp);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject(url_setTemp,void.class);
|
||||
}
|
||||
|
||||
@GetMapping("getHeatingSystemONOFF/")
|
||||
public boolean getHeatingSystemONOFF() {
|
||||
String url_getONOFF = automChauffageURI + "isActive/";
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
return (restTemplate.getForObject(url_getONOFF,boolean.class));
|
||||
}
|
||||
|
||||
public boolean getMovementDetection() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
boolean resultat = false;
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
return (restTemplate.getForObject(url_getDetection, boolean.class));
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("getTemperatureAlarm/")
|
||||
public boolean getTemperatureAlarm() {
|
||||
return (TemperatureAlarmActivated);
|
||||
}
|
||||
@GetMapping("setTemperatureAlarm/")
|
||||
public void setTemperatureAlarm(boolean active) {
|
||||
TemperatureAlarmActivated = active;
|
||||
}
|
||||
|
||||
@GetMapping("setMouvementAlarm/")
|
||||
public void setMouvementAlarm(boolean active) {
|
||||
MouvementAlarmActivated = active;
|
||||
}
|
||||
@GetMapping("getMouvementAlarm/")
|
||||
public boolean getMouvementAlarm() {
|
||||
return (MouvementAlarmActivated);
|
||||
}
|
||||
|
||||
@GetMapping("setCO2Alarm/")
|
||||
public void setCO2Alarm(boolean active) {
|
||||
CO2AlarmActivated = active;
|
||||
}
|
||||
@GetMapping("getCO2Alarm/")
|
||||
public boolean getCO2Alarm() {
|
||||
return (CO2AlarmActivated);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("run")
|
||||
public int run() throws Exception {
|
||||
|
||||
if (ControlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2();
|
||||
}
|
||||
|
||||
//Notification de mouvement Alarm
|
||||
if (MouvementAlarmActivated & (getMovementDetection())) {
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="data" val="Mouvement_GEI213"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Notification/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
|
||||
}
|
||||
|
||||
//Notification temperature elevée
|
||||
if (TemperatureAlarmActivated) {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
int temp;
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
temp = restTemplate.getForObject(url_getTemp,int.class);
|
||||
if ((temp > 35) | (temp<15)) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="location" val="GEI213"/>\n"
|
||||
+ " <str name="data" val="" + String.valueOf(temp) +""/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Temperature/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
}
|
||||
}
|
||||
|
||||
//Notification CO2 elevée
|
||||
if (CO2AlarmActivated) {
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
double CO2;
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
CO2 = restTemplate.getForObject(url_getCO2,double.class);
|
||||
if (CO2 > 1000) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="location" val="GEI213"/>\n"
|
||||
+ " <str name="data" val="" + String.valueOf(CO2) +""/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_CO2/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ControllerApplication.class, args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package Services.CaptMouv;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/CaptMouv/")
|
||||
public class CaptMouvApplication {
|
||||
|
||||
|
||||
private double range;
|
||||
private boolean detection;
|
||||
|
||||
|
||||
//Constructor
|
||||
public CaptMouvApplication() {
|
||||
|
||||
this.range = 7;
|
||||
this.detection = false;
|
||||
}
|
||||
|
||||
//Methodes
|
||||
@GetMapping("getRange/")
|
||||
public double getRange() {
|
||||
return range;
|
||||
}
|
||||
@GetMapping("setRange/")
|
||||
public void setRange(double range) {
|
||||
this.range = range;
|
||||
}
|
||||
@GetMapping("getDetection/")
|
||||
public boolean getDetection() {
|
||||
return detection;
|
||||
}
|
||||
@GetMapping("setDetection/")
|
||||
public void setDetection(boolean detection) {
|
||||
this.detection = detection;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CaptMouvApplication.class, args);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,355 @@
|
|||
package Services.Controller;
|
||||
import java.awt.Color;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.web.client.*;
|
||||
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/controller/")
|
||||
public class ControllerApplication {
|
||||
|
||||
private final String captMouvURI = "http://localhost:8081/CaptMouv/";
|
||||
private final String captTempURI = "http://localhost:8082/CaptTemp/";
|
||||
private final String captCO2URI = "http://localhost:8083/CaptCO2/";
|
||||
private final String captHumURI = "http://localhost:8084/";
|
||||
private final String automPorteURI = "http://localhost:8085/AutomPorteApplication/";
|
||||
private final String automFenetreURI = "http://localhost:8086/AutomFenetreApplication/";
|
||||
private final String automLumiereURI = "http://localhost:8087/AutomLumiereApplication/";
|
||||
private final String automChauffageURI = "http://localhost:8088/AutomChauffageApplication/";
|
||||
private final String simulationURI = "http://localhost:8089/Simulation/";
|
||||
|
||||
|
||||
boolean ControlLumiereAutomatique = false;
|
||||
boolean PorteFenetreAutomatique_TemperatureCO2 = false;
|
||||
boolean PorteFenetreAutomatique_CO2 = false;
|
||||
boolean MouvementAlarmActivated = false;
|
||||
boolean TemperatureAlarmActivated = false;
|
||||
boolean CO2AlarmActivated = false;
|
||||
|
||||
|
||||
//Controle de la lumiere automatique
|
||||
//Controle en fonction du mouvement
|
||||
@GetMapping("isControlLumiereAutomatiqueActivated/")
|
||||
private final boolean isControlLumiereAutomatique() {
|
||||
return ControlLumiereAutomatique;
|
||||
}
|
||||
@GetMapping("setControlLumiereAutomatique/")
|
||||
private final void setControlLumiereAutomatique(boolean controlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique = controlLumiereAutomatique;
|
||||
}
|
||||
|
||||
//Control de l'ouverture de la porte et fenetre
|
||||
//Control en fonction de la temperature et CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_TemperatureCO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_TemperatureCO2() {
|
||||
return PorteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_TemperatureCO2/")
|
||||
private final void setPorteFenetreAutomatique_TemperatureCO2(boolean porteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2 = porteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
//Controle en fonction du CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_CO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_CO2() {
|
||||
return PorteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_CO2/")
|
||||
private final void setPorteFenetreAutomatique_CO2(boolean porteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2 = porteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ControlLumiereAutomatique() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
String url_allumerLumiere = automLumiereURI + "setON/?oN=true";
|
||||
String url_eteindreLumiere = automLumiereURI + "setON/?oN=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
//return restTemplate.getForObject(test, String.class);
|
||||
|
||||
|
||||
if (restTemplate.getForObject(url_getDetection,boolean.class)) {
|
||||
restTemplate.getForObject(url_allumerLumiere,boolean.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_eteindreLumiere,boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_TemperatureCO2() {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getTemp,double.class)) > 30) | ((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_CO2() {
|
||||
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("getSalleOccupee/")
|
||||
public String SalleOccupe() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
boolean salle_occupe = restTemplate.getForObject(url_getDetection,boolean.class);
|
||||
|
||||
|
||||
return ("La salle est:" + String.valueOf(salle_occupe)) ;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureHeatingSystem/")
|
||||
public void setTemperatureHeatingSystem(int temp) {
|
||||
String url_setTemp = automChauffageURI + "setTemperatureSet/?temperatureSet=" + String.valueOf(temp);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject(url_setTemp,void.class);
|
||||
}
|
||||
|
||||
@GetMapping("getHeatingSystemONOFF/")
|
||||
public boolean getHeatingSystemONOFF() {
|
||||
String url_getONOFF = automChauffageURI + "isActive/";
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
return (restTemplate.getForObject(url_getONOFF,boolean.class));
|
||||
}
|
||||
|
||||
public boolean getMovementDetection() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
boolean resultat = false;
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
return (restTemplate.getForObject(url_getDetection, boolean.class));
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureAlarm/")
|
||||
public void setTemperatureAlarm(boolean active) {
|
||||
TemperatureAlarmActivated = active;
|
||||
}
|
||||
|
||||
@GetMapping("setMouvementAlarm/")
|
||||
public void setMouvementAlarm(boolean active) {
|
||||
MouvementAlarmActivated = active;
|
||||
}
|
||||
|
||||
@GetMapping("setCO2Alarm/")
|
||||
public void setCO2Alarm(boolean active) {
|
||||
CO2AlarmActivated = active;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("run")
|
||||
public int run() throws Exception {
|
||||
|
||||
if (ControlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2();
|
||||
}
|
||||
|
||||
//Notification de mouvement Alarm
|
||||
if (MouvementAlarmActivated & (getMovementDetection())) {
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="data" val="Mouvement_GEI213"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Notification/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
|
||||
}
|
||||
|
||||
//Notification temperature elevée
|
||||
if (TemperatureAlarmActivated) {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
int temp;
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
temp = restTemplate.getForObject(url_getTemp,int.class);
|
||||
if ((temp > 35) | (temp<15)) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="location" val="GEI213"/>\n"
|
||||
+ " <str name="data" val="" + String.valueOf(temp) +""/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Temperature/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
}
|
||||
}
|
||||
|
||||
//Notification CO2 elevée
|
||||
if (CO2AlarmActivated) {
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
double CO2;
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
CO2 = restTemplate.getForObject(url_getCO2,double.class);
|
||||
if (CO2 > 1000) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="location" val="GEI213"/>\n"
|
||||
+ " <str name="data" val="" + String.valueOf(CO2) +""/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_CO2/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
//Communication avec OneM2M
|
||||
/*
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="presence" val="1"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Capteur_Mouvement/DATA/";
|
||||
|
||||
ResponseEntity respEntity = restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
String resp = (String) respEntity.getBody();
|
||||
return resp;
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ControllerApplication.class, args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,281 @@
|
|||
package Services.Controller;
|
||||
import java.awt.Color;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.web.client.*;
|
||||
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/controller/")
|
||||
public class ControllerApplication {
|
||||
|
||||
private final String captMouvURI = "http://localhost:8081/CaptMouv/";
|
||||
private final String captTempURI = "http://localhost:8082/CaptTemp/";
|
||||
private final String captCO2URI = "http://localhost:8083/CaptCO2/";
|
||||
private final String captHumURI = "http://localhost:8084/";
|
||||
private final String automPorteURI = "http://localhost:8085/AutomPorteApplication/";
|
||||
private final String automFenetreURI = "http://localhost:8086/AutomFenetreApplication/";
|
||||
private final String automLumiereURI = "http://localhost:8087/AutomLumiereApplication/";
|
||||
private final String automChauffageURI = "http://localhost:8088/AutomChauffageApplication/";
|
||||
private final String simulationURI = "http://localhost:8089/Simulation/";
|
||||
|
||||
|
||||
boolean ControlLumiereAutomatique = false;
|
||||
boolean PorteFenetreAutomatique_TemperatureCO2 = false;
|
||||
boolean PorteFenetreAutomatique_CO2 = false;
|
||||
boolean MouvementAlarmActivated = false;
|
||||
boolean TemperatureAlarmActivated = false;
|
||||
|
||||
|
||||
//Controle de la lumiere automatique
|
||||
//Controle en fonction du mouvement
|
||||
@GetMapping("isControlLumiereAutomatiqueActivated/")
|
||||
private final boolean isControlLumiereAutomatique() {
|
||||
return ControlLumiereAutomatique;
|
||||
}
|
||||
@GetMapping("setControlLumiereAutomatique/")
|
||||
private final void setControlLumiereAutomatique(boolean controlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique = controlLumiereAutomatique;
|
||||
}
|
||||
|
||||
//Control de l'ouverture de la porte et fenetre
|
||||
//Control en fonction de la temperature et CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_TemperatureCO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_TemperatureCO2() {
|
||||
return PorteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_TemperatureCO2/")
|
||||
private final void setPorteFenetreAutomatique_TemperatureCO2(boolean porteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2 = porteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
//Controle en fonction du CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_CO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_CO2() {
|
||||
return PorteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_CO2/")
|
||||
private final void setPorteFenetreAutomatique_CO2(boolean porteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2 = porteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ControlLumiereAutomatique() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
String url_allumerLumiere = automLumiereURI + "setON/?oN=true";
|
||||
String url_eteindreLumiere = automLumiereURI + "setON/?oN=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
//return restTemplate.getForObject(test, String.class);
|
||||
|
||||
|
||||
if (restTemplate.getForObject(url_getDetection,boolean.class)) {
|
||||
restTemplate.getForObject(url_allumerLumiere,boolean.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_eteindreLumiere,boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_TemperatureCO2() {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getTemp,double.class)) > 30) | ((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_CO2() {
|
||||
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("getSalleOccupee/")
|
||||
public String SalleOccupe() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
boolean salle_occupe = restTemplate.getForObject(url_getDetection,boolean.class);
|
||||
|
||||
|
||||
return ("La salle est:" + String.valueOf(salle_occupe)) ;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureHeatingSystem/")
|
||||
public void setTemperatureHeatingSystem(int temp) {
|
||||
String url_setTemp = automChauffageURI + "setTemperatureSet/?temperatureSet=" + String.valueOf(temp);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject(url_setTemp,void.class);
|
||||
}
|
||||
|
||||
@GetMapping("getHeatingSystemONOFF/")
|
||||
public boolean getHeatingSystemONOFF() {
|
||||
String url_getONOFF = automChauffageURI + "isActive/";
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
return (restTemplate.getForObject(url_getONOFF,boolean.class));
|
||||
}
|
||||
|
||||
public boolean getMovementDetection() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
boolean resultat = false;
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
return (restTemplate.getForObject(url_getDetection, boolean.class));
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureAlarm/")
|
||||
public void setTemperatureAlarm(boolean active) {
|
||||
TemperatureAlarmActivated = active;
|
||||
}
|
||||
|
||||
@GetMapping("setMouvementAlarm/")
|
||||
public void setMouvementAlarm(boolean active) {
|
||||
MouvementAlarmActivated = active;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("run")
|
||||
public int run() throws Exception {
|
||||
|
||||
if (ControlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2();
|
||||
}
|
||||
if (MouvementAlarmActivated & (getMovementDetection())) {
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="data" val="Mouvement_GEI213"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Notification/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
|
||||
return 3;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
//Communication avec OneM2M
|
||||
/*
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="presence" val="1"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Capteur_Mouvement/DATA/";
|
||||
|
||||
ResponseEntity respEntity = restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
String resp = (String) respEntity.getBody();
|
||||
return resp;
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ControllerApplication.class, args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,271 @@
|
|||
package Services.Controller;
|
||||
import java.awt.Color;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.web.client.*;
|
||||
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/controller/")
|
||||
public class ControllerApplication {
|
||||
|
||||
private final String captMouvURI = "http://localhost:8081/CaptMouv/";
|
||||
private final String captTempURI = "http://localhost:8082/CaptTemp/";
|
||||
private final String captCO2URI = "http://localhost:8083/CaptCO2/";
|
||||
private final String captHumURI = "http://localhost:8084/";
|
||||
private final String automPorteURI = "http://localhost:8085/AutomPorteApplication/";
|
||||
private final String automFenetreURI = "http://localhost:8086/AutomFenetreApplication/";
|
||||
private final String automLumiereURI = "http://localhost:8087/AutomLumiereApplication/";
|
||||
private final String automChauffageURI = "http://localhost:8088/AutomChauffageApplication/";
|
||||
private final String simulationURI = "http://localhost:8089/Simulation/";
|
||||
|
||||
|
||||
boolean ControlLumiereAutomatique = false;
|
||||
boolean PorteFenetreAutomatique_TemperatureCO2 = false;
|
||||
boolean PorteFenetreAutomatique_CO2 = false;
|
||||
boolean AlarmActivated = false;
|
||||
|
||||
|
||||
//Controle de la lumiere automatique
|
||||
//Controle en fonction du mouvement
|
||||
@GetMapping("isControlLumiereAutomatiqueActivated/")
|
||||
private final boolean isControlLumiereAutomatique() {
|
||||
return ControlLumiereAutomatique;
|
||||
}
|
||||
@GetMapping("setControlLumiereAutomatique/")
|
||||
private final void setControlLumiereAutomatique(boolean controlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique = controlLumiereAutomatique;
|
||||
}
|
||||
|
||||
//Control de l'ouverture de la porte et fenetre
|
||||
//Control en fonction de la temperature et CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_TemperatureCO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_TemperatureCO2() {
|
||||
return PorteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_TemperatureCO2/")
|
||||
private final void setPorteFenetreAutomatique_TemperatureCO2(boolean porteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2 = porteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
//Controle en fonction du CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_CO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_CO2() {
|
||||
return PorteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_CO2/")
|
||||
private final void setPorteFenetreAutomatique_CO2(boolean porteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2 = porteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ControlLumiereAutomatique() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
String url_allumerLumiere = automLumiereURI + "setON/?oN=true";
|
||||
String url_eteindreLumiere = automLumiereURI + "setON/?oN=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
//return restTemplate.getForObject(test, String.class);
|
||||
|
||||
|
||||
if (restTemplate.getForObject(url_getDetection,boolean.class)) {
|
||||
restTemplate.getForObject(url_allumerLumiere,boolean.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_eteindreLumiere,boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_TemperatureCO2() {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getTemp,double.class)) > 30) | ((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_CO2() {
|
||||
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("getSalleOccupee/")
|
||||
public String SalleOccupe() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
boolean salle_occupe = restTemplate.getForObject(url_getDetection,boolean.class);
|
||||
|
||||
|
||||
return ("La salle est:" + String.valueOf(salle_occupe)) ;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureHeatingSystem/")
|
||||
public void setTemperatureHeatingSystem(int temp) {
|
||||
String url_setTemp = automChauffageURI + "setTemperatureSet/?temperatureSet=" + String.valueOf(temp);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject(url_setTemp,void.class);
|
||||
}
|
||||
|
||||
@GetMapping("getHeatingSystemONOFF/")
|
||||
public boolean getHeatingSystemONOFF() {
|
||||
String url_getONOFF = automChauffageURI + "isActive/";
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
return (restTemplate.getForObject(url_getONOFF,boolean.class));
|
||||
}
|
||||
|
||||
public boolean getMovementDetection() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
boolean resultat = false;
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
return (restTemplate.getForObject(url_getDetection, boolean.class));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("run")
|
||||
public int run() throws Exception {
|
||||
|
||||
if (ControlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2();
|
||||
}
|
||||
if (AlarmActivated & (getMovementDetection())) {
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="data" val="Mouvement_GEI213"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Notification/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
//Communication avec OneM2M
|
||||
/*
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="presence" val="1"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Capteur_Mouvement/DATA/";
|
||||
|
||||
ResponseEntity respEntity = restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
String resp = (String) respEntity.getBody();
|
||||
return resp;
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ControllerApplication.class, args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,334 @@
|
|||
package Services.Controller;
|
||||
import java.awt.Color;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.web.client.*;
|
||||
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/controller/")
|
||||
public class ControllerApplication {
|
||||
|
||||
private final String captMouvURI = "http://localhost:8081/CaptMouv/";
|
||||
private final String captTempURI = "http://localhost:8082/CaptTemp/";
|
||||
private final String captCO2URI = "http://localhost:8083/CaptCO2/";
|
||||
private final String captHumURI = "http://localhost:8084/";
|
||||
private final String automPorteURI = "http://localhost:8085/AutomPorteApplication/";
|
||||
private final String automFenetreURI = "http://localhost:8086/AutomFenetreApplication/";
|
||||
private final String automLumiereURI = "http://localhost:8087/AutomLumiereApplication/";
|
||||
private final String automChauffageURI = "http://localhost:8088/AutomChauffageApplication/";
|
||||
private final String simulationURI = "http://localhost:8089/Simulation/";
|
||||
|
||||
|
||||
boolean ControlLumiereAutomatique = false;
|
||||
boolean PorteFenetreAutomatique_TemperatureCO2 = false;
|
||||
boolean PorteFenetreAutomatique_CO2 = false;
|
||||
boolean MouvementAlarmActivated = false;
|
||||
boolean TemperatureAlarmActivated = false;
|
||||
boolean CO2AlarmActivated = false;
|
||||
|
||||
|
||||
//Controle de la lumiere automatique
|
||||
//Controle en fonction du mouvement
|
||||
@GetMapping("isControlLumiereAutomatiqueActivated/")
|
||||
private final boolean isControlLumiereAutomatique() {
|
||||
return ControlLumiereAutomatique;
|
||||
}
|
||||
@GetMapping("setControlLumiereAutomatique/")
|
||||
private final void setControlLumiereAutomatique(boolean controlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique = controlLumiereAutomatique;
|
||||
}
|
||||
|
||||
//Control de l'ouverture de la porte et fenetre
|
||||
//Control en fonction de la temperature et CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_TemperatureCO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_TemperatureCO2() {
|
||||
return PorteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_TemperatureCO2/")
|
||||
private final void setPorteFenetreAutomatique_TemperatureCO2(boolean porteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2 = porteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
//Controle en fonction du CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_CO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_CO2() {
|
||||
return PorteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_CO2/")
|
||||
private final void setPorteFenetreAutomatique_CO2(boolean porteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2 = porteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ControlLumiereAutomatique() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
String url_allumerLumiere = automLumiereURI + "setON/?oN=true";
|
||||
String url_eteindreLumiere = automLumiereURI + "setON/?oN=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
//return restTemplate.getForObject(test, String.class);
|
||||
|
||||
|
||||
if (restTemplate.getForObject(url_getDetection,boolean.class)) {
|
||||
restTemplate.getForObject(url_allumerLumiere,boolean.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_eteindreLumiere,boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_TemperatureCO2() {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getTemp,double.class)) > 30) | ((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_CO2() {
|
||||
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("getSalleOccupee/")
|
||||
public String SalleOccupe() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
boolean salle_occupe = restTemplate.getForObject(url_getDetection,boolean.class);
|
||||
|
||||
|
||||
return ("La salle est:" + String.valueOf(salle_occupe)) ;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureHeatingSystem/")
|
||||
public void setTemperatureHeatingSystem(int temp) {
|
||||
String url_setTemp = automChauffageURI + "setTemperatureSet/?temperatureSet=" + String.valueOf(temp);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject(url_setTemp,void.class);
|
||||
}
|
||||
|
||||
@GetMapping("getHeatingSystemONOFF/")
|
||||
public boolean getHeatingSystemONOFF() {
|
||||
String url_getONOFF = automChauffageURI + "isActive/";
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
return (restTemplate.getForObject(url_getONOFF,boolean.class));
|
||||
}
|
||||
|
||||
public boolean getMovementDetection() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
boolean resultat = false;
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
return (restTemplate.getForObject(url_getDetection, boolean.class));
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("getTemperatureAlarm/")
|
||||
public boolean getTemperatureAlarm() {
|
||||
return (TemperatureAlarmActivated);
|
||||
}
|
||||
@GetMapping("setTemperatureAlarm/")
|
||||
public void setTemperatureAlarm(boolean active) {
|
||||
TemperatureAlarmActivated = active;
|
||||
}
|
||||
|
||||
@GetMapping("setMouvementAlarm/")
|
||||
public void setMouvementAlarm(boolean active) {
|
||||
MouvementAlarmActivated = active;
|
||||
}
|
||||
|
||||
@GetMapping("setCO2Alarm/")
|
||||
public void setCO2Alarm(boolean active) {
|
||||
CO2AlarmActivated = active;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("run")
|
||||
public int run() throws Exception {
|
||||
|
||||
if (ControlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2();
|
||||
}
|
||||
|
||||
//Notification de mouvement Alarm
|
||||
if (MouvementAlarmActivated & (getMovementDetection())) {
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="data" val="Mouvement_GEI213"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Notification/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
|
||||
}
|
||||
|
||||
//Notification temperature elevée
|
||||
if (TemperatureAlarmActivated) {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
int temp;
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
temp = restTemplate.getForObject(url_getTemp,int.class);
|
||||
if ((temp > 35) | (temp<15)) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="location" val="GEI213"/>\n"
|
||||
+ " <str name="data" val="" + String.valueOf(temp) +""/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Temperature/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
}
|
||||
}
|
||||
|
||||
//Notification CO2 elevée
|
||||
if (CO2AlarmActivated) {
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
double CO2;
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
CO2 = restTemplate.getForObject(url_getCO2,double.class);
|
||||
if (CO2 > 1000) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="location" val="GEI213"/>\n"
|
||||
+ " <str name="data" val="" + String.valueOf(CO2) +""/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_CO2/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ControllerApplication.class, args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,225 @@
|
|||
package Services.Controller;
|
||||
import java.awt.Color;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.web.client.*;
|
||||
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/controller/")
|
||||
public class ControllerApplication {
|
||||
|
||||
private final String captMouvURI = "http://localhost:8081/CaptMouv/";
|
||||
private final String captTempURI = "http://localhost:8082/CaptTemp/";
|
||||
private final String captCO2URI = "http://localhost:8083/CaptCO2/";
|
||||
private final String captHumURI = "http://localhost:8084/";
|
||||
private final String automPorteURI = "http://localhost:8085/AutomPorteApplication/";
|
||||
private final String automFenetreURI = "http://localhost:8086/AutomFenetreApplication/";
|
||||
private final String automLumiereURI = "http://localhost:8087/AutomLumiereApplication/";
|
||||
private final String automChauffageURI = "http://localhost:8088/AutomChauffageApplication/";
|
||||
private final String simulationURI = "http://localhost:8089/Simulation/";
|
||||
|
||||
|
||||
boolean ControlLumiereAutomatique = false;
|
||||
boolean PorteFenetreAutomatique_TemperatureCO2 = false;
|
||||
boolean PorteFenetreAutomatique_CO2 = false;
|
||||
|
||||
|
||||
|
||||
//Controle de la lumiere automatique
|
||||
//Controle en fonction du mouvement
|
||||
@GetMapping("isControlLumiereAutomatiqueActivated/")
|
||||
private final boolean isControlLumiereAutomatique() {
|
||||
return ControlLumiereAutomatique;
|
||||
}
|
||||
@GetMapping("setControlLumiereAutomatique/")
|
||||
private final void setControlLumiereAutomatique(boolean controlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique = controlLumiereAutomatique;
|
||||
}
|
||||
|
||||
//Control de l'ouverture de la porte et fenetre
|
||||
//Control en fonction de la temperature et CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_TemperatureCO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_TemperatureCO2() {
|
||||
return PorteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_TemperatureCO2/")
|
||||
private final void setPorteFenetreAutomatique_TemperatureCO2(boolean porteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2 = porteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
//Controle en fonction du CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_CO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_CO2() {
|
||||
return PorteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_CO2/")
|
||||
private final void setPorteFenetreAutomatique_CO2(boolean porteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2 = porteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ControlLumiereAutomatique() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
String url_allumerLumiere = automLumiereURI + "setON/?oN=true";
|
||||
String url_eteindreLumiere = automLumiereURI + "setON/?oN=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
//return restTemplate.getForObject(test, String.class);
|
||||
|
||||
|
||||
if (restTemplate.getForObject(url_getDetection,boolean.class)) {
|
||||
restTemplate.getForObject(url_allumerLumiere,boolean.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_eteindreLumiere,boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_TemperatureCO2() {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getTemp,double.class)) > 30) | ((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_CO2() {
|
||||
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("getSalleOccupee/")
|
||||
public String SalleOccupe() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
boolean salle_occupe = restTemplate.getForObject(url_getDetection,boolean.class);
|
||||
|
||||
|
||||
return ("La salle est:" + String.valueOf(salle_occupe)) ;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureHeatingSystem/")
|
||||
public void setTemperatureHeatingSystem(double temp) {
|
||||
String url_setTemp = automChauffageURI + "setTemperatureSet/";
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject(url_setTemp,void.class);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("run")
|
||||
public int run() throws Exception {
|
||||
/*
|
||||
if (ControlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
return 0;
|
||||
//Communication avec OneM2M
|
||||
/*
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="presence" val="1"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Capteur_Mouvement/DATA/";
|
||||
|
||||
ResponseEntity respEntity = restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
String resp = (String) respEntity.getBody();
|
||||
return resp;
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ControllerApplication.class, args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,314 @@
|
|||
package Services.Controller;
|
||||
import java.awt.Color;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.web.client.*;
|
||||
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/controller/")
|
||||
public class ControllerApplication {
|
||||
|
||||
private final String captMouvURI = "http://localhost:8081/CaptMouv/";
|
||||
private final String captTempURI = "http://localhost:8082/CaptTemp/";
|
||||
private final String captCO2URI = "http://localhost:8083/CaptCO2/";
|
||||
private final String captHumURI = "http://localhost:8084/";
|
||||
private final String automPorteURI = "http://localhost:8085/AutomPorteApplication/";
|
||||
private final String automFenetreURI = "http://localhost:8086/AutomFenetreApplication/";
|
||||
private final String automLumiereURI = "http://localhost:8087/AutomLumiereApplication/";
|
||||
private final String automChauffageURI = "http://localhost:8088/AutomChauffageApplication/";
|
||||
private final String simulationURI = "http://localhost:8089/Simulation/";
|
||||
|
||||
|
||||
boolean ControlLumiereAutomatique = false;
|
||||
boolean PorteFenetreAutomatique_TemperatureCO2 = false;
|
||||
boolean PorteFenetreAutomatique_CO2 = false;
|
||||
boolean MouvementAlarmActivated = false;
|
||||
boolean TemperatureAlarmActivated = false;
|
||||
|
||||
|
||||
//Controle de la lumiere automatique
|
||||
//Controle en fonction du mouvement
|
||||
@GetMapping("isControlLumiereAutomatiqueActivated/")
|
||||
private final boolean isControlLumiereAutomatique() {
|
||||
return ControlLumiereAutomatique;
|
||||
}
|
||||
@GetMapping("setControlLumiereAutomatique/")
|
||||
private final void setControlLumiereAutomatique(boolean controlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique = controlLumiereAutomatique;
|
||||
}
|
||||
|
||||
//Control de l'ouverture de la porte et fenetre
|
||||
//Control en fonction de la temperature et CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_TemperatureCO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_TemperatureCO2() {
|
||||
return PorteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_TemperatureCO2/")
|
||||
private final void setPorteFenetreAutomatique_TemperatureCO2(boolean porteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2 = porteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
//Controle en fonction du CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_CO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_CO2() {
|
||||
return PorteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_CO2/")
|
||||
private final void setPorteFenetreAutomatique_CO2(boolean porteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2 = porteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ControlLumiereAutomatique() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
String url_allumerLumiere = automLumiereURI + "setON/?oN=true";
|
||||
String url_eteindreLumiere = automLumiereURI + "setON/?oN=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
//return restTemplate.getForObject(test, String.class);
|
||||
|
||||
|
||||
if (restTemplate.getForObject(url_getDetection,boolean.class)) {
|
||||
restTemplate.getForObject(url_allumerLumiere,boolean.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_eteindreLumiere,boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_TemperatureCO2() {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getTemp,double.class)) > 30) | ((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_CO2() {
|
||||
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("getSalleOccupee/")
|
||||
public String SalleOccupe() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
boolean salle_occupe = restTemplate.getForObject(url_getDetection,boolean.class);
|
||||
|
||||
|
||||
return ("La salle est:" + String.valueOf(salle_occupe)) ;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureHeatingSystem/")
|
||||
public void setTemperatureHeatingSystem(int temp) {
|
||||
String url_setTemp = automChauffageURI + "setTemperatureSet/?temperatureSet=" + String.valueOf(temp);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject(url_setTemp,void.class);
|
||||
}
|
||||
|
||||
@GetMapping("getHeatingSystemONOFF/")
|
||||
public boolean getHeatingSystemONOFF() {
|
||||
String url_getONOFF = automChauffageURI + "isActive/";
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
return (restTemplate.getForObject(url_getONOFF,boolean.class));
|
||||
}
|
||||
|
||||
public boolean getMovementDetection() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
boolean resultat = false;
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
return (restTemplate.getForObject(url_getDetection, boolean.class));
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureAlarm/")
|
||||
public void setTemperatureAlarm(boolean active) {
|
||||
TemperatureAlarmActivated = active;
|
||||
}
|
||||
|
||||
@GetMapping("setMouvementAlarm/")
|
||||
public void setMouvementAlarm(boolean active) {
|
||||
MouvementAlarmActivated = active;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("run")
|
||||
public int run() throws Exception {
|
||||
|
||||
if (ControlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2();
|
||||
}
|
||||
|
||||
//Notification de mouvement Alarm
|
||||
if (MouvementAlarmActivated & (getMovementDetection())) {
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="data" val="Mouvement_GEI213"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Notification/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
|
||||
}
|
||||
|
||||
//Notification temperature elevée
|
||||
if (TemperatureAlarmActivated) {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
int temp;
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
temp = restTemplate.getForObject(url_getTemp,int.class);
|
||||
if ((temp > 35) | (temp<15)) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="location" val="GEI213"/>\n"
|
||||
+ " <str name="data" val="" + String.valueOf(temp) +""/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Temperature/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
//Communication avec OneM2M
|
||||
/*
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="presence" val="1"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Capteur_Mouvement/DATA/";
|
||||
|
||||
ResponseEntity respEntity = restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
String resp = (String) respEntity.getBody();
|
||||
return resp;
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ControllerApplication.class, args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package Services.CaptMouv;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/CaptMouv/")
|
||||
public class CaptMouvApplication {
|
||||
|
||||
|
||||
private double range;
|
||||
private boolean detection;
|
||||
private int nbrDetection;
|
||||
|
||||
|
||||
//Constructor
|
||||
public CaptMouvApplication() {
|
||||
|
||||
this.range = 7;
|
||||
this.detection = false;
|
||||
this.nbrDetection = 0;
|
||||
}
|
||||
|
||||
//Methodes
|
||||
@GetMapping("getRange/")
|
||||
public double getRange() {
|
||||
return range;
|
||||
}
|
||||
@GetMapping("setRange/")
|
||||
public void setRange(double range) {
|
||||
this.range = range;
|
||||
}
|
||||
@GetMapping("getDetection/")
|
||||
public boolean getDetection() {
|
||||
return this.detection;
|
||||
}
|
||||
@GetMapping("setDetection/")
|
||||
public void setDetection(boolean detection) {
|
||||
this.detection = detection;
|
||||
}
|
||||
|
||||
@GetMapping("getNbrDetection/")
|
||||
public boolean getnbrDetection() {
|
||||
return this.nbrDetection;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CaptMouvApplication.class, args);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,358 @@
|
|||
package Services.Controller;
|
||||
import java.awt.Color;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.web.client.*;
|
||||
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/controller/")
|
||||
public class ControllerApplication {
|
||||
|
||||
private final String captMouvURI = "http://localhost:8081/CaptMouv/";
|
||||
private final String captTempURI = "http://localhost:8082/CaptTemp/";
|
||||
private final String captCO2URI = "http://localhost:8083/CaptCO2/";
|
||||
private final String captHumURI = "http://localhost:8084/CaptHum/";
|
||||
private final String automPorteURI = "http://localhost:8085/AutomPorteApplication/";
|
||||
private final String automFenetreURI = "http://localhost:8086/AutomFenetreApplication/";
|
||||
private final String automLumiereURI = "http://localhost:8087/AutomLumiereApplication/";
|
||||
private final String automChauffageURI = "http://localhost:8088/AutomChauffageApplication/";
|
||||
private final String simulationURI = "http://localhost:8089/Simulation/";
|
||||
|
||||
|
||||
boolean ControlLumiereAutomatique = false;
|
||||
boolean PorteFenetreAutomatique_TemperatureCO2 = false;
|
||||
boolean PorteFenetreAutomatique_CO2 = false;
|
||||
boolean MouvementAlarmActivated = false;
|
||||
boolean TemperatureAlarmActivated = false;
|
||||
boolean CO2AlarmActivated = false;
|
||||
|
||||
|
||||
//Controle de la lumiere automatique
|
||||
//Controle en fonction du mouvement
|
||||
@GetMapping("isControlLumiereAutomatiqueActivated/")
|
||||
private final boolean isControlLumiereAutomatique() {
|
||||
return ControlLumiereAutomatique;
|
||||
}
|
||||
@GetMapping("setControlLumiereAutomatique/")
|
||||
private final void setControlLumiereAutomatique(boolean controlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique = controlLumiereAutomatique;
|
||||
}
|
||||
|
||||
//Control de l'ouverture de la porte et fenetre
|
||||
//Control en fonction de la temperature et CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_TemperatureCO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_TemperatureCO2() {
|
||||
return PorteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_TemperatureCO2/")
|
||||
private final void setPorteFenetreAutomatique_TemperatureCO2(boolean porteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2 = porteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
//Controle en fonction du CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_CO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_CO2() {
|
||||
return PorteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_CO2/")
|
||||
private final void setPorteFenetreAutomatique_CO2(boolean porteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2 = porteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ControlLumiereAutomatique() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
String url_allumerLumiere = automLumiereURI + "setON/?oN=true";
|
||||
String url_eteindreLumiere = automLumiereURI + "setON/?oN=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
//return restTemplate.getForObject(test, String.class);
|
||||
|
||||
|
||||
if (restTemplate.getForObject(url_getDetection,boolean.class)) {
|
||||
restTemplate.getForObject(url_allumerLumiere,boolean.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_eteindreLumiere,boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_TemperatureCO2() {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getTemp,double.class)) > 30) | ((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_CO2() {
|
||||
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("getSalleOccupee/")
|
||||
public String SalleOccupe() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
boolean salle_occupe = restTemplate.getForObject(url_getDetection,boolean.class);
|
||||
|
||||
|
||||
return ("La salle est:" + String.valueOf(salle_occupe)) ;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureHeatingSystem/")
|
||||
public void setTemperatureHeatingSystem(int temp) {
|
||||
String url_setTemp = automChauffageURI + "setTemperatureSet/?temperatureSet=" + String.valueOf(temp);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject(url_setTemp,void.class);
|
||||
}
|
||||
|
||||
@GetMapping("getHeatingSystemONOFF/")
|
||||
public boolean getHeatingSystemONOFF() {
|
||||
String url_getONOFF = automChauffageURI + "isActive/";
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
return (restTemplate.getForObject(url_getONOFF,boolean.class));
|
||||
}
|
||||
|
||||
public boolean getMovementDetection() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
boolean resultat = false;
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
return (restTemplate.getForObject(url_getDetection, boolean.class));
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("getTemperatureAlarm/")
|
||||
public boolean getTemperatureAlarm() {
|
||||
return (TemperatureAlarmActivated);
|
||||
}
|
||||
@GetMapping("setTemperatureAlarm/")
|
||||
public void setTemperatureAlarm(boolean active) {
|
||||
TemperatureAlarmActivated = active;
|
||||
}
|
||||
|
||||
@GetMapping("setMouvementAlarm/")
|
||||
public void setMouvementAlarm(boolean active) {
|
||||
MouvementAlarmActivated = active;
|
||||
}
|
||||
@GetMapping("getMouvementAlarm/")
|
||||
public boolean getMouvementAlarm() {
|
||||
return (MouvementAlarmActivated);
|
||||
}
|
||||
|
||||
@GetMapping("setCO2Alarm/")
|
||||
public void setCO2Alarm(boolean active) {
|
||||
CO2AlarmActivated = active;
|
||||
}
|
||||
@GetMapping("getCO2Alarm/")
|
||||
public boolean getCO2Alarm() {
|
||||
return (CO2AlarmActivated);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@GetMapping("run")
|
||||
public int run() throws Exception {
|
||||
|
||||
if (ControlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2();
|
||||
}
|
||||
|
||||
//Notification de mouvement Alarm
|
||||
if (MouvementAlarmActivated & (getMovementDetection())) {
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="data" val="Mouvement_GEI213"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Notification/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
|
||||
}
|
||||
|
||||
//Notification temperature elevée
|
||||
if (TemperatureAlarmActivated) {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
int temp;
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
temp = restTemplate.getForObject(url_getTemp,int.class);
|
||||
if ((temp > 35) | (temp<15)) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="location" val="GEI213"/>\n"
|
||||
+ " <str name="data" val="" + String.valueOf(temp) +""/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Temperature/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
}
|
||||
}
|
||||
|
||||
//Notification CO2 elevée
|
||||
if (CO2AlarmActivated) {
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
double CO2;
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
CO2 = restTemplate.getForObject(url_getCO2,double.class);
|
||||
if (CO2 > 1000) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="location" val="GEI213"/>\n"
|
||||
+ " <str name="data" val="" + String.valueOf(CO2) +""/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_CO2/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
}
|
||||
}
|
||||
|
||||
//Gestion de la date:
|
||||
Date date = new Date();
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
int day = date.getDay();
|
||||
if ((day==0)|(day==6)) {
|
||||
//On eteint le chauffage
|
||||
restTemplate.getForObject(automChauffageURI+"setActive/?active=false",double.class);
|
||||
//On eteint la lumière
|
||||
restTemplate.getForObject(automLumiereURI+"setON/?oN=false",double.class);
|
||||
//On ferme les fenetres
|
||||
restTemplate.getForObject(automFenetreURI+"setOpen/?open=false",double.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ControllerApplication.class, args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,225 @@
|
|||
package Services.Controller;
|
||||
import java.awt.Color;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.web.client.*;
|
||||
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/controller/")
|
||||
public class ControllerApplication {
|
||||
|
||||
private final String captMouvURI = "http://localhost:8081/CaptMouv/";
|
||||
private final String captTempURI = "http://localhost:8082/CaptTemp/";
|
||||
private final String captCO2URI = "http://localhost:8083/CaptCO2/";
|
||||
private final String captHumURI = "http://localhost:8084/";
|
||||
private final String automPorteURI = "http://localhost:8085/AutomPorteApplication/";
|
||||
private final String automFenetreURI = "http://localhost:8086/AutomFenetreApplication/";
|
||||
private final String automLumiereURI = "http://localhost:8087/AutomLumiereApplication/";
|
||||
private final String automChauffageURI = "http://localhost:8088/AutomChauffageApplication/";
|
||||
private final String simulationURI = "http://localhost:8089/Simulation/";
|
||||
|
||||
|
||||
boolean ControlLumiereAutomatique = false;
|
||||
boolean PorteFenetreAutomatique_TemperatureCO2 = false;
|
||||
boolean PorteFenetreAutomatique_CO2 = false;
|
||||
|
||||
|
||||
|
||||
//Controle de la lumiere automatique
|
||||
//Controle en fonction du mouvement
|
||||
@GetMapping("isControlLumiereAutomatiqueActivated/")
|
||||
private final boolean isControlLumiereAutomatique() {
|
||||
return ControlLumiereAutomatique;
|
||||
}
|
||||
@GetMapping("setControlLumiereAutomatique/")
|
||||
private final void setControlLumiereAutomatique(boolean controlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique = controlLumiereAutomatique;
|
||||
}
|
||||
|
||||
//Control de l'ouverture de la porte et fenetre
|
||||
//Control en fonction de la temperature et CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_TemperatureCO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_TemperatureCO2() {
|
||||
return PorteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_TemperatureCO2/")
|
||||
private final void setPorteFenetreAutomatique_TemperatureCO2(boolean porteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2 = porteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
//Controle en fonction du CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_CO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_CO2() {
|
||||
return PorteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_CO2/")
|
||||
private final void setPorteFenetreAutomatique_CO2(boolean porteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2 = porteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ControlLumiereAutomatique() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
String url_allumerLumiere = automLumiereURI + "setON/?oN=true";
|
||||
String url_eteindreLumiere = automLumiereURI + "setON/?oN=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
//return restTemplate.getForObject(test, String.class);
|
||||
|
||||
|
||||
if (restTemplate.getForObject(url_getDetection,boolean.class)) {
|
||||
restTemplate.getForObject(url_allumerLumiere,boolean.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_eteindreLumiere,boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_TemperatureCO2() {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getTemp,double.class)) > 30) | ((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_CO2() {
|
||||
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("getSalleOccupee/")
|
||||
public String SalleOccupe() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
boolean salle_occupe = restTemplate.getForObject(url_getDetection,boolean.class);
|
||||
|
||||
|
||||
return ("La salle est:" + String.valueOf(salle_occupe)) ;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureHeatingSystem/")
|
||||
public void setTemperatureHeatingSystem(int temp) {
|
||||
String url_setTemp = automChauffageURI + "setTemperatureSet/";
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject(url_setTemp,void.class);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("run")
|
||||
public int run() throws Exception {
|
||||
/*
|
||||
if (ControlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
return 0;
|
||||
//Communication avec OneM2M
|
||||
/*
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="presence" val="1"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Capteur_Mouvement/DATA/";
|
||||
|
||||
ResponseEntity respEntity = restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
String resp = (String) respEntity.getBody();
|
||||
return resp;
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ControllerApplication.class, args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,216 @@
|
|||
package Services.Controller;
|
||||
import java.awt.Color;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.web.client.*;
|
||||
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/controller/")
|
||||
public class ControllerApplication {
|
||||
|
||||
private final String captMouvURI = "http://localhost:8081/CaptMouv/";
|
||||
private final String captTempURI = "http://localhost:8082/CaptTemp/";
|
||||
private final String captCO2URI = "http://localhost:8083/CaptCO2/";
|
||||
private final String captHumURI = "http://localhost:8084/";
|
||||
private final String automPorteURI = "http://localhost:8085/AutomPorteApplication/";
|
||||
private final String automFenetreURI = "http://localhost:8086/AutomFenetreApplication/";
|
||||
private final String automLumiereURI = "http://localhost:8087/AutomLumiereApplication/";
|
||||
private final String automChauffageURI = "http://localhost:8088/AutomChauffageApplication/";
|
||||
private final String simulationURI = "http://localhost:8089/Simulation/";
|
||||
|
||||
|
||||
boolean ControlLumiereAutomatique = false;
|
||||
boolean PorteFenetreAutomatique_TemperatureCO2 = false;
|
||||
boolean PorteFenetreAutomatique_CO2 = false;
|
||||
|
||||
|
||||
|
||||
//Controle de la lumiere automatique
|
||||
//Controle en fonction du mouvement
|
||||
@GetMapping("isControlLumiereAutomatiqueActivated/")
|
||||
private final boolean isControlLumiereAutomatique() {
|
||||
return ControlLumiereAutomatique;
|
||||
}
|
||||
@GetMapping("setControlLumiereAutomatique/")
|
||||
private final void setControlLumiereAutomatique(boolean controlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique = controlLumiereAutomatique;
|
||||
}
|
||||
|
||||
//Control de l'ouverture de la porte et fenetre
|
||||
//Control en fonction de la temperature et CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_TemperatureCO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_TemperatureCO2() {
|
||||
return PorteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_TemperatureCO2/")
|
||||
private final void setPorteFenetreAutomatique_TemperatureCO2(boolean porteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2 = porteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
//Controle en fonction du CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_CO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_CO2() {
|
||||
return PorteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_CO2/")
|
||||
private final void setPorteFenetreAutomatique_CO2(boolean porteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2 = porteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ControlLumiereAutomatique() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
String url_allumerLumiere = automLumiereURI + "setON/?oN=true";
|
||||
String url_eteindreLumiere = automLumiereURI + "setON/?oN=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
//return restTemplate.getForObject(test, String.class);
|
||||
|
||||
|
||||
if (restTemplate.getForObject(url_getDetection,boolean.class)) {
|
||||
restTemplate.getForObject(url_allumerLumiere,boolean.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_eteindreLumiere,boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_TemperatureCO2() {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getTemp,double.class)) > 30) | ((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_CO2() {
|
||||
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("run")
|
||||
public String run() throws Exception {
|
||||
/*
|
||||
if (ControlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2();
|
||||
}
|
||||
*/
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="presence" val="1"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Capteur_Mouvement/DATA/";
|
||||
|
||||
ResponseEntity respEntity = restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
String resp = (String) respEntity.getBody();
|
||||
return resp;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ControllerApplication.class, args);
|
||||
|
||||
JFrame f= new JFrame("Panel Example");
|
||||
JPanel panel=new JPanel();
|
||||
panel.setBounds(40,80,200,200);
|
||||
panel.setBackground(Color.gray);
|
||||
JButton b1=new JButton("Button 1");
|
||||
b1.setBounds(50,100,80,30);
|
||||
b1.setBackground(Color.yellow);
|
||||
JButton b2=new JButton("Button 2");
|
||||
b2.setBounds(100,100,80,30);
|
||||
b2.setBackground(Color.green);
|
||||
panel.add(b1); panel.add(b2);
|
||||
f.add(panel);
|
||||
f.setSize(400,400);
|
||||
f.setLayout(null);
|
||||
f.setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,225 @@
|
|||
package Services.Controller;
|
||||
import java.awt.Color;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.web.client.*;
|
||||
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/controller/")
|
||||
public class ControllerApplication {
|
||||
|
||||
private final String captMouvURI = "http://localhost:8081/CaptMouv/";
|
||||
private final String captTempURI = "http://localhost:8082/CaptTemp/";
|
||||
private final String captCO2URI = "http://localhost:8083/CaptCO2/";
|
||||
private final String captHumURI = "http://localhost:8084/";
|
||||
private final String automPorteURI = "http://localhost:8085/AutomPorteApplication/";
|
||||
private final String automFenetreURI = "http://localhost:8086/AutomFenetreApplication/";
|
||||
private final String automLumiereURI = "http://localhost:8087/AutomLumiereApplication/";
|
||||
private final String automChauffageURI = "http://localhost:8088/AutomChauffageApplication/";
|
||||
private final String simulationURI = "http://localhost:8089/Simulation/";
|
||||
|
||||
|
||||
boolean ControlLumiereAutomatique = false;
|
||||
boolean PorteFenetreAutomatique_TemperatureCO2 = false;
|
||||
boolean PorteFenetreAutomatique_CO2 = false;
|
||||
|
||||
|
||||
|
||||
//Controle de la lumiere automatique
|
||||
//Controle en fonction du mouvement
|
||||
@GetMapping("isControlLumiereAutomatiqueActivated/")
|
||||
private final boolean isControlLumiereAutomatique() {
|
||||
return ControlLumiereAutomatique;
|
||||
}
|
||||
@GetMapping("setControlLumiereAutomatique/")
|
||||
private final void setControlLumiereAutomatique(boolean controlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique = controlLumiereAutomatique;
|
||||
}
|
||||
|
||||
//Control de l'ouverture de la porte et fenetre
|
||||
//Control en fonction de la temperature et CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_TemperatureCO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_TemperatureCO2() {
|
||||
return PorteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_TemperatureCO2/")
|
||||
private final void setPorteFenetreAutomatique_TemperatureCO2(boolean porteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2 = porteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
//Controle en fonction du CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_CO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_CO2() {
|
||||
return PorteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_CO2/")
|
||||
private final void setPorteFenetreAutomatique_CO2(boolean porteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2 = porteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ControlLumiereAutomatique() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
String url_allumerLumiere = automLumiereURI + "setON/?oN=true";
|
||||
String url_eteindreLumiere = automLumiereURI + "setON/?oN=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
//return restTemplate.getForObject(test, String.class);
|
||||
|
||||
|
||||
if (restTemplate.getForObject(url_getDetection,boolean.class)) {
|
||||
restTemplate.getForObject(url_allumerLumiere,boolean.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_eteindreLumiere,boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_TemperatureCO2() {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getTemp,double.class)) > 30) | ((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_CO2() {
|
||||
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("getSalleOccupee/")
|
||||
public String SalleOccupe() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
boolean salle_occupe = restTemplate.getForObject(url_getDetection,boolean.class);
|
||||
|
||||
|
||||
return ("La salle est:" + String.valueOf(salle_occupe)) ;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureHeatingSystem/")
|
||||
public void setTemperatureHeatingSystem(int temp) {
|
||||
String url_setTemp = automChauffageURI + "setTemperatureSet/?temperatureSet=" + String.valueOf(temp);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject(url_setTemp,void.class);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("run")
|
||||
public int run() throws Exception {
|
||||
/*
|
||||
if (ControlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
return 0;
|
||||
//Communication avec OneM2M
|
||||
/*
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="presence" val="1"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Capteur_Mouvement/DATA/";
|
||||
|
||||
ResponseEntity respEntity = restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
String resp = (String) respEntity.getBody();
|
||||
return resp;
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ControllerApplication.class, args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,330 @@
|
|||
package Services.Controller;
|
||||
import java.awt.Color;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.web.client.*;
|
||||
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/controller/")
|
||||
public class ControllerApplication {
|
||||
|
||||
private final String captMouvURI = "http://localhost:8081/CaptMouv/";
|
||||
private final String captTempURI = "http://localhost:8082/CaptTemp/";
|
||||
private final String captCO2URI = "http://localhost:8083/CaptCO2/";
|
||||
private final String captHumURI = "http://localhost:8084/";
|
||||
private final String automPorteURI = "http://localhost:8085/AutomPorteApplication/";
|
||||
private final String automFenetreURI = "http://localhost:8086/AutomFenetreApplication/";
|
||||
private final String automLumiereURI = "http://localhost:8087/AutomLumiereApplication/";
|
||||
private final String automChauffageURI = "http://localhost:8088/AutomChauffageApplication/";
|
||||
private final String simulationURI = "http://localhost:8089/Simulation/";
|
||||
|
||||
|
||||
boolean ControlLumiereAutomatique = false;
|
||||
boolean PorteFenetreAutomatique_TemperatureCO2 = false;
|
||||
boolean PorteFenetreAutomatique_CO2 = false;
|
||||
boolean MouvementAlarmActivated = false;
|
||||
boolean TemperatureAlarmActivated = false;
|
||||
boolean CO2AlarmActivated = false;
|
||||
|
||||
|
||||
//Controle de la lumiere automatique
|
||||
//Controle en fonction du mouvement
|
||||
@GetMapping("isControlLumiereAutomatiqueActivated/")
|
||||
private final boolean isControlLumiereAutomatique() {
|
||||
return ControlLumiereAutomatique;
|
||||
}
|
||||
@GetMapping("setControlLumiereAutomatique/")
|
||||
private final void setControlLumiereAutomatique(boolean controlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique = controlLumiereAutomatique;
|
||||
}
|
||||
|
||||
//Control de l'ouverture de la porte et fenetre
|
||||
//Control en fonction de la temperature et CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_TemperatureCO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_TemperatureCO2() {
|
||||
return PorteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_TemperatureCO2/")
|
||||
private final void setPorteFenetreAutomatique_TemperatureCO2(boolean porteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2 = porteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
//Controle en fonction du CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_CO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_CO2() {
|
||||
return PorteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_CO2/")
|
||||
private final void setPorteFenetreAutomatique_CO2(boolean porteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2 = porteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ControlLumiereAutomatique() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
String url_allumerLumiere = automLumiereURI + "setON/?oN=true";
|
||||
String url_eteindreLumiere = automLumiereURI + "setON/?oN=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
//return restTemplate.getForObject(test, String.class);
|
||||
|
||||
|
||||
if (restTemplate.getForObject(url_getDetection,boolean.class)) {
|
||||
restTemplate.getForObject(url_allumerLumiere,boolean.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_eteindreLumiere,boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_TemperatureCO2() {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getTemp,double.class)) > 30) | ((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_CO2() {
|
||||
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("getSalleOccupee/")
|
||||
public String SalleOccupe() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
boolean salle_occupe = restTemplate.getForObject(url_getDetection,boolean.class);
|
||||
|
||||
|
||||
return ("La salle est:" + String.valueOf(salle_occupe)) ;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureHeatingSystem/")
|
||||
public void setTemperatureHeatingSystem(int temp) {
|
||||
String url_setTemp = automChauffageURI + "setTemperatureSet/?temperatureSet=" + String.valueOf(temp);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject(url_setTemp,void.class);
|
||||
}
|
||||
|
||||
@GetMapping("getHeatingSystemONOFF/")
|
||||
public boolean getHeatingSystemONOFF() {
|
||||
String url_getONOFF = automChauffageURI + "isActive/";
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
return (restTemplate.getForObject(url_getONOFF,boolean.class));
|
||||
}
|
||||
|
||||
public boolean getMovementDetection() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
boolean resultat = false;
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
return (restTemplate.getForObject(url_getDetection, boolean.class));
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureAlarm/")
|
||||
public void setTemperatureAlarm(boolean active) {
|
||||
TemperatureAlarmActivated = active;
|
||||
}
|
||||
|
||||
@GetMapping("setMouvementAlarm/")
|
||||
public void setMouvementAlarm(boolean active) {
|
||||
MouvementAlarmActivated = active;
|
||||
}
|
||||
|
||||
@GetMapping("setCO2Alarm/")
|
||||
public void setCO2Alarm(boolean active) {
|
||||
CO2AlarmActivated = active;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("run")
|
||||
public int run() throws Exception {
|
||||
|
||||
if (ControlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2();
|
||||
}
|
||||
|
||||
//Notification de mouvement Alarm
|
||||
if (MouvementAlarmActivated & (getMovementDetection())) {
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="data" val="Mouvement_GEI213"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Notification/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
|
||||
}
|
||||
|
||||
//Notification temperature elevée
|
||||
if (TemperatureAlarmActivated) {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
int temp;
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
temp = restTemplate.getForObject(url_getTemp,int.class);
|
||||
if ((temp > 35) | (temp<15)) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="location" val="GEI213"/>\n"
|
||||
+ " <str name="data" val="" + String.valueOf(temp) +""/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Temperature/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
}
|
||||
}
|
||||
|
||||
//Notification CO2 elevée
|
||||
if (CO2AlarmActivated) {
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
double CO2;
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
CO2 = restTemplate.getForObject(url_getCO2,double.class);
|
||||
if (CO2 > 1000) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="location" val="GEI213"/>\n"
|
||||
+ " <str name="data" val="" + String.valueOf(CO2) +""/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_CO2/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ControllerApplication.class, args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,353 @@
|
|||
package Services.Controller;
|
||||
import java.awt.Color;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.web.client.*;
|
||||
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/controller/")
|
||||
public class ControllerApplication {
|
||||
|
||||
private final String captMouvURI = "http://localhost:8081/CaptMouv/";
|
||||
private final String captTempURI = "http://localhost:8082/CaptTemp/";
|
||||
private final String captCO2URI = "http://localhost:8083/CaptCO2/";
|
||||
private final String captHumURI = "http://localhost:8084/CaptHum/";
|
||||
private final String automPorteURI = "http://localhost:8085/AutomPorteApplication/";
|
||||
private final String automFenetreURI = "http://localhost:8086/AutomFenetreApplication/";
|
||||
private final String automLumiereURI = "http://localhost:8087/AutomLumiereApplication/";
|
||||
private final String automChauffageURI = "http://localhost:8088/AutomChauffageApplication/";
|
||||
private final String simulationURI = "http://localhost:8089/Simulation/";
|
||||
|
||||
|
||||
boolean ControlLumiereAutomatique = false;
|
||||
boolean PorteFenetreAutomatique_TemperatureCO2 = false;
|
||||
boolean PorteFenetreAutomatique_CO2 = false;
|
||||
boolean MouvementAlarmActivated = false;
|
||||
boolean TemperatureAlarmActivated = false;
|
||||
boolean CO2AlarmActivated = false;
|
||||
|
||||
|
||||
//Controle de la lumiere automatique
|
||||
//Controle en fonction du mouvement
|
||||
@GetMapping("isControlLumiereAutomatiqueActivated/")
|
||||
private final boolean isControlLumiereAutomatique() {
|
||||
return ControlLumiereAutomatique;
|
||||
}
|
||||
@GetMapping("setControlLumiereAutomatique/")
|
||||
private final void setControlLumiereAutomatique(boolean controlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique = controlLumiereAutomatique;
|
||||
}
|
||||
|
||||
//Control de l'ouverture de la porte et fenetre
|
||||
//Control en fonction de la temperature et CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_TemperatureCO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_TemperatureCO2() {
|
||||
return PorteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_TemperatureCO2/")
|
||||
private final void setPorteFenetreAutomatique_TemperatureCO2(boolean porteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2 = porteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
//Controle en fonction du CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_CO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_CO2() {
|
||||
return PorteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_CO2/")
|
||||
private final void setPorteFenetreAutomatique_CO2(boolean porteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2 = porteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ControlLumiereAutomatique() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
String url_allumerLumiere = automLumiereURI + "setON/?oN=true";
|
||||
String url_eteindreLumiere = automLumiereURI + "setON/?oN=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
//return restTemplate.getForObject(test, String.class);
|
||||
|
||||
|
||||
if (restTemplate.getForObject(url_getDetection,boolean.class)) {
|
||||
restTemplate.getForObject(url_allumerLumiere,boolean.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_eteindreLumiere,boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_TemperatureCO2() {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getTemp,double.class)) > 30) | ((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_CO2() {
|
||||
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("getSalleOccupee/")
|
||||
public String SalleOccupe() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
boolean salle_occupe = restTemplate.getForObject(url_getDetection,boolean.class);
|
||||
|
||||
|
||||
return ("La salle est:" + String.valueOf(salle_occupe)) ;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureHeatingSystem/")
|
||||
public void setTemperatureHeatingSystem(int temp) {
|
||||
String url_setTemp = automChauffageURI + "setTemperatureSet/?temperatureSet=" + String.valueOf(temp);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject(url_setTemp,void.class);
|
||||
}
|
||||
|
||||
@GetMapping("getHeatingSystemONOFF/")
|
||||
public boolean getHeatingSystemONOFF() {
|
||||
String url_getONOFF = automChauffageURI + "isActive/";
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
return (restTemplate.getForObject(url_getONOFF,boolean.class));
|
||||
}
|
||||
|
||||
public boolean getMovementDetection() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
boolean resultat = false;
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
return (restTemplate.getForObject(url_getDetection, boolean.class));
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("getTemperatureAlarm/")
|
||||
public boolean getTemperatureAlarm() {
|
||||
return (TemperatureAlarmActivated);
|
||||
}
|
||||
@GetMapping("setTemperatureAlarm/")
|
||||
public void setTemperatureAlarm(boolean active) {
|
||||
TemperatureAlarmActivated = active;
|
||||
}
|
||||
|
||||
@GetMapping("setMouvementAlarm/")
|
||||
public void setMouvementAlarm(boolean active) {
|
||||
MouvementAlarmActivated = active;
|
||||
}
|
||||
@GetMapping("getMouvementAlarm/")
|
||||
public boolean getMouvementAlarm() {
|
||||
return (MouvementAlarmActivated);
|
||||
}
|
||||
|
||||
@GetMapping("setCO2Alarm/")
|
||||
public void setCO2Alarm(boolean active) {
|
||||
CO2AlarmActivated = active;
|
||||
}
|
||||
@GetMapping("getCO2Alarm/")
|
||||
public boolean getCO2Alarm() {
|
||||
return (CO2AlarmActivated);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@GetMapping("run")
|
||||
public int run() throws Exception {
|
||||
|
||||
if (ControlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2();
|
||||
}
|
||||
|
||||
//Notification de mouvement Alarm
|
||||
if (MouvementAlarmActivated & (getMovementDetection())) {
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="data" val="Mouvement_GEI213"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Notification/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
|
||||
}
|
||||
|
||||
//Notification temperature elevée
|
||||
if (TemperatureAlarmActivated) {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
int temp;
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
temp = restTemplate.getForObject(url_getTemp,int.class);
|
||||
if ((temp > 35) | (temp<15)) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="location" val="GEI213"/>\n"
|
||||
+ " <str name="data" val="" + String.valueOf(temp) +""/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Temperature/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
}
|
||||
}
|
||||
|
||||
//Notification CO2 elevée
|
||||
if (CO2AlarmActivated) {
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
double CO2;
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
CO2 = restTemplate.getForObject(url_getCO2,double.class);
|
||||
if (CO2 > 1000) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="location" val="GEI213"/>\n"
|
||||
+ " <str name="data" val="" + String.valueOf(CO2) +""/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_CO2/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
}
|
||||
}
|
||||
|
||||
//Gestion de la date:
|
||||
|
||||
Date date = new Date();
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
int day = date.getDay();
|
||||
if ((day==0)|(day==6)) {
|
||||
restTemplate.getForObject(automChauffageURI+"setActive/?active=false",double.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ControllerApplication.class, args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,345 @@
|
|||
package Services.Controller;
|
||||
import java.awt.Color;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.web.client.*;
|
||||
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@RequestMapping("/controller/")
|
||||
public class ControllerApplication {
|
||||
|
||||
private final String captMouvURI = "http://localhost:8081/CaptMouv/";
|
||||
private final String captTempURI = "http://localhost:8082/CaptTemp/";
|
||||
private final String captCO2URI = "http://localhost:8083/CaptCO2/";
|
||||
private final String captHumURI = "http://localhost:8084/CaptHum/";
|
||||
private final String automPorteURI = "http://localhost:8085/AutomPorteApplication/";
|
||||
private final String automFenetreURI = "http://localhost:8086/AutomFenetreApplication/";
|
||||
private final String automLumiereURI = "http://localhost:8087/AutomLumiereApplication/";
|
||||
private final String automChauffageURI = "http://localhost:8088/AutomChauffageApplication/";
|
||||
private final String simulationURI = "http://localhost:8089/Simulation/";
|
||||
|
||||
|
||||
boolean ControlLumiereAutomatique = false;
|
||||
boolean PorteFenetreAutomatique_TemperatureCO2 = false;
|
||||
boolean PorteFenetreAutomatique_CO2 = false;
|
||||
boolean MouvementAlarmActivated = false;
|
||||
boolean TemperatureAlarmActivated = false;
|
||||
boolean CO2AlarmActivated = false;
|
||||
|
||||
|
||||
//Controle de la lumiere automatique
|
||||
//Controle en fonction du mouvement
|
||||
@GetMapping("isControlLumiereAutomatiqueActivated/")
|
||||
private final boolean isControlLumiereAutomatique() {
|
||||
return ControlLumiereAutomatique;
|
||||
}
|
||||
@GetMapping("setControlLumiereAutomatique/")
|
||||
private final void setControlLumiereAutomatique(boolean controlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique = controlLumiereAutomatique;
|
||||
}
|
||||
|
||||
//Control de l'ouverture de la porte et fenetre
|
||||
//Control en fonction de la temperature et CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_TemperatureCO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_TemperatureCO2() {
|
||||
return PorteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_TemperatureCO2/")
|
||||
private final void setPorteFenetreAutomatique_TemperatureCO2(boolean porteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2 = porteFenetreAutomatique_TemperatureCO2;
|
||||
}
|
||||
//Controle en fonction du CO2
|
||||
@GetMapping("isPorteFenetreAutomatique_CO2Activated/")
|
||||
private final boolean isPorteFenetreAutomatique_CO2() {
|
||||
return PorteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("setPorteFenetreAutomatique_CO2/")
|
||||
private final void setPorteFenetreAutomatique_CO2(boolean porteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2 = porteFenetreAutomatique_CO2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ControlLumiereAutomatique() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
String url_allumerLumiere = automLumiereURI + "setON/?oN=true";
|
||||
String url_eteindreLumiere = automLumiereURI + "setON/?oN=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
//return restTemplate.getForObject(test, String.class);
|
||||
|
||||
|
||||
if (restTemplate.getForObject(url_getDetection,boolean.class)) {
|
||||
restTemplate.getForObject(url_allumerLumiere,boolean.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_eteindreLumiere,boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_TemperatureCO2() {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getTemp,double.class)) > 30) | ((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PorteFenetreAutomatique_CO2() {
|
||||
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
String url_setOuvertureFenetre = automFenetreURI + "setOpen/?open=true";
|
||||
String url_setFermetureFenetre = automFenetreURI + "setOpen/?open=false";
|
||||
String url_setOuverturePorte = automPorteURI + "setOpen/?open=true";
|
||||
String url_setFermeturePorte = automPorteURI + "setOpen/?open=false";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
if (((restTemplate.getForObject(url_getCO2,int.class)) > 500)) {
|
||||
restTemplate.getForObject(url_setOuvertureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setOuverturePorte,double.class);
|
||||
}
|
||||
else {
|
||||
restTemplate.getForObject(url_setFermetureFenetre,double.class);
|
||||
restTemplate.getForObject(url_setFermeturePorte,double.class);
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("getSalleOccupee/")
|
||||
public String SalleOccupe() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
boolean salle_occupe = restTemplate.getForObject(url_getDetection,boolean.class);
|
||||
|
||||
|
||||
return ("La salle est:" + String.valueOf(salle_occupe)) ;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("setTemperatureHeatingSystem/")
|
||||
public void setTemperatureHeatingSystem(int temp) {
|
||||
String url_setTemp = automChauffageURI + "setTemperatureSet/?temperatureSet=" + String.valueOf(temp);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getForObject(url_setTemp,void.class);
|
||||
}
|
||||
|
||||
@GetMapping("getHeatingSystemONOFF/")
|
||||
public boolean getHeatingSystemONOFF() {
|
||||
String url_getONOFF = automChauffageURI + "isActive/";
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
return (restTemplate.getForObject(url_getONOFF,boolean.class));
|
||||
}
|
||||
|
||||
public boolean getMovementDetection() {
|
||||
String url_getDetection = captMouvURI + "getDetection/";
|
||||
boolean resultat = false;
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
return (restTemplate.getForObject(url_getDetection, boolean.class));
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("getTemperatureAlarm/")
|
||||
public boolean getTemperatureAlarm() {
|
||||
return (TemperatureAlarmActivated);
|
||||
}
|
||||
@GetMapping("setTemperatureAlarm/")
|
||||
public void setTemperatureAlarm(boolean active) {
|
||||
TemperatureAlarmActivated = active;
|
||||
}
|
||||
|
||||
@GetMapping("setMouvementAlarm/")
|
||||
public void setMouvementAlarm(boolean active) {
|
||||
MouvementAlarmActivated = active;
|
||||
}
|
||||
@GetMapping("getMouvementAlarm/")
|
||||
public boolean getMouvementAlarm() {
|
||||
return (MouvementAlarmActivated);
|
||||
}
|
||||
|
||||
@GetMapping("setCO2Alarm/")
|
||||
public void setCO2Alarm(boolean active) {
|
||||
CO2AlarmActivated = active;
|
||||
}
|
||||
@GetMapping("getCO2Alarm/")
|
||||
public boolean getCO2Alarm() {
|
||||
return (CO2AlarmActivated);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@GetMapping("run")
|
||||
public int run() throws Exception {
|
||||
|
||||
if (ControlLumiereAutomatique) {
|
||||
ControlLumiereAutomatique();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_TemperatureCO2) {
|
||||
PorteFenetreAutomatique_TemperatureCO2();
|
||||
}
|
||||
|
||||
if (PorteFenetreAutomatique_CO2) {
|
||||
PorteFenetreAutomatique_CO2();
|
||||
}
|
||||
|
||||
//Notification de mouvement Alarm
|
||||
if (MouvementAlarmActivated & (getMovementDetection())) {
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="data" val="Mouvement_GEI213"/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Notification/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
|
||||
}
|
||||
|
||||
//Notification temperature elevée
|
||||
if (TemperatureAlarmActivated) {
|
||||
String url_getTemp = captTempURI + "getTemp/";
|
||||
int temp;
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
temp = restTemplate.getForObject(url_getTemp,int.class);
|
||||
if ((temp > 35) | (temp<15)) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="location" val="GEI213"/>\n"
|
||||
+ " <str name="data" val="" + String.valueOf(temp) +""/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_Temperature/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
}
|
||||
}
|
||||
|
||||
//Notification CO2 elevée
|
||||
if (CO2AlarmActivated) {
|
||||
String url_getCO2 = captCO2URI + "getCO2/";
|
||||
double CO2;
|
||||
//Communication avec OneM2M
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
CO2 = restTemplate.getForObject(url_getCO2,double.class);
|
||||
if (CO2 > 1000) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.set("X-M2M-ORIGIN", "admin:admin");
|
||||
headers.set("Content-Type", "application/xml;ty=4");
|
||||
//headers.set("Accept", "application/xml");
|
||||
String parameters = " \n"
|
||||
+ "<m2m:cin xmlns:m2m=\"http://www.onem2m.org/xml/protocols\">\n"
|
||||
+ " <cnf>message</cnf>\n"
|
||||
+ " <con>\n"
|
||||
+ " <obj>\n"
|
||||
+ " <str name="location" val="GEI213"/>\n"
|
||||
+ " <str name="data" val="" + String.valueOf(CO2) +""/>\n"
|
||||
+ " \n"
|
||||
+ " </obj>\n"
|
||||
+ " </con>\n"
|
||||
+ "</m2m:cin>";
|
||||
|
||||
HttpEntity <String> entity = new HttpEntity <String> (parameters,headers);
|
||||
String url = "http://127.0.0.1:8080/~/in-cse/in-name/Alarm_CO2/DATA/";
|
||||
|
||||
restTemplate.exchange(url,HttpMethod.POST,entity,String.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Date date = new Date();
|
||||
|
||||
return date.getDay();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ControllerApplication.class, args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
#GitProjectData
|
||||
#Mon Nov 30 08:54:08 CET 2020
|
||||
.gitdir=.git
|
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
|
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
|
BIN
.metadata/.plugins/org.eclipse.core.resources/.root/10.tree
Normal file
BIN
.metadata/.plugins/org.eclipse.core.resources/.root/10.tree
Normal file
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
version=1
|
|
@ -0,0 +1,3 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>\r\n<launchPerspectives/>\r\n
|
||||
preferredTargets=default\:default|
|
|
@ -0,0 +1,3 @@
|
|||
GitRepositoriesView.GitDirectories=C\:\\Users\\nunes\\OneDrive\\Bureau\\WorkDay\\INSA\\Semantique\\iss-semantics-lab\\.git;
|
||||
GitRepositoriesView.GitDirectories.relative=C\:\\Users\\nunes\\OneDrive\\Bureau\\WorkDay\\INSA\\Semantique\\iss-semantics-lab\\.git;
|
||||
eclipse.preferences.version=1
|
|
@ -0,0 +1,9 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.codeComplete.visibilityCheck=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=13
|
||||
org.eclipse.jdt.core.compiler.compliance=13
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=13
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.junit.content_assist_favorite_static_members_migrated=true
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.launching.PREF_VM_XML=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>\r\n<vmSettings defaultVM\="57,org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType13,1606492818227" defaultVMConnector\="">\r\n <vmType id\="org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType">\r\n <vm id\="1606492818227" name\="jdk-13.0.2" path\="C\:\\Program Files\\Java\\jdk-13.0.2"/>\r\n </vmType>\r\n</vmSettings>\r\n
|
|
@ -0,0 +1,12 @@
|
|||
content_assist_favorite_static_members=org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.*;org.hamcrest.Matchers.*;org.hamcrest.MatcherAssert.*;org.junit.Assert.*;org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory.*;org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable.*;org.eclipse.swtbot.swt.finder.SWTBotAssert.*;org.eclipse.swtbot.eclipse.finder.waits.Conditions.*;org.eclipse.swtbot.swt.finder.waits.Conditions.*;org.junit.Assume.*;org.junit.jupiter.api.Assertions.*;org.junit.jupiter.api.Assumptions.*;org.junit.jupiter.api.DynamicContainer.*;org.junit.jupiter.api.DynamicTest.*
|
||||
content_assist_lru_history=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><history maxLHS\="100" maxRHS\="10"/>
|
||||
content_assist_number_of_computers=14
|
||||
content_assist_proposals_background=255,255,255
|
||||
content_assist_proposals_foreground=0,0,0
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.internal.ui.navigator.layout=2
|
||||
org.eclipse.jdt.internal.ui.navigator.librariesnode=true
|
||||
org.eclipse.jdt.ui.formatterprofiles.version=20
|
||||
spelling_locale_initialized=true
|
||||
useAnnotationsPrefPage=true
|
||||
useQuickDiffPrefPage=true
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jsch.core.hasChangedDefaultWin32SshHome=true
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.m2e.discovery.pref.projects=
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
knownEEFragments=
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
workspace_target_handle=local\:1606492799495.target
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
overviewRuler_migration=migrated_3.1
|
|
@ -0,0 +1,5 @@
|
|||
PROBLEMS_FILTERS_MIGRATE=true
|
||||
eclipse.preferences.version=1
|
||||
platformState=1604479820083
|
||||
quickStart=false
|
||||
tipsAndTricks=true
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.ui.navigator.ProjectExplorer.filterActivation=\:org.eclipse.jdt.java.ui.filters.HidePackageDeclaration\:org.eclipse.jdt.java.ui.filters.HideOutputFolder\:org.eclipse.buildship.ui.navigator.filter.gradle.subProject\:org.eclipse.ui.navigator.resources.nested.HideTopLevelProjectIfNested\:org.eclipse.buildship.ui.navigator.filter.gradle.buildfolder\:org.eclipse.jdt.java.ui.filters.HideEmptyInnerPackages\:org.eclipse.jdt.java.ui.filters.HideInnerClassFiles\:org.eclipse.ui.navigator.resources.filters.startsWithDot\:org.eclipse.jdt.java.ui.filters.HideEmptyLibraryContainers\:org.eclipse.jdt.java.ui.filters.HideImportDeclaration\:org.eclipse.jdt.java.ui.filters.HideSyntheticMembers\:org.eclipse.ui.navigator.resources.nested.HideFolderWhenProjectIsShownAsNested\:
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
showIntro=false
|
|
@ -0,0 +1,9 @@
|
|||
//org.eclipse.ui.commands/state/org.eclipse.ui.navigator.resources.nested.changeProjectPresentation/org.eclipse.ui.commands.radioState=false
|
||||
PLUGINS_NOT_ACTIVATED_ON_STARTUP=;org.eclipse.m2e.discovery;
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_END=255,255,255
|
||||
org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_START=255,255,255
|
||||
org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_TEXT_COLOR=16,16,16
|
||||
org.eclipse.ui.workbench.ACTIVE_TAB_BG_END=255,255,255
|
||||
org.eclipse.ui.workbench.ACTIVE_TAB_BG_START=255,255,255
|
||||
org.eclipse.ui.workbench.INACTIVE_TAB_BG_START=242,242,242
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
processedSchemes=,eclipse+command,eclipse+mpc
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/AutomChauffage/src/main/java/Services/AutomChauffage/AutomChauffageApplication.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_EXCLUDE_TEST_CODE" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="Services.AutomChauffage.AutomChauffageApplication"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="AutomChauffage"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
|
||||
</launchConfiguration>
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/AutomFenetre/src/main/java/Services/AutomFenetre/AutomFenetreApplication.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_EXCLUDE_TEST_CODE" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="Services.AutomFenetre.AutomFenetreApplication"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="AutomFenetre"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
|
||||
</launchConfiguration>
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/AutomLumiere/src/main/java/Services/AutomLumiere/AutomLumiereApplication.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_EXCLUDE_TEST_CODE" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="Services.AutomLumiere.AutomLumiereApplication"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="AutomLumiere"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
|
||||
</launchConfiguration>
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/AutomPorte/src/main/java/Services/AutomPorte/AutomPorteApplication.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_EXCLUDE_TEST_CODE" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="Services.AutomPorte.AutomPorteApplication"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="AutomPorte"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
|
||||
</launchConfiguration>
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/CaptCO2/src/main/java/Services/CaptCO2/CaptCo2Application.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_EXCLUDE_TEST_CODE" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="Services.CaptCO2.CaptCo2Application"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="CaptCO2"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
|
||||
</launchConfiguration>
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/CaptMouv/src/main/java/Services/CaptMouv/CaptMouvApplication.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_EXCLUDE_TEST_CODE" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="Services.CaptMouv.CaptMouvApplication"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="CaptMouv"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
|
||||
</launchConfiguration>
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/CaptTemp/src/main/java/Services/CaptTemp/CaptTempApplication.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_EXCLUDE_TEST_CODE" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="Services.CaptTemp.CaptTempApplication"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="CaptTemp"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
|
||||
</launchConfiguration>
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue