svghmi/svghmi_server.py
branchsvghmi
changeset 3281 1fc4274de64e
parent 3278 2bcfbea6a2a8
child 3284 55e69df85fe1
equal deleted inserted replaced
3280:09133b155f0c 3281:1fc4274de64e
    28 
    28 
    29 
    29 
    30 svghmi_wait = PLCBinary.svghmi_wait
    30 svghmi_wait = PLCBinary.svghmi_wait
    31 svghmi_wait.restype = ctypes.c_int # error or 0
    31 svghmi_wait.restype = ctypes.c_int # error or 0
    32 svghmi_wait.argtypes = []
    32 svghmi_wait.argtypes = []
       
    33 
       
    34 svghmi_continue_collect = ctypes.c_int.in_dll(PLCBinary, "svghmi_continue_collect")
    33 
    35 
    34 svghmi_send_collect = PLCBinary.svghmi_send_collect
    36 svghmi_send_collect = PLCBinary.svghmi_send_collect
    35 svghmi_send_collect.restype = ctypes.c_int # error or 0
    37 svghmi_send_collect.restype = ctypes.c_int # error or 0
    36 svghmi_send_collect.argtypes = [
    38 svghmi_send_collect.argtypes = [
    37     ctypes.c_uint32,  # index
    39     ctypes.c_uint32,  # index
   242 def SendThreadProc():
   244 def SendThreadProc():
   243     global svghmi_session_manager
   245     global svghmi_session_manager
   244     size = ctypes.c_uint32()
   246     size = ctypes.c_uint32()
   245     ptr = ctypes.c_void_p()
   247     ptr = ctypes.c_void_p()
   246     res = 0
   248     res = 0
   247     finished = False
   249     while svghmi_continue_collect:
   248     while not(finished):
       
   249         svghmi_wait()
   250         svghmi_wait()
   250         for svghmi_session in svghmi_session_manager.iter_sessions():
   251         for svghmi_session in svghmi_session_manager.iter_sessions():
   251             res = svghmi_send_collect(
   252             res = svghmi_send_collect(
   252                 svghmi_session.session_index,
   253                 svghmi_session.session_index,
   253                 ctypes.byref(size), ctypes.byref(ptr))
   254                 ctypes.byref(size), ctypes.byref(ptr))
   259                 # because of hmi data refresh period longer than
   260                 # because of hmi data refresh period longer than
   260                 # PLC common ticktime
   261                 # PLC common ticktime
   261                 pass
   262                 pass
   262             else:
   263             else:
   263                 # this happens when finishing
   264                 # this happens when finishing
   264                 finished = True
       
   265                 break
   265                 break
   266 
   266 
   267 def AddPathToSVGHMIServers(path, factory):
   267 def AddPathToSVGHMIServers(path, factory):
   268     for k,v in svghmi_servers.iteritems():
   268     for k,v in svghmi_servers.iteritems():
   269         svghmi_root, svghmi_listener, path_list = v
   269         svghmi_root, svghmi_listener, path_list = v