diff --git a/src/techdomotica/java/forms/devices/DeviceManager.java b/src/techdomotica/java/forms/devices/DeviceManager.java
index e9df81e..07959f0 100644
--- a/src/techdomotica/java/forms/devices/DeviceManager.java
+++ b/src/techdomotica/java/forms/devices/DeviceManager.java
@@ -95,7 +95,8 @@ public void run() {
while(continueOnThread) {
try {
Thread.sleep(2000);
- System.out.println("bruh");
+ checkComponentUse();
+ /*System.out.println("bruh");
for(int i = 0 ; i < allButtons.length ; i++) {
switch(i) {
case 0:
@@ -131,7 +132,7 @@ public void run() {
}
break;
}
- }
+ }*/
}
catch(InterruptedException e) {
System.out.println(e);
@@ -1893,31 +1894,13 @@ private void btndeleteprojectorActionPerformed(java.awt.event.ActionEvent evt) {
}//GEN-LAST:event_btndeleteprojectorActionPerformed
private void rdbtnprojectoronActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdbtnprojectoronActionPerformed
- progressDialog dialogo = new progressDialog(this, true, 25) {
- @Override
- public void progressBarFilled() {
- ambiente.getTelevisor().toggleComponenteEncendido(true);
- rdbtnprojectoron.setSelected(true);
- checkComponentUse();
- }
- };
- dialogo.setTitle("Encendiendo dispositivo");
- dialogo.textVar.setText("Modificando valores del dispositivo " + ambiente.getTelevisor().getComponenteFullName() + ", puede tardar unos segundos...");
- dialogo.setVisible(true);
+ toggleDevice(ambiente.getTelevisor(), 15, true);
+ rdbtnprojectoron.setSelected(true);
}//GEN-LAST:event_rdbtnprojectoronActionPerformed
private void rdbtnprojectoroffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdbtnprojectoroffActionPerformed
- progressDialog dialogo = new progressDialog(this, true, 25) {
- @Override
- public void progressBarFilled() {
- ambiente.getTelevisor().toggleComponenteEncendido(false);
- rdbtnprojectoroff.setSelected(true);
- checkComponentUse();
- }
- };
- dialogo.setTitle("Apagando dispositivo");
- dialogo.textVar.setText("Modificando valores del dispositivo " + ambiente.getTelevisor().getComponenteFullName() + ", puede tardar unos segundos...");
- dialogo.setVisible(true);
+ toggleDevice(ambiente.getTelevisor(), 15, false);
+ rdbtnprojectoroff.setSelected(true);
}//GEN-LAST:event_rdbtnprojectoroffActionPerformed
public void saveChangesToMain() {}
diff --git a/src/techdomotica/java/forms/gestorusuarios/Usuarios.java b/src/techdomotica/java/forms/gestorusuarios/Usuarios.java
index 22c846d..deb7b9b 100644
--- a/src/techdomotica/java/forms/gestorusuarios/Usuarios.java
+++ b/src/techdomotica/java/forms/gestorusuarios/Usuarios.java
@@ -263,8 +263,9 @@ else if(evt.getClickCount() == 1) {
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
int conf = JOptionPane.showConfirmDialog(null, "¿Estás seguro de eliminar al usuario " + users.get(selectedRow).getFullName() + "?\nEsta acción es irreversible.", "Confirmación de eliminación", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if(conf == JOptionPane.YES_OPTION) {
- if(conx.execute("DELETE FROM usuario WHERE id_usuario = " + Integer.parseInt(users.get(selectedRow).getID()) +";") == 1) {
+ if(conx.execute("UPDATE usuario SET habilitado = 0 WHERE id_usuario = " + Integer.parseInt(users.get(selectedRow).getID()) +";") == 1) {
loadTable();
+ JOptionPane.showMessageDialog(null, "El usuario se ha deshabilitado exitosamente.", "Operación completada", JOptionPane.INFORMATION_MESSAGE);
}
}
}//GEN-LAST:event_jButton1ActionPerformed
diff --git a/src/techdomotica/java/forms/security/SecurityAddRep.form b/src/techdomotica/java/forms/security/SecurityAddRep.form
index 013736f..880234b 100644
--- a/src/techdomotica/java/forms/security/SecurityAddRep.form
+++ b/src/techdomotica/java/forms/security/SecurityAddRep.form
@@ -83,6 +83,7 @@
+
diff --git a/src/techdomotica/java/forms/security/SecurityAddRep.java b/src/techdomotica/java/forms/security/SecurityAddRep.java
index 4754864..1148f88 100644
--- a/src/techdomotica/java/forms/security/SecurityAddRep.java
+++ b/src/techdomotica/java/forms/security/SecurityAddRep.java
@@ -48,6 +48,9 @@ private void initComponents() {
public void keyPressed(java.awt.event.KeyEvent evt) {
areaReportKeyPressed(evt);
}
+ public void keyTyped(java.awt.event.KeyEvent evt) {
+ areaReportKeyTyped(evt);
+ }
});
jScrollPane1.setViewportView(areaReport);
@@ -111,12 +114,17 @@ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS
}//GEN-LAST:event_jButton1ActionPerformed
private void areaReportKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_areaReportKeyPressed
+
+ }//GEN-LAST:event_areaReportKeyPressed
+
+ private void areaReportKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_areaReportKeyTyped
String currentText = areaReport.getText();
- if(currentText.length() > 1001) {
- areaReport.setText(currentText);
+ if(currentText.length() >= 1000) {
+ String realText = currentText.substring(0, 999);
+ areaReport.setText(realText);
}
charLim.setText(String.format("Límite de caracteres: %d/1000", currentText.length()));
- }//GEN-LAST:event_areaReportKeyPressed
+ }//GEN-LAST:event_areaReportKeyTyped
/**
* @param args the command line arguments
diff --git a/src/techdomotica/java/forms/security/SecurityHistory.form b/src/techdomotica/java/forms/security/SecurityHistory.form
index 9783c36..e3f99ce 100644
--- a/src/techdomotica/java/forms/security/SecurityHistory.form
+++ b/src/techdomotica/java/forms/security/SecurityHistory.form
@@ -245,6 +245,7 @@
+
diff --git a/src/techdomotica/java/forms/security/SecurityHistory.java b/src/techdomotica/java/forms/security/SecurityHistory.java
index 9084ed4..e546f3b 100644
--- a/src/techdomotica/java/forms/security/SecurityHistory.java
+++ b/src/techdomotica/java/forms/security/SecurityHistory.java
@@ -161,6 +161,9 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
public void keyPressed(java.awt.event.KeyEvent evt) {
txtReportKeyPressed(evt);
}
+ public void keyTyped(java.awt.event.KeyEvent evt) {
+ txtReportKeyTyped(evt);
+ }
});
jScrollPane2.setViewportView(txtReport);
@@ -261,17 +264,22 @@ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS
}//GEN-LAST:event_jButton1ActionPerformed
private void txtReportKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtReportKeyPressed
- String currentText = txtReport.getText();
- if(currentText.length() > 1001) {
- txtReport.setText(currentText);
- }
- charRemaining.setText(String.format("Caracteres restantes: %d", (1000 - currentText.length())));
+
}//GEN-LAST:event_txtReportKeyPressed
private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
loadTable(jCheckBox1.isSelected());
}//GEN-LAST:event_jCheckBox1ActionPerformed
+ private void txtReportKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtReportKeyTyped
+ String currentText = txtReport.getText();
+ if(currentText.length() >= 1000) {
+ String realText = currentText.substring(0, 999);
+ txtReport.setText(realText);
+ }
+ charRemaining.setText(String.format("Caracteres restantes: %d", (1000 - currentText.length())));
+ }//GEN-LAST:event_txtReportKeyTyped
+
/**
* @param args the command line arguments
*/
diff --git a/src/techdomotica/objs/Ambiente.java b/src/techdomotica/objs/Ambiente.java
index 13a6187..334608d 100644
--- a/src/techdomotica/objs/Ambiente.java
+++ b/src/techdomotica/objs/Ambiente.java
@@ -89,14 +89,6 @@ public void loadComponentes() {
if(!perfilLoaded) loadPerfilFromAdmin(adminEncargado);
}
- public void loadComponentesValues() {
- loadACondicionadosValues();
- loadCamarasValues();
- //loadLucesValues();
- loadSensoresValues();
- loadProyectorValues();
- }
-
public void createACondicionado(int index, String model, String mark) {
acondicionado[index] = new ACondicionado(model, mark);
acondicionado[index].toggleComponenteEncendido(true);
@@ -108,22 +100,11 @@ public void createACondicionado(int index, String model, String mark, double val
}
public void loadACondicionados() {
- connection.executeRS("SELECT * FROM acondicionado INNER JOIN componente ON acondicionado.id_componente = componente.id_componente WHERE habilitado = 1 LIMIT 2;");
- int i = 0, count = 0;
- while(connection.nextRow()) {
- count++;
- if(acondicionado[i] == null) {
- createACondicionado(i, String.valueOf(connection.getResultSetRow("nom_componente")), String.valueOf(connection.getResultSetRow("marca")), Double.parseDouble(String.valueOf(connection.getResultSetRow("uso"))));
- acondicionado[i].setGastoEnergetico(Double.parseDouble(String.valueOf(connection.getResultSetRow("gasto_energetico"))));
- acondicionado[i].changeTemperatura(Double.parseDouble(String.valueOf(connection.getResultSetRow("temperatura"))));
- System.out.println(acondicionado[i].getTemperatura());
- acondicionado[i].setDeviceID(Integer.parseInt(String.valueOf(connection.getResultSetRow("id_componente"))));
- if(Integer.parseInt(String.valueOf(connection.getResultSetRow("componente_on"))) == 1) acondicionado[i].toggleComponenteEncendido(true);
- else acondicionado[i].toggleComponenteEncendido(false);
- }
- else {
- if(acondicionado[i].getDeviceID() != Integer.parseInt(String.valueOf(connection.getResultSetRow("id_componente")))) {
- acondicionado[i] = null;
+ if(connection.executeRS("SELECT * FROM acondicionado INNER JOIN componente ON acondicionado.id_componente = componente.id_componente WHERE habilitado = 1 LIMIT 2;")) {
+ int[] gotIDs = {-1, -1};
+ int i = 0;
+ while(connection.nextRow()) {
+ if(acondicionado[i] == null) {
createACondicionado(i, String.valueOf(connection.getResultSetRow("nom_componente")), String.valueOf(connection.getResultSetRow("marca")), Double.parseDouble(String.valueOf(connection.getResultSetRow("uso"))));
acondicionado[i].setGastoEnergetico(Double.parseDouble(String.valueOf(connection.getResultSetRow("gasto_energetico"))));
acondicionado[i].changeTemperatura(Double.parseDouble(String.valueOf(connection.getResultSetRow("temperatura"))));
@@ -131,38 +112,34 @@ public void loadACondicionados() {
acondicionado[i].setDeviceID(Integer.parseInt(String.valueOf(connection.getResultSetRow("id_componente"))));
if(Integer.parseInt(String.valueOf(connection.getResultSetRow("componente_on"))) == 1) acondicionado[i].toggleComponenteEncendido(true);
else acondicionado[i].toggleComponenteEncendido(false);
+ gotIDs[i] = Integer.parseInt(String.valueOf(connection.getResultSetRow("id_componente")));
}
else {
+ gotIDs[i] = Integer.parseInt(String.valueOf(connection.getResultSetRow("id_componente")));
acondicionado[i].changeTemperatura(Double.parseDouble(String.valueOf(connection.getResultSetRow("temperatura"))));
acondicionado[i].toggleComponenteEncendido(Integer.parseInt(String.valueOf(connection.getResultSetRow("componente_on"))) == 1);
acondicionado[i].setUsoComponente(Double.parseDouble(String.valueOf(connection.getResultSetRow("uso"))));
}
+ i++;
}
- i++;
- }
- int lastDefinedIndex = acondicionado.length - count;
- System.out.println("Last index not null: " + lastDefinedIndex);
- for(int j = lastDefinedIndex ; j < count ; j++) {
- acondicionado[j] = null;
+ i = 0;
+ for(int j = 0 ; j < acondicionado.length ; j++, i++) {
+ if(acondicionado[i] != null) {
+ if(gotIDs[j] == -1) {
+ if(acondicionado[j].getDeviceID() != gotIDs[j]) acondicionado[i] = null;
+ }
+ }
+ }
+
}
- connection.destroyResultSet();
-
- }
-
- public void loadACondicionadosValues() {
- connection.executeRS("SELECT temperatura, uso, componente_on FROM acondicionado INNER JOIN componente ON acondicionado.id_componente = componente.id_componente WHERE habilitado = 1 LIMIT 2;");
- int i = 0;
- while(connection.nextRow()) {
- if(acondicionado[i] != null) {
- acondicionado[i].changeTemperatura(Double.parseDouble(String.valueOf(connection.getResultSetRow("temperatura"))));
- acondicionado[i].toggleComponenteEncendido(Integer.parseInt(String.valueOf(connection.getResultSetRow("componente_on"))) == 1);
- acondicionado[i].setUsoComponente(Double.parseDouble(String.valueOf(connection.getResultSetRow("uso"))));
+ else {
+ for(int i = 0 ; i < acondicionado.length ; i++) {
+ acondicionado[i] = null;
}
- i++;
}
- connection.destroyResultSet();
+// connection.destroyResultSet();
}
-
+
public Admin getAdminEncargado() {
return adminEncargado;
}
@@ -184,23 +161,12 @@ public void createSensor(int index, String model, String mark, double value) {
}
public void loadSensores() {
- connection.executeRS("SELECT * FROM sensor INNER JOIN componente ON sensor.id_componente = componente.id_componente WHERE habilitado = 1 LIMIT 2;");
- int i = 0, count = 0;
- while(connection.nextRow()) {
- count++;
- if(String.valueOf(connection.getResultSetRow("tiposensor")).equalsIgnoreCase("puerta")) i = 0;
- else i = 1;
- if(sensores[i] == null) {
- createSensor(i, String.valueOf(connection.getResultSetRow("nom_componente")), String.valueOf(connection.getResultSetRow("marca")), Double.parseDouble(String.valueOf(connection.getResultSetRow("uso"))));
- sensores[i].setGastoEnergetico(Double.parseDouble(String.valueOf(connection.getResultSetRow("gasto_energetico"))));
- sensores[i].setTipoSensor(String.valueOf(connection.getResultSetRow("tiposensor")));
- sensores[i].setDeviceID(Integer.parseInt(String.valueOf(connection.getResultSetRow("id_componente"))));
- if(Integer.parseInt(String.valueOf(connection.getResultSetRow("componente_on"))) == 1) sensores[i].toggleComponenteEncendido(true);
- else sensores[i].toggleComponenteEncendido(false);
- }
- else {
- if(sensores[i].getDeviceID() != Integer.parseInt(String.valueOf(connection.getResultSetRow("id_componente")))) {
- sensores[i] = null;
+ if(connection.executeRS("SELECT * FROM sensor INNER JOIN componente ON sensor.id_componente = componente.id_componente WHERE habilitado = 1 LIMIT 2;")) {
+ int[] gotIDs = {-1, -1};
+ int i = 0;
+ while(connection.nextRow()) {
+ System.out.println("Current index: " + i);
+ if(sensores[i] == null) {
createSensor(i, String.valueOf(connection.getResultSetRow("nom_componente")), String.valueOf(connection.getResultSetRow("marca")), Double.parseDouble(String.valueOf(connection.getResultSetRow("uso"))));
sensores[i].setGastoEnergetico(Double.parseDouble(String.valueOf(connection.getResultSetRow("gasto_energetico"))));
sensores[i].setTipoSensor(String.valueOf(connection.getResultSetRow("tiposensor")));
@@ -209,32 +175,33 @@ public void loadSensores() {
else sensores[i].toggleComponenteEncendido(false);
}
else {
+ gotIDs[i] = Integer.parseInt(String.valueOf(connection.getResultSetRow("id_componente")));
sensores[i].toggleComponenteEncendido(Integer.parseInt(String.valueOf(connection.getResultSetRow("componente_on"))) == 1);
sensores[i].setUsoComponente(Double.parseDouble(String.valueOf(connection.getResultSetRow("uso"))));
}
+ i++;
}
+ i = 0;
+ for(int j = 0 ; j < sensores.length ; j++, i++) {
+ if(sensores[i] != null) {
+ if(gotIDs[j] == -1) {
+ if(sensores[j].getDeviceID() != gotIDs[j]) acondicionado[i] = null;
+ }
+ }
+ }
+
}
- int lastDefinedIndex = sensores.length - count;
- System.out.println("Last index not null: " + lastDefinedIndex);
- for(int j = lastDefinedIndex ; j < count ; j++) {
- sensores[j] = null;
- }
- connection.destroyResultSet();
- }
-
- public void loadSensoresValues() {
- connection.executeRS("SELECT uso, componente_on FROM sensor INNER JOIN componente ON sensor.id_componente = componente.id_componente WHERE habilitado = 1 LIMIT 2;");
- int i = 0;
- while(connection.nextRow()) {
- sensores[i].toggleComponenteEncendido(Integer.parseInt(String.valueOf(connection.getResultSetRow("componente_on"))) == 1);
- sensores[i].setUsoComponente(Double.parseDouble(String.valueOf(connection.getResultSetRow("uso"))));
- i++;
+ else {
+ for(int i = 0 ; i < sensores.length ; i++) {
+ sensores[i] = null;
+ }
}
- connection.destroyResultSet();
+// connection.destroyResultSet();
}
public void loadProyector() {
if(connection.executeRSOne("SELECT * FROM tv INNER JOIN componente ON tv.id_componente = componente.id_componente WHERE habilitado = 1 LIMIT 1;")) {
+ int gotID = Integer.parseInt(String.valueOf(connection.getResultSetRow("id_componente")));
if(proyector == null) {
proyector = new Televisor(String.valueOf(connection.getResultSetRow("nom_componente")), String.valueOf(connection.getResultSetRow("marca")), Double.parseDouble(String.valueOf(connection.getResultSetRow("uso"))));
proyector.setDeviceID(Integer.parseInt(String.valueOf(connection.getResultSetRow("id_componente"))));
@@ -254,18 +221,12 @@ public void loadProyector() {
proyector.setUsoComponente(Double.parseDouble(String.valueOf(connection.getResultSetRow("uso"))));
}
}
- }
- connection.destroyResultSet();
- }
-
- public void loadProyectorValues() {
- if(connection.executeRSOne("SELECT uso, componente_on FROM tv INNER JOIN componente ON tv.id_componente = componente.id_componente WHERE habilitado = 1 LIMIT 2;")) {
- if(proyector != null) {
- proyector.toggleComponenteEncendido(Integer.parseInt(String.valueOf(connection.getResultSetRow("componente_on"))) == 1);
- proyector.setUsoComponente(Double.parseDouble(String.valueOf(connection.getResultSetRow("uso"))));
+ if(proyector.getDeviceID() != gotID) {
+ proyector = null;
}
}
- connection.destroyResultSet();
+ else proyector = null;
+// connection.destroyResultSet();
}
public void createCamara(int index, String model, String mark) {
@@ -279,54 +240,43 @@ public void createCamara(int index, String model, String mark, double value) {
}
public void loadCamaras() {
- connection.executeRS("SELECT * FROM camara INNER JOIN componente ON camara.id_componente = componente.id_componente WHERE habilitado = 1 LIMIT 4;");
- int i = 0, count = 0;
- while(connection.nextRow()) {
- count++;
- if(camaras[i] == null) {
- i = Integer.parseInt(String.valueOf(connection.getResultSetRow("ubicacion"))) - 1;
- createCamara(i, String.valueOf(connection.getResultSetRow("nom_componente")), String.valueOf(connection.getResultSetRow("marca")), Double.parseDouble(String.valueOf(connection.getResultSetRow("uso"))));
- camaras[i].setGastoEnergetico(Double.parseDouble(String.valueOf(connection.getResultSetRow("gasto_energetico"))));
- camaras[i].setResolucion(String.valueOf(connection.getResultSetRow("resolucion")));
- camaras[i].setDeviceID(Integer.parseInt(String.valueOf(connection.getResultSetRow("id_componente"))));
- if(Integer.parseInt(String.valueOf(connection.getResultSetRow("componente_on"))) == 1) camaras[i].toggleComponenteEncendido(true);
- else camaras[i].toggleComponenteEncendido(false);
- }
- else {
- if(camaras[i].getDeviceID() != Integer.parseInt(String.valueOf(connection.getResultSetRow("ubicacion"))) - 1) {
- i = Integer.parseInt(String.valueOf(connection.getResultSetRow("ubicacion"))) - 1;
+ if(connection.executeRS("SELECT * FROM camara INNER JOIN componente ON camara.id_componente = componente.id_componente WHERE habilitado = 1 LIMIT 4;")) {
+ int[] gotIDs = {-1, -1, -1, -1};
+ int i = 0;
+ while(connection.nextRow()) {
+ System.out.println("Current index: " + i);
+ if(camaras[i] == null) {
createCamara(i, String.valueOf(connection.getResultSetRow("nom_componente")), String.valueOf(connection.getResultSetRow("marca")), Double.parseDouble(String.valueOf(connection.getResultSetRow("uso"))));
camaras[i].setGastoEnergetico(Double.parseDouble(String.valueOf(connection.getResultSetRow("gasto_energetico"))));
camaras[i].setResolucion(String.valueOf(connection.getResultSetRow("resolucion")));
camaras[i].setDeviceID(Integer.parseInt(String.valueOf(connection.getResultSetRow("id_componente"))));
if(Integer.parseInt(String.valueOf(connection.getResultSetRow("componente_on"))) == 1) camaras[i].toggleComponenteEncendido(true);
else camaras[i].toggleComponenteEncendido(false);
+ gotIDs[i] = Integer.parseInt(String.valueOf(connection.getResultSetRow("id_componente")));
}
else {
+ gotIDs[i] = Integer.parseInt(String.valueOf(connection.getResultSetRow("id_componente")));
camaras[i].toggleComponenteEncendido(Integer.parseInt(String.valueOf(connection.getResultSetRow("componente_on"))) == 1);
camaras[i].setUsoComponente(Double.parseDouble(String.valueOf(connection.getResultSetRow("uso"))));
}
+ i++;
}
+ i = 0;
+ for(int j = 0 ; j < camaras.length ; j++, i++) {
+ if(camaras[i] != null) {
+ if(gotIDs[j] == -1) {
+ if(camaras[j].getDeviceID() != gotIDs[j]) acondicionado[i] = null;
+ }
+ }
+ }
+
}
- int lastDefinedIndex = camaras.length - count;
- System.out.println("Last index not null: " + lastDefinedIndex);
- for(int j = lastDefinedIndex ; j < count ; j++) {
- camaras[j] = null;
- }
- connection.destroyResultSet();
- }
-
- public void loadCamarasValues() {
- connection.executeRS("SELECT uso, componente_on FROM camara INNER JOIN componente ON camara.id_componente = componente.id_componente WHERE habilitado = 1 LIMIT 2;");
- int i = 0;
- while(connection.nextRow()) {
- if(camaras[i] != null) {
- camaras[i].toggleComponenteEncendido(Integer.parseInt(String.valueOf(connection.getResultSetRow("componente_on"))) == 1);
- camaras[i].setUsoComponente(Double.parseDouble(String.valueOf(connection.getResultSetRow("uso"))));
+ else {
+ for(int i = 0 ; i < camaras.length ; i++) {
+ camaras[i] = null;
}
- i++;
}
- connection.destroyResultSet();
+// connection.destroyResultSet();
}
public void insertACIntoDB(String model, String mark) {
@@ -336,7 +286,7 @@ public void insertACIntoDB(String model, String mark) {
connection.execute(String.format("INSERT INTO acondicionado VALUES (null, %d, 23);", id_componente));
Reporte.insertReport(Integer.parseInt(adminEncargado.getID()), 3, "Este usuario agregó un nuevo aire acondicionado: " + mark + " " + model +".");
}
- connection.destroyResultSet();
+// connection.destroyResultSet();
}
}
@@ -347,7 +297,7 @@ public void insertCamaraIntoDB(int index, String model, String mark) {
connection.execute(String.format("INSERT INTO camara VALUES (null, %d, '1080p', %d);", id_componente, (index + 1)));
Reporte.insertReport(Integer.parseInt(adminEncargado.getID()), 3, "Este usuario agregó una nueva cámara: " + mark + " " + model +".");
}
- connection.destroyResultSet();
+// connection.destroyResultSet();
}
}
@@ -359,7 +309,7 @@ public void insertSensorIntoDB(String tipo, String model, String mark) {
else if(tipo.equalsIgnoreCase("movimiento")) connection.execute(String.format("INSERT INTO sensor VALUES (null, %d, 'movimiento', 'sala');", id_componente));
Reporte.insertReport(Integer.parseInt(adminEncargado.getID()), 3, "Este usuario agregó un nuevo sensor: " + mark + " " + model +".");
}
- connection.destroyResultSet();
+// connection.destroyResultSet();
}
}
@@ -370,7 +320,7 @@ public void insertTVIntoDB(String model, String mark) {
connection.execute(String.format("INSERT INTO tv VALUES (null, %d, 'Full HD', '1080p');", id_componente));
Reporte.insertReport(Integer.parseInt(adminEncargado.getID()), 3, "Este usuario agregó un nuevo proyector: " + mark + " " + model +".");
}
- connection.destroyResultSet();
+// connection.destroyResultSet();
}
}
@@ -393,6 +343,7 @@ public void loadPerfilFromAdmin(Admin admin) {
public void loadPerfil(Perfil perfil) {
if(perfil != null) {
System.out.println("perfil no es null");
+ perfilLoaded = true;
if(acondicionado[0] != null) {
//System.out.println("acondcionado 1 no es null - temp: " + acondicionado[0].getTemperatura());
acondicionado[0].toggleComponenteEncendido(perfil.isAire1On());
@@ -545,7 +496,6 @@ public void run() {
while(continueSyncThread) {
Thread.sleep(2000);
loadComponentes();
- //loadComponentesValues();
}
}
catch(Exception e) {
diff --git a/src/techdomotica/objs/Conectar.java b/src/techdomotica/objs/Conectar.java
index 9392b6b..1daf0cc 100644
--- a/src/techdomotica/objs/Conectar.java
+++ b/src/techdomotica/objs/Conectar.java
@@ -5,8 +5,8 @@
public class Conectar {
private static Connection conx;
private static final String driver = "com.mysql.jdbc.Driver",
- user = "andres",//andres
- pswd = "andres123",//andres123
+ user = "root",//andres
+ pswd = "",//andres123
url = String.format("jdbc:mysql://%s:%s/techdomotica", new Config().getConfigKey("hostname"), new Config().getConfigKey("port"));
private Statement ps;
private ResultSet rs;
diff --git a/src/techdomotica/objs/TimeChecker.java b/src/techdomotica/objs/TimeChecker.java
index c5e48e6..09a116e 100644
--- a/src/techdomotica/objs/TimeChecker.java
+++ b/src/techdomotica/objs/TimeChecker.java
@@ -48,7 +48,7 @@ public void setNextEvent() {
}
public void checkEvents() {
- if(eventList.isEmpty()) {
+ if(!eventList.isEmpty()) {
System.out.println("Not empty, updating!");
nextHours = eventList.get(0).getHora().getHour();
nextMinutes = eventList.get(0).getHora().getMinute();