diff --git a/examples/somersaultecu.py b/examples/somersaultecu.py
index 864fdd1c..6eff7daa 100755
--- a/examples/somersaultecu.py
+++ b/examples/somersaultecu.py
@@ -38,7 +38,7 @@
from odxtools.parentref import ParentRef
from odxtools.physicaltype import PhysicalType
from odxtools.service import DiagService
-from odxtools.singleecujob import ProgCode, SingleEcuJob
+from odxtools.singleecujob import ProgCode, ProgCodeSyntax, SingleEcuJob
from odxtools.structures import Request, Response
from odxtools.table import Table, TableRow
from odxtools.units import PhysicalDimension, Unit, UnitGroup, UnitSpec
@@ -1781,7 +1781,7 @@ class SomersaultSID(IntEnum):
ProgCode(
code_file="jobs.jar",
encryption=None,
- syntax="JAR",
+ syntax=ProgCodeSyntax.JAR,
entrypoint="com.supervisor.jobs.CompulsoryProgram",
revision="1.23.4",
library_refs=[],
diff --git a/odxtools/singleecujob.py b/odxtools/singleecujob.py
index 8f54fe5d..15ed42f1 100644
--- a/odxtools/singleecujob.py
+++ b/odxtools/singleecujob.py
@@ -167,11 +167,17 @@ def dop(self) -> Optional[DopBase]:
return self._dop
+class ProgCodeSyntax(Enum):
+ JAVA = "JAVA"
+ CLASS = "CLASS"
+ JAR = "JAR"
+
+
@dataclass
class ProgCode:
"""A reference to code that is executed by a single ECU job"""
code_file: str
- syntax: Literal["JAVA", "CLASS", "JAR"]
+ syntax: ProgCodeSyntax
revision: str
encryption: Optional[str]
entrypoint: Optional[str]
@@ -183,7 +189,14 @@ def from_et(et_element: Element, doc_frags: List[OdxDocFragment]) -> "ProgCode":
encryption = et_element.findtext("ENCRYPTION")
- syntax = et_element.findtext("SYNTAX")
+ syntax = ProgCodeSyntax("JAR")
+ try:
+ syntax = ProgCodeSyntax(odxrequire(et_element.findtext("SYNTAX")))
+ except ValueError as e:
+ try:
+ odxraise(f"Could not parse program code syntax")
+ except Exception as ee:
+ raise ee from e
revision = odxrequire(et_element.findtext("REVISION"))
entrypoint = et_element.findtext("ENTRYPOINT")
diff --git a/odxtools/templates/macros/printSingleEcuJob.xml.jinja2 b/odxtools/templates/macros/printSingleEcuJob.xml.jinja2
index 5ea53e15..ae163a17 100644
--- a/odxtools/templates/macros/printSingleEcuJob.xml.jinja2
+++ b/odxtools/templates/macros/printSingleEcuJob.xml.jinja2
@@ -64,7 +64,7 @@
{%- if prog.encryption %}
{{prog.encryption}}
{%- endif %}
- {{prog.syntax}}
+ {{prog.syntax.value}}
{{prog.revision}}
{%- if prog.entrypoint %}
{{prog.entrypoint}}
diff --git a/tests/test_singleecujob.py b/tests/test_singleecujob.py
index 68d6864b..32cc93c6 100644
--- a/tests/test_singleecujob.py
+++ b/tests/test_singleecujob.py
@@ -20,7 +20,8 @@
from odxtools.odxlink import OdxDocFragment, OdxLinkDatabase, OdxLinkId, OdxLinkRef
from odxtools.odxtypes import DataType
from odxtools.physicaltype import PhysicalType
-from odxtools.singleecujob import InputParam, NegOutputParam, OutputParam, ProgCode, SingleEcuJob
+from odxtools.singleecujob import (InputParam, NegOutputParam, OutputParam, ProgCode,
+ ProgCodeSyntax, SingleEcuJob)
from odxtools.utils import short_name_as_id
from odxtools.write_pdx_file import jinja2_odxraise_helper, make_bool_xml_attrib, make_xml_attrib
@@ -198,7 +199,7 @@ class Context(NamedTuple):
ProgCode(
code_file="abc.jar",
encryption="RSA512",
- syntax="JAR",
+ syntax=ProgCodeSyntax.JAR,
revision="0.12.34",
entrypoint="CalledClass",
library_refs=[OdxLinkRef("my.favourite.lib", doc_frags)],
@@ -228,7 +229,7 @@ class Context(NamedTuple):
{self.singleecujob_object.prog_codes[0].code_file}
{self.singleecujob_object.prog_codes[0].encryption}
- {self.singleecujob_object.prog_codes[0].syntax}
+ {self.singleecujob_object.prog_codes[0].syntax.value}
{self.singleecujob_object.prog_codes[0].revision}
{self.singleecujob_object.prog_codes[0].entrypoint}