Exemplo n.º 1
0
 def post(self, request, valor):
     try:
         recb = str(request.POST['agendado']).split(':')
         h = int(recb[0])
         m = int(recb[1])
         agendado = h * 60 + m
         forma = int(request.POST['forma'])
         nome = str(request.POST['nome'])
         vel_esp = int(request.POST['vel_esp'])
         print(f'{valor}: {agendado}, {forma}, {nome}, {vel_esp}')
         servico.dxm.write_multiple_registers(107 + valor * 13, [vel_esp])
         sleep(1)
         servico.dxm.write_multiple_registers(109 + valor * 13, [forma])
         sleep(1)
         servico.dxm.write_multiple_registers(110 + valor * 13, [agendado])
         sleep(1)
         servico.oee.linhas[valor].nome = nome
         for x in range(len(servico.oee.linhas)):
             servico.mapa.blocos[x].nome = servico.oee.linhas[x].nome
         servico.oee.salva()
         servico.mapa.salva()
         scr = Script(servico.oee.linhas, servico.mapa, servico.oee.tickLog)
         scr.salvaArquivo()
         sleep(1)
         return logado('config/index.html',
                       request,
                       titulo='configurar DXM',
                       msg='executado',
                       dados=servico.oee)
     except:
         return logado('config/index.html',
                       request,
                       titulo='configurar DXM',
                       msg='falha',
                       dados=servico.oee)
Exemplo n.º 2
0
 def post(self, request):
     try:
         ret = request.POST['json']
         dic = json.loads(ret)
         b = []
         for x in range(len(dic)):
             temp_reg = []
             for y in range(len(dic[x]['regList'])):
                 temp_reg.append(
                     Reg(dic[x]['regList'][y]['reg'],
                         ciclo=dic[x]['regList'][y]['ciclo'],
                         dword=dic[x]['regList'][y]['dword'],
                         ativo=dic[x]['regList'][y]['ativo'],
                         slaveID=dic[x]['regList'][y]['slaveID'],
                         id=y,
                         nome=dic[x]['regList'][y]['nome']))
             b.append(Bloco(dic[x]['nome'], temp_reg))
         servico.mapa.blocos = b
         servico.mapa.salva()
         cont_temp = 0
         for r in servico.mapa.blocos:
             if r.regList[2].dword == '2':
                 servico.oee.linhas[cont_temp].sts_inv = True
             else:
                 servico.oee.linhas[cont_temp].sts_inv = False
             cont_temp += 1
         servico.oee.salva()
         scr = Script(servico.oee.linhas, servico.mapa, servico.oee.tickLog)
         scr.salvaArquivo()
         sleep(1)
         dado = servico.mapa.blocos
         s = json.dumps(para_dict(dado))
         return logado('config/mapio.html',
                       request,
                       context={
                           'json': s,
                           'modo': servico.mapa.modo
                       },
                       titulo='Mapa Io',
                       dados=b,
                       nivel_min=1,
                       msg='executado')
     except Exception as ex:
         dado = servico.mapa.blocos
         s = json.dumps(para_dict(dado))
         return logado('config/mapio.html',
                       request,
                       context={
                           'json': s,
                           'modo': servico.mapa.modo
                       },
                       titulo='Mapa Io',
                       dados=dado,
                       nivel_min=1,
                       msg='falha')
Exemplo n.º 3
0
 def get(self, request):
     dado = servico.mapa.turnos
     return logado('config/turno.html',
                   request,
                   titulo='Turnos',
                   dados=dado,
                   nivel_min=2)
Exemplo n.º 4
0
 def get(self, request):
     dado = servico.oee
     return logado('config/index.html',
                   request,
                   titulo='configurar DXM',
                   dados=dado,
                   nivel_min=1)
Exemplo n.º 5
0
 def post(self, request, value):
     try:
         servico.mapa.turnos.remove(servico.mapa.turnos[value])
         for x in range(len(servico.mapa.turnos)):
             servico.mapa.turnos[x].id = x
         servico.mapa.salva()
         return logado('config/turno.html',
                       request,
                       titulo='Turnos',
                       msg='executado',
                       dados=servico.mapa.turnos)
     except:
         return logado('config/turno.html',
                       request,
                       titulo='Turnos',
                       msg='falha',
                       dados=servico.mapa.turnos)
Exemplo n.º 6
0
 def get(self, request, id):
     print(id)
     l = servico.oee.linhas[id]
     return logado('oee/linha.html',
                   request,
                   dados=l,
                   titulo=l.nome,
                   nivel_min=3)
Exemplo n.º 7
0
 def get(self, request):
     dados = servico.oee
     #dados=3
     return logado('oee/index.html',
                   request,
                   dados=dados,
                   titulo='Fabrica',
                   nivel_min=3)
Exemplo n.º 8
0
 def get(self, request):
     dado = servico.mapa.blocos
     s = json.dumps(para_dict(dado))
     return logado('config/mapio.html',
                   request,
                   context={
                       'json': s,
                       'modo': servico.mapa.modo
                   },
                   titulo='Mapa Io',
                   dados=dado,
                   nivel_min=1)
Exemplo n.º 9
0
 def post(self, request, value):
     try:
         recb = str(request.POST['time']).split(':')
         h = int(recb[0])
         m = int(recb[1])
         time = datetime(1, 1, 1, h, m, 0)
         nome = str(request.POST['nome'])
         servico.mapa.turnos[value].nome = nome
         servico.mapa.turnos[value].start = time
         servico.mapa.salva()
         return logado('config/turno.html',
                       request,
                       titulo='Turnos',
                       msg='executado',
                       dados=servico.mapa.turnos)
     except:
         return logado('config/turno.html',
                       request,
                       titulo='Turnos',
                       msg='falha',
                       dados=servico.mapa.turnos)
Exemplo n.º 10
0
 def post(self, request):
     try:
         recb = str(request.POST['time']).split(':')
         h = int(recb[0])
         m = int(recb[1])
         time = datetime(1, 1, 1, h, m, 0)
         nome = str(request.POST['nome'])
         index = int(request.POST['index'])
         e = Evento(nome, time, id=index)
         servico.mapa.turnos.append(e)
         servico.mapa.salva()
         return logado('config/turno.html',
                       request,
                       titulo='Turnos',
                       msg='executado',
                       dados=servico.mapa.turnos)
     except:
         return logado('config/turno.html',
                       request,
                       titulo='Turnos',
                       msg='falha',
                       dados=servico.mapa.turnos)
Exemplo n.º 11
0
 def post(self, request, valor):
     inis = str(request.POST['ini'])
     fims = str(request.POST['fim'])
     ini = datetime(int(inis[0:4]), int(inis[5:7]), int(inis[8:10]),
                    int(inis[11:13]), int(inis[14:16]), 0)
     fim = datetime(int(fims[0:4]), int(fims[5:7]), int(fims[8:10]),
                    int(fims[11:13]), int(fims[14:16]), 0)
     dado = Hist.objects.filter(
         Q(linha__exact=valor) & Q(time__gt=ini)
         & Q(time__lt=fim)).order_by('time')
     dadof = Hist.objects.filter(
         Q(linha__exact=valor) & Q(time__gt=ini)
         & Q(time__lt=fim)).order_by('time')
     for h in dado:
         hora = int(h.time.hour) - 5
         if hora < 0:
             hora += 23
         h.time = f'{hora}:{h.time.minute} {h.time.day}/{h.time.month}/{h.time.year}'
     for hf in dadof:
         hora = int(hf.time.hour) - 5
         if hora < 0:
             hora += 23
         hf.time = f'{hora}:{hf.time.minute} {hf.time.day}/{hf.time.month}/{hf.time.year}'
         hf.t_par = f'{str(int(hf.t_par/60))}:{str(hf.t_par%60)}'
         hf.t_prod = f'{str(int(hf.t_prod/60))}:{str(hf.t_prod%60)}'
     return logado('oee/historico.html',
                   request,
                   titulo=f'historico {servico.oee.linhas[valor].nome}',
                   context={
                       'linha_id': valor,
                       'linha_nome': servico.oee.linhas[valor].nome,
                       'dadosf': dadof,
                       'ini': inis,
                       'fim': fims
                   },
                   dados=dado,
                   nivel_min=2)
Exemplo n.º 12
0
 def get(self, request, valor):
     ago = datetime.now()
     ini = datetime(ago.year, ago.month, ago.day, 0, 0, 0)
     inis = f'{ago.year}-{ago.month}-{ago.day}T00:00:00'
     fim = datetime(ago.year, ago.month, ago.day, 23, 59, 0)
     fims = f'{ago.year}-{ago.month}-{ago.day}T23:59:00'
     dado = Hist.objects.filter(
         Q(linha__exact=valor) & Q(time__gt=ini)
         & Q(time__lt=fim)).order_by('time')
     dadof = Hist.objects.filter(
         Q(linha__exact=valor) & Q(time__gt=ini)
         & Q(time__lt=fim)).order_by('time')
     for h in dado:
         hora = int(h.time.hour) - 5
         if hora < 0:
             hora += 23
         h.time = f'{hora}:{h.time.minute} {h.time.day}/{h.time.month}/{h.time.year}'
     for hf in dadof:
         hora = int(hf.time.hour) - 5
         if hora < 0:
             hora += 23
         hf.time = f'{hora}:{hf.time.minute} {hf.time.day}/{hf.time.month}/{hf.time.year}'
         hf.t_par = f'{str(int(hf.t_par/60))}:{str(hf.t_par%60)}'
         hf.t_prod = f'{str(int(hf.t_prod/60))}:{str(hf.t_prod%60)}'
     return logado('oee/historico.html',
                   request,
                   titulo=f'historico {servico.oee.linhas[valor].nome}',
                   context={
                       'linha_id': valor,
                       'linha_nome': servico.oee.linhas[valor].nome,
                       'dadosf': dadof,
                       'ini': inis,
                       'fim': fims
                   },
                   dados=dado,
                   nivel_min=2)
Exemplo n.º 13
0
 def get(self, request):
     return logado('config/dxmconfig.html', request, titulo='Programar DXM')