Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void lerEventos(JSONArray listaEventos) {
- this.eventos = listaEventos;
- for (Object obj : listaEventos) {
- String accao = (String) ((JSONObject)obj).get("accao");
- if (accao.equals("LIGA")) {
- String id = (String) ((JSONObject)obj).get("idAparelho");
- for (Linha l : linhaEletrica) {
- if (l.getAparelho(id) != null) {
- long time = (long) ((JSONObject)obj).get("tempo");
- if (Relogio.getInstanciaUnica().getTique() == (int) time)
- l.getAparelho(id).liga();
- }
- }
- }
- if (accao.equals("DESLIGA")) {
- String id = (String) ((JSONObject)obj).get("idAparelho");
- for (Linha l : linhaEletrica) {
- if (l.getAparelho(id) != null) {
- long time = (long) ((JSONObject)obj).get("tempo");
- if (Relogio.getInstanciaUnica().getTique() == (int) time)
- l.getAparelho(id).desliga();
- }
- }
- }
- if (accao.equals("AUMENTA")) {
- String id = (String) ((JSONObject)obj).get("idAparelho");
- for (Linha l: linhaEletrica) {
- if (l.getAparelho(id) != null) {
- long time = (long)((JSONObject)obj).get("tempo");
- if (Relogio.getInstanciaUnica().getTique() == time)
- ((AparelhoPotenciaVariavel) l.getAparelho(id)).aumenta((int) (double) ((JSONObject)obj).get("valor"));
- }
- }
- }
- if (accao.equals("PROGRAMA")) {
- String id = (String) ((JSONObject)obj).get("idAparelho");
- String programa = (String)((JSONObject)obj).get("programa");
- for (Linha l : linhaEletrica) {
- if (l.getAparelho(id) != null) {
- long time = (long) ((JSONObject)obj).get("tempo");
- if (Relogio.getInstanciaUnica().getTique() == (int) time) {
- ((MaqLavar) l.getAparelho(id)).setPrograma(programa);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement