Skip to content

Basic use

One of the main differences between a single IMX file and a containerized IMX is that a single file can represent multiple situations. A containerized IMX, on the other hand, is a snapshot in time and can be seen as a single situation. For more information, refer to the way of working section

To maintain consistency and ease of use, the APIs for handling both single and containerized IMX files are designed to be as similar as possible. This allows end users to switch between single and containerized IMX files with minimal changes to their code.

Single file IMX

In this case, the IMX is a single XML file containing a situation or a project with an initial situation and optional a new situation. You need to define the situation of interest.

Containerized IMX

In this case, the IMX is a container holding multiple XML files that represent a snapshot in time. You do not need to define a situation.

The basic examples below can be switched using the tabs, making the differences clear.

todo: migrate to new tab ensure javascript tab syncer

Load file

from imxInsights import ImxSingleFile

imx = ImxSingleFile(r"path to xml file")
from imxInsights import ImxContainer

imx = ImxContainer(r"path to xml zip container or folder")

Get file metadata

print(imx.file.imx_version)
print(imx.file.file_hash)
print(imx.files.signaling_design.imx_version)
print(imx.files.signaling_design.file_hash)

print(imx.files.observations.imx_version)
print(imx.files.observations.file_hash)

Get build exceptions

for puic, exceptions in imx.situation.get_build_exceptions():
    print(puic, [exception.msg for exception in exceptions])
for puic, exceptions in imx.get_build_exceptions():
    print(puic, [exception.msg for exception in exceptions])

Query Objects

# get all
all_objects = imx.situation.get_all()

# get from situation
imx_object = imx.initial_situation.find("puic_uuid4")

# get all types
object_types = imx.new_situation.get_types()

# get by type
object_subset = imx.new_situation.get_by_types([object_types[0], imx_object.tag])
# get all
all_objects = imx.get_all()

# get from situation
imx_object = imx.find("puic_uuid4")

# get all types
object_types = imx.get_types()

# get by type
object_subset = imx.get_by_types([object_types[0], imx_object.tag])

MultiContainer

from imxInsights import ImxMultiRepo, ImxSingleFile

imx = ImxSingleFile(r"path to xml file")

multi_repo = ImxMultiRepo([imx.initial_situation, imx.new_situation])
from imxInsights import ImxContainer, ImxMultiRepo

imx_a = ImxContainer(r"path to xml zip container or folder")
imx_b = ImxContainer(r"path to xml zip container or folder")

multi_repo = ImxMultiRepo([imx_a, imx_b])

Compair Objects

Below is a preview feature, changes will be made!

compair = multi_repo.compair()

for puic, imx_compair in compair.values.items():
    print(puic)
    print(imx_compair.global_status)

    for field in imx_compair.fields:
        print(field.name)
        print(field.global_status)

        for value in field.values:
            print(value.container_id)
            print(value.value)
            print(value.status)