etherlab/EthercatCFileGenerator.py
changeset 2437 105c20fdeb19
parent 2425 68e7da937162
child 2643 b98d9e08231f
equal deleted inserted replaced
2436:82bfc75bcd9d 2437:105c20fdeb19
     8 #                          Higen Motor : Donggu Kang
     8 #                          Higen Motor : Donggu Kang
     9 #
     9 #
    10 # See COPYING file for copyrights details.
    10 # See COPYING file for copyrights details.
    11 
    11 
    12 from __future__ import absolute_import
    12 from __future__ import absolute_import
       
    13 from __future__ import division
    13 import os
    14 import os
    14 
    15 
    15 from etherlab.EthercatSlave import ExtractHexDecValue, DATATYPECONVERSION, ExtractName
    16 from etherlab.EthercatSlave import ExtractHexDecValue, DATATYPECONVERSION, ExtractName
    16 
    17 
    17 SLAVE_PDOS_CONFIGURATION_DECLARATION = """
    18 SLAVE_PDOS_CONFIGURATION_DECLARATION = """
   252                 for initCmd in initCmds:
   253                 for initCmd in initCmds:
   253                     index = initCmd["Index"]
   254                     index = initCmd["Index"]
   254                     subindex = initCmd["Subindex"]
   255                     subindex = initCmd["Subindex"]
   255                     entry = device_entries.get((index, subindex), None)
   256                     entry = device_entries.get((index, subindex), None)
   256                     if entry is not None:
   257                     if entry is not None:
   257                         data_size = entry["BitSize"] / 8
   258                         data_size = entry["BitSize"] // 8
   258                         data_str = ("0x%%.%dx" % (data_size * 2)) % initCmd["Value"]
   259                         data_str = ("0x%%.%dx" % (data_size * 2)) % initCmd["Value"]
   259                         init_cmd_infos = {
   260                         init_cmd_infos = {
   260                             "index": index,
   261                             "index": index,
   261                             "subindex": subindex,
   262                             "subindex": subindex,
   262                             "data": data_str,
   263                             "data": data_str,
   411                             ConfigureVariable(entry_infos, str_completion)
   412                             ConfigureVariable(entry_infos, str_completion)
   412 
   413 
   413                         elif pdo_type == "Outputs" and entry.getDataType() is not None and device_coe is not None:
   414                         elif pdo_type == "Outputs" and entry.getDataType() is not None and device_coe is not None:
   414                             data_type = entry.getDataType().getcontent()
   415                             data_type = entry.getDataType().getcontent()
   415                             entry_infos["dir"] = "Q"
   416                             entry_infos["dir"] = "Q"
   416                             entry_infos["data_size"] = max(1, entry_infos["bitlen"] / 8)
   417                             entry_infos["data_size"] = max(1, entry_infos["bitlen"] // 8)
   417                             entry_infos["data_type"] = DATATYPECONVERSION.get(data_type)
   418                             entry_infos["data_type"] = DATATYPECONVERSION.get(data_type)
   418                             entry_infos["var_type"] = data_type
   419                             entry_infos["var_type"] = data_type
   419                             entry_infos["real_var"] = "slave%(slave)d_%(index).4x_%(subindex).2x_default" % entry_infos
   420                             entry_infos["real_var"] = "slave%(slave)d_%(index).4x_%(subindex).2x_default" % entry_infos
   420 
   421 
   421                             ConfigureVariable(entry_infos, str_completion)
   422                             ConfigureVariable(entry_infos, str_completion)