Checker
OperationGenericCheck ¶
Bases: OperationAbstract
Check FMU compliance against the FMI standard XSD schema.
Validates the modelDescription.xml file of an FMU against the official XSD schema for FMI-2 or FMI-3. Reports validation errors via the logger and indicates whether the FMU is compliant.
This checker is always included by default in the checkers list.
Attributes:
| Name | Type | Description |
|---|---|---|
SUPPORTED_FMI_VERSIONS | tuple[str, ...] | FMI versions supported by this checker ( |
compliant_with_version | str | None | The FMI version the FMU is compliant with after validation, or |
Source code in fmu_manipulation_toolbox/checker.py
closure() ¶
Log the final compliance result.
Called after the FMU descriptor has been fully parsed. Logs whether the FMU is compliant with the detected FMI version.
Source code in fmu_manipulation_toolbox/checker.py
fmi_attrs(attrs) ¶
Validate the FMU descriptor against the appropriate FMI XSD schema.
Called during FMU parsing when the root fmiModelDescription element is encountered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attrs | dict[str, str] | XML attributes of the | required |
Source code in fmu_manipulation_toolbox/checker.py
OperationLsBusCheck ¶
Bases: OperationAbstract
Check the rules of FMI-LS-BUS, for an FMU that declares this layered standard.
Each violation is logged as an error and kept in errors:
- the manifest
extra/org.fmi-standard.fmi-ls-bus/fmi-ls-manifest.xmland its attributes; - the
matchingRuleof each kind of terminal of LS-BUS; - a Bus Terminal of the Network Abstraction has the members
Tx_Data,Tx_Clock,Rx_DataandRx_Clock, of kindsignal, that no other Bus Terminal uses; Tx_DataandRx_Dataare binaries clocked byTx_ClockandRx_Clock, of the same MIME type of LS-BUS;- the causality and the
intervalVariabilityofTx_ClockandRx_Clock; - the name and the rule of a Configuration Terminal.
A time-based Tx_Clock without canHandleVariableCommunicationStepSize gives a warning: the specification only recommends it.
Attributes:
| Name | Type | Description |
|---|---|---|
errors | list[str] | Violations found. |
Source code in fmu_manipulation_toolbox/checker.py
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 | |
OperationLsRefCheck ¶
Bases: OperationAbstract
Check the rules of FMI-LS-REF, for an FMU that declares this layered standard.
Each violation is logged as an error and kept in errors:
- the manifest
extra/org.fmi-standard.fmi-ls-ref/fmi-ls-manifest.xmlagainst the XSD of FMI-LS-REF (roles and experiment sub-roles included); - the experiment files (
application/x-ma-hs-experiments) against the XSD of MA-HS-Experiments; for each experiment:startTimebeforestopTime, a positivestepSize; - the files of an experiment replayed by the checker (sub-role
smoke-test, the default, orvalidation): found in the FMU; the CSV files (convention of the FMI cross-check) readable, their columnsinputvariables for the stimuli andoutputvariables for the references; the parameters of the SSV filesparameterorstructuralParametervariables, orinputvariables with a start value; - a CSV file of role
result(output of theDefaultExperimentof the FMU, as in the Reference-FMUs): readable; it is replayed with theDefaultExperiment, its columns compared when they are outputs of a comparable type; - the experiments to replay are simulated with the container runtime (
simulation.replay), each one in a dedicated process stopped aftertimeoutseconds (a crash or a timeout is an error), and their outputs compared with the references at the instants of the references (timeseries.compare,rtol,atol): simulation interpolated linearly for the continuous reals, previous value otherwise; strings compared exactly; at an event of the references, the value after it. An experiment without references is only simulated.
Warnings: the fmi-ls-description of the manifest missing or different from the one of the XSD (the Reference-FMUs have none), a related file not found in the FMU (absolute URI, path leaving the FMU, missing file), an experiment file of another type, a stimuli, references or parameters file of a type other than CSV or SSV, a file of an uncertainty-analysis experiment not found, a column of a result file that is not an output or is a binary, a binary of the references (ignored), the container runtime or the binary of the FMU not available for the host platform (no replay), a stimulus on a boolean input of an FMI-2 FMU (experiment not replayed).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rtol | float | Relative tolerance of the comparison with the references ( | RTOL |
atol | float | Absolute tolerance of the comparison with the references ( | ATOL |
timeout | float | Time limit of the replay of an experiment, in seconds ( | TIMEOUT |
Raises:
| Type | Description |
|---|---|
ValueError | A setting is out of its range or not finite. |
Attributes:
| Name | Type | Description |
|---|---|---|
errors | list[str] | Violations found. |
experiments | list[RefReplay] | The experiments to replay. |
Source code in fmu_manipulation_toolbox/checker.py
707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 | |
check_experiment(label, experiment, replayed, ports) ¶
Checks an experiment; returns the variables of its references when it can be replayed (no error, its files found and supported), None otherwise.
Source code in fmu_manipulation_toolbox/checker.py
check_result(label, related, directory, ports) ¶
A result file, replayed with the DefaultExperiment of the FMU.
Source code in fmu_manipulation_toolbox/checker.py
check_time_series(label, kind, source, ports) ¶
Checks the stimuli or the references of an experiment; returns the names of their columns.
Source code in fmu_manipulation_toolbox/checker.py
replay_experiments(ports) ¶
Replays the experiments on the FMU as it is now (repacked in a temporary directory).
Source code in fmu_manipulation_toolbox/checker.py
OperationLsXcpCheck ¶
Bases: OperationAbstract
Check the rules of FMI-LS-XCP, for an FMU that declares this layered standard.
Each violation is logged as an error and kept in errors:
- the manifest
extra/org.fmi-standard.fmi-ls-xcp/fmi-ls-manifest.xmlagainst the XSD of FMI-LS-XCP 1.0.0; - the
definitionof eachInterface: a relative URI without dot segment, whose A2L file exists for the source code (in the directory of the manifest) or for at least one platform; an A2L file must not use/include; - an
InterfacehascontainsXCPServiceorsupportsDirectMemoryAccess; - each
Variablerefers to an existing scalar variable, of the type of its role, declared as a fixedstructuralParameter(FMI-3), a fixedparameter, aconstantoutput or a fixed or tunablecalculatedParameter; a variable in one entry only, a role once perInterface.
Warnings: an Interface restricted to interface types the FMU does not provide, roles in an Interface without XCP service, A2L files of a platform without binaries.
Attributes:
| Name | Type | Description |
|---|---|---|
errors | list[str] | Violations found. |
Source code in fmu_manipulation_toolbox/checker.py
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 | |
OperationSemanticCheck ¶
Bases: OperationAbstract
Check the rules of the FMI standard that the XSD schema cannot express.
Rules are those of FMI-2.0.5 (§2.2.7, §2.2.8) and FMI-3.0.2 (§2.4, §2.4.7, §2.4.8). Each violation is logged as an error and kept in errors:
- variable names (and FMI-3 alias names) are unique;
- FMI-3 value references are unique;
- allowed combinations of
causalityandvariability; onlyReal(FMI-2) orFloat32/Float64(FMI-3) variables are continuous; - allowed values of
initialfor each combination; - presence or absence of a
startvalue; - references between variables:
derivative,<ModelStructure>entries and theirdependencies; <Outputs>(FMI-2) /<Output>(FMI-3) lists exactly the variables withcausality="output"; state derivatives have aderivativeattribute;<InitialUnknowns>(FMI-2) /<InitialUnknown>(FMI-3) lists the outputs withinitial="calculated"or"approx"(clocks and clocked variables excepted, as the Reference FMUs do) and no output withinitial="exact".
Attributes:
| Name | Type | Description |
|---|---|---|
errors | list[str] | Violations found. |
Source code in fmu_manipulation_toolbox/checker.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | |
check_initial_unknowns(fmi_version, ports, outputs, listed, initial_section, section) ¶
The initial unknowns are the outputs with initial calculated or approx (FMI-2 §2.2.8, FMI-3 §2.4.8), the clocks and the clocked variables excepted (they have no value in Initialization Mode: the Reference FMUs do not list them); an output with initial="exact" has a start value and is not an initial unknown. The other entries (calculated parameters, states, derivatives) are not checked.
Source code in fmu_manipulation_toolbox/checker.py
RefReplay dataclass ¶
An experiment of FMI-LS-REF that the checker replays.
Attributes:
| Name | Type | Description |
|---|---|---|
related | RefRelated | The related file it comes from: an experiment file, or a result file replayed with the |
experiment | Experiment | The experiment. |
outputs | list[str] | The variables to compare with the references. |
Source code in fmu_manipulation_toolbox/checker.py
add_from_file(checker_filename) ¶
Dynamically load checker classes from a Python file.
Imports the given Python file and registers any class that directly subclasses OperationAbstract into the global checkers list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checker_filename | str | Path to the Python file containing checker class(es). | required |
Source code in fmu_manipulation_toolbox/checker.py
get_checkers() ¶
Collect all registered FMU checkers.
Returns the built-in checkers combined with any additional checkers discovered via the fmu_manipulation_toolbox.checkers entry point group.
Returns:
| Type | Description |
|---|---|
list[type[OperationAbstract]] | list[type[OperationAbstract]]: List of checker classes, each being a subclass of OperationAbstract. |
Source code in fmu_manipulation_toolbox/checker.py
xsd_reason(error) ¶
Reason of an error of validation against an XSD, its names without their namespace ({uri}name -> name).