Skip to content

Commit

Permalink
correct paths
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlWalther committed Dec 15, 2024
1 parent 91a25d5 commit 7d586c1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .CI/tests/translate_test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
sys.path.append('../../')
import cdl_plc

cxf_json_path = '../../cxf/ModelicaTestCases/'
cxf_json_path = 'cxf/ModelicaTestCases/'

test_cases = [
cxf_json_path + 'SingleBlocks/Reals/' + 'Add',
Expand Down
4 changes: 2 additions & 2 deletions IEC61131-10XML/Add/plc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<expression>u2</expression>
</inVariable>
<block localId="1" typeName="ADD" executionOrderId="0" width="20" height="20">
<position x="672" y="60"/>
<position x="792" y="60"/>
<inputVariables>
<variable formalParameter="IN1">
<connectionPointIn>
Expand All @@ -82,7 +82,7 @@
</outputVariables>
</block>
<outVariable localId="4" executionOrderId="0" width="10" height="10" negated="false">
<position x="1152" y="40"/>
<position x="1440" y="40"/>
<connectionPointIn>
<relPosition x="0" y="22"/>
<connection refLocalId="1" formalParameter="OUT"/>
Expand Down
2 changes: 1 addition & 1 deletion IEC61131-10XML/MultiplyByParameter/plc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<expression>r1</expression>
</inVariable>
<block localId="1" typeName="Reals_MultiplyByParameter" instanceName="gain" executionOrderId="0" width="20" height="20">
<position x="792" y="20"/>
<position x="804" y="20"/>
<inputVariables>
<variable formalParameter="u">
<connectionPointIn>
Expand Down
15 changes: 13 additions & 2 deletions cdl_plc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
import ast


import os

abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
print(dname)
os.chdir(dname)


class Cdl2Plc:

dict_assign_cdl_to_iec_standard_lib = {
Expand Down Expand Up @@ -1091,19 +1099,22 @@ def create_dict_cdl_blocks(self):
cdl_block = fileBlock.read()
self.dict_cdl_blocks["scalar_inputs"].add(cdl_block)

def create_iec_xml(self):
def create_iec_xml(self, debug=False):
"""
Render based on dicts
"""
template_loader = jinja2.FileSystemLoader(searchpath="./")
template_env = jinja2.Environment(loader=template_loader)


# fileTemplateVariable = "templateVariable.xml"
file_template_global = [
"xml_templates/structure/global.xml",
"templateVariable.xml",
][0]

if debug:
print('cwd: ', os.getcwd())

template = template_env.get_template(file_template_global)
self.output_text = template.render(
dictInputVars=self.program_inputs,
Expand Down

0 comments on commit 7d586c1

Please sign in to comment.