-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
103 lines (72 loc) · 2.94 KB
/
main.py
File metadata and controls
103 lines (72 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import sqlite3
from dataBaseName import dataBaseName
from sqliteQuerys import signalSave
from sqliteQuerys import selectLineProduction
from sqliteQuerys import existSignalFromHour
from sqliteQuerys import signalUpdate
from sqliteQuerys import showMeTheProducaoTable
from sqliteQuerys import existLineProduction
from sqliteQuerys import incrementContadorIntable1
from sqliteQuerys import existDataInTable1
from sqliteQuerys import countToday
from terminalClear import terminalClear
import datetime
import time
import RPi.GPIO as GPIO
PIN =23
# Configura o modo de definicao de pinos como BOARD
GPIO.setmode(GPIO.BCM)
# Destiva avisos
GPIO.setwarnings(False)
# Resistencia interna no input
#GPIO.setup(PIN,GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
#modificacao 6 nov
GPIO.setup(PIN, GPIO.IN)
# Cadastrando evento de borda de descida
#GPIO.add_event_detect(PIN, GPIO.FALLING, bouncetime = 200)
#-------------------------------------------------------------------------------
# Verifica se existe algum registro na Tabela Linha de Produção
#-------------------------------------------------------------------------------
if existLineProduction() == False:
terminalClear()
print("Voce esqueceu de Cadastrar uma Linha de Producao. \n Digite: python lineProduction.py para criar!")
exit()
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Verifica se existe algum registro por hora atual e data atual
#-------------------------------------------------------------------------------
while (1):
#if GPIO.event_detected(PIN):
if (GPIO.input(PIN)==GPIO.HIGH):
if (existSignalFromHour() != True):
try:
signalSave(selectLineProduction()[0], selectLineProduction()[1])
print("Novo registro realizado com Sucesso.")
showMeTheProducaoTable()
except Exception as e:
print("Erro ao tentar Cadastrar um novo Registro: ", e)
# Verifica se existe registros na tabela 1
if existDataInTable1():
try:
incrementContadorIntable1(str(countToday()), selectLineProduction()[1])
except Exception as e:
print("Erro ao tentar Incrementar o Contador na tabela1", e)
else:
print("Nao existe registros na tabela 1. O campo contador nao pode ser Incrementado")
else:
try:
signalUpdate()
print("Novo incremento realizado com Sucesso.")
showMeTheProducaoTable()
except Exception as e:
print("Erro ao tentar Incrementar um Registro: ", e)
# Verifica se existe registros na tabela 1
if existDataInTable1():
try:
incrementContadorIntable1(str(countToday()), selectLineProduction()[1])
except Exception as e:
print("Erro ao tentar Incrementar o Contador na tabela1", e)
else:
print("Nao existe registros na tabela 1. O campo contador nao pode ser Incrementado")
time.sleep(.2)
#-------------------------------------------------------------------------------