diff -r 253110ba0fd7 -r 680ea4684209 modbus/modbus.py --- a/modbus/modbus.py Sun Jun 07 23:46:16 2020 +0100 +++ b/modbus/modbus.py Mon Dec 21 21:15:47 2020 +0000 @@ -131,13 +131,22 @@ # %QX1.2.3.n entries = [] entries.append({ - "name": "Exec. request flag", + "name": "Execute request flag", "type": LOCATION_VAR_MEMORY, "size": 1, # BOOL flag "IEC_type": "BOOL", # BOOL flag "var_name": "var_name", "location": "X" + ".".join([str(i) for i in current_location]) + ".0.0", - "description": "MB request execution control flag", + "description": "Modbus request execution control flag", + "children": []}) + entries.append({ + "name": "Request Status flag", + "type": LOCATION_VAR_MEMORY, + "size": 16, # WORD flag + "IEC_type": "WORD", # WORD flag + "var_name": "var_name", + "location": "W" + ".".join([str(i) for i in current_location]) + ".0.1", + "description": "Modbus request status flag", "children": []}) for offset in range(address, address + count): entries.append({ @@ -879,15 +888,19 @@ if ( relative_addr in xrange(int(GetCTVal(subchild, 2))) # condition (a) explained above and len(iecvar["LOC"]) < 5): # condition (b) explained above if str(iecvar["NAME"]) not in loc_vars_list: - loc_vars.append( - "u16 *" + str(iecvar["NAME"]) + " = &client_requests[%d].plcv_buffer[%d];" % (client_requestid, relative_addr)) + loc_vars.append("u16 *" + str(iecvar["NAME"]) + " = &client_requests[%d].plcv_buffer[%d];" % (client_requestid, relative_addr)) loc_vars_list.append(str(iecvar["NAME"])) # Now add the located variable in case it is a flag (condition (b) above if len(iecvar["LOC"]) >= 5: # condition (b) explained above if str(iecvar["NAME"]) not in loc_vars_list: - loc_vars.append( - "u16 *" + str(iecvar["NAME"]) + " = &client_requests[%d].flag_exec_req;" % (client_requestid)) - loc_vars_list.append(str(iecvar["NAME"])) + # Add if it is a Execution Request Flag (mapped onto %QXa.b.c.0.0), so last number is a '0' + if iecvar["LOC"][4] == 0: + loc_vars.append("u16 *" + str(iecvar["NAME"]) + " = &client_requests[%d].flag_exec_req;" % (client_requestid)) + loc_vars_list.append(str(iecvar["NAME"])) + # Add if it is a Communication Status Flag (mapped onto %QWa.b.c.0.1), so last number is a '1' + if iecvar["LOC"][4] == 1: + loc_vars.append("u16 *" + str(iecvar["NAME"]) + " = &client_requests[%d].flag_exec_status;" % (client_requestid)) + loc_vars_list.append(str(iecvar["NAME"])) client_requestid += 1 tcpclient_node_count += 1 client_nodeid += 1 @@ -920,7 +933,7 @@ # onto a location with 4 numbers (e.g. %QX0.1.2.0.0), where the last # two numbers are always '0.0', and the first two identify the request. # In the following if, we check for this condition by checking - # if their are at least 4 or more number in the location's address. + # if there are at least 4 or more number in the location's address. if ( relative_addr in xrange(int(GetCTVal(subchild, 2))) # condition (a) explained above and len(iecvar["LOC"]) < 5): # condition (b) explained above if str(iecvar["NAME"]) not in loc_vars_list: @@ -930,9 +943,14 @@ # Now add the located variable in case it is a flag (condition (b) above if len(iecvar["LOC"]) >= 5: # condition (b) explained above if str(iecvar["NAME"]) not in loc_vars_list: - loc_vars.append( - "u16 *" + str(iecvar["NAME"]) + " = &client_requests[%d].flag_exec_req;" % (client_requestid)) - loc_vars_list.append(str(iecvar["NAME"])) + # Add if it is a Execution Request Flag (mapped onto %QXa.b.c.0.0), so last number is a '0' + if iecvar["LOC"][4] == 0: + loc_vars.append("u16 *" + str(iecvar["NAME"]) + " = &client_requests[%d].flag_exec_req;" % (client_requestid)) + loc_vars_list.append(str(iecvar["NAME"])) + # Add if it is a Communication Status Flag (mapped onto %QWa.b.c.0.1), so last number is a '1' + if iecvar["LOC"][4] == 1: + loc_vars.append("u16 *" + str(iecvar["NAME"]) + " = &client_requests[%d].flag_exec_status;" % (client_requestid)) + loc_vars_list.append(str(iecvar["NAME"])) client_requestid += 1 rtuclient_node_count += 1 client_nodeid += 1