etherlab/EthercatCFileGenerator.py
changeset 2377 88a9d64560d3
parent 2374 aed3ca79a10a
child 2378 7aa47c09f8f5
equal deleted inserted replaced
2376:47775c9367bd 2377:88a9d64560d3
    73     entry_infos["data_type"] = DATATYPECONVERSION.get(entry_infos["var_type"], None)
    73     entry_infos["data_type"] = DATATYPECONVERSION.get(entry_infos["var_type"], None)
    74     if entry_infos["data_type"] is None:
    74     if entry_infos["data_type"] is None:
    75         raise ValueError, _("Type of location \"%s\" not yet supported!") % entry_infos["var_name"]
    75         raise ValueError, _("Type of location \"%s\" not yet supported!") % entry_infos["var_name"]
    76 
    76 
    77     if not entry_infos.get("no_decl", False):
    77     if not entry_infos.get("no_decl", False):
    78         if entry_infos.has_key("real_var"):
    78         if "real_var" in entry_infos:
    79             str_completion["located_variables_declaration"].append(
    79             str_completion["located_variables_declaration"].append(
    80                 "IEC_%(var_type)s %(real_var)s;" % entry_infos)
    80                 "IEC_%(var_type)s %(real_var)s;" % entry_infos)
    81         else:
    81         else:
    82             entry_infos["real_var"] = "beremiz" + entry_infos["var_name"]
    82             entry_infos["real_var"] = "beremiz" + entry_infos["var_name"]
    83             str_completion["located_variables_declaration"].extend(
    83             str_completion["located_variables_declaration"].extend(
    85                  "IEC_%(var_type)s *%(var_name)s = &%(real_var)s;" % entry_infos])
    85                  "IEC_%(var_type)s *%(var_name)s = &%(real_var)s;" % entry_infos])
    86         for declaration in entry_infos.get("extra_declarations", []):
    86         for declaration in entry_infos.get("extra_declarations", []):
    87             entry_infos["extra_decl"] = declaration
    87             entry_infos["extra_decl"] = declaration
    88             str_completion["located_variables_declaration"].append(
    88             str_completion["located_variables_declaration"].append(
    89                  "IEC_%(var_type)s *%(extra_decl)s = &%(real_var)s;" % entry_infos)
    89                  "IEC_%(var_type)s *%(extra_decl)s = &%(real_var)s;" % entry_infos)
    90     elif not entry_infos.has_key("real_var"):
    90     elif "real_var" not in entry_infos:
    91         entry_infos["real_var"] = "beremiz" + entry_infos["var_name"]
    91         entry_infos["real_var"] = "beremiz" + entry_infos["var_name"]
    92 
    92 
    93     str_completion["used_pdo_entry_offset_variables_declaration"].append(
    93     str_completion["used_pdo_entry_offset_variables_declaration"].append(
    94         "unsigned int slave%(slave)d_%(index).4x_%(subindex).2x;" % entry_infos)
    94         "unsigned int slave%(slave)d_%(index).4x_%(subindex).2x;" % entry_infos)
    95 
    95 
   488                             elif entry_infos["dir"] == "Q" and entry["PDOMapping"] in ["R", "RT"]:
   488                             elif entry_infos["dir"] == "Q" and entry["PDOMapping"] in ["R", "RT"]:
   489                                 pdo_type = "Outputs"
   489                                 pdo_type = "Outputs"
   490                             else:
   490                             else:
   491                                 raise ValueError, _("Wrong direction for location \"%s\"!") % entry_infos["var_name"]
   491                                 raise ValueError, _("Wrong direction for location \"%s\"!") % entry_infos["var_name"]
   492 
   492 
   493                             if not dynamic_pdos.has_key(pdo_type):
   493                             if pdo_type not in dynamic_pdos:
   494                                 raise ValueError, _("No Sync manager defined for %s!") % pdo_type
   494                                 raise ValueError, _("No Sync manager defined for %s!") % pdo_type
   495 
   495 
   496                             ConfigureVariable(entry_infos, str_completion)
   496                             ConfigureVariable(entry_infos, str_completion)
   497 
   497 
   498                             if len(dynamic_pdos[pdo_type]["pdos"]) > 0:
   498                             if len(dynamic_pdos[pdo_type]["pdos"]) > 0: