etherlab/EthercatCIA402Slave.py
changeset 2155 d63541200d8e
parent 2154 6bbe93799956
child 2156 c8eee6be2da8
equal deleted inserted replaced
2154:6bbe93799956 2155:d63541200d8e
   131         return _EthercatSlaveCTN.SetParamsAttribute(self, path, value)
   131         return _EthercatSlaveCTN.SetParamsAttribute(self, path, value)
   132     
   132     
   133     def GetVariableLocationTree(self):
   133     def GetVariableLocationTree(self):
   134         axis_name = self.CTNName()
   134         axis_name = self.CTNName()
   135         current_location = self.GetCurrentLocation()
   135         current_location = self.GetCurrentLocation()
   136         children = [{"name": "%s Network Position" % (axis_name),
   136         children = [{"name": name_frmt % (axis_name),
   137                      "type": LOCATION_VAR_INPUT,
   137                      "type": LOCATION_VAR_INPUT,
   138                      "size": "W",
   138                      "size": "W",
   139                      "IEC_type": "UINT",
   139                      "IEC_type": iec_type,
   140                      "var_name": axis_name,
   140                      "var_name": var_name_frmt % axis_name,
   141                      "location": "%%IW%s" % (".".join(map(str, current_location))),
   141                      "location": location_frmt % (
       
   142                             ".".join(map(str, current_location))),
   142                      "description": "",
   143                      "description": "",
   143                      "children": []},
   144                      "children": []}
   144                     {"name": "%s Axis Ref" % (axis_name),
   145                     for name_frmt, iec_type, var_name_frmt, location_frmt in
   145                      "type": LOCATION_VAR_INPUT,
   146                         [("%s Network Position", "UINT", "%s_pos", "%%IW%s"),
   146                      "size": "W",
   147                          ("%s Axis Ref", "AXIS_REF", "%s", "%%IW%s.402")]]
   147                      "IEC_type": "AXIS_REF",
   148         children.extend(self.CTNParent.GetDeviceLocationTree(
   148                      "var_name": axis_name,
   149                             self.GetSlavePos(), current_location, axis_name))
   149                      "location": "%%IW%s.402" % (".".join(map(str, current_location))),
       
   150                      "description": "",
       
   151                      "children": []}]
       
   152         children.extend(self.CTNParent.GetDeviceLocationTree(self.GetSlavePos(), current_location, axis_name))
       
   153         return  {"name": axis_name,
   150         return  {"name": axis_name,
   154                  "type": LOCATION_CONFNODE,
   151                  "type": LOCATION_CONFNODE,
   155                  "location": self.GetFullIEC_Channel(),
   152                  "location": self.GetFullIEC_Channel(),
   156                  "children": children,
   153                  "children": children,
   157         }
   154         }
   251             param_name = param["name"]
   248             param_name = param["name"]
   252             
   249             
   253             # Param is optional variables section enable flag
   250             # Param is optional variables section enable flag
   254             extra_node_variable_infos = EXTRA_NODE_VARIABLES_DICT.get(param_name)
   251             extra_node_variable_infos = EXTRA_NODE_VARIABLES_DICT.get(param_name)
   255             if extra_node_variable_infos is not None:
   252             if extra_node_variable_infos is not None:
       
   253                 param_name += "Enabled"
   256                 
   254                 
   257                 if not param["value"]:
   255                 if not param["value"]:
   258                     continue
   256                     continue
   259                 
   257                 
   260                 # Optional variables section is enabled
   258                 # Optional variables section is enabled
   276                                                       default_template)
   274                                                       default_template)
   277                         if template is not None:
   275                         if template is not None:
   278                             extra_variables_publish.append(template % locals())
   276                             extra_variables_publish.append(template % locals())
   279             
   277             
   280             # Set AxisRef public struct member value if defined
   278             # Set AxisRef public struct member value if defined
   281             elif param["value"] is not None:
   279             if param["value"] is not None:
   282                 param_value = ({True: "1", False: "0"}[param["value"]]
   280                 param_value = ({True: "1", False: "0"}[param["value"]]
   283                                if param["type"] == "boolean"
   281                                if param["type"] == "boolean"
   284                                else str(param["value"]))
   282                                else str(param["value"]))
   285                 
   283                 
   286                 init_axis_params.append("""\
   284                 init_axis_params.append("""\