Skip to content

Commit

Permalink
main no sirve nada
Browse files Browse the repository at this point in the history
  • Loading branch information
afpinzon10 committed May 19, 2018
1 parent fc04d1c commit 7433f38
Show file tree
Hide file tree
Showing 21 changed files with 854 additions and 912 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
**/*.xml
*.iml
/__pycache__
Binary file modified EntidadFisica/WiringArquisoft/editing/build/core.a
Binary file not shown.
4 changes: 2 additions & 2 deletions EntidadFisica/WiringArquisoft/editing/build/editing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ void loop()

//BATERIA
//Value conversion from digital to voltage
batteryCharge = (analogRead(BATTERY_PIN)*3.3)/1024;
//Serial.println(batteryCharge);
batteryCharge = 1000;//(analogRead(BATTERY_PIN)*3.3)/1024;
//Serial.println(analogRead(BATTERY_PIN)*100);

//Measured value comparison with min voltage required
if(batteryCharge<=MIN_VOLTAGE) {
Expand Down
Binary file modified EntidadFisica/WiringArquisoft/editing/build/editing.cpp.elf
Binary file not shown.
1,674 changes: 807 additions & 867 deletions EntidadFisica/WiringArquisoft/editing/build/editing.cpp.hex

Large diffs are not rendered by default.

Binary file modified EntidadFisica/WiringArquisoft/editing/build/editing.cpp.o
Binary file not shown.
4 changes: 2 additions & 2 deletions EntidadFisica/WiringArquisoft/editing/build/editing.pde
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ void loop()

//BATERIA
//Value conversion from digital to voltage
batteryCharge = (analogRead(BATTERY_PIN)*3.3)/1024;
//Serial.println(batteryCharge);
batteryCharge = 1000;//(analogRead(BATTERY_PIN)*3.3)/1024;
//Serial.println(analogRead(BATTERY_PIN)*100);

//Measured value comparison with min voltage required
if(batteryCharge<=MIN_VOLTAGE) {
Expand Down
2 changes: 1 addition & 1 deletion EntidadFisica/WiringArquisoft/editing/editing.pde
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void loop()
//BATERIA
//Value conversion from digital to voltage
batteryCharge = (analogRead(BATTERY_PIN)*3.3)/1024;
//Serial.println(batteryCharge);
Serial.println(analogRead(BATTERY_PIN)*100);

//Measured value comparison with min voltage required
if(batteryCharge<=MIN_VOLTAGE) {
Expand Down
Binary file not shown.
Binary file not shown.
15 changes: 15 additions & 0 deletions EntidadVirtual/API_REST/insercion_alarmas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from flask import Flask
import paho.mqtt.client as paho

user = mqtt_connect.Client("C1")

user.connect('localhost', port=8083)
user.subscribe("conjunto1/residencia1/alerta")

def on_message(user, data, message):
alarmas = mongo.db.alarmas
if


user.on_message = on_message
user.loop_start()
9 changes: 4 additions & 5 deletions EntidadVirtual/API_REST/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import json
from os import environ as env
from werkzeug.exceptions import HTTPException

import horarios.horariosLogic as hl
from authlib.flask.client import OAuth
from six.moves.urllib.parse import urlencode
import requests
Expand All @@ -28,7 +28,7 @@
client.connect("broker.mqtt-dashboard.com", 1883)

app.config['MONGO_DBNAME'] = 'restdb'
app.config['MONGO_URI'] = 'mongodb://localhost:27017/restdb'
app.config['MONGO_URI'] = 'mongodb://localhdost:27017/restdb'

mongo = PyMongo(app)
oauth = OAuth(app)
Expand All @@ -45,7 +45,7 @@
},
)

##Cerradura TEST
##Cerradura

#Insertar una cerradura
@app.route("/cerradura", methods=["POST"])
Expand All @@ -58,7 +58,7 @@ def insert_cerradura():
nuevo_candado = "0;"+password+";"+posicion;

#hl.agregar_candado(hora_inicio, hora_fin, posicion)
client.publish("horariocandado", hora_inicio+";"+hora_fin+";"+posicion)
hl.agregar_candado(hora_inicio, hora_fin, posicion)
client.publish(topico, nuevo_candado)
return jsonify(nuevo_candado)

Expand Down Expand Up @@ -105,7 +105,6 @@ def home():
def callback_handling():
# Handles response from token endpoint
resp = auth0.authorize_access_token()

url = 'https://isis2503-softsecurity.auth0.com/userinfo'
headers = {'authorization': 'Bearer ' + resp['access_token']}
resp = requests.get(url, headers=headers)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file added EntidadVirtual/__pycache__/main.cpython-36.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
48 changes: 17 additions & 31 deletions EntidadVirtual/horarios/horariosLogic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import paho.mqtt.client as paho
import threading
import time
from multiprocessing import Pipe

posicion = 0
hora_inicio = 0
Expand All @@ -10,10 +11,7 @@
def on_publish(client, userdata, mid):
print("mid: "+str(mid))

def on_subscribe(client, userdata, mid, granted_qos):
print("Subscribed: " + str(mid) + " " + str(granted_qos))
client = paho.Client()
client.on_subscribe = on_subscribe
client.on_publish = on_publish
topic = "conjunto1/residencia1/cerradura"
client.connect("broker.mqtt-dashboard.com", 1883)
Expand Down Expand Up @@ -51,18 +49,18 @@ def actualizar_estado(self):
self.estado = False


candados = []


def agregar_candado(hora_inicio, hora_fin, index):
candados = ["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]
def agregar_candado(hora_inicio, hora_fin, pindex):
global candados
index=int(pindex)
cand = Candado(hora_inicio, hora_fin, index, False)
candados.insert(index, cand)
candados[index]=cand
print("candado agregado")
c = agregar_candado(50,53,5)
c2 = agregar_candado(13,17,2)
print(len(candados))


def borrar_candado(index):
global candados
candados.pop(index)


Expand All @@ -72,28 +70,16 @@ def borrar_todos():


def actualizador():
print("aacr")
global candados
while True:
global candados
print("aacr")
time.sleep(10)
print(len(candados))
for c in candados:
time.sleep(10)
c.actualizar_estado()

def on_message(client, userdata, msg):
global hora_inicio,hora_fin,posicion
x=str(msg.payload)
x=x[2:-1]
print(x)
hora_inicio, hora_fin, posicion = x.split(";")
agregar_candado(int(hora_inicio),int(hora_fin),int(posicion))
client.on_message = on_message
a = threading.Thread(target=actualizador())
a.start()

client.subscribe("horariocandado")
client.loop_forever()



if not c == "0":
# c.actualizar_estado()
print(c.dar_index)
print("se actualizo")

print("end")

9 changes: 5 additions & 4 deletions EntidadVirtual/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from multiprocessing import Process
from multiprocessing import Process, Pipe
import API_REST.server as server
import time

Expand All @@ -12,14 +12,13 @@ def funt3():


def funt4():
import horarios.horariosLogic as hl
server.hl.actualizador()


def funt5():
import ServidorMensajeriaYCorreo.Notificador

p1 = Process(target=funt)

p3 = Process(target=funt3)
p4 = Process(target=funt4)
p5 = Process(target=funt5)
Expand All @@ -41,10 +40,12 @@ def f2(b):
p2 = Process(target=f2, args=(a,))
"""
if __name__ == '__main__':
parent, child = Pipe()
p1.start()
print("correra el proceso 3 -------------------------------------------------------------------------------")
p3.start()
print("correra el proceso 4 -------------------------------------------------------------------------------")
p4.start()
print("correra el proceso 5 -------------------------------------------------------------------------------")
p5.start()
p5.start()

Binary file not shown.
Binary file not shown.

0 comments on commit 7433f38

Please sign in to comment.