# 为了演示，我们把下面的脚本新建到main.py脚本文件中，并且从mylib中引入测试函数。
# 在问题返回时 出现版本信息 其他正常指令不回复[减少问题的处理  -- 因为不涉及与控制器的通信]
# softwareVersion = "2.31" #2021-03-14 23:26:18 软件版本
# softwareVersion = "2.32 (2021-04-21)" #2021-04-21 11:08:01 修改HTML架构 #2021-03-14 23:26:18 软件版本
# 2021-04-24 18:08:58 dataserverIP = ""   #服务器IP
# dataserverPort = 61005           #服务器端口
# 2023-11-20 18:08:08 import operator
# from m1006debugmem import * #2023-03-03 19:06:39
import sys
if 82 - 82: Iii1i
from . m1001CloudServerUDP import *
from . m1001CloudServerTCP import *
if 87 - 87: Ii % i1i1i1111I . Oo / OooOoo * I1Ii1I1 - I1I
from . m1002CloudServerWEBAPI import *
from . m1004websocketServer import WGWSServerProtocol
from . mMonitorInfo import wgcontrollerDoorStatus , mMonitorInfo , wgConRPCLongTime
from autobahn . twisted . websocket import WebSocketServerFactory , WebSocketServerProtocol
if 81 - 81: i1 + ooOOO / oOo0O00 * i1iiIII111 * IiIIii11Ii
if 84 - 84: ooo000 - Ooo0Ooo + iI1iII1I1I1i . IIiIIiIi11I1
if 98 - 98: I11iiIi11i1I % oOO
if 31 - 31: i1I
import paho . mqtt . publish as publish
import paho . mqtt . client as mqtt
from . wgAppConfig import wgAppConfig
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
from . m1005rsa import *
from . m1006OptimizePrivilege import *
if 10 - 10: ooOOO / IIiIIiIi11I1 * oOO / i1I / i1I
if 61 - 61: Ooo0Ooo - I1I
if 13 - 13: Ooo0Ooo
if 46 - 46: iI1iII1I1I1i - Ii * Oo * Ii
def getConfigString ( paramval , paramName ) :
 Ooo = configparser . ConfigParser ( allow_no_value = True )
 Ooo . read ( wgGlobal . wgcloudpath1001configfileName , encoding = "utf-8-sig" )
 if ( Ooo . has_option ( 'wgconf' , paramName ) ) :
  paramval = Ooo [ 'wgconf' ] [ paramName ]
 return paramval
 if 25 - 25: OooOoo - I1Ii1I1 - iI1iII1I1I1i + i1i1i1111I / iI1iII1I1I1i
 if 71 - 71: Ii
def getConfigInt ( paramval , paramName ) :
 Ooo = configparser . ConfigParser ( allow_no_value = True )
 Ooo . read ( wgGlobal . wgcloudpath1001configfileName , encoding = "utf-8-sig" )
 if ( Ooo . has_option ( 'wgconf' , paramName ) ) :
  paramval = int ( Ooo [ 'wgconf' ] [ paramName ] )
 return paramval
 if 84 - 84: i1i1i1111I . I1Ii1I1 / IIiIIiIi11I1 - I1I - ooo000
 if 8 - 8: Iii1i - ooo000
 if 34 - 34: Ooo0Ooo + oOO * IIiIIiIi11I1 * OooOoo
 if 25 - 25: Ii / oOO % Ii
 if 96 - 96: Ii . IIiIIiIi11I1 % I11iiIi11i1I
 if 68 - 68: I11iiIi11i1I . i1i1i1111I
 if 24 - 24: IiI11Ii111
 if 9 - 9: ooo000 / i1I . i1I / Ii % i1i1i1111I % Ooo0Ooo
 if 85 - 85: I11iiIi11i1I % ooOOO + i1iiIII111 / ooOOO / ooo000
 if 17 - 17: oOo0O00 * i1iiIII111 - Iii1i . IiI11Ii111 - Oo % i1i1i1111I
 if 69 - 69: ooOOO % OooOoo
 if 45 - 45: i1
 if 48 - 48: iI1iII1I1I1i / oOo0O00 % IiI11Ii111
 if 84 - 84: 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
 if 41 - 41: oOO
 if 98 - 98: I1I / IIiIIiIi11I1 / i1I + IiI11Ii111 % Oo + I1I
 if 38 - 38: I1Ii1I1 + oOo0O00
 if 2 - 2: OooOoo % Ii + oOO . OooOoo + IIiIIiIi11I1 * Oo
 if 2 - 2: IIiIIiIi11I1 + iI1iII1I1I1i - I1Ii1I1 + ooOOO . IIiIIiIi11I1
 if 15 - 15: ooo000
 if 63 - 63: i1I
 if 81 - 81: OooOoo . i1I / i1i1i1111I + Oo / Ooo0Ooo % IiI11Ii111
 if 77 - 77: I11iiIi11i1I / iI1iII1I1I1i - oOo0O00 - Ooo0Ooo % oOo0O00
 if 73 - 73: IiI11Ii111 . Oo * I1I / i1i1i1111I + I1Ii1I1
 if 31 - 31: i1i1i1111I % I1Ii1I1
 if 1 - 1: IiI11Ii111 - oOo0O00 - i1 . oOo0O00
 if 91 - 91: iI1iII1I1I1i * i1 . ooOOO
 if 81 - 81: I1I * Oo - i1 % OooOoo * ooOOO
 if 19 - 19: Ii
 if 22 - 22: i1I % iI1iII1I1I1i + Oo
 if 60 - 60: ooo000 + I11iiIi11i1I + IIiIIiIi11I1 % i1i1i1111I - Ii % Ooo0Ooo
 if 95 - 95: 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 1 > 0 :
 mMonitorInfo . printCHS ( "1001CloudServer V{:s}" . format ( wgGlobal . softwareVersion ) )
 mMonitorInfo . wglog (
 "1001CloudServer V{}" . format ( wgGlobal . softwareVersion ) )
 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
 mMonitorInfo . printCHS ( "path= {:s}" . format ( wgGlobal . wgcloudpathdir ) )
 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
 if 40 - 40: i1I . OooOoo + oOo0O00 . i1iiIII111
 if 96 - 96: I1I / oOO / I11iiIi11i1I + I11iiIi11i1I
 try :
  if 35 - 35: IIiIIiIi11I1 + oOo0O00
  if 96 - 96: iI1iII1I1I1i . OooOoo . i1
  if 87 - 87: ooo000 * IiIIii11Ii % ooo000 . ooOOO . Oo % iI1iII1I1I1i
  if 48 - 48: ooOOO * ooo000 % IiIIii11Ii * i1 . Iii1i - IiI11Ii111
  if sys . platform == 'win32' :
   if sys . maxsize > 2 ** 32 :
    mMonitorInfo . printCHS ( "Software: {0:s}" . format ( "win64" ) )
   else :
    mMonitorInfo . printCHS ( "Software: {0:s}" . format ( "win32" ) )
   try :
    import ctypes
    if 72 - 72: i1 % i1i1i1111I * iI1iII1I1I1i
    if 90 - 90: Ooo0Ooo * OooOoo . Ii
    kernel32 = ctypes . windll . kernel32
    kernel32 . SetConsoleMode ( kernel32 . GetStdHandle ( - 10 ) ,
 ( 0x4 | 0x80 | 0x20 | 0x2 | 0x10 | 0x1 | 0x00 | 0x100 ) )
    if 5 - 5: Oo - i1 . oOO
   except Exception as e2 :
    pass
  else :
   mMonitorInfo . printCHS ( "platform: {0:s}" . format ( sys . platform ) )
  mMonitorInfo . printCHS ( "Starting up..." )
 except Exception as e :
  try :
   pass
   print ( e )
   print ( "the System don't support Chinese print...?" )
  finally :
   pass
  wgGlobal . printSupportChinese = False
 wgGlobal . testModeDebugPrint = 0
 if 18 - 18: IiIIii11Ii - oOO * i1I - OooOoo
 if 54 - 54: IIiIIiIi11I1 . Ooo0Ooo % Ii + IiIIii11Ii * iI1iII1I1I1i / iI1iII1I1I1i
 if 31 - 31: IiIIii11Ii . IiIIii11Ii % Ii
 if 51 - 51: Oo / i1i1i1111I - I1I
 if 83 - 83: Iii1i % i1iiIII111 . OooOoo / I1I % oOO . I1I
 cp = configparser . ConfigParser ( allow_no_value = True )
 cp . read ( wgGlobal . wgcloudpath1001configfileName , encoding = "utf-8-sig" )
 if cp . has_section ( 'wgconf' ) :
  config = cp . items ( "wgconf" )
  if 76 - 76: i1iiIII111 / OooOoo
  if cp . has_option ( 'wgconf' , 'cloudserverIP' ) :
   wgGlobal . dataserverIP = cp [ 'wgconf' ] [ 'cloudserverIP' ]
   if 77 - 77: ooOOO
 try :
  if 19 - 19: ooOOO % I1Ii1I1
  checktimes = 0
  if 15 - 15: OooOoo . IiIIii11Ii . i1I / Iii1i + ooOOO / Ii
  while True :
   if FrmADCT3000 . checkValidIPOnline ( ) > 0 :
    time . sleep ( 3 )
    break
   else :
    if checktimes == 0 :
     mMonitorInfo . wglog ( "waiting for network on-line..." )
     mMonitorInfo . printCHS ( "waiting for network on-line..." )
    if checktimes == 10 :
     if 17 - 17: I11iiIi11i1I - i1i1i1111I . iI1iII1I1I1i - I11iiIi11i1I + Oo % iI1iII1I1I1i
     arrips = wgAppConfig . getIPV4 ( )
     mMonitorInfo . wglog ( arrips )
     mMonitorInfo . wglog ( "please check whether network connected????" )
     mMonitorInfo . printCHS ( "please check whether network connected????" )
    checktimes = checktimes + 1
    time . sleep ( 1 )
    if 65 - 65: Ii % I11iiIi11i1I
 except Exception as e2 :
  print ( e2 )
  if 39 - 39: Iii1i * IIiIIiIi11I1 . Ooo0Ooo - Oo
 cp = configparser . ConfigParser ( allow_no_value = True )
 cp . read ( wgGlobal . wgcloudpath1001configfileName , encoding = "utf-8-sig" )
 if cp . has_section ( 'wgconf' ) :
  config = cp . items ( "wgconf" )
  if 63 - 63: i1i1i1111I - i1iiIII111 . OooOoo % OooOoo . IiI11Ii111 + i1I
  if cp . has_option ( 'wgconf' , 'cloudserverIP' ) :
   wgGlobal . dataserverIP = cp [ 'wgconf' ] [ 'cloudserverIP' ]
  if cp . has_option ( 'wgconf' , 'cloudserverPort' ) :
   wgGlobal . dataserverPort = int ( cp [ 'wgconf' ] [ 'cloudserverPort' ] )
   if 71 - 71: ooo000 + I11iiIi11i1I % iI1iII1I1I1i + IiI11Ii111 % Oo - Oo
   if 84 - 84: I1I % iI1iII1I1I1i - Ooo0Ooo / iI1iII1I1I1i + Ooo0Ooo - Oo
   if 41 - 41: ooOOO + OooOoo + IIiIIiIi11I1 * i1i1i1111I
   if 12 - 12: i1i1i1111I
   if 56 - 56: IiIIii11Ii
   if 17 - 17: i1I . oOO % Oo + IiIIii11Ii - Ooo0Ooo
   if 93 - 93: oOo0O00
   if 77 - 77: Oo + I11iiIi11i1I % I1I
   if 20 - 20: i1 - IiIIii11Ii . IiIIii11Ii % ooOOO . i1 % Ooo0Ooo
   if 72 - 72: oOO % IiI11Ii111 . ooOOO * I1Ii1I1 . ooOOO
   if 90 - 90: IiIIii11Ii + I1Ii1I1 . OooOoo
   if 73 - 73: i1i1i1111I - Iii1i / I11iiIi11i1I . ooo000 / iI1iII1I1I1i - i1iiIII111
   if 21 - 21: i1iiIII111 + IiI11Ii111 % i1i1i1111I
  if cp . has_option ( 'wgconf' , 'testModeAllowAutoRemoteOpenDoor' ) :
   if 7 - 7: IiI11Ii111 / Ii
   WGControllerCenter . setTestMode ( int ( cp [ 'wgconf' ] [ 'testModeAllowAutoRemoteOpenDoor' ] ) )
   if int ( cp [ 'wgconf' ] [ 'testModeAllowAutoRemoteOpenDoor' ] ) > 0 :
    mMonitorInfo . printCHS (
 "当前服务处于测试模式:  刷任意卡 远程开门...\r\n[可以通过修改 wgconfig.ini 文件中的 testModeAllowAutoRemoteOpenDoor =0 来关闭测试模式]" )
    mMonitorInfo . wglog (
 "当前服务处于测试模式:  刷任意卡 远程开门...\r\n[可以通过修改 wgconfig.ini 文件中的 testModeAllowAutoRemoteOpenDoor =0 来关闭测试模式]" )
    if 87 - 87: ooOOO
  if cp . has_option ( 'wgconf' , 'testModeDebugPrint' ) :
   WGControllerCenter . setModeDebugPrint ( int ( cp [ 'wgconf' ] [ 'testModeDebugPrint' ] ) )
  if cp . has_option ( 'wgconf' , 'commPID' ) :
   if 57 - 57: IIiIIiIi11I1 - iI1iII1I1I1i % ooOOO - I11iiIi11i1I / IiIIii11Ii . Ooo0Ooo
   WGControllerCenter . setCommPID ( ( cp [ 'wgconf' ] [ 'commPID' ] ) )
   if 15 - 15: i1I * I11iiIi11i1I - oOo0O00
  WGControllerCenter . commTimeControl = getConfigInt ( WGControllerCenter . commTimeControl ,
 "commTimeControl" )
  mMonitorInfo . websocketHeartCycle = getConfigInt ( mMonitorInfo . websocketHeartCycle ,
 "websocketHeartCycle" )
  if 6 - 6: IiI11Ii111 - Ii
  mMonitorInfo . backupLogfile = getConfigInt ( mMonitorInfo . backupLogfile ,
 "backupLogfile" )
  if 1 - 1: I1I + OooOoo
  if cp . has_option ( 'wgconf' , 'commSM4' ) :
   strinfo = cp [ 'wgconf' ] [ 'commSM4' ]
   WGControllerCenter . setCommSM4 ( strinfo )
   mMonitorInfo . printCHS (
 "当前服务 启用了通信加密...\r\n[可以通过修改 wgconfig.ini 文件中的 commSM4 =0 来关闭]" )
   mMonitorInfo . wglog (
 "当前服务 启用了通信加密...\r\n[可以通过修改 wgconfig.ini 文件中的 commSM4 =0 来关闭]" )
  if cp . has_option ( 'wgconf' , 'allowpcip' ) :
   wgGlobal . allowpcip = ( cp [ 'wgconf' ] [
 'allowpcip' ] )
  if cp . has_option ( 'wgconf' , 'whitelist' ) :
   wgGlobal . whitelist = ( cp [ 'wgconf' ] [ 'whitelist' ] ) . split ( ',' )
   mMonitorInfo . printCHS ( "IP whitelist Enabled..." )
   mMonitorInfo . wglog ( "IP whitelist Enabled..." )
  if cp . has_option ( 'wgconf' , 'controllersWhiteList' ) :
   try :
    val = ( cp [ 'wgconf' ] [ 'controllersWhiteList' ] ) . split ( ',' )
    wgGlobal . controllersWhiteList = [ ]
    for itm in val :
     wgGlobal . controllersWhiteList . append ( int ( itm ) )
    mMonitorInfo . printCHS ( "Controllers whitelist Enabled..." )
    mMonitorInfo . wglog ( "Controllers whitelist Enabled..." )
   except Exception as ex :
    wgGlobal . controllersWhiteList = None
    pass
  if cp . has_option ( 'wgconf' , 'supportNXP4G' ) :
   try :
    wgGlobal . supportNXP4G = int ( cp [ 'wgconf' ] [ 'supportNXP4G' ] )
    if wgGlobal . supportNXP4G :
     mMonitorInfo . printCHS ( "NXP 4G Enabled..." )
     mMonitorInfo . wglog ( "NXP 4G Enabled..." )
   except Exception as ex :
    pass
    if 98 - 98: i1iiIII111 + Iii1i . IIiIIiIi11I1
  if cp . has_option ( 'wgconf' , 'supportSendSyncInfo2025' ) :
   try :
    wgGlobal . supportSendSyncInfo2025 = int ( cp [ 'wgconf' ] [ 'supportSendSyncInfo2025' ] )
    if wgGlobal . supportSendSyncInfo2025 :
     if 96 - 96: OooOoo / oOO - i1 * I11iiIi11i1I
     if 72 - 72: i1i1i1111I + Ii - Iii1i - i1i1i1111I - i1I + Ooo0Ooo
     mMonitorInfo . printCHS ( "supportSendSyncInfo2025 = {} Enabled..." . format ( wgGlobal . supportSendSyncInfo2025 ) )
     mMonitorInfo . wglog ( "supportSendSyncInfo2025 = {} Enabled..." . format ( wgGlobal . supportSendSyncInfo2025 ) )
   except Exception as ex :
    pass
    if 74 - 74: Ooo0Ooo * Oo + Iii1i - i1iiIII111
 if len ( wgGlobal . dataserverIP ) < 1 :
  mMonitorInfo . printCHS ( "??? wgconfig.ini , configuration..." )
  mMonitorInfo . wglog ( "??? wgconfig.ini , configuration..." )
  if wgGlobal . printSupportChinese :
   input ( "Press Enter exit..." )
  else :
   input ( "press Enter exit 111" )
  sys . exit ( 0 )
  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
 mMonitorInfo . printCHS (
 "2021-02-04 引入支持SM4 start wg cloud server 启动云服务 IP信息: [{0:s}:{1:d}  udp]" . format (
 wgGlobal . dataserverIP ,
 wgGlobal . dataserverPort ) )
 if 83 - 83: IiI11Ii111
 if 77 - 77: iI1iII1I1I1i - oOO % Ii * i1I - I1I
 if 42 - 42: I11iiIi11i1I - Ii / Oo - i1i1i1111I + I11iiIi11i1I
 mMonitorInfo . wglog (
 "2021-02-04 引入支持SM4 start wg cloud server 启动云服务 IP信息: [{0:s}:{1:d}  udp]" . format (
 wgGlobal . dataserverIP , wgGlobal . dataserverPort ) )
 if 1 < 0 :
  mMonitorInfo . printCHS (
 "2021-09-15 实时记录或二维码信息写入wgrecord.log (UTF-8)文件中 [每天凌晨3点清空]  开发人员可以读取wgrecord.log作处理" )
  mMonitorInfo . wglog (
 "2021-09-15 实时记录或二维码信息写入wgrecord.log (UTF-8)文件中 [每天凌晨3点清空]  开发人员可以读取wgrecord.log作处理" )
  if 83 - 83: i1 . iI1iII1I1I1i
  if 57 - 57: IiI11Ii111 % IiIIii11Ii / oOo0O00 + Ooo0Ooo - i1iiIII111
  if 87 - 87: i1iiIII111 . i1iiIII111 . oOO . ooo000 * oOo0O00
  if 33 - 33: IiI11Ii111 * i1iiIII111 / i1I . OooOoo * oOo0O00 + ooo000
 portSocket = socket . socket ( socket . AF_INET , socket . SOCK_DGRAM )
 if 17 - 17: i1i1i1111I * oOO + i1iiIII111 - I11iiIi11i1I / i1i1i1111I
 if 83 - 83: I11iiIi11i1I - Iii1i + oOo0O00 + I1I / IIiIIiIi11I1 + I1I
 portSocket . setblocking ( False )
 try :
  portSocket . bind ( ( wgGlobal . dataserverIP , wgGlobal . dataserverPort ) )
 except Exception as e :
  pass
  if 29 - 29: i1i1i1111I / oOo0O00
  mMonitorInfo . printCHS ( "{0}: {1} {2} {3}\r\n" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , wgGlobal . dataserverIP ,
 wgGlobal . dataserverPort , e ) )
  if 13 - 13: I11iiIi11i1I % i1iiIII111 . OooOoo % ooo000 % OooOoo
  mMonitorInfo . printCHS ( "请检查是否已启动了 1001CloudServer..." )
  mMonitorInfo . wglog ( "{0}: {1} {2} {3}\r\n" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , wgGlobal . dataserverIP ,
 wgGlobal . dataserverPort , e ) )
  mMonitorInfo . wglog ( "wgconfig.ini..." )
  if wgGlobal . printSupportChinese :
   input ( "Press Enter exit..." )
  else :
   input ( "press Enter exit (IP Port Already in use.  occupied udpport)..." )
  sys . exit ( 0 )
  if 21 - 21: IiI11Ii111 * I1Ii1I1
  if 93 - 93: Ooo0Ooo . i1 + IiI11Ii111 - oOo0O00
  if 97 - 97: i1 - i1 % IIiIIiIi11I1 + IiIIii11Ii / i1I * iI1iII1I1I1i
  if 60 - 60: I11iiIi11i1I - Ooo0Ooo % I1Ii1I1
 wgControllerCenter = WGControllerCenter ( )
 port = reactor . adoptDatagramPort (
 portSocket . fileno ( ) , socket . AF_INET , wgControllerCenter )
 if 26 - 26: ooOOO / IIiIIiIi11I1 . oOO + I11iiIi11i1I . Oo
 if 37 - 37: I1Ii1I1
 portSocket . close ( )
 mMonitorInfo . wgControllerCenter = wgControllerCenter
 if 35 - 35: OooOoo % i1i1i1111I - iI1iII1I1I1i / IiIIii11Ii
 if 4 - 4: ooo000 . IiIIii11Ii % ooo000 / i1i1i1111I
 portSocketUDPWS = socket . socket ( socket . AF_INET , socket . SOCK_DGRAM )
 if 48 - 48: i1iiIII111 . Oo
 portSocketUDPWS . setblocking ( False )
 try :
  portSocketUDPWS . bind ( ( wgGlobal . dataserverIP , wgGlobal . dataserverPort + 2 ) )
  wgControllerCenterUDPWS = WGControllerCenterUDPWS ( )
  port = reactor . adoptDatagramPort (
 portSocketUDPWS . fileno ( ) , socket . AF_INET , wgControllerCenterUDPWS )
  if 92 - 92: OooOoo + Ii / IIiIIiIi11I1 + OooOoo * IIiIIiIi11I1 * iI1iII1I1I1i
  if 79 - 79: i1i1i1111I
  portSocketUDPWS . close ( )
  mMonitorInfo . wsudp = wgControllerCenterUDPWS
  mMonitorInfo . bSendBywsudp = 0
  if 3 - 3: OooOoo / IiI11Ii111 % I11iiIi11i1I
 except Exception as e :
  pass
  if 55 - 55: oOo0O00
  mMonitorInfo . printCHS ( "{0}: {1} {2} {3}\r\n" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , wgGlobal . dataserverIP ,
 wgGlobal . dataserverPort + 2 , e ) )
  if 31 - 31: Ii . Ooo0Ooo / IiI11Ii111
  mMonitorInfo . printCHS ( "请检查是否已启动了 1001CloudServer--2..." )
  mMonitorInfo . wglog ( "{0}: {1} {2} {3}\r\n" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , wgGlobal . dataserverIP ,
 wgGlobal . dataserverPort + 2 , e ) )
  mMonitorInfo . wglog ( "请检查config.ini文件中配置的IP地址正确, 端口没有被占用--2..." )
  if wgGlobal . printSupportChinese :
   input ( "Press Enter exit..." )
  else :
   input ( "press Enter exit (IP Port Already in use.  occupied udpport)..." )
  sys . exit ( 0 )
  if 59 - 59: Oo
 tcpport = getConfigInt ( wgGlobal . dataserverPort , "tcpport" )
 if 64 - 64: Iii1i % I11iiIi11i1I * i1 % OooOoo * oOo0O00
 try :
  if tcpport > 0 :
   if 55 - 55: IiI11Ii111
   if 46 - 46: Ooo0Ooo % I1Ii1I1
   if 86 - 86: I11iiIi11i1I . i1i1i1111I + oOO % I11iiIi11i1I % Iii1i % ooo000
   endpoints . serverFromString ( reactor , "tcp:{0}:interface={1}" . format ( tcpport , wgGlobal . dataserverIP ) ) . listen (
 WGControllerCenterTCP ( ) )
   mMonitorInfo . printCHS (
 "2021-09-19 引入支持SM4 start wg cloud server 启动云服务 IP信息: [{0:s}:{1:d}  tcp]" . format (
 wgGlobal . dataserverIP , tcpport ) )
   mMonitorInfo . wglog (
 "2021-09-19 引入支持SM4 start wg cloud server 启动云服务 IP信息: [{0:s}:{1:d}  tcp]" . format (
 wgGlobal . dataserverIP , tcpport ) )
   if 61 - 61: ooo000
   if 48 - 48: Iii1i * i1i1i1111I + IiIIii11Ii
   if 31 - 31: Oo * i1iiIII111 % Ii / oOO + I1Ii1I1 + iI1iII1I1I1i
   if 90 - 90: I1Ii1I1 * i1i1i1111I / iI1iII1I1I1i * Ii
   if 38 - 38: I1I . Ii
   if 41 - 41: ooo000 % IIiIIiIi11I1 % ooOOO
   if 5 - 5: oOo0O00 / Ii + i1iiIII111 * Oo + Ooo0Ooo + ooo000
   if 96 - 96: i1iiIII111 - IIiIIiIi11I1 / IIiIIiIi11I1 * IiIIii11Ii
   if 67 - 67: Ooo0Ooo . Ooo0Ooo . IiI11Ii111
   if 24 - 24: i1iiIII111 + i1i1i1111I . oOo0O00 + iI1iII1I1I1i + IiI11Ii111
   if 92 - 92: iI1iII1I1I1i / iI1iII1I1I1i + IiIIii11Ii . IiI11Ii111
   if 56 - 56: Ii * ooo000 . IiIIii11Ii
   if 66 - 66: I1Ii1I1 * OooOoo . iI1iII1I1I1i % OooOoo . i1 . IiIIii11Ii
   if 47 - 47: Ii % OooOoo % iI1iII1I1I1i * IiIIii11Ii
   if 48 - 48: i1I . I11iiIi11i1I / ooo000 + i1iiIII111
   if 84 - 84: Oo / I1Ii1I1 . IIiIIiIi11I1
   if 67 - 67: Oo % ooOOO + iI1iII1I1I1i * I1I
   if 79 - 79: IIiIIiIi11I1 * Oo / OooOoo
   if 10 - 10: iI1iII1I1I1i / i1iiIII111 . IiIIii11Ii * i1i1i1111I
   if 71 - 71: oOo0O00 + I1Ii1I1 / I11iiIi11i1I + Oo / I1I
   if 18 - 18: Iii1i - IiIIii11Ii
   if 71 - 71: iI1iII1I1I1i + OooOoo % i1i1i1111I % oOo0O00 . ooo000
   if 92 - 92: I11iiIi11i1I - Ooo0Ooo - i1i1i1111I % i1iiIII111 / i1i1i1111I * iI1iII1I1I1i
   if 60 - 60: IiIIii11Ii % oOO / i1I * OooOoo / I11iiIi11i1I - Ii
   if 16 - 16: oOo0O00 / I1Ii1I1 / i1 + I11iiIi11i1I + oOo0O00
   if 11 - 11: oOO / OooOoo + oOo0O00
 except Exception as e :
  pass
  if 79 - 79: I11iiIi11i1I . I1Ii1I1 * i1I % I1Ii1I1 / IiI11Ii111
  if 93 - 93: i1I + Iii1i . Ii . i1I * ooOOO
  if 84 - 84: Ooo0Ooo % IiI11Ii111
  if 82 - 82: IIiIIiIi11I1
  if 81 - 81: oOo0O00 + i1 - ooo000 * iI1iII1I1I1i + i1i1i1111I
  mMonitorInfo . printCHS (
 "{0}: {1} {2} {3}\r\n" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , wgGlobal . dataserverIP , tcpport ,
 e ) )
  if 89 - 89: I1Ii1I1
  mMonitorInfo . printCHS ( "请检查是否已启动了 1001CloudServer..." )
  mMonitorInfo . wglog (
 "{0}: {1} {2} {3}\r\n" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , wgGlobal . dataserverIP , tcpport ,
 e ) )
  mMonitorInfo . wglog ( "wgconfig.ini..." )
  if wgGlobal . printSupportChinese :
   input ( "Press Enter exit..." )
  else :
   input ( "press Enter exit (IP Port Already in use.  occupied tcpport)..." )
  sys . exit ( 0 )
  if 57 - 57: iI1iII1I1I1i - i1iiIII111 / OooOoo % i1iiIII111
  if 92 - 92: IiIIii11Ii * OooOoo - IiIIii11Ii
  if 66 - 66: i1iiIII111 . iI1iII1I1I1i / ooOOO . i1 - OooOoo
 wgGlobal . webServerPort = getConfigInt ( wgGlobal . webServerPort , "webServerPort" )
 if wgGlobal . webServerPort > 0 :
  root = wgDoorControllerWEBApi ( )
  factory = Site ( root )
  try :
   if ( httpsCert == "" ) or ( httpsKey == "" ) :
    if 13 - 13: oOo0O00
    mMonitorInfo . printCHS (
 "2021-02-22 引入支持json-rpc HTTP信息: [{0:s}:{1:d}]" . format ( wgGlobal . dataserverIP ,
 wgGlobal . webServerPort ) )
    mMonitorInfo . wglog ( "2021-02-22 引入支持json-rpc HTTP信息: [{0:s}:{1:d}]" . format ( wgGlobal . dataserverIP ,
 wgGlobal . webServerPort ) )
    if 50 - 50: i1 - i1iiIII111 / i1iiIII111 % I1Ii1I1 / IIiIIiIi11I1
    endpoint = endpoints . TCP4ServerEndpoint ( reactor , wgGlobal . webServerPort ,
 interface = wgGlobal . dataserverIP )
    endpoint . listen ( factory )
   else :
    mMonitorInfo . printCHS (
 "2023-11-20 18:09:04 关闭HTTPS支持 HTTPS信息: [{0:s}:{1:d}]" . format ( wgGlobal . dataserverIP ,
 wgGlobal . webServerPort ) )
    mMonitorInfo . wglog (
 "2023-11-20 18:09:04 关闭HTTPS支持 HTTPS信息: [{0:s}:{1:d}]" . format ( wgGlobal . dataserverIP ,
 wgGlobal . webServerPort ) )
    if 66 - 66: oOo0O00 - Iii1i - ooo000 . I11iiIi11i1I
    if wgGlobal . printSupportChinese :
     input ( "关闭了HTTPS支持 按回车键退出..." )
    else :
     input ( "press Enter exit (don't support HTTPS Server)..." )
    sys . exit ( 0 )
    if 59 - 59: i1I / IiIIii11Ii
    if 7 - 7: oOo0O00
    mMonitorInfo . printCHS (
 "2021-02-22 引入支持json-rpc HTTPS信息: [{0:s}:{1:d}]" . format ( wgGlobal . dataserverIP ,
 wgGlobal . webServerPort ) )
    mMonitorInfo . wglog ( "2021-02-22 引入支持json-rpc HTTPS信息: [{0:s}:{1:d}]" . format ( wgGlobal . dataserverIP ,
 wgGlobal . webServerPort ) )
    if 64 - 64: IIiIIiIi11I1 * oOO + Oo . OooOoo - ooOOO
    sslContext = ssl . DefaultOpenSSLContextFactory (
 httpsKey ,
    httpsCert ,
    )
    if 94 - 94: IiIIii11Ii - ooo000 . Ii
    if 73 - 73: IiIIii11Ii / oOo0O00 % ooo000 . iI1iII1I1I1i % oOO
    if 36 - 36: IiI11Ii111 * OooOoo . ooo000 . i1iiIII111 + oOO
    if 47 - 47: IiI11Ii111 / I11iiIi11i1I
    if 52 - 52: Ii . OooOoo . i1iiIII111 * I11iiIi11i1I - iI1iII1I1I1i
    reactor . listenSSL ( wgGlobal . webServerPort , factory , sslContext ,
 interface = wgGlobal . dataserverIP )
    if 20 - 20: OooOoo % IiI11Ii111 + I1Ii1I1 + IiI11Ii111 - oOo0O00
    if 76 - 76: I11iiIi11i1I % IIiIIiIi11I1 % i1I
    if 39 - 39: IiIIii11Ii . Oo + i1I - oOo0O00
    if 93 - 93: Iii1i * IIiIIiIi11I1 % i1I + i1 % Ii * i1I
    if 62 - 62: IiI11Ii111 % ooo000
    if 19 - 19: Ii / Oo % Iii1i / i1iiIII111 - OooOoo - Ooo0Ooo
  except Exception as e :
   pass
   if 89 - 89: I11iiIi11i1I - IiI11Ii111
   mMonitorInfo . printCHS (
 "{0}: {1} {2} {3}\r\n" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , wgGlobal . dataserverIP ,
 wgGlobal . webServerPort , e ) )
   mMonitorInfo . printCHS ( "wgconfig.ini..." )
   mMonitorInfo . wglog ( "{0}: {1} {2} {3}\r\n" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , wgGlobal . dataserverIP ,
 wgGlobal . webServerPort , e ) )
   mMonitorInfo . wglog ( "wgconfig.ini..." )
   if 61 - 61: Ii * OooOoo * I1I % i1iiIII111 % IIiIIiIi11I1 * I11iiIi11i1I
   if wgGlobal . printSupportChinese :
    input ( "Press Enter exit..." )
   else :
    input ( "press Enter exit (IP Port Already in use.  occupied webServerPort)..." )
   sys . exit ( 0 )
   if 49 - 49: iI1iII1I1I1i / i1iiIII111 % oOO
   if 46 - 46: ooOOO * IIiIIiIi11I1 % i1 / oOO + i1 + oOo0O00
   if 99 - 99: I1I * IIiIIiIi11I1 * i1iiIII111
 wsport = 61081
 wsport = getConfigInt ( wsport , "wsport" )
 if 62 - 62: ooOOO % Oo + i1I
 if wsport > 1 :
  try :
   factory = WebSocketServerFactory (
 "ws://{0:s}:{1:d}" . format ( wgGlobal . dataserverIP , wsport ) )
   factory . protocol = WGWSServerProtocol
   if 87 - 87: ooo000 - OooOoo + Ii + i1i1i1111I + IiIIii11Ii
   factory . doStart ( )
   reactor . listenTCP ( wsport , factory )
   if 57 - 57: IIiIIiIi11I1 + I1I / ooOOO % ooOOO % Oo / IiI11Ii111
   mMonitorInfo . printCHS ( "2022-06-11 引入支持websocket 信息: {0}" . format (
 "ws://{0:s}:{1:d}" . format ( wgGlobal . dataserverIP , wsport ) ) )
  except Exception as e :
   pass
   if 95 - 95: i1 / I11iiIi11i1I . i1 / Oo . Ooo0Ooo
   if 43 - 43: Oo - OooOoo * oOO . Ooo0Ooo / IIiIIiIi11I1 * IIiIIiIi11I1
   mMonitorInfo . printCHS (
 "{0}: {1} {2} {3}\r\n" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , wgGlobal . dataserverIP , wsport , e ) )
   if 84 - 84: i1iiIII111 + oOo0O00
   mMonitorInfo . printCHS ( "请检查是否已启动了 1001CloudServer..." )
   mMonitorInfo . wglog (
 "{0}: {1} {2} {3}\r\n" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , wgGlobal . dataserverIP , wsport ,
 e ) )
   mMonitorInfo . wglog ( "wgconfig.ini..." )
   if 83 - 83: i1i1i1111I
   if wgGlobal . printSupportChinese :
    input ( "Press Enter exit..." )
   else :
    input ( "press Enter exit (IP Port Already in use.  occupied  wsport)..." )
   sys . exit ( 0 )
   if 84 - 84: oOO / Ii * Ooo0Ooo / Ii / ooo000
   if 64 - 64: oOo0O00 * Ii
 wgGlobal . mqttHostName = getConfigString ( wgGlobal . mqttHostName , "mqttHostName" )
 if 2 - 2: IiI11Ii111 % i1iiIII111 . oOo0O00
 wgGlobal . mqttHostPort = getConfigInt ( wgGlobal . mqttHostPort , "mqttHostPort" )
 if len ( wgGlobal . mqttHostName ) > 1 :
  try :
   mqttUserName = getConfigString ( "" , "mqttUserName" )
   mqttPassword = getConfigString ( "" , "mqttPassword" )
   if len ( mqttUserName ) > 0 :
    client = mqtt . Client ( )
    if len ( mqttPassword ) > 0 :
     client . username_pw_set ( mqttUserName , mqttPassword )
    else :
     client . username_pw_set ( mqttUserName )
   else :
    client_id = time . strftime ( '1001CloudServer%Y%m%d%H%M%S' , time . localtime ( time . time ( ) ) )
    client = mqtt . Client ( client_id )
    if 59 - 59: I11iiIi11i1I % OooOoo - iI1iII1I1I1i % I1I + i1iiIII111 . I1Ii1I1
    if 94 - 94: ooOOO * I1Ii1I1 * i1iiIII111 . oOo0O00
   client . on_connect = mMonitorInfo . mqtt_on_connect
   client . on_message = mMonitorInfo . mqtt_on_message
   if 73 - 73: I1Ii1I1 / ooo000 % I11iiIi11i1I - i1i1i1111I + Oo - I1Ii1I1
   client . on_disconnect = mMonitorInfo . mqtt_on_disconnect
   if 18 - 18: i1 + ooOOO . i1 - iI1iII1I1I1i
   if 97 - 97: oOo0O00 + i1I % Iii1i
   mMonitorInfo . wgConRPC4MQTT = wgConRPCLongTime ( )
   reactor . listenUDP ( 0 , mMonitorInfo . wgConRPC4MQTT )
   if 34 - 34: i1 + Oo . oOo0O00 - ooo000 / I11iiIi11i1I * oOo0O00
   mMonitorInfo . mqttclient = client
   client . connect ( wgGlobal . mqttHostName , wgGlobal . mqttHostPort , 5 )
   client . loop_start ( )
   client . subscribe ( 'OpenDoorCommand' , qos = 0 )
   client . subscribe ( 'kaimenzhiling' , qos = 0 )
   if 89 - 89: oOo0O00
   mMonitorInfo . bSendByMQTT = True
   if 1 > 0 :
    mMonitorInfo . printCHS (
 "2021-10-13 Introduced support for publishing information to MQTT server: [{0:s}:{1:d}] (Topics: Door status, card swipe, QR code, heartbeat packets, alarms, remote door opening records, others) [Door status: 1 indicates door open, 0 indicates door closed]" . format (
 wgGlobal . mqttHostName , wgGlobal . mqttHostPort ) )
    mMonitorInfo . printCHS (
 "2021-10-22          增加 主题: 开门指令, 消息: 4510000002,1 (说明: 序列号,门号  [用逗号分开]--指令成功可以查看 远程开门记录 主题)" )
    mMonitorInfo . wglog (
 "2021-10-13 Introduced support for publishing information to MQTT server: [{0:s}:{1:d}] (Topics: Door status, card swipe, QR code, heartbeat packets, alarms, remote door opening records, others) [Door status: 1 indicates door open, 0 indicates door closed]" . format (
 wgGlobal . mqttHostName , wgGlobal . mqttHostPort ) )
    mMonitorInfo . wglog (
 "2021-10-22          增加 主题: 开门指令, 消息: 4510000002,1 (说明: 序列号,门号  [用逗号分开]--指令成功可以查看 远程开门记录 主题)" )
  except Exception as e :
   pass
   if 48 - 48: i1 / IIiIIiIi11I1 / iI1iII1I1I1i / IiI11Ii111 * IiIIii11Ii
   if 54 - 54: IIiIIiIi11I1 % I1I % IiI11Ii111 / I11iiIi11i1I . I11iiIi11i1I - IiIIii11Ii
   if 10 - 10: Ii . I11iiIi11i1I % i1I / OooOoo % I1Ii1I1
   if not ( wgGlobal . mqttHostName == "127.0.0.1" ) :
    mMonitorInfo . printCHS ( "           mqtt 服务器未连接: [{0:s}:{1:d}..." . format ( wgGlobal . mqttHostName ,
 wgGlobal . mqttHostPort ) )
    mMonitorInfo . wglog ( "           mqtt 服务器未连接: [{0:s}:{1:d}..." . format ( wgGlobal . mqttHostName ,
 wgGlobal . mqttHostPort ) )
   pass
 wgAppConfig . timeStampEnable = getConfigInt ( wgAppConfig . timeStampEnable ,
 "timeStampEnable" )
 try :
  mMonitorInfo . loadhttpconifg ( "" )
 except Exception as e :
  pass
  if 42 - 42: Oo - I1I * i1I * i1i1i1111I - I11iiIi11i1I
 finally :
  pass
  if 58 - 58: iI1iII1I1I1i
 try :
  mMonitorInfo . wgConRPCCommonWebapi = wgConRPCCommon ( )
  reactor . listenUDP ( 0 , mMonitorInfo . wgConRPCCommonWebapi )
 except Exception as e :
  pass
  mMonitorInfo . printCHS ( " wgConRPCCommonWebapi 创建失败" )
 finally :
  pass
  if 17 - 17: iI1iII1I1I1i - Ii % iI1iII1I1I1i % oOo0O00 * Iii1i
 try :
  f = open ( 'favicon.ico' , 'rb' )
  info = f . read ( )
  if len ( info ) > 0 :
   wgAppConfig . htmlIconExisted = True
 except Exception as e2 :
  if 51 - 51: I1I . i1i1i1111I % Ii
  if 55 - 55: i1i1i1111I * Ii % i1i1i1111I
  if 61 - 61: oOo0O00
  pass
  pass
  if 53 - 53: Ooo0Ooo / IiIIii11Ii
  if 49 - 49: ooo000 - oOO . IiIIii11Ii / Oo
  if 23 - 23: I11iiIi11i1I - i1 / Iii1i . iI1iII1I1I1i + oOO
  if 55 - 55: i1 - iI1iII1I1I1i / OooOoo + I1I + Oo
  if 5 - 5: IiI11Ii111 - i1 . i1i1i1111I / IiI11Ii111 . iI1iII1I1I1i . IiI11Ii111
  if 87 - 87: i1 . Ii * iI1iII1I1I1i - oOO / Ii / OooOoo
  if 65 - 65: i1I / i1I + IiI11Ii111
  if 99 - 99: i1 + OooOoo + I11iiIi11i1I * Ooo0Ooo / ooOOO + Ii
  if 72 - 72: I1Ii1I1 * Ooo0Ooo * IIiIIiIi11I1 % IiIIii11Ii . ooo000
  if 68 - 68: Ooo0Ooo * OooOoo - oOo0O00
  if 49 - 49: IIiIIiIi11I1 % i1
 if getConfigInt ( 0 , "printAll" ) > 0 or 'Debug' in wgGlobal . softwareVersion :
  wgGlobal . testModeDebugPrint = 1
  wgGlobal . allowprint = True
  if 29 - 29: OooOoo * Ii - oOO
 try :
  f = open ( './vistors.json' , 'rb' )
  info = f . read ( )
  if len ( info ) > 0 :
   if wgGlobal . visitorDB is None :
    wgGlobal . visitorDB = TinyDB ( 'vistors.json' )
   if not wgGlobal . visitorDBIsEnabled :
    wgGlobal . visitorDBIsEnabled = True
   if 1 > 0 :
    mMonitorInfo . printCHS ( "2023-02-23 访客预约启用中" )
   wgGlobal . visitorDBConfigOnlyOnce = 0
   db = wgGlobal . visitorDB
   vistor = Query ( )
   foundvistor = db . search ( vistor [ "Description" ] == "VisitorConfiguration" )
   if foundvistor :
    if 'SwipeValidOnlyOnce' in foundvistor [ 0 ] :
     wgGlobal . visitorDBConfigOnlyOnce = foundvistor [ 0 ] [ "SwipeValidOnlyOnce" ]
 except Exception as e2 :
  pass
  pass
  if 53 - 53: I11iiIi11i1I % ooo000 / ooOOO / I1I
 mMonitorInfo . memAllocMaxMB = getConfigInt ( mMonitorInfo . memAllocMaxMB ,
 "memAllocMaxMB" )
 mMonitorInfo . mqtt_timesMaxInOneSecond = getConfigInt ( mMonitorInfo . mqtt_timesMaxInOneSecond ,
 "mqtt_timesMaxInOneSecond" )
 mMonitorInfo . mqtt_englishTopic = getConfigInt ( mMonitorInfo . mqtt_englishTopic ,
 "mqtt_englishTopic" )
 if 43 - 43: iI1iII1I1I1i . i1i1i1111I + I1I % ooOOO . IiI11Ii111 - IiI11Ii111
 mMonitorInfo . mqtt_cycle_seconds = getConfigInt ( mMonitorInfo . mqtt_cycle_seconds ,
 "mqtt_cycle_seconds" )
 if 6 - 6: I1I
 try :
  rsa1 = WGRsa ( )
  if 98 - 98: oOO * IIiIIiIi11I1 / i1iiIII111 / Iii1i + I1I
  deferToThread ( DealRSAData )
 except Exception as e :
  pass
  mMonitorInfo . printCHS ( " mWGRsa 创建失败" )
  mMonitorInfo . printCHS ( e )
 finally :
  pass
 mMonitorInfo . OnlyVirtualCardOpenDoor = getConfigInt ( mMonitorInfo . OnlyVirtualCardOpenDoor ,
 "OnlyVirtualCardOpenDoor" )
 if 25 - 25: IIiIIiIi11I1 . IiI11Ii111 / I1I * i1 - i1iiIII111 % oOo0O00
 try :
  enablebroadcastCon = 1
  enablebroadcastCon = getConfigInt ( enablebroadcastCon ,
 "enablebroadcastCon" )
  if enablebroadcastCon > 0 and wgGlobal . dataserverIP == "0.0.0.0" :
   broadcastCon = FrmADCT3000 ( )
   mMonitorInfo . wgFrmADCT3000 = broadcastCon
   broadcastCon . start1001server ( )
   if len ( broadcastCon . arripsAreWatching ) == 0 :
    print ( "please check network connected????" )
    mMonitorInfo . wglog ( "please check network connected????" )
    try :
     checktimes = 0
     while True :
      broadcastCon . checkNetChanged ( )
      if len ( broadcastCon . arripsAreWatching ) > 0 :
       break
      else :
       checktimes = checktimes + 1
       time . sleep ( 0.5 )
    except Exception as e2 :
     print ( e2 )
     if 49 - 49: IiIIii11Ii % ooOOO + I11iiIi11i1I + IIiIIiIi11I1
 except Exception as e :
  pass
  mMonitorInfo . printCHS ( "广播包方式 创建失败" )
  mMonitorInfo . printCHS ( e )
 finally :
  pass
  if 60 - 60: IIiIIiIi11I1
 try :
  if 98 - 98: IiIIii11Ii / Ooo0Ooo + Ii
  wgOptimizePrivilege . Active = getConfigInt ( wgOptimizePrivilege . Active , "OptimizePrivilegeActive" )
  wgOptimizePrivilege . AutoRun = getConfigInt ( wgOptimizePrivilege . AutoRun , "OptimizePrivilegeAutoRun" )
  wgOptimizePrivilege . load ( )
 except Exception as e :
  pass
  mMonitorInfo . printCHS ( "wgOptimizePrivilegeA create failed" )
  mMonitorInfo . printCHS ( e )
 finally :
  pass
  if 73 - 73: OooOoo * Iii1i
 try :
  wgGlobal . wglogmaxBytes = getConfigInt ( wgGlobal . wglogmaxBytes , "wglogmaxBytes" )
  if 34 - 34: i1I % Ooo0Ooo * OooOoo + i1iiIII111 / i1
  if 49 - 49: IIiIIiIi11I1 / i1iiIII111 % IIiIIiIi11I1 + IIiIIiIi11I1 * iI1iII1I1I1i
 finally :
  pass
  if 22 - 22: I1Ii1I1 + oOO / I1Ii1I1 - Ii % Ii % i1i1i1111I
 try :
  wgGlobal . bNeedAutoAdjustTime = getConfigInt ( wgGlobal . bNeedAutoAdjustTime , "bNeedAutoAdjustTime" )
  if wgGlobal . bNeedAutoAdjustTime != 0 :
   mMonitorInfo . printCHS ( "已启用 自动校准时间" )
   if 86 - 86: Iii1i
   if 53 - 53: i1 * i1i1i1111I
 finally :
  pass
 try :
  wgGlobal . syncCycle = getConfigInt ( wgGlobal . syncCycle , "syncCycle" )
  if 91 - 91: I1I . I11iiIi11i1I
  if 59 - 59: IiI11Ii111 . IiI11Ii111 * IIiIIiIi11I1
 finally :
  pass
  if 85 - 85: Iii1i . oOO % Iii1i - Iii1i
  if 68 - 68: oOO + Iii1i + Ooo0Ooo % Oo / I11iiIi11i1I . OooOoo
  if 31 - 31: I11iiIi11i1I % ooOOO
  if 46 - 46: i1i1i1111I - ooo000 + iI1iII1I1I1i
 if 1 < 0 :
  mMonitorInfo . printCHS (
 "2022-05-13 增加提取权限, 上传全部有用时段, 清空时段, 提取时段; 修改BUG: 上传全部权限; 记录提取" )
  mMonitorInfo . printCHS (
 "2022-05-19 增加指定时间范围提取记录, 统一控制时段数组[驱动日期2022-05-19之后]" )
  mMonitorInfo . printCHS (
 "2022-05-26 BUG: 上传全部权限时 用户密码存在异常" )
  mMonitorInfo . printCHS (
 "2022-05-27 增加 梯控 储物柜 权限下发" )
  mMonitorInfo . printCHS (
 "2022-05-28 增加 生成二维码信息" )
  if 73 - 73: i1 * oOo0O00
  mMonitorInfo . printCHS (
 "2022-06-08 修改 与门禁软件对接; 优化 TCP连接" )
  if 88 - 88: Ii
  mMonitorInfo . printCHS (
 "2022-06-11 优化 统一控制时段和假期约束 TCP连接" )
  mMonitorInfo . printCHS (
 "2022-06-13 增加 梯控 远程开门_直达楼层号" )
  mMonitorInfo . printCHS (
 "2022-06-17 兼容 glibc 2.17" )
  mMonitorInfo . printCHS ( "2022-06-19 引入 二维码刷卡实时推送到HTTP服务器" )
  mMonitorInfo . printCHS ( "2022-06-25 增加 梯控允许常开楼层 输入6位临时密码作卡号[可选只许一次有效](按#号结束)" )
  if 12 - 12: ooo000 - IIiIIiIi11I1 % Iii1i . I1Ii1I1
  mMonitorInfo . printCHS ( "2022-07-05 优化 http服务占用的udp通信资源" )
  mMonitorInfo . printCHS ( "2022-07-05 优化 多线程兼容 二维码生成" )
  mMonitorInfo . printCHS ( "2022-07-08 修改BUG: 二维码生成(20220705版本)" )
  mMonitorInfo . printCHS ( "2022-07-25 增加mqtt参数: mqttHostName, mqttHostPort, mqttUserName, mqttPassword" )
  mMonitorInfo . printCHS (
 "2022-07-25 修改BUG: 解决提取记录(包含异常卡号)的失败问题--卡号超过9223372036854775807时将显示为负数" )
  if 11 - 11: i1iiIII111 - Oo % Ii % i1
  if 28 - 28: IIiIIiIi11I1 % Ii + ooOOO . i1I % Ii * I1Ii1I1
  mMonitorInfo . printCHS ( "2022-08-22 增加: 常开/复位 扩展口, 扩展口信息" )
  mMonitorInfo . printCHS ( "2022-08-24 修改BUG: 二维码刷卡实时推送到HTTP服务器  (请先启动HTTP服务后, 再启动1001)" )
  mMonitorInfo . printCHS ( "2022-08-26 增加: 串口透传 (要求: 驱动2022-08-26之后的)" )
  mMonitorInfo . printCHS ( "2022-08-26 修改: 远程开门记录 可显示 出门" )
  mMonitorInfo . printCHS ( "2022-11-07 修改: 权限中 针对双门四门的单个时段修改(驱动9.121或以上)" )
  mMonitorInfo . printCHS ( "2022-11-11 修改: 调整 刷卡开 刷卡关" )
  if 41 - 41: I1I
  mMonitorInfo . printCHS ( "2022-12-20 修改: 生成二维码信息 的ID值" )
  mMonitorInfo . printCHS (
 "2023-01-03 修改: 默认关闭指令时间约束[排除时区干扰]" )
  mMonitorInfo . printCHS (
 "2023-02-05 增加: 请排查: 空格;禁用全角字符; 指令中参数值为数字的, 请按指令要求填写, 不要加引号变成字符串 (指令要求见webapi开发指南);" )
  mMonitorInfo . printCHS ( "2023-02-23 增加: 访客预约" )
  mMonitorInfo . printCHS ( "2023-03-02 修改: 关闭部分调试信息" )
  mMonitorInfo . printCHS ( "2023-03-20 增加: 品控" )
  mMonitorInfo . printCHS ( "2023-03-20 修改: 加强ws保护" )
  mMonitorInfo . printCHS ( "2023-03-20 增加: 内存限制300MB" )
  mMonitorInfo . printCHS ( "2023-05-07 优化: 提取记录; 实时监控缓存" )
  mMonitorInfo . printCHS ( "2023-07-06 增加: 白名单" )
  mMonitorInfo . printCHS ( "2023-07-08 优化: 控制器驱动升级后 免重启1001" )
 if 1 > 0 :
  mMonitorInfo . printCHS ( "2023-07-08 优化: 驱动升级后 免重启" )
  mMonitorInfo . printCHS ( "2023-07-15 增加: 局域网控制器免配置" )
  if 76 - 76: ooo000 * i1i1i1111I
  mMonitorInfo . printCHS ( "2023-08-15 修改: 二维码支持身份证号" )
  if 39 - 39: i1 % i1I
  mMonitorInfo . printCHS (
 "2023-09-07 增加: 显示新的SwipeRecord及透传二维码信息(共200条)--调试用" )
  mMonitorInfo . printCHS ( "2023-09-17 增加: 显示身份证记录信息" )
  mMonitorInfo . printCHS ( "2023-10-09 修改: 显示非法刷卡报警" )
  mMonitorInfo . printCHS ( "2023-12-16 增加: 支持HTTP CORP跨域请求" )
  mMonitorInfo . printCHS ( "2023-12-16 修改: 原始64字节扩展到1024" )
  mMonitorInfo . printCHS ( "2023-12-30 修改: 对版本python3.5兼容" )
  mMonitorInfo . printCHS ( "2023-12-30 修改: win/arm/linux同步" )
  mMonitorInfo . printCHS (
 "2024-01-02 修改: 默认不启用wgrecord.log日志(可修改wgconfig.ini启用)" )
  mMonitorInfo . printCHS ( "2024-01-11 修改BUG: 解决内存泄漏[修改后, 正常工作时占用内存 30M]" )
  mMonitorInfo . printCHS ( "2024-02-27 修改BUG: websocket心跳包异常" )
  mMonitorInfo . printCHS ( "2024-03-20 修改BUG: 二维码TCP方式透传(上电,有透传后不开门)" )
  mMonitorInfo . printCHS ( "2024-03-28 优化: 局域网控制器免配置" )
  if 50 - 50: i1iiIII111 % OooOoo - i1i1i1111I * IiIIii11Ii % Oo . Ooo0Ooo
  if 30 - 30: i1iiIII111
  if 78 - 78: ooo000 % Iii1i + ooOOO * IIiIIiIi11I1 - i1
  if 46 - 46: Ooo0Ooo - i1I / ooo000 * IiI11Ii111 . oOo0O00
  if 32 - 32: i1i1i1111I . OooOoo + OooOoo - ooo000 * IiIIii11Ii + Oo
  if 12 - 12: oOo0O00
  mMonitorInfo . printCHS (
 "2024-05-06 控制器接入数: UDP连接不受限;TCP最大连接数>480[selectreactor(win): 500, pollreactor: 1024,epollreactor: 可过百万], 具体看系统支持能力" )
  mMonitorInfo . printCHS (
 "2024-05-06 优化: websocket[百台以上]" )
  mMonitorInfo . printCHS (
 "2024-05-06 优化: MQTT[百台以上]" )
  mMonitorInfo . printCHS (
 "2024-05-10 增加: 61007订阅-支持实时提取" )
  if 57 - 57: Oo + i1i1i1111I / I1Ii1I1
  if 56 - 56: oOO % Ooo0Ooo % Iii1i . i1i1i1111I
  if 46 - 46: IiI11Ii111 . i1iiIII111 % Iii1i - Ooo0Ooo + ooo000
  mMonitorInfo . printCHS (
 "2024-05-27 优化: 某些Linux环境下 CPU占用高." )
  mMonitorInfo . printCHS (
 "2024-06-17 BUG: 查询单个权限[截止日期 缺少具体时分], 查询全部则正常" )
  if 100 - 100: oOO
  mMonitorInfo . printCHS ( "2024-06-17 优化: json指令串" )
  mMonitorInfo . printCHS ( "2024-06-24 增加: 如果所有控制器断开,自动重启1001" )
  mMonitorInfo . printCHS ( "2024-07-16 修改: 梯控远程开门直达楼层" )
  mMonitorInfo . printCHS (
 "2024-07-20 修改: 兼容4G/WIFI控制器(设置参数 supportNXP4G = 1)[使用4G时, 请将等待超时加大到原来的3倍]" )
  mMonitorInfo . printCHS ( "2024-07-26 增加: 特殊通信方式显示(By_4G, By_WIFI)" )
  mMonitorInfo . printCHS ( "2024-07-26 修改: 提取记录" )
  mMonitorInfo . printCHS (
 "2024-07-27 修改: 控制器接入地址已变-日志限制1万条" )
  mMonitorInfo . printCHS ( "2024-07-29 修改: 禁用windows终端的快速编辑模式" )
  mMonitorInfo . printCHS ( "2024-08-12 优化: 自动重启1001[时间修改时]" )
  mMonitorInfo . printCHS ( "2024-08-12 增加: 优化控制器权限存储" )
  mMonitorInfo . printCHS ( "2024-08-21 优化: http转发操作" )
  mMonitorInfo . printCHS (
 "2024-08-22 BUG: N3000的实时监控异常(V8.240624到8.240821之间版本)" )
  if 32 - 32: I1Ii1I1 % ooo000 * OooOoo / oOo0O00 + ooOOO
  mMonitorInfo . printCHS ( "2024-09-02 增加: 支持Service服务启动[windows/linux]" )
  mMonitorInfo . printCHS ( "2024-09-02 优化: 动态适应网络配置变更" )
  mMonitorInfo . printCHS ( "2024-09-25 优化: 检查webapi指令中的键值含有空格" )
  mMonitorInfo . printCHS ( "2024-09-25 修改: 终端显示的调试信息写入wg_log.log中" )
  mMonitorInfo . printCHS ( "2024-09-30 修改: 提高指定云服务器IP的优先级" )
  mMonitorInfo . printCHS ( "2024-10-02 修改: 日志文件大小限制30M" )
  mMonitorInfo . printCHS ( "2024-10-11 优化: 上传512n权限" )
  mMonitorInfo . printCHS ( "2024-11-08 优化: 权限截止日期最大限制为2099年" )
  mMonitorInfo . printCHS ( "2024-11-27 修改: 远程开门 允许到达的楼层" )
  mMonitorInfo . printCHS ( "2024-12-10 增加: 闸机485串口透传" )
  mMonitorInfo . printCHS ( "2024-12-27 优化: MQTT重连" )
  mMonitorInfo . printCHS ( "2024-12-27 增加: 配置自动校准时间" )
  mMonitorInfo . printCHS ( "2024-12-27 增加: 开门超级密码设置和读取" )
  mMonitorInfo . printCHS ( "2025-02-17 增加: 引入配置TCP/UDP的同步信号-保持2秒周期" )
  mMonitorInfo . printCHS ( "2025-02-17 增加: ws记录中引入 服务器时间" )
  mMonitorInfo . printCHS ( "2025-03-16 修改: 上传假期约束的bug" )
  mMonitorInfo . printCHS ( "2025-09-22 修改: 处理BUG SM4加密通信(远程开门动作, 但接收不到回复) TCPClient方式 数据包转UDP时保持加密方式" )
  mMonitorInfo . printCHS ( "2025-10-10 修改: BUG: 生成的二维码在有效期内无法开门" )
  mMonitorInfo . printCHS ( "2025-11-17 修改: 增加socket.connect获取IP方法, 降低权限级别; xlsx取消openpyxl依赖, 适用于鸿蒙" )
  mMonitorInfo . printCHS ( "2025-11-27 修改: 查询控制器 加 储物柜接入, 打开的柜门, 合上的柜门" )
  mMonitorInfo . printCHS ( "2025-12-07 修改: 64字节指令兼容F2-F4短报文" )
 mMonitorInfo . printCHS ( """
!!!!!!!!!                    重要提示                  !!!!!!!!!
  确保防火墙开放以下端口 
  [特别是 云服务器安全组规则(入站规则/出站规则) 开通如下协议口]
################################################################
#     UDP: 61005                                               #   
#     TCP: 61005, 61080, 61081, 61085, 1883                    #
################################################################
""" )
 if 64 - 64: I1Ii1I1 . Ooo0Ooo
 if 36 - 36: IIiIIiIi11I1 + IiIIii11Ii . i1 + IIiIIiIi11I1
 wgGlobal . startuptime = time . strftime (
 '%Y-%m-%d %H:%M:%S' )
 mMonitorInfo . printCHS ( "{0} {1}" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , sys . modules [ 'twisted.internet.reactor' ] ) )
 mMonitorInfo . wglog ( "{0} {1}" . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) , sys . modules [ 'twisted.internet.reactor' ] ) )
 if 77 - 77: iI1iII1I1I1i / OooOoo . Iii1i + i1iiIII111 - IiI11Ii111
 mMonitorInfo . printCHS ( "{0} 开始正式运行..." . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) ) )
 if 49 - 49: i1iiIII111 - IiI11Ii111 - OooOoo
 mMonitorInfo . wglog ( "{0} 开始正式运行..." . format ( time . strftime ( '%Y-%m-%d %H:%M:%S' ) ) )
 if 39 - 39: I1I % i1iiIII111 - I1Ii1I1
 if 51 - 51: IIiIIiIi11I1 + i1 % i1iiIII111
 reactor . run ( )
 if 49 - 49: IiIIii11Ii - i1I . I1I
 if 76 - 76: oOO / iI1iII1I1I1i . I1I * oOo0O00 - i1i1i1111I
 if 53 - 53: OooOoo - oOo0O00 * ooOOO / OooOoo * Ooo0Ooo * ooo000
 if 10 - 10: IIiIIiIi11I1 % ooo000 % I11iiIi11i1I % Ooo0Ooo
 if 70 - 70: IiIIii11Ii
 if 90 - 90: i1i1i1111I % i1 . IiIIii11Ii * IiI11Ii111 / Ii
 if 73 - 73: ooo000 * Ooo0Ooo + Iii1i . ooOOO . I11iiIi11i1I / I11iiIi11i1I
 if 72 - 72: i1I * iI1iII1I1I1i / ooo000 + i1I - I11iiIi11i1I
 if 20 - 20: IIiIIiIi11I1 . oOo0O00 . Ooo0Ooo
 if 11 - 11: OooOoo
 if 45 - 45: iI1iII1I1I1i + I11iiIi11i1I / IIiIIiIi11I1
# dd678faae9ac167bc83abf78e5cb2f3f0688d3a3
