modbus/web_settings.py
changeset 2676 b276d05bdb09
parent 2675 3ca5611d6308
child 2686 703ebf57508a
equal deleted inserted replaced
2675:3ca5611d6308 2676:b276d05bdb09
   545     # If the "__modbus_plugin_client_node_count" 
   545     # If the "__modbus_plugin_client_node_count" 
   546     # or the "__modbus_plugin_server_node_count" C variables 
   546     # or the "__modbus_plugin_server_node_count" C variables 
   547     # are not present in the .so file we conclude that the currently loaded 
   547     # are not present in the .so file we conclude that the currently loaded 
   548     # PLC does not have the Modbus plugin included (situation (2b) described above init())
   548     # PLC does not have the Modbus plugin included (situation (2b) described above init())
   549     try:
   549     try:
       
   550         # XXX TODO : stop reading from PLC .so file. This code is template code
       
   551         #            that can use modbus extension build data, such as client node count.
   550         client_count = ctypes.c_int.in_dll(PLCObject.PLClibraryHandle, "__modbus_plugin_client_node_count").value
   552         client_count = ctypes.c_int.in_dll(PLCObject.PLClibraryHandle, "__modbus_plugin_client_node_count").value
   551         server_count = ctypes.c_int.in_dll(PLCObject.PLClibraryHandle, "__modbus_plugin_server_node_count").value
   553         server_count = ctypes.c_int.in_dll(PLCObject.PLClibraryHandle, "__modbus_plugin_server_node_count").value
   552     except Exception:
   554     except Exception:
   553         # Loaded PLC does not have the Modbus plugin => nothing to do
   555         # Loaded PLC does not have the Modbus plugin => nothing to do
   554         #   (i.e. do _not_ configure and make available the Modbus web interface)
   556         #   (i.e. do _not_ configure and make available the Modbus web interface)
   567     GetClientParamFuncs = {}
   569     GetClientParamFuncs = {}
   568     SetClientParamFuncs = {}
   570     SetClientParamFuncs = {}
   569     GetServerParamFuncs = {}
   571     GetServerParamFuncs = {}
   570     SetServerParamFuncs = {}
   572     SetServerParamFuncs = {}
   571 
   573 
       
   574     # XXX TODO : stop reading from PLC .so file. This code is template code
       
   575     #            that can use modbus extension build data
   572     for name, web_label, c_dtype, web_dtype in TCPclient_parameters + RTUclient_parameters + General_parameters:
   576     for name, web_label, c_dtype, web_dtype in TCPclient_parameters + RTUclient_parameters + General_parameters:
   573         ParamFuncName                      = "__modbus_get_ClientNode_" + name        
   577         ParamFuncName                      = "__modbus_get_ClientNode_" + name        
   574         GetClientParamFuncs[name]          = getattr(PLCObject.PLClibraryHandle, ParamFuncName)
   578         GetClientParamFuncs[name]          = getattr(PLCObject.PLClibraryHandle, ParamFuncName)
   575         GetClientParamFuncs[name].restype  = c_dtype
   579         GetClientParamFuncs[name].restype  = c_dtype
   576         GetClientParamFuncs[name].argtypes = [ctypes.c_int]
   580         GetClientParamFuncs[name].argtypes = [ctypes.c_int]
   579         ParamFuncName                      = "__modbus_set_ClientNode_" + name
   583         ParamFuncName                      = "__modbus_set_ClientNode_" + name
   580         SetClientParamFuncs[name]          = getattr(PLCObject.PLClibraryHandle, ParamFuncName)
   584         SetClientParamFuncs[name]          = getattr(PLCObject.PLClibraryHandle, ParamFuncName)
   581         SetClientParamFuncs[name].restype  = None
   585         SetClientParamFuncs[name].restype  = None
   582         SetClientParamFuncs[name].argtypes = [ctypes.c_int, c_dtype]
   586         SetClientParamFuncs[name].argtypes = [ctypes.c_int, c_dtype]
   583 
   587 
       
   588     # XXX TODO : stop reading from PLC .so file. This code is template code
       
   589     #            that can use modbus extension build data
   584     for name, web_label, c_dtype, web_dtype in TCPserver_parameters + RTUslave_parameters + General_parameters:
   590     for name, web_label, c_dtype, web_dtype in TCPserver_parameters + RTUslave_parameters + General_parameters:
   585         ParamFuncName                      = "__modbus_get_ServerNode_" + name        
   591         ParamFuncName                      = "__modbus_get_ServerNode_" + name        
   586         GetServerParamFuncs[name]          = getattr(PLCObject.PLClibraryHandle, ParamFuncName)
   592         GetServerParamFuncs[name]          = getattr(PLCObject.PLClibraryHandle, ParamFuncName)
   587         GetServerParamFuncs[name].restype  = c_dtype
   593         GetServerParamFuncs[name].restype  = c_dtype
   588         GetServerParamFuncs[name].argtypes = [ctypes.c_int]
   594         GetServerParamFuncs[name].argtypes = [ctypes.c_int]