edouard@2165: #!/usr/bin/env python
edouard@2165: # -*- coding: utf-8 -*-
edouard@2165:
edouard@2165: # This file is part of Beremiz
edouard@2165: #
edouard@2165: # Copyright (C) 2011-2014: Laurent BESSARD, Edouard TISSERANT
edouard@2165: # RTES Lab : CRKim, JBLee, youcu
edouard@2165: # Higen Motor : Donggu Kang
edouard@2165: #
edouard@2165: # See COPYING file for copyrights details.
edouard@2165:
andrej@2405: from __future__ import absolute_import
Laurent@2111: import os
Laurent@2111:
Laurent@2111: import wx
Laurent@2111:
andrej@2396: from PLCControler import LOCATION_CONFNODE, LOCATION_VAR_INPUT
Laurent@2111:
andrej@2406: from MotionLibrary import AxisXSD
andrej@2405: from etherlab.EthercatSlave import _EthercatSlaveCTN, _CommonSlave
andrej@2405: from etherlab.ConfigEditor import CIA402NodeEditor
Laurent@2111:
Laurent@2153: # Definition of node variables that have to be mapped in PDO
andrej@2355: # [(name, index, subindex, type,
Laurent@2153: # direction for master ('I': input, 'Q': output)),...]
Laurent@2111: NODE_VARIABLES = [
Laurent@2153: ("ControlWord", 0x6040, 0x00, "UINT", "Q"),
Laurent@2153: ("TargetPosition", 0x607a, 0x00, "DINT", "Q"),
Laurent@2153: ("TargetVelocity", 0x60ff, 0x00, "DINT", "Q"),
Laurent@2153: ("TargetTorque", 0x6071, 0x00, "INT", "Q"),
Laurent@2153: ("ModesOfOperation", 0x6060, 0x00, "SINT", "Q"),
Laurent@2153: ("StatusWord", 0x6041, 0x00, "UINT", "I"),
Laurent@2153: ("ModesOfOperationDisplay", 0x6061, 0x00, "SINT", "I"),
Laurent@2153: ("ActualPosition", 0x6064, 0x00, "DINT", "I"),
Laurent@2153: ("ActualVelocity", 0x606c, 0x00, "DINT", "I"),
Laurent@2153: ("ActualTorque", 0x6077, 0x00, "INT", "I"),
Laurent@2111: ]
Laurent@2111:
Laurent@2153: # Definition of optional node variables that can be added to PDO mapping.
Laurent@2153: # A checkbox will be displayed for each section in node configuration panel to
Laurent@2153: # enable them
andrej@2355: # [(section_name,
andrej@2355: # [{'description', (name, index, subindex, type,
Laurent@2153: # direction for master ('I': input, 'Q': output)),
andrej@2355: # 'retrieve', string_template_for_retrieve_variable (None: not retrieved,
Laurent@2153: # default string template if not defined),
andrej@2355: # 'publish', string_template_for_publish_variable (None: not published,
Laurent@2153: # default string template if not defined),
Laurent@2153: # },...]
Laurent@2111: EXTRA_NODE_VARIABLES = [
Laurent@2111: ("ErrorCode", [
Laurent@2111: {"description": ("ErrorCode", 0x603F, 0x00, "UINT", "I"),
Laurent@2111: "publish": None}
Laurent@2111: ]),
Laurent@2111: ("DigitalInputs", [
Laurent@2111: {"description": ("DigitalInputs", 0x60FD, 0x00, "UDINT", "I"),
Laurent@2111: "publish": None}
Laurent@2111: ]),
Laurent@2111: ("DigitalOutputs", [
Laurent@2111: {"description": ("DigitalOutputs", 0x60FE, 0x00, "UDINT", "Q"),
Laurent@2111: "retrieve": None}
Laurent@2146: ]),
Laurent@2146: ("TouchProbe", [
Laurent@2146: {"description": ("TouchProbeFunction", 0x60B8, 0x00, "UINT", "Q"),
Laurent@2146: "retrieve": None},
Laurent@2146: {"description": ("TouchProbeStatus", 0x60B9, 0x00, "UINT", "I"),
Laurent@2146: "publish": None},
Laurent@2146: {"description": ("TouchProbePos1PosValue", 0x60BA, 0x00, "DINT", "I"),
Laurent@2146: "publish": None},
Laurent@2146: {"description": ("TouchProbePos1NegValue", 0x60BB, 0x00, "DINT", "I"),
Laurent@2146: "publish": None},
Laurent@2146: ]),
Laurent@2111: ]
Laurent@2153:
Laurent@2153: # List of parameters name in no configuration panel for optional variable
Laurent@2153: # sections
Laurent@2153: EXTRA_NODE_VARIABLES_DICT = {
andrej@2355: "Enable" + name: params
Laurent@2153: for name, params in EXTRA_NODE_VARIABLES}
Laurent@2153:
Laurent@2153: # List of block to define to interface MCL to fieldbus for specific functions
Laurent@2153: FIELDBUS_INTERFACE_GLOBAL_INSTANCES = [
andrej@2355: {"blocktype": "GetTorqueLimit",
Laurent@2111: "inputs": [],
Laurent@2111: "outputs": [{"name": "TorqueLimitPos", "type": "UINT"},
Laurent@2111: {"name": "TorqueLimitNeg", "type": "UINT"}]},
andrej@2355: {"blocktype": "SetTorqueLimit",
Laurent@2111: "inputs": [{"name": "TorqueLimitPos", "type": "UINT"},
Laurent@2111: {"name": "TorqueLimitNeg", "type": "UINT"}],
Laurent@2111: "outputs": []},
Laurent@2111: ]
Laurent@2111:
andrej@2356: # --------------------------------------------------
Laurent@2111: # Ethercat CIA402 Node
andrej@2356: # --------------------------------------------------
Laurent@2111:
Laurent@2111:
Laurent@2111: class _EthercatCIA402SlaveCTN(_EthercatSlaveCTN):
Laurent@2111: XSD = """
Laurent@2111:
Laurent@2111:
Laurent@2111:
Laurent@2111: %s
Laurent@2111:
Laurent@2111:
Laurent@2111:
Laurent@2153: """ % ("\n".join(["""\
Laurent@2153: """ % category
andrej@2381: for category, variables in EXTRA_NODE_VARIABLES]) + AxisXSD)
andrej@2355:
Laurent@2111: NODE_PROFILE = 402
Laurent@2111: EditorType = CIA402NodeEditor
andrej@2355:
Laurent@2111: ConfNodeMethods = [
andrej@2375: {
andrej@2375: "bitmap": "CIA402AxisRef",
andrej@2375: "name": _("Axis Ref"),
andrej@2375: "tooltip": _("Initiate Drag'n drop of Axis ref located variable"),
andrej@2375: "method": "_getCIA402AxisRef",
andrej@2375: "push": True,
andrej@2375: },
andrej@2375: {
andrej@2375: "bitmap": "CIA402NetPos",
andrej@2375: "name": _("Axis Pos"),
andrej@2375: "tooltip": _("Initiate Drag'n drop of Network position located variable"),
andrej@2375: "method": "_getCIA402NetworkPosition",
andrej@2375: "push": True,
andrej@2375: },
Laurent@2153: ]
andrej@2355:
andrej@2356: # --------------------------------------------------
Edouard@2152: # class code
andrej@2356: # --------------------------------------------------
andrej@2355:
Edouard@2152: def __init__(self):
andrej@2393: _EthercatSlaveCTN.__init__(self)
andrej@2393:
Edouard@2152: # ----------- call ethercat mng. function --------------
Edouard@2152: self.CommonMethod = _CommonSlave(self)
edouard@2641:
Laurent@2111: def GetIconName(self):
Laurent@2111: return "CIA402Slave"
andrej@2355:
Laurent@2111: def SetParamsAttribute(self, path, value):
Laurent@2111: if path == "CIA402SlaveParams.Type":
Laurent@2111: path = "SlaveParams.Type"
Laurent@2111: elif path == "CIA402SlaveParams.Alias":
Laurent@2111: path = "SlaveParams.Alias"
Laurent@2111: return _EthercatSlaveCTN.SetParamsAttribute(self, path, value)
andrej@2355:
Laurent@2111: def GetVariableLocationTree(self):
Laurent@2111: axis_name = self.CTNName()
Laurent@2111: current_location = self.GetCurrentLocation()
andrej@2380: children = [
andrej@2380: {
andrej@2380: "name": name_frmt % (axis_name),
andrej@2380: "type": LOCATION_VAR_INPUT,
andrej@2380: "size": "W",
andrej@2380: "IEC_type": iec_type,
andrej@2380: "var_name": var_name_frmt % axis_name,
andrej@2380: "location": location_frmt % (".".join(map(str, current_location))),
andrej@2380: "description": "",
andrej@2380: "children": []
andrej@2380: }
andrej@2380: for name_frmt, iec_type, var_name_frmt, location_frmt in [
andrej@2407: ("%s Network Position", "UINT", "%s_pos", "%%IW%s"),
andrej@2407: ("%s Axis Ref", "AXIS_REF", "%s", "%%IW%s.402")
andrej@2380: ]
andrej@2380: ]
andrej@2407: children.extend(self.CTNParent.GetDeviceLocationTree(self.GetSlavePos(),
andrej@2407: current_location,
andrej@2407: axis_name))
andrej@2362: return {
andrej@2362: "name": axis_name,
andrej@2362: "type": LOCATION_CONFNODE,
andrej@2362: "location": self.GetFullIEC_Channel(),
andrej@2362: "children": children,
Laurent@2111: }
andrej@2355:
Laurent@2111: def CTNGlobalInstances(self):
Laurent@2111: current_location = self.GetCurrentLocation()
andrej@2355: return [("%s_%s" % (block_infos["blocktype"],
Laurent@2153: "_".join(map(str, current_location))),
andrej@2355: "EtherLab%s" % block_infos["blocktype"], "")
Laurent@2153: for block_infos in FIELDBUS_INTERFACE_GLOBAL_INSTANCES]
andrej@2355:
Laurent@2154: def StartDragNDrop(self, data):
Laurent@2154: data_obj = wx.TextDataObject(str(data))
Laurent@2154: dragSource = wx.DropSource(self.GetCTRoot().AppFrame)
Laurent@2154: dragSource.SetData(data_obj)
Laurent@2154: dragSource.DoDragDrop()
andrej@2355:
Laurent@2154: def _getCIA402NetworkPosition(self):
Laurent@2154: self.StartDragNDrop(
andrej@2355: ("%%IW%s" % ".".join(map(str, self.GetCurrentLocation())),
Laurent@2154: "location", "UINT", self.CTNName() + "_Pos", ""))
andrej@2355:
Laurent@2111: def _getCIA402AxisRef(self):
Laurent@2154: self.StartDragNDrop(
andrej@2355: ("%%IW%s.402" % ".".join(map(str, self.GetCurrentLocation())),
Laurent@2154: "location", "AXIS_REF", self.CTNName(), ""))
edouard@2641:
edouard@2641: # add jblee
edouard@2641: """
edouard@2641: def LoadPDOSelectData(self):
edouard@2641: ReadData = []
edouard@2641: files = os.listdir(self.CTNPath())
edouard@2641: filepath = os.path.join(self.CTNPath(), "DataForPDO.txt")
edouard@2641: if os.path.isfile(filepath):
edouard@2641: PDODataRead = open(filepath, 'r')
edouard@2641: ReadData = PDODataRead.readlines()
edouard@2641: PDODataRead.close()
edouard@2641:
edouard@2641: if len(ReadData) > 1:
edouard@2641: for data in ReadData[0].split() :
edouard@2641: if data == "RxPDO":
edouard@2641: continue
edouard@2641: self.SelectedRxPDOIndex.append(int(data, 0))
edouard@2641:
edouard@2641: for data in ReadData[1].split() :
edouard@2641: if data == "TxPDO":
edouard@2641: continue
edouard@2641: self.SelectedTxPDOIndex.append(int(data, 0))
edouard@2641: """
edouard@2641:
edouard@2641: def LoadPDOSelectData(self):
edouard@2641: RxPDOData = self.BaseParams.getRxPDO()
edouard@2641: RxPDOs = []
edouard@2641: if RxPDOData != "None":
edouard@2641: RxPDOs = RxPDOData.split()
edouard@2641: if RxPDOs :
edouard@2641: for RxPDO in RxPDOs :
edouard@2641: self.SelectedRxPDOIndex.append(int(RxPDO, 0))
edouard@2641:
edouard@2641: TxPDOData = self.BaseParams.getTxPDO()
edouard@2641: TxPDOs = []
edouard@2641: if TxPDOData != "None":
edouard@2641: TxPDOs = TxPDOData.split()
edouard@2641: if TxPDOs :
edouard@2641: for TxPDO in TxPDOs :
edouard@2641: self.SelectedTxPDOIndex.append(int(TxPDO, 0))
edouard@2641:
edouard@2641: def LoadDefaultPDOSet(self):
edouard@2641: ReturnData = []
edouard@2641: rx_pdo_entries = self.CommonMethod.GetRxPDOCategory()
edouard@2641: if len(rx_pdo_entries):
edouard@2641: for i in range(len(rx_pdo_entries)):
edouard@2641: if rx_pdo_entries[i]['sm'] is not None:
edouard@2641: ReturnData.append(rx_pdo_entries[i]['pdo_index'])
edouard@2641:
edouard@2641: tx_pdo_entries = self.CommonMethod.GetTxPDOCategory()
edouard@2641: if len(tx_pdo_entries):
edouard@2641: for i in range(len(tx_pdo_entries)):
edouard@2641: if tx_pdo_entries[i]['sm'] is not None:
edouard@2641: ReturnData.append(tx_pdo_entries[i]['pdo_index'])
edouard@2641:
edouard@2641: if ReturnData :
edouard@2641: return ReturnData
edouard@2641: else :
edouard@2641: return [5632, 6656]
Laurent@2154:
Laurent@2111: def CTNGenerate_C(self, buildpath, locations):
Laurent@2111: current_location = self.GetCurrentLocation()
andrej@2355:
andrej@2391: location_str = "_".join(map(str, current_location))
andrej@2355:
andrej@2355: # Open CIA402 node code template file
andrej@2355: plc_cia402node_filepath = os.path.join(os.path.split(__file__)[0],
Laurent@2153: "plc_cia402node.c")
Laurent@2111: plc_cia402node_file = open(plc_cia402node_filepath, 'r')
Laurent@2111: plc_cia402node_code = plc_cia402node_file.read()
Laurent@2111: plc_cia402node_file.close()
edouard@2641: # HSAHN 150726
edouard@2641: # add "default_variables_retrieve": [], "default_variables_publish": [],
edouard@2641: # As PDO mapping object, it will add auto-complete code.
edouard@2641: # add "modeofop_homing_method", "modeofop_computation_mode" by jblee
edouard@2641: str_completion = {
edouard@2641: "slave_pos": self.GetSlavePos(),
edouard@2641: "location": location_str,
edouard@2641: "MCL_headers": Headers,
edouard@2641: "extern_located_variables_declaration": [],
edouard@2641: "fieldbus_interface_declaration": [],
edouard@2641: "fieldbus_interface_definition": [],
edouard@2641: "entry_variables": [],
edouard@2641: "init_axis_params": [],
edouard@2641: "init_entry_variables": [],
edouard@2641: "default_variables_retrieve": [],
edouard@2641: "default_variables_publish": [],
edouard@2641: "extra_variables_retrieve": [],
edouard@2641: "extra_variables_publish": [],
edouard@2641: "modeofop_homing_method": [],
edouard@2641: "modeofop_computation_mode": []
edouard@2641: }
edouard@2641:
Laurent@2153: for blocktype_infos in FIELDBUS_INTERFACE_GLOBAL_INSTANCES:
edouard@2641: texts = {
edouard@2641: "blocktype": blocktype_infos["blocktype"],
edouard@2641: "ucase_blocktype": blocktype_infos["blocktype"].upper(),
edouard@2641: "location": "_".join(map(str, current_location))
edouard@2641: }
edouard@2641: texts["blockname"] = "%(ucase_blocktype)s_%(location)s" % texts
Laurent@2153:
edouard@2641: inputs = [{"input_name": "POS", "input_value": str(self.GetSlavePos())},
edouard@2641: {"input_name": "EXECUTE", "input_value": "__GET_VAR(data__->EXECUTE)"}] +\
edouard@2641: [{"input_name": input["name"].upper(),
edouard@2641: "input_value": "__GET_VAR(data__->%s)" % input["name"].upper()}
edouard@2641: for input in blocktype_infos["inputs"]]
edouard@2641: input_texts = []
edouard@2641: for input_infos in inputs:
edouard@2641: input_infos.update(texts)
edouard@2641: input_texts.append(BLOCK_INPUT_TEMPLATE % input_infos)
edouard@2641: texts["extract_inputs"] = "\n".join(input_texts)
Laurent@2153:
edouard@2641: outputs = [{"output_name": output} for output in ["DONE", "BUSY", "ERROR"]] + \
edouard@2641: [{"output_name": output["name"].upper()} for output in blocktype_infos["outputs"]]
edouard@2641: output_texts = []
edouard@2641: for output_infos in outputs:
edouard@2641: output_infos.update(texts)
edouard@2641: output_texts.append(BLOCK_OUTPUT_TEMPLATE % output_infos)
edouard@2641: texts["return_outputs"] = "\n".join(output_texts)
Laurent@2153:
edouard@2641: str_completion["fieldbus_interface_declaration"].append(
edouard@2641: BLOCK_FUNCTION_TEMPLATE % texts)
edouard@2641:
edouard@2641: str_completion["fieldbus_interface_definition"].append(
edouard@2641: BLOCK_FUNTION_DEFINITION_TEMPLATE % texts)
edouard@2641:
edouard@2641: variables = NODE_VARIABLES[:]
edouard@2641:
edouard@2641: #HSAHN
edouard@2641: #2015. 7. 24 PDO Variable
edouard@2641: #if PDO is not selected, use 1st PDO set
edouard@2641: self.LoadPDOSelectData()
edouard@2641: if not self.SelectedRxPDOIndex and not self.SelectedTxPDOIndex :
edouard@2641: self.SelectedPDOIndex = self.LoadDefaultPDOSet()
edouard@2641: else :
edouard@2641: self.SelectedPDOIndex = self.SelectedRxPDOIndex + self.SelectedTxPDOIndex
edouard@2641:
edouard@2641: add_idx = []
edouard@2641: for i in range(len(ADD_NODE_VARIABLES)):
edouard@2641: add_idx.append(ADD_NODE_VARIABLES[i]['index'])
edouard@2641:
edouard@2641: self.CommonMethod.RequestPDOInfo()
edouard@2641: pdo_info = self.CommonMethod.GetRxPDOCategory() + self.CommonMethod.GetTxPDOCategory()
edouard@2641: pdo_entry = self.CommonMethod.GetRxPDOInfo() + self.CommonMethod.GetTxPDOInfo()
edouard@2641: list_index = 0
edouard@2641: ModeOfOpFlag = False
edouard@2641: ModeOfOpDisplayFlag = False
edouard@2641: for i in range(len(pdo_info)):
edouard@2641: #if pdo_index is in the SelectedPDOIndex: put the PDO mapping information intto the "used" object
edouard@2641: if pdo_info[i]['pdo_index'] in self.SelectedPDOIndex:
edouard@2641: used = pdo_entry[list_index:list_index + pdo_info[i]['number_of_entry']]
edouard@2641: for used_data in used:
edouard@2641: # 24672 -> 0x6060, Mode of Operation
edouard@2641: if used_data['entry_index'] == 24672:
edouard@2641: ModeOfOpFlag = True
edouard@2641: # 24673 -> 0x6061, Mode of Operation Display
edouard@2641: elif used_data["entry_index"] == 24673:
edouard@2641: ModeOfOpDisplayFlag = True
edouard@2641:
edouard@2641: if used_data['entry_index'] in add_idx:
edouard@2641: idx = add_idx.index(used_data['entry_index'])
edouard@2641: adder = list([ADD_NODE_VARIABLES[idx]['name'], ADD_NODE_VARIABLES[idx]['index'], \
edouard@2641: ADD_NODE_VARIABLES[idx]['sub-index'], ADD_NODE_VARIABLES[idx]['type'], \
edouard@2641: ADD_NODE_VARIABLES[idx]['direction']])
edouard@2641: variables.append(adder)
edouard@2641: if ADD_NODE_VARIABLES[idx]['direction'] == "Q":
edouard@2641: parsed_string = ADD_NODE_VARIABLES[idx]['name'].replace("Target", "")
edouard@2641: # add jblee
edouard@2641: check_q_data = " *(AxsPub.Target%s) = AxsPub.axis->Raw%sSetPoint;" %(parsed_string, parsed_string)
edouard@2641: if check_q_data not in str_completion["default_variables_publish"]:
edouard@2641: str_completion["default_variables_publish"].append(check_q_data)
edouard@2641: elif ADD_NODE_VARIABLES[idx]['direction'] == "I":
edouard@2641: parsed_string = ADD_NODE_VARIABLES[idx]['name'].replace("Actual", "")
edouard@2641: # add jblee
edouard@2641: check_i_data = " AxsPub.axis->ActualRaw%s = *(AxsPub.Actual%s);" %(parsed_string, parsed_string)
edouard@2641: if check_i_data not in str_completion["default_variables_retrieve"]:
edouard@2641: str_completion["default_variables_retrieve"].append(check_i_data)
edouard@2641: list_index += pdo_info[i]['number_of_entry']
edouard@2641: #HSAHN END
edouard@2641:
edouard@2641: params = self.CTNParams[1].getElementInfos(self.CTNParams[0])
edouard@2641: for param in params["children"]:
edouard@2641: if param["name"] in EXTRA_NODE_VARIABLES_DICT:
edouard@2641: if param["value"]:
edouard@2641: extra_variables = EXTRA_NODE_VARIABLES_DICT.get(param["name"])
edouard@2641: for variable_infos in extra_variables:
edouard@2641: var_infos = {
edouard@2641: "location": location_str,
edouard@2641: "name": variable_infos["description"][0]
edouard@2641: }
edouard@2641: variables.append(variable_infos["description"])
edouard@2641: retrieve_template = variable_infos.get("retrieve", DEFAULT_RETRIEVE)
edouard@2641: publish_template = variable_infos.get("publish", DEFAULT_PUBLISH)
Laurent@2153:
edouard@2641: if retrieve_template is not None:
edouard@2641: str_completion["extra_variables_retrieve"].append(
edouard@2641: retrieve_template % var_infos)
edouard@2641: if publish_template is not None:
edouard@2641: str_completion["extra_variables_publish"].append(
edouard@2641: publish_template % var_infos)
edouard@2641:
edouard@2641: #elif param["value"] is not None:
Laurent@2155: if param["value"] is not None:
edouard@2641: param_infos = {
edouard@2641: "location": location_str,
edouard@2641: "param_name": param["name"],
edouard@2641: }
edouard@2641: if param["type"] == "boolean":
edouard@2641: param_infos["param_value"] = {True: "1", False: "0"}[param["value"]]
edouard@2641: param_infos["param_name"] = param["name"].replace("Enable", "") + "Enabled"
edouard@2641: if param["value"] == False:
edouard@2641: continue
edouard@2641: else:
edouard@2641: param_infos["param_value"] = str(param["value"])
edouard@2641: # param_name = param_name.replace("Enable", "") + "Enabled"
edouard@2641: str_completion["init_axis_params"].append(
edouard@2641: " __CIA402Node_%(location)s.axis->%(param_name)s = %(param_value)s;" % param_infos)
edouard@2641:
edouard@2641: check_variable = []
edouard@2641: for variable in variables:
edouard@2641: # add jblee
edouard@2641: if variable in check_variable:
edouard@2641: continue
edouard@2641:
edouard@2641: var_infos = dict(zip(["name", "index", "subindex", "var_type", "dir"], variable))
edouard@2641: var_infos["location"] = location_str
edouard@2641: var_infos["var_size"] = self.GetSizeOfType(var_infos["var_type"])
edouard@2641: var_infos["var_name"] = "__%(dir)s%(var_size)s%(location)s_%(index)d_%(subindex)d" % var_infos
edouard@2641:
edouard@2641: # add jblee
edouard@2641: if var_infos["index"] in [24672] and ModeOfOpFlag:
edouard@2641: str_completion["modeofop_homing_method"].append(MODEOFOP_HOMING_METHOD_TEMPLATE)
edouard@2641: str_completion["modeofop_computation_mode"].append(MODEOFOP_COMPUTATION_MODE_TEMPLATE)
edouard@2641:
edouard@2641: # add jblee
edouard@2641: if var_infos["index"] in [24672, 24673] and (not ModeOfOpFlag or not ModeOfOpDisplayFlag):
edouard@2641: continue
edouard@2641:
edouard@2641: str_completion["extern_located_variables_declaration"].append(
edouard@2641: "IEC_%(var_type)s *%(var_name)s;" % var_infos)
edouard@2641: str_completion["entry_variables"].append(
edouard@2641: " IEC_%(var_type)s *%(name)s;" % var_infos)
edouard@2641: str_completion["init_entry_variables"].append(
edouard@2641: " __CIA402Node_%(location)s.%(name)s = %(var_name)s;" % var_infos)
Laurent@2111:
Laurent@2111: self.CTNParent.FileGenerator.DeclareVariable(
edouard@2641: self.GetSlavePos(), var_infos["index"], var_infos["subindex"],
edouard@2641: var_infos["var_type"], var_infos["dir"], var_infos["var_name"])
edouard@2641:
edouard@2641: # add jblee
edouard@2641: check_variable.append(variable)
edouard@2641:
edouard@2641: for element in ["extern_located_variables_declaration",
edouard@2641: "fieldbus_interface_declaration",
edouard@2641: "fieldbus_interface_definition",
edouard@2641: "entry_variables",
edouard@2641: "init_axis_params",
edouard@2641: "init_entry_variables",
edouard@2641: "default_variables_retrieve",
edouard@2641: "default_variables_publish",
edouard@2641: "extra_variables_retrieve",
edouard@2641: "extra_variables_publish",
edouard@2641: "modeofop_homing_method",
edouard@2641: "modeofop_computation_mode"]:
edouard@2641: str_completion[element] = "\n".join(str_completion[element])
edouard@2641:
edouard@2641: Gen_CIA402Nodefile_path = os.path.join(buildpath, "cia402node_%s.c"%location_str)
Laurent@2111: cia402nodefile = open(Gen_CIA402Nodefile_path, 'w')
edouard@2641: cia402nodefile.write(plc_cia402node_code % str_completion)
Laurent@2111: cia402nodefile.close()
andrej@2355:
andrej@2363: return [(Gen_CIA402Nodefile_path, '"-I%s"' % os.path.abspath(self.GetCTRoot().GetIECLibPath()))], "", True