etherlab/EthercatCFileGenerator.py
changeset 2360 2a3d022a7dac
parent 2355 fec77f2b9e07
child 2374 aed3ca79a10a
equal deleted inserted replaced
2359:e945fcb54cd4 2360:2a3d022a7dac
    65             goto ecat_failed;
    65             goto ecat_failed;
    66         }
    66         }
    67         %(real_var)s = EC_READ_%(data_type)s((uint8_t *)value);
    67         %(real_var)s = EC_READ_%(data_type)s((uint8_t *)value);
    68     }
    68     }
    69 """
    69 """
       
    70 
    70 
    71 
    71 def ConfigureVariable(entry_infos, str_completion):
    72 def ConfigureVariable(entry_infos, str_completion):
    72     entry_infos["data_type"] = DATATYPECONVERSION.get(entry_infos["var_type"], None)
    73     entry_infos["data_type"] = DATATYPECONVERSION.get(entry_infos["var_type"], None)
    73     if entry_infos["data_type"] is None:
    74     if entry_infos["data_type"] is None:
    74         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"]
   122         elif entry_infos["dir"] == "Q":
   123         elif entry_infos["dir"] == "Q":
   123             str_completion["publish_variables"].append(
   124             str_completion["publish_variables"].append(
   124                 ("    EC_WRITE_%(data_type)s(domain1_pd + slave%(slave)d_%(index).4x_%(subindex).2x, " +
   125                 ("    EC_WRITE_%(data_type)s(domain1_pd + slave%(slave)d_%(index).4x_%(subindex).2x, " +
   125                  "%(real_var)s);") % entry_infos)
   126                  "%(real_var)s);") % entry_infos)
   126 
   127 
       
   128 
   127 def ExclusionSortFunction(x, y):
   129 def ExclusionSortFunction(x, y):
   128     if x["matching"] == y["matching"]:
   130     if x["matching"] == y["matching"]:
   129         if x["assigned"] and not y["assigned"]:
   131         if x["assigned"] and not y["assigned"]:
   130             return -1
   132             return -1
   131         elif not x["assigned"] and y["assigned"]:
   133         elif not x["assigned"] and y["assigned"]:
   132             return 1
   134             return 1
   133         return cmp(x["count"], y["count"])
   135         return cmp(x["count"], y["count"])
   134     return -cmp(x["matching"], y["matching"])
   136     return -cmp(x["matching"], y["matching"])
       
   137 
   135 
   138 
   136 class _EthercatCFileGenerator:
   139 class _EthercatCFileGenerator:
   137 
   140 
   138     def __init__(self, controler):
   141     def __init__(self, controler):
   139         self.Controler = controler
   142         self.Controler = controler