modbus/mb_utils.py
changeset 3733 d1acf20e8e7c
parent 2713 680ea4684209
child 3750 f62625418bff
equal deleted inserted replaced
3625:bb1eff4091ab 3733:d1acf20e8e7c
   138     """
   138     """
   139     Outputs a string to be used on C files
   139     Outputs a string to be used on C files
   140     params: child - the correspondent subplugin in Beremiz
   140     params: child - the correspondent subplugin in Beremiz
   141     """
   141     """
   142     node_init_template = '''/*node %(locnodestr)s*/
   142     node_init_template = '''/*node %(locnodestr)s*/
   143 {"%(locnodestr)s", "%(config_name)s", "%(device)s", "", {naf_rtu, {.rtu = {NULL, %(baud)s /*baud*/, %(parity)s /*parity*/, 8 /*data bits*/, %(stopbits)s, 0 /* ignore echo */}}}, -1 /* mb_nd */, 0 /* init_state */, %(coms_period)s /* communication period */}'''
   143 {"%(locnodestr)s", "%(config_name)s", "%(device)s", "", {naf_rtu, {.rtu = {NULL, %(baud)s /*baud*/, %(parity)s /*parity*/, 8 /*data bits*/, %(stopbits)s, 0 /* ignore echo */}}}, -1 /* mb_nd */, 0 /* init_state */, %(coms_period)s /* communication period  (ms)*/, %(coms_delay)s /* inter request delay (ms)*/, 0 /* prev_error */}'''
   144 
   144 
   145     location = ".".join(map(str, child.GetCurrentLocation()))
   145     location = ".".join(map(str, child.GetCurrentLocation()))
   146     config_name, device, baud, parity, stopbits, coms_period = GetCTVals(child, range(6))
   146     config_name, device, baud, parity, stopbits, coms_period, coms_delay = GetCTVals(child, range(7))
   147 
   147 
   148     node_dict = {"locnodestr": location,
   148     node_dict = {"locnodestr": location,
   149                  "config_name": config_name,
   149                  "config_name": config_name,
   150                  "device": device,
   150                  "device": device,
   151                  "baud": baud,
   151                  "baud": baud,
   152                  "parity": modbus_serial_parity_dict[parity],
   152                  "parity": modbus_serial_parity_dict[parity],
   153                  "stopbits": stopbits,
   153                  "stopbits": stopbits,
   154                  "coms_period": coms_period}
   154                  "coms_period": coms_period,
       
   155                  "coms_delay": coms_delay}
   155     return node_init_template % node_dict
   156     return node_init_template % node_dict
   156 
   157 
   157 
   158 
   158 def GetTCPClientNodePrinted(self, child):
   159 def GetTCPClientNodePrinted(self, child):
   159     """
   160     """
   160     Outputs a string to be used on C files
   161     Outputs a string to be used on C files
   161     params: child - the correspondent subplugin in Beremiz
   162     params: child - the correspondent subplugin in Beremiz
   162     """
   163     """
   163     node_init_template = '''/*node %(locnodestr)s*/
   164     node_init_template = '''/*node %(locnodestr)s*/
   164 {"%(locnodestr)s", "%(config_name)s", "%(host)s", "%(port)s", {naf_tcp, {.tcp = {NULL, NULL, DEF_CLOSE_ON_SILENCE}}}, -1 /* mb_nd */, 0 /* init_state */, %(coms_period)s /* communication period */, 0 /* prev_error */}'''
   165 {"%(locnodestr)s", "%(config_name)s", "%(host)s", "%(port)s", {naf_tcp, {.tcp = {NULL, NULL, DEF_CLOSE_ON_SILENCE}}}, -1 /* mb_nd */, 0 /* init_state */, %(coms_period)s /* communication period (ms)*/, %(coms_delay)s /* inter request delay (ms)*/, 0 /* prev_error */}'''
   165 
   166 
   166     location = ".".join(map(str, child.GetCurrentLocation()))
   167     location = ".".join(map(str, child.GetCurrentLocation()))
   167     config_name, host, port, coms_period = GetCTVals(child, range(4))
   168     config_name, host, port, coms_period, coms_delay = GetCTVals(child, range(5))
   168 
   169 
   169     node_dict = {"locnodestr": location,
   170     node_dict = {"locnodestr": location,
   170                  "config_name": config_name,
   171                  "config_name": config_name,
   171                  "host": host,
   172                  "host": host,
   172                  "port": port,
   173                  "port": port,
   173                  "coms_period": coms_period}
   174                  "coms_period": coms_period,
       
   175                  "coms_delay": coms_delay}
   174     return node_init_template % node_dict
   176     return node_init_template % node_dict
   175 
   177 
   176 
   178 
   177 def GetClientRequestPrinted(self, child, nodeid):
   179 def GetClientRequestPrinted(self, child, nodeid):
   178     """
   180     """