svghmi/svghmi_server.py
branchsvghmi
changeset 2776 246ae685ab65
parent 2775 3b93409ba22c
child 2777 cdf6584953a0
equal deleted inserted replaced
2775:3b93409ba22c 2776:246ae685ab65
    32 svghmi_recv_dispatch.restype = ctypes.c_int # error or 0
    32 svghmi_recv_dispatch.restype = ctypes.c_int # error or 0
    33 svghmi_recv_dispatch.argtypes = [
    33 svghmi_recv_dispatch.argtypes = [
    34     ctypes.c_uint32,                  # size
    34     ctypes.c_uint32,                  # size
    35     ctypes.POINTER(ctypes.c_void_p)]  # data ptr
    35     ctypes.POINTER(ctypes.c_void_p)]  # data ptr
    36 # TODO multiclient : switch to arrays
    36 # TODO multiclient : switch to arrays
    37 
       
    38 def SendThreadProc():
       
    39    assert(svghmi_session)
       
    40    size = ctypes.c_uint32()
       
    41    ptr = ctypes.c_void_p()
       
    42    res = 0
       
    43    while svghmi_send_collect(ctypes.byref(size), ctypes.byref(ptr)) == 0 and \
       
    44          svghmi_session is not None and \
       
    45          svghmi_session.sendMessage(ctypes.string_at(ptr,size)) == 0:
       
    46          pass
       
    47 
       
    48        # TODO multiclient : dispatch to sessions
       
    49 
    37 
    50 class HMISession(object):
    38 class HMISession(object):
    51     def __init__(self, protocol_instance):
    39     def __init__(self, protocol_instance):
    52         global svghmi_session
    40         global svghmi_session
    53 
    41 
   104 
    92 
   105 svghmi_root = None
    93 svghmi_root = None
   106 svghmi_listener = None
    94 svghmi_listener = None
   107 svghmi_send_thread = None
    95 svghmi_send_thread = None
   108 
    96 
       
    97 def SendThreadProc():
       
    98    global svghmi_session
       
    99    size = ctypes.c_uint32()
       
   100    ptr = ctypes.c_void_p()
       
   101    res = 0
       
   102    while svghmi_send_collect(ctypes.byref(size), ctypes.byref(ptr)) == 0 and \
       
   103          svghmi_session is not None and \
       
   104          svghmi_session.sendMessage(ctypes.string_at(ptr,size)) == 0:
       
   105          pass
       
   106 
       
   107        # TODO multiclient : dispatch to sessions
       
   108 
   109 
   109 
   110 # Called by PLCObject at start
   110 # Called by PLCObject at start
   111 def _runtime_svghmi0_start():
   111 def _runtime_svghmi0_start():
   112     global svghmi_listener, svghmi_root, svghmi_send_thread
   112     global svghmi_listener, svghmi_root, svghmi_send_thread
   113 
   113