import json
if 82 - 82: Iii1i
from flask import Blueprint , render_template , request , g , redirect , url_for , flash
from sqlalchemy import or_ , and_
if 87 - 87: Ii % i1i1i1111I . Oo / OooOoo * I1Ii1I1 - I1I
from forms . wgcommform import *
from exts import db
from decorators import login_required
from forms . wgcommform import extern_peripheral_control_setup_form
from models . iccard import *
import vwAppConfig
from sqlalchemy import text
if 81 - 81: i1 + ooOOO / oOo0O00 * i1iiIII111 * IiIIii11Ii
__all__ = [
 "bp" ,
 "web_extern_peripheral_control_list" ,
"web_extern_peripheral_control_edit" ,
"web_extern_peripheral_control_option"
]
bp = Blueprint ( 'wgcomm_extern_peripheral_control' , __name__ , url_prefix = '/' )
if 84 - 84: ooo000 - Ooo0Ooo + iI1iII1I1I1i . IIiIIiIi11I1
if 98 - 98: I11iiIi11i1I % oOO
@ bp . route ( '/extern_peripheral_control_list' , methods = [ 'GET' , 'POST' ] )
@ login_required
def web_extern_peripheral_control_list ( ) :
 if 31 - 31: i1I
 if 9 - 9: IiI11Ii111 / oOo0O00 / IiIIii11Ii - I11iiIi11i1I - iI1iII1I1I1i
 if 16 - 16: i1i1i1111I / i1iiIII111
 if 3 - 3: i1 % i1 % i1i1i1111I . Ii * i1
 if 9 - 9: i1iiIII111
 if 10 - 10: ooOOO / IIiIIiIi11I1 * oOO / i1I / i1I
 if 61 - 61: Ooo0Ooo - I1I
 if 13 - 13: Ooo0Ooo
 if 46 - 46: iI1iII1I1I1i - Ii * Oo * Ii
 Ooo = TBController . query
 IIiI = Ooo . all ( )
 if 60 - 60: iI1iII1I1I1i . oOO
 i1iiiiIIIiIi = {
 "objlist" : IIiI ,

 }
 return render_template ( "wgcomm/extern-peripheral-control-list.html" , ** i1iiiiIIIiIi )
 if 22 - 22: ooo000 . iI1iII1I1I1i + Ooo0Ooo + oOO
 if 85 - 85: OooOoo - oOo0O00 / Ii / oOO % i1iiIII111 . Ii
 if 7 - 7: I11iiIi11i1I - I1Ii1I1 % I11iiIi11i1I . I1Ii1I1 . i1i1i1111I
 if 77 - 77: i1
 if 52 - 52: i1I
 if 32 - 32: Ii % i1i1i1111I % i1I - I11iiIi11i1I % i1iiIII111
 if 34 - 34: i1iiIII111 * i1
 if 34 - 34: oOo0O00 / i1iiIII111 - Iii1i . iI1iII1I1I1i
 if 80 - 80: i1i1i1111I . I1I % ooOOO % IiIIii11Ii / i1i1i1111I
 if 32 - 32: I1Ii1I1 + oOO - oOo0O00
 if 79 - 79: Iii1i % oOO * Oo + ooOOO / Oo . oOO
 if 20 - 20: IiI11Ii111 + i1iiIII111 / I1I
 if 88 - 88: I11iiIi11i1I + ooOOO - i1i1i1111I . Ooo0Ooo * Ii + Iii1i
 if 43 - 43: ooOOO * I1Ii1I1
 if 95 - 95: Ooo0Ooo % Iii1i % i1i1i1111I . OooOoo
 if 70 - 70: IiIIii11Ii
 if 75 - 75: Ooo0Ooo / Ii / IiIIii11Ii + IiIIii11Ii . I1I
 if 88 - 88: Oo * IiIIii11Ii
 if 100 - 100: IiI11Ii111 - OooOoo * I1Ii1I1 / Ooo0Ooo / Iii1i
 if 23 - 23: Ooo0Ooo + i1 * I1Ii1I1 + Oo * Ii - IIiIIiIi11I1
 if 29 - 29: IiIIii11Ii - oOo0O00
 if 30 - 30: I1I . ooo000
 if 43 - 43: ooOOO . I11iiIi11i1I + ooo000
 if 87 - 87: Iii1i + ooOOO . i1I / Ii + Oo
 if 77 - 77: i1iiIII111 + IiI11Ii111 - Oo % ooo000
 if 74 - 74: Ii + Ooo0Ooo
 if 1 - 1: I1I % Ooo0Ooo + i1iiIII111 . i1iiIII111 % Oo
 if 93 - 93: oOo0O00 % Ooo0Ooo * i1iiIII111
 if 52 - 52: oOO + I1I / ooo000 - I1Ii1I1 * i1I % oOo0O00
 if 52 - 52: oOo0O00 . I1I + i1I - i1iiIII111 % iI1iII1I1I1i
 if 57 - 57: I1I * IIiIIiIi11I1 % I1Ii1I1 * i1i1i1111I
 if 37 - 37: IiI11Ii111 * i1i1i1111I + oOo0O00 / I1I / OooOoo
 if 4 - 4: i1
 if 61 - 61: iI1iII1I1I1i . i1I - ooo000 / ooo000 - i1
 if 19 - 19: Iii1i * Ooo0Ooo . I1Ii1I1 / I11iiIi11i1I * Ii - oOO
 if 32 - 32: iI1iII1I1I1i
 if 18 - 18: I11iiIi11i1I * IiI11Ii111 % iI1iII1I1I1i + IiI11Ii111
 if 93 - 93: oOO - I1Ii1I1 - IIiIIiIi11I1 * ooOOO - i1
 if 82 - 82: IIiIIiIi11I1 % i1 * ooOOO
 if 57 - 57: oOo0O00
 if 31 - 31: i1iiIII111 + i1i1i1111I % OooOoo
 if 20 - 20: OooOoo - I1I
 if 9 - 9: i1iiIII111 - iI1iII1I1I1i % Ii - I1I
 if 54 - 54: Iii1i % ooo000 % Iii1i - IiIIii11Ii
 if 39 - 39: oOO - oOO * i1 % IIiIIiIi11I1
 if 29 - 29: IIiIIiIi11I1 - ooo000 . i1iiIII111
 if 86 - 86: I1Ii1I1 - OooOoo - oOO % ooo000 . i1I % Iii1i
 if 11 - 11: OooOoo - I1Ii1I1 - ooOOO . i1iiIII111 - iI1iII1I1I1i / i1iiIII111
 if 44 - 44: Ooo0Ooo + i1i1i1111I + Iii1i - oOO
 if 7 - 7: i1i1i1111I / Ii * Iii1i
 if 32 - 32: IiI11Ii111 . OooOoo
 if 31 - 31: Oo - i1I
 if 28 - 28: ooOOO * I1Ii1I1 + IiI11Ii111 % Oo
 if 100 - 100: Oo + i1I
 if 4 - 4: ooo000 % I1I - i1i1i1111I
 if 76 - 76: i1 * oOo0O00 . IiI11Ii111 * i1I . IiIIii11Ii . oOO
 if 55 - 55: i1i1i1111I + i1iiIII111 % Ooo0Ooo . Oo - IiIIii11Ii - iI1iII1I1I1i
 if 91 - 91: I1Ii1I1 - I11iiIi11i1I
 if 84 - 84: oOO % iI1iII1I1I1i - Ooo0Ooo
 if 94 - 94: i1iiIII111 + i1i1i1111I / iI1iII1I1I1i + iI1iII1I1I1i / i1I
 if 79 - 79: i1iiIII111 - IIiIIiIi11I1 . I1Ii1I1 + I1I - ooOOO + i1iiIII111
 if 36 - 36: ooOOO * Iii1i % I1I % i1 . Ooo0Ooo
 if 63 - 63: IIiIIiIi11I1 / IIiIIiIi11I1 * Iii1i - oOo0O00 . i1
 if 52 - 52: oOo0O00 / i1I * IIiIIiIi11I1 + I11iiIi11i1I % Ooo0Ooo + oOO
 if 43 - 43: iI1iII1I1I1i * oOo0O00 + ooOOO
 if 30 - 30: I1I
@ bp . route ( '/extern_peripheral_control_edit' , methods = [ 'POST' ] )
@ login_required
def web_extern_peripheral_control_edit ( ) :
 o00ooo0OO0000 = "wgcomm/extern-peripheral-control-edit.html"
 oOoOo = "wgcomm_extern_peripheral_control.web_extern_peripheral_control_list"
 if 39 - 39: oOO
 if request . form . get ( 'conID' ) :
  IioOoo0OOOOOoo = request . form . get ( 'conID' )
  OoO = AddControllerForm ( )
  OoO . f_ControllerNO . data = 1
  o00ooo0Oooo = TBController . query . get ( IioOoo0OOOOOoo )
  if o00ooo0Oooo :
   OoO . f_ControllerID . data = IioOoo0OOOOOoo
   OoO . f_ControllerNO . data = o00ooo0Oooo . f_ControllerNO
   OoO . f_ControllerSN . data = o00ooo0Oooo . f_ControllerSN
   OoO . f_ForceWarn . data = o00ooo0Oooo . f_ForceWarn
   OoO . f_InvalidCardWarn . data = o00ooo0Oooo . f_InvalidCardWarn
   OoO . f_DoorInvalidOpen . data = o00ooo0Oooo . f_DoorInvalidOpen
   OoO . f_DoorOpenTooLong . data = o00ooo0Oooo . f_DoorOpenTooLong
   OoO . producttype . data = vwAppConfig . getProductType ( o00ooo0Oooo . f_ControllerSN )
   oOOOO0OO00 = o00ooo0Oooo . f_PeripheralControl
   if oOOOO0OO00 :
    i1iI1 = oOOOO0OO00 . split ( ',' )
    if len ( i1iI1 ) > 4 :
     try :
      OoO . f_PeripheralControl_1_source . data = int ( i1iI1 [ 0 ] )
      OoO . f_PeripheralControl_2_source . data = int ( i1iI1 [ 1 ] )
      OoO . f_PeripheralControl_3_source . data = int ( i1iI1 [ 2 ] )
      OoO . f_PeripheralControl_4_source . data = int ( i1iI1 [ 3 ] )
      OoO . f_PeripheralControl_1_event1 . data = int ( i1iI1 [ 4 ] )
      OoO . f_PeripheralControl_1_event2 . data = int ( i1iI1 [ 5 ] )
      OoO . f_PeripheralControl_1_event3 . data = int ( i1iI1 [ 6 ] )
      OoO . f_PeripheralControl_1_event4 . data = int ( i1iI1 [ 7 ] )
      OoO . f_PeripheralControl_1_event5 . data = int ( i1iI1 [ 8 ] )
      OoO . f_PeripheralControl_1_event6 . data = int ( i1iI1 [ 9 ] )
      OoO . f_PeripheralControl_2_event1 . data = int ( i1iI1 [ 10 ] )
      OoO . f_PeripheralControl_2_event2 . data = int ( i1iI1 [ 11 ] )
      OoO . f_PeripheralControl_2_event3 . data = int ( i1iI1 [ 12 ] )
      OoO . f_PeripheralControl_2_event4 . data = int ( i1iI1 [ 13 ] )
      OoO . f_PeripheralControl_2_event5 . data = int ( i1iI1 [ 14 ] )
      OoO . f_PeripheralControl_2_event6 . data = int ( i1iI1 [ 15 ] )
      OoO . f_PeripheralControl_3_event1 . data = int ( i1iI1 [ 16 ] )
      OoO . f_PeripheralControl_3_event2 . data = int ( i1iI1 [ 17 ] )
      OoO . f_PeripheralControl_3_event3 . data = int ( i1iI1 [ 18 ] )
      OoO . f_PeripheralControl_3_event4 . data = int ( i1iI1 [ 19 ] )
      OoO . f_PeripheralControl_3_event5 . data = int ( i1iI1 [ 20 ] )
      OoO . f_PeripheralControl_3_event6 . data = int ( i1iI1 [ 21 ] )
      OoO . f_PeripheralControl_4_event1 . data = int ( i1iI1 [ 22 ] )
      OoO . f_PeripheralControl_4_event2 . data = int ( i1iI1 [ 23 ] )
      OoO . f_PeripheralControl_4_event3 . data = int ( i1iI1 [ 24 ] )
      OoO . f_PeripheralControl_4_event4 . data = int ( i1iI1 [ 25 ] )
      OoO . f_PeripheralControl_4_event5 . data = int ( i1iI1 [ 26 ] )
      OoO . f_PeripheralControl_4_event6 . data = int ( i1iI1 [ 27 ] )
      if 11 - 11: I1Ii1I1 / oOO
      OoO . f_PeripheralControl_1_output_duration . data = int ( i1iI1 [ 28 ] )
      OoO . f_PeripheralControl_2_output_duration . data = int ( i1iI1 [ 29 ] )
      OoO . f_PeripheralControl_3_output_duration . data = int ( i1iI1 [ 30 ] )
      OoO . f_PeripheralControl_4_output_duration . data = int ( i1iI1 [ 31 ] )
      if 10 - 10: Ooo0Ooo . iI1iII1I1I1i
      OoO . f_PeripheralControl_1_control_mode . data = int ( i1iI1 [ 32 ] )
      OoO . f_PeripheralControl_2_control_mode . data = int ( i1iI1 [ 33 ] )
      OoO . f_PeripheralControl_3_control_mode . data = int ( i1iI1 [ 34 ] )
      OoO . f_PeripheralControl_4_control_mode . data = int ( i1iI1 [ 35 ] )
      if 89 - 89: oOo0O00 - i1 . oOo0O00 + iI1iII1I1I1i * i1i1i1111I
      OoO . f_PeripheralControl_1_signal_1 . data = int ( i1iI1 [ 36 ] )
      OoO . f_PeripheralControl_1_signal_2 . data = int ( i1iI1 [ 37 ] )
      OoO . f_PeripheralControl_1_signal_3 . data = int ( i1iI1 [ 38 ] )
      OoO . f_PeripheralControl_1_signal_4 . data = int ( i1iI1 [ 39 ] )
      OoO . f_PeripheralControl_1_signal_5 . data = int ( i1iI1 [ 40 ] )
      OoO . f_PeripheralControl_1_signal_6 . data = int ( i1iI1 [ 41 ] )
      OoO . f_PeripheralControl_1_signal_7 . data = int ( i1iI1 [ 42 ] )
      OoO . f_PeripheralControl_1_signal_8 . data = int ( i1iI1 [ 43 ] )
      OoO . f_PeripheralControl_2_signal_1 . data = int ( i1iI1 [ 44 ] )
      OoO . f_PeripheralControl_2_signal_2 . data = int ( i1iI1 [ 45 ] )
      OoO . f_PeripheralControl_2_signal_3 . data = int ( i1iI1 [ 46 ] )
      OoO . f_PeripheralControl_2_signal_4 . data = int ( i1iI1 [ 47 ] )
      OoO . f_PeripheralControl_2_signal_5 . data = int ( i1iI1 [ 48 ] )
      OoO . f_PeripheralControl_2_signal_6 . data = int ( i1iI1 [ 49 ] )
      OoO . f_PeripheralControl_2_signal_7 . data = int ( i1iI1 [ 50 ] )
      OoO . f_PeripheralControl_2_signal_8 . data = int ( i1iI1 [ 51 ] )
      OoO . f_PeripheralControl_3_signal_1 . data = int ( i1iI1 [ 52 ] )
      OoO . f_PeripheralControl_3_signal_2 . data = int ( i1iI1 [ 53 ] )
      OoO . f_PeripheralControl_3_signal_3 . data = int ( i1iI1 [ 54 ] )
      OoO . f_PeripheralControl_3_signal_4 . data = int ( i1iI1 [ 55 ] )
      OoO . f_PeripheralControl_3_signal_5 . data = int ( i1iI1 [ 56 ] )
      OoO . f_PeripheralControl_3_signal_6 . data = int ( i1iI1 [ 57 ] )
      OoO . f_PeripheralControl_3_signal_7 . data = int ( i1iI1 [ 58 ] )
      OoO . f_PeripheralControl_3_signal_8 . data = int ( i1iI1 [ 59 ] )
      OoO . f_PeripheralControl_4_signal_1 . data = int ( i1iI1 [ 60 ] )
      OoO . f_PeripheralControl_4_signal_2 . data = int ( i1iI1 [ 61 ] )
      OoO . f_PeripheralControl_4_signal_3 . data = int ( i1iI1 [ 62 ] )
      OoO . f_PeripheralControl_4_signal_4 . data = int ( i1iI1 [ 63 ] )
      OoO . f_PeripheralControl_4_signal_5 . data = int ( i1iI1 [ 64 ] )
      OoO . f_PeripheralControl_4_signal_6 . data = int ( i1iI1 [ 65 ] )
      OoO . f_PeripheralControl_4_signal_7 . data = int ( i1iI1 [ 66 ] )
      OoO . f_PeripheralControl_4_signal_8 . data = int ( i1iI1 [ 67 ] )
      if 88 - 88: i1I + I1I
      if 55 - 55: oOO
      if 29 - 29: ooOOO / i1i1i1111I / I1Ii1I1 . IiI11Ii111 + i1I * oOo0O00
     except Exception as o0O0OO00O :
      print ( o0O0OO00O )
      if 57 - 57: IiI11Ii111
      if 6 - 6: i1iiIII111 * ooOOO % i1i1i1111I . i1
      if 87 - 87: Iii1i % ooOOO * Ii % IIiIIiIi11I1 / I11iiIi11i1I
      if 84 - 84: I1Ii1I1 + Ooo0Ooo % IIiIIiIi11I1 * i1i1i1111I
      if 61 - 61: i1iiIII111 - Oo + I1Ii1I1
      if 43 - 43: IIiIIiIi11I1 * ooo000 + Ii % iI1iII1I1I1i
      if 12 - 12: i1iiIII111 + ooo000 . I11iiIi11i1I
      if 1 - 1: iI1iII1I1I1i % Ii - I11iiIi11i1I / IiI11Ii111 + iI1iII1I1I1i - Ii
      if 27 - 27: OooOoo % iI1iII1I1I1i + IIiIIiIi11I1
      if 16 - 16: IiI11Ii111
      if 31 - 31: oOo0O00 / Iii1i % Ooo0Ooo % i1 . iI1iII1I1I1i . Oo
      if 83 - 83: oOo0O00 - I11iiIi11i1I
      if 91 - 91: IIiIIiIi11I1 - i1 - iI1iII1I1I1i
      if 71 - 71: I1I - IiI11Ii111
      if 66 - 66: i1i1i1111I / Ooo0Ooo + I11iiIi11i1I + Iii1i + oOo0O00 + i1I
      if 75 - 75: OooOoo - oOO - IiIIii11Ii - oOO + ooo000 % iI1iII1I1I1i
      if 42 - 42: i1 * i1I
      if 50 - 50: Ii - i1iiIII111
      if 96 - 96: ooo000 * OooOoo - Ii - OooOoo
      if 65 - 65: Oo + Oo - iI1iII1I1I1i % OooOoo . Ooo0Ooo
      if 84 - 84: IIiIIiIi11I1 . ooOOO
      if 44 - 44: ooo000 * i1i1i1111I * oOO + i1iiIII111 - IIiIIiIi11I1
      if 70 - 70: IiI11Ii111
      if 9 - 9: oOo0O00 * i1
      if 96 - 96: Ooo0Ooo
      if 13 - 13: Oo * I1Ii1I1 - oOo0O00 * Ii . Ii + oOo0O00
      if 46 - 46: OooOoo - I11iiIi11i1I / Ooo0Ooo
      if 73 - 73: I1Ii1I1 / i1i1i1111I / ooo000 % i1 % i1I - OooOoo
      if 30 - 30: ooOOO * ooOOO - Iii1i * iI1iII1I1I1i
      if 37 - 37: I1Ii1I1 % iI1iII1I1I1i . i1I + Ooo0Ooo + ooOOO * iI1iII1I1I1i
      if 39 - 39: IIiIIiIi11I1 - Oo
      if 31 - 31: IiIIii11Ii % oOo0O00 % oOo0O00 * Iii1i
      if 85 - 85: Iii1i + Ii % IIiIIiIi11I1 % oOo0O00
      if 100 - 100: IiIIii11Ii % i1
      if 82 - 82: ooOOO % OooOoo
      if 81 - 81: Ii
  return render_template ( o00ooo0OO0000 , wgform = OoO )
 if request . form . get ( 'f_ControllerID' ) :
  OoO = AddControllerForm ( request . form )
  if OoO . submitcancel . data :
   return redirect ( url_for ( oOoOo ) )
  if OoO . submitsaveandadd . data :
   IioOoo0OOOOOoo = OoO . f_ControllerID . data
   OoO = AddControllerForm ( )
   OoO . f_ControllerNO . data = 1
   o00ooo0Oooo = TBController . query . get ( IioOoo0OOOOOoo )
   if o00ooo0Oooo :
    OoO . f_ControllerID . data = IioOoo0OOOOOoo
    OoO . f_ControllerNO . data = o00ooo0Oooo . f_ControllerNO
    OoO . f_ControllerSN . data = o00ooo0Oooo . f_ControllerSN
    OoO . producttype . data = vwAppConfig . getProductType ( o00ooo0Oooo . f_ControllerSN )
   return render_template ( o00ooo0OO0000 , wgform = OoO )
  if OoO . validate ( ) :
   O0 = OoO . f_ControllerNO . data
   oOOoo0O0 = OoO . f_ControllerSN . data
   oOO0Oo = OoO . f_ControllerID . data
   oo00 = OoO . f_ForceWarn . data
   OOo = OoO . f_InvalidCardWarn . data
   oO000O0O0 = OoO . f_DoorInvalidOpen . data
   ooOo00O0o0o0 = OoO . f_DoorOpenTooLong . data
   OOooooOOooo0 = vwAppConfig . getProductType ( oOOoo0O0 )
   if 18 - 18: IiIIii11Ii - oOO * i1I - OooOoo
   if 54 - 54: IIiIIiIi11I1 . Ooo0Ooo % Ii + IiIIii11Ii * iI1iII1I1I1i / iI1iII1I1I1i
   TBController . query . filter_by ( f_ControllerID = oOO0Oo ) . update (
 { "f_ForceWarn" : oo00 , "f_InvalidCardWarn" : OOo ,
 "f_DoorInvalidOpen" : oO000O0O0 ,
 "f_DoorOpenTooLong" : ooOo00O0o0o0 } , synchronize_session = False )
   if 31 - 31: IiIIii11Ii . IiIIii11Ii % Ii
   i1iI1 = [ OoO . f_PeripheralControl_1_source . data ,
 OoO . f_PeripheralControl_2_source . data ,
 OoO . f_PeripheralControl_3_source . data ,
 OoO . f_PeripheralControl_4_source . data ,

   # I1I + iI1iII1I1I1i . I1I . IiI11Ii111
   # Ii
   # OooOoo / I1I % i1i1i1111I
   # i1I / i1 / OooOoo + Iii1i % ooOOO
   # oOO / ooOOO
   # Iii1i . OooOoo
   # IiIIii11Ii
   # i1iiIII111 % Iii1i
   # Ii + OooOoo
   # I11iiIi11i1I - i1i1i1111I . iI1iII1I1I1i - I11iiIi11i1I + Oo % iI1iII1I1I1i
   # IiI11Ii111 / I11iiIi11i1I . iI1iII1I1I1i + Iii1i * Ii
   # Ooo0Ooo - Oo * iI1iII1I1I1i - i1i1i1111I
   # i1iiIII111
   # i1i1i1111I / ooOOO / i1I % i1iiIII111 % ooo000
   # oOo0O00 % I11iiIi11i1I - Ooo0Ooo % Oo . oOO
   # Ooo0Ooo / i1 - i1iiIII111 - ooo000 - Oo - i1iiIII111
   # ooOOO + OooOoo + IIiIIiIi11I1 * i1i1i1111I
   # i1i1i1111I
   # Ooo0Ooo
   # IiIIii11Ii
   # Ii % i1I
   # i1iiIII111 % Oo * IiIIii11Ii - Ooo0Ooo * Ii
   # oOo0O00 % Oo + i1I
   1 if OoO . f_PeripheralControl_1_event1 . data else 0 ,
 1 if OoO . f_PeripheralControl_1_event2 . data else 0 ,
 1 if OoO . f_PeripheralControl_1_event3 . data else 0 ,
 1 if OoO . f_PeripheralControl_1_event4 . data else 0 ,
 1 if OoO . f_PeripheralControl_1_event5 . data else 0 ,
 1 if OoO . f_PeripheralControl_1_event6 . data else 0 ,
 1 if OoO . f_PeripheralControl_2_event1 . data else 0 ,
 1 if OoO . f_PeripheralControl_2_event2 . data else 0 ,
 1 if OoO . f_PeripheralControl_2_event3 . data else 0 ,
 1 if OoO . f_PeripheralControl_2_event4 . data else 0 ,
 1 if OoO . f_PeripheralControl_2_event5 . data else 0 ,
 1 if OoO . f_PeripheralControl_2_event6 . data else 0 ,
 1 if OoO . f_PeripheralControl_3_event1 . data else 0 ,
 1 if OoO . f_PeripheralControl_3_event2 . data else 0 ,
 1 if OoO . f_PeripheralControl_3_event3 . data else 0 ,
 1 if OoO . f_PeripheralControl_3_event4 . data else 0 ,
 1 if OoO . f_PeripheralControl_3_event5 . data else 0 ,
 1 if OoO . f_PeripheralControl_3_event6 . data else 0 ,
 1 if OoO . f_PeripheralControl_4_event1 . data else 0 ,
 1 if OoO . f_PeripheralControl_4_event2 . data else 0 ,
 1 if OoO . f_PeripheralControl_4_event3 . data else 0 ,
 1 if OoO . f_PeripheralControl_4_event4 . data else 0 ,
 1 if OoO . f_PeripheralControl_4_event5 . data else 0 ,
 1 if OoO . f_PeripheralControl_4_event6 . data else 0 ,
 OoO . f_PeripheralControl_1_output_duration . data ,
 OoO . f_PeripheralControl_2_output_duration . data ,
 OoO . f_PeripheralControl_3_output_duration . data ,
 OoO . f_PeripheralControl_4_output_duration . data ,
 OoO . f_PeripheralControl_1_control_mode . data ,
 OoO . f_PeripheralControl_2_control_mode . data ,
 OoO . f_PeripheralControl_3_control_mode . data ,
 OoO . f_PeripheralControl_4_control_mode . data ,
 1 if OoO . f_PeripheralControl_1_signal_1 . data else 0 ,
 1 if OoO . f_PeripheralControl_1_signal_2 . data else 0 ,
 1 if OoO . f_PeripheralControl_1_signal_3 . data else 0 ,
 1 if OoO . f_PeripheralControl_1_signal_4 . data else 0 ,
 1 if OoO . f_PeripheralControl_1_signal_5 . data else 0 ,
 1 if OoO . f_PeripheralControl_1_signal_6 . data else 0 ,
 1 if OoO . f_PeripheralControl_1_signal_7 . data else 0 ,
 1 if OoO . f_PeripheralControl_1_signal_8 . data else 0 ,
 1 if OoO . f_PeripheralControl_2_signal_1 . data else 0 ,
 1 if OoO . f_PeripheralControl_2_signal_2 . data else 0 ,
 1 if OoO . f_PeripheralControl_2_signal_3 . data else 0 ,
 1 if OoO . f_PeripheralControl_2_signal_4 . data else 0 ,
 1 if OoO . f_PeripheralControl_2_signal_5 . data else 0 ,
 1 if OoO . f_PeripheralControl_2_signal_6 . data else 0 ,
 1 if OoO . f_PeripheralControl_2_signal_7 . data else 0 ,
 1 if OoO . f_PeripheralControl_2_signal_8 . data else 0 ,
 1 if OoO . f_PeripheralControl_3_signal_1 . data else 0 ,
 1 if OoO . f_PeripheralControl_3_signal_2 . data else 0 ,
 1 if OoO . f_PeripheralControl_3_signal_3 . data else 0 ,
 1 if OoO . f_PeripheralControl_3_signal_4 . data else 0 ,
 1 if OoO . f_PeripheralControl_3_signal_5 . data else 0 ,
 1 if OoO . f_PeripheralControl_3_signal_6 . data else 0 ,
 1 if OoO . f_PeripheralControl_3_signal_7 . data else 0 ,
 1 if OoO . f_PeripheralControl_3_signal_8 . data else 0 ,
 1 if OoO . f_PeripheralControl_4_signal_1 . data else 0 ,
 1 if OoO . f_PeripheralControl_4_signal_2 . data else 0 ,
 1 if OoO . f_PeripheralControl_4_signal_3 . data else 0 ,
 1 if OoO . f_PeripheralControl_4_signal_4 . data else 0 ,
 1 if OoO . f_PeripheralControl_4_signal_5 . data else 0 ,
 1 if OoO . f_PeripheralControl_4_signal_6 . data else 0 ,
 1 if OoO . f_PeripheralControl_4_signal_7 . data else 0 ,
 1 if OoO . f_PeripheralControl_4_signal_8 . data else 0



 ]
   oOOOO0OO00 = "," . join ( str ( x ) for x in i1iI1 )
   TBController . query . filter_by ( f_ControllerID = oOO0Oo ) . update (
 { "f_PeripheralControl" : oOOOO0OO00 } , synchronize_session = False )
   if 65 - 65: IIiIIiIi11I1 / i1
   if 14 - 14: IiIIii11Ii % ooOOO . i1I
   if 29 - 29: IiI11Ii111 % oOO % IiI11Ii111 . ooOOO
   if 4 - 4: oOo0O00 + i1iiIII111
   if 45 - 45: I1Ii1I1
   if 19 - 19: ooo000 * OooOoo . Iii1i * I11iiIi11i1I . I1I
   if 49 - 49: i1iiIII111 - IiIIii11Ii / i1iiIII111 + i1I
   if 77 - 77: Ii
   if 20 - 20: Ii % i1i1i1111I
   if 35 - 35: Ooo0Ooo * IiI11Ii111 - Ooo0Ooo - ooOOO
   if 28 - 28: IiIIii11Ii . Oo - i1I + I11iiIi11i1I - oOo0O00
   if 6 - 6: IiI11Ii111 - Ii
   if 1 - 1: I1I + OooOoo
   if 98 - 98: i1iiIII111 + Iii1i . IIiIIiIi11I1
   if 96 - 96: OooOoo / oOO - i1 * I11iiIi11i1I
   if 72 - 72: i1i1i1111I + Ii - Iii1i - i1i1i1111I - i1I + Ooo0Ooo
   if 74 - 74: Ooo0Ooo * Oo + Iii1i - i1iiIII111
   if 22 - 22: IiIIii11Ii - Ooo0Ooo . i1 . i1I - ooo000
   if 68 - 68: ooo000
   if 40 - 40: i1 + I1Ii1I1 + I11iiIi11i1I . Oo * I11iiIi11i1I % I1I
   if 100 - 100: OooOoo + Oo / OooOoo
   if 33 - 33: IiI11Ii111 / OooOoo
   if 98 - 98: I1Ii1I1 . IIiIIiIi11I1 * i1I - iI1iII1I1I1i % i1I * IiI11Ii111
   if 42 - 42: OooOoo + i1i1i1111I - iI1iII1I1I1i - oOo0O00 * i1I + Ii
   if 46 - 46: oOo0O00 . iI1iII1I1I1i - Ii . oOo0O00 + i1i1i1111I
   if 83 - 83: IiI11Ii111
   if 77 - 77: iI1iII1I1I1i - oOO % Ii * i1I - I1I
   if 42 - 42: I11iiIi11i1I - Ii / Oo - i1i1i1111I + I11iiIi11i1I
   if 83 - 83: i1 . iI1iII1I1I1i
   try :
    db . session . commit ( )
    vwAppConfig . setcontrollerdoorChangeTime ( )
    flash ( "Controller {} modified successfully! Takes effect only after uploading settings in the main console!!!" . format ( oOOoo0O0 ) )
    vwAppConfig . vwlog ( '{}--{}' . format ( g . user . f_OperatorName , "Controller {} modified successfully! Takes effect only after uploading settings in the main console!!!" . format (
 oOOoo0O0 ) ) )
    return redirect ( url_for ( oOoOo ) )
   except Exception as o0O0OO00O :
    print ( o0O0OO00O )
    if 57 - 57: IiI11Ii111 % IiIIii11Ii / oOo0O00 + Ooo0Ooo - i1iiIII111
    db . session . rollback ( )
    flash ( "Controller Edit Failed！" )
    return render_template ( o00ooo0OO0000 , wgform = OoO )
  else :
   for IIi in OoO . messages :
    flash ( IIi )
   return render_template ( o00ooo0OO0000 , wgform = OoO )
   if 72 - 72: oOo0O00 - IiI11Ii111 + i1iiIII111 / i1I . OooOoo * IiIIii11Ii
@ bp . route ( '/extern_peripheral_control_option' , methods = [ 'POST' , 'GET' ] )
@ login_required
def web_extern_peripheral_control_option ( ) :
 o00ooo0OO0000 = "wgcomm/extern-peripheral-control-option.html"
 oOoOo = "wgcomm_extern_peripheral_control.web_extern_peripheral_control_list"
 if request . form . get ( "submitcancel" ) is not None :
  return redirect ( url_for ( oOoOo ) )
 if request . form . get ( 'submitsaveandadd' ) :
  flash ( "Retrieved default value successfully!" . format ( "" ) )
  OoO = extern_peripheral_control_setup_form ( )
  i1iiiiIIIiIi = {
 "wgform" : OoO ,
 }
  return render_template ( "wgcomm/extern-peripheral-control-option.html" , ** i1iiiiIIIiIi )
 if request . form . get ( "submitsave" ) is not None :
  OoO = extern_peripheral_control_setup_form ( request . form )
  O00o = OoO . f_fire_share . data
  OOo00000o00O = OoO . f_forceopen_password . data
  oOooOOo = OoO . f_opendoor_timeout . data
  TASystemparam . query . filter_by ( f_NO = 60 ) . update (
 { "f_Value" : O00o } , synchronize_session = False )
  TASystemparam . query . filter_by ( f_NO = 24 ) . update (
 { "f_Value" : OOo00000o00O } , synchronize_session = False )
  TASystemparam . query . filter_by ( f_NO = 40 ) . update (
 { "f_Value" : oOooOOo } , synchronize_session = False )
  try :
   db . session . commit ( )
   vwAppConfig . setcontrollerdoorChangeTime ( )
   flash ( "Alarm option modified  successfully! Takes effect only after uploading settings in the main console!!!" . format ( "" ) )
   vwAppConfig . vwlog ( '{}--{}' . format ( g . user . f_OperatorName , "Modified successfully! Takes effect only after uploading settings in the main console!!!" . format (
 ) ) )
   return redirect ( url_for ( oOoOo ) )
  except Exception as o0O0OO00O :
   print ( o0O0OO00O )
   if 29 - 29: i1i1i1111I / oOo0O00
   db . session . rollback ( )
   flash ( "Warn option modification failed！" )
   return render_template ( o00ooo0OO0000 , wgform = OoO )
   if 13 - 13: I11iiIi11i1I % i1iiIII111 . OooOoo % ooo000 % OooOoo
 OoO = extern_peripheral_control_setup_form ( )
 OoO . f_fire_share . data = int ( TASystemparam . query . filter_by ( f_NO = 60 ) . first ( ) . f_Value ) > 0
 OoO . f_forceopen_password . data = TASystemparam . query . filter_by ( f_NO = 24 ) . first ( ) . f_Value
 OoO . f_opendoor_timeout . data = TASystemparam . query . filter_by ( f_NO = 40 ) . first ( ) . f_Value
 i1iiiiIIIiIi = {
 "wgform" : OoO ,
 }
 return render_template ( "wgcomm/extern-peripheral-control-option.html" , ** i1iiiiIIIiIi )
 if 21 - 21: IiI11Ii111 * I1Ii1I1
# dd678faae9ac167bc83abf78e5cb2f3f0688d3a3
