Converter helpers
apply_alarm_flags(widget, obj)
Make the widget follow its channel's alarm severity only where the object's alarm flags say EDM does (edm_qt.EDM_ALARM_PROPS); an object without them never changes colour for alarms. A flag the table doesn't map for the class (a slider's bgAlarm, a bar's indicatorAlarm, a text's bgAlarm) is dropped with a warning.
Source code in pydmconverter/edm/converter_helpers.py
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 | |
apply_channel_roles(widget, obj)
Bind the widget's channel to the PV channel_attr names, and warn about each of the object's other PVs, which a .ui has no place for: a PyDM widget reads and writes its one channel, with no readback and no colour rules (drawings aside, which the converter doesn't write yet).
Source code in pydmconverter/edm/converter_helpers.py
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 | |
apply_widget_post_processing(widget, obj, pydm_widgets, scale, offset_x, offset_y, container_height, parent_pydm_group)
Apply widget-specific post-processing after attribute mapping.
Handles geometry transformation, polyline points, button variants, embedded display filenames, dimension padding, and minimum sizes.
Source code in pydmconverter/edm/converter_helpers.py
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 | |
channel_attr(obj)
The tag of the PV the object's widget binds as its channel, or None.
That is the class's data PV (edm_qt.EDM_CHANNEL_ROLES). PyDM colours a widget for alarms only from its own channel, so a class that shows no PV (drawings, static text) binds its alarmPv instead.
Source code in pydmconverter/edm/converter_helpers.py
591 592 593 594 595 596 597 598 599 600 601 602 | |
convert_attribute_value(edm_attr, value, widget, obj, color_list_dict)
Convert a single EDM attribute value to its PyDM equivalent.
Returns the converted value, or None to signal the attribute should be skipped.
Source code in pydmconverter/edm/converter_helpers.py
693 694 695 696 697 698 699 700 701 702 703 704 705 706 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 | |
convert_edm_to_pydm_widgets(parser, site=None, color_list_file=None, display_roots=None)
Converts an EDMFileParser object into a collection of PyDM widget instances.
Parameters
parser : EDMFileParser
The EDMFileParser instance containing parsed EDM objects and groups.
color_list_file : str, optional
Explicit path to an EDM colors.list palette used to resolve "index N"
colors. Falls back to EDMCOLORFILE, $EDMFILES/colors.list, then
/etc/edm/colors.list when omitted.
display_roots : str | Sequence[str], optional
Absolute directories whose display names become root-relative (see
pydmconverter.edm.display_roots). Falls back to PYDMCONVERTER_DISPLAY_ROOTS
when omitted.
Returns
Tuple[List, set]
A tuple of (pydm_widgets, used_classes). The screen's menu muxes and the
loc:// declarations their menu screen shares with the .ui are left on the
parser (menu_mux_buttons, menu_loc_declarations) for convert() to
write once the .ui is written.
Source code in pydmconverter/edm/converter_helpers.py
1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 | |
convert_pointsize(pixel_size, dpi=96)
Convert the edm pizelsize to pydm pointsize (multiply by 0.75)
Source code in pydmconverter/edm/converter_helpers.py
2113 2114 2115 2116 2117 2118 | |
create_button_variant(widget, suffix, variant_type, attr_mappings, original_mappings=None)
Clone a PyDMPushButton into a variant (e.g. "off" or "freeze") with remapped attributes.
Parameters
widget : PyDMPushButton The original button to clone. suffix : str Name suffix for the variant (e.g. "_off", "_freeze"). variant_type : str Type label for the variant flag (e.g. "off", "freeze"). attr_mappings : list of (src, dst) tuples Copies widget.src → variant.dst for each pair. original_mappings : list of (src, dst) tuples, optional Copies widget.src → widget.dst on the original widget for each pair.
Source code in pydmconverter/edm/converter_helpers.py
1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 | |
create_freeze_button(widget)
Create a 'freeze' variant of an activefreezebuttonclass button.
Source code in pydmconverter/edm/converter_helpers.py
1375 1376 1377 1378 1379 1380 1381 1382 | |
create_multi_sliders(widget, object)
Given a ActiveSlider converted from a mmvclass, create stacked sliders to show each slider indicator. Modifies the size and channel of the current slider. The sliders share the mover's thickness, so each keeps EDM's full track length: horizontal ones stack top to bottom, vertical ones sit side by side.
Source code in pydmconverter/edm/converter_helpers.py
1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 | |
create_off_button(widget)
Create an 'off' variant of a push button with distinct off/on states.
Source code in pydmconverter/edm/converter_helpers.py
1364 1365 1366 1367 1368 1369 1370 1371 1372 | |
edm_line_width(obj)
The width EDM draws a rectangle, circle or arc outline with: its lineWidth, 1 by default (rectangle_obj.cc, circle_obj.cc, arc_obj.cc). Width 0 is X11's thinnest line, which is also one pixel wide.
Source code in pydmconverter/edm/converter_helpers.py
375 376 377 378 379 | |
find_objects(group, obj_name)
Recursively search through an EDMGroup and its nested groups to find all instances of EDMObjects that match a specified name.
Parameters
group : EDMGroup The EDMGroup instance within which to search for objects. obj_name : str The name of the object to search for (case insensitive)
Returns
List[EDMObject] A list of EDMObject instances that match the specified name. If no matches are found, an empty list is returned.
Source code in pydmconverter/edm/converter_helpers.py
1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 | |
get_arc_widget_type(obj)
Determine if an activearcclass should be PyDMDrawingPie or PyDMDrawingArc.
Returns PyDMDrawingPie if the arc has fill enabled. Otherwise returns PyDMDrawingArc.
Parameters
obj : EDMObject The EDM object to analyze
Returns
type Either PyDMDrawingPie or PyDMDrawingArc
Source code in pydmconverter/edm/converter_helpers.py
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | |
get_polyline_widget_type(obj)
Determine if an activelineclass should be PyDMDrawingPolyline or PyDMDrawingIrregularPolygon.
Returns PyDMDrawingIrregularPolygon if the polyline is: - Closed (first point == last point OR closePolygon is set) AND - Has fill color
Otherwise returns PyDMDrawingPolyline.
Parameters
obj : EDMObject The EDM object to analyze
Returns
type Either PyDMDrawingIrregularPolygon or PyDMDrawingPolyline
Source code in pydmconverter/edm/converter_helpers.py
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 | |
get_string_value(value)
Takes in a value string and joins each element into a string separated by a new line
Source code in pydmconverter/edm/converter_helpers.py
2079 2080 2081 2082 2083 | |
handle_button_polygon_overlaps(pydm_widgets)
Detect when PyDMRelatedDisplayButton overlaps with PyDMDrawingIrregularPolygon. Set the button's flat property to True to make it transparent, and ensure the button is placed after the polygon in the widget list (on top in z-order).
Parameters
pydm_widgets : List List of PyDM widget instances
Returns
List Updated list of PyDM widgets with proper ordering and flat property set
Source code in pydmconverter/edm/converter_helpers.py
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 546 547 548 549 550 551 552 553 554 555 556 557 | |
is_menu_pip(obj)
An embedded window whose filePv picks among its displayFileName entries.
Source code in pydmconverter/edm/converter_helpers.py
1712 1713 1714 1715 1716 1717 | |
loc_declarations(root)
Map each loc:// variable the converted .ui configures, by its bare address (loc://name), to the address that configures it. Menu muxes are left out: they become the separate .py screen. When several widgets configure a variable differently the richest wins, as in pair_menu_pips: most enum strings, then the first in the file.
Source code in pydmconverter/edm/converter_helpers.py
1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 | |
mmv_orientation(obj)
A multi-mover's direction, "horizontal" or "vertical".
EDM reads it from the numeric orientation (mmover.cc createFromFile). orientStr is the editor's name for the same choice, used here only when orientation is missing. None leaves the slider horizontal, Qt's default.
Source code in pydmconverter/edm/converter_helpers.py
1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 | |
object_vis_range(name, properties)
The (visMin, visMax) an EDM object or group shows between, read with EDM's atof() as the IR reads them (parser_helpers.vis_range).
None when a limit can't be evaluated here, such as one that starts with a macro: the caller drops the visibility rule, so the widget always shows, as in the IR, and a warning says why. PyDM would substitute the macro when it loads the screen, but only as text in the rule expression, which has no atof(): a limit that names a PV would not parse, and the widget would stay hidden.
Source code in pydmconverter/edm/converter_helpers.py
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | |
pair_menu_pips(root, color_list_dict, skip_widgets=None)
Convert each menu embedded window that a choice button or a menu mux drives.
In EDM the two are separate widgets sharing a LOC\ variable: the choice button writes it (its states are the variable's enum strings) and the window shows displayFileName[value]. When the button sits on top of the window and nothing else uses the variable, the pair becomes one QTabWidget: the choice button carries the pages and the window is removed. Otherwise the button stays a PyDMEnumButton and the window becomes one embedded display per file, shown only at its index, so EDM's layout and every other user of the variable keep working.
A menu mux whose controlPv names the variable writes it too: the generated menu mux screen writes the chosen item's index there. The menu becomes part of that separate .py rather than a widget in the .ui, so it is never a tab bar, and its window always becomes the switched displays. So does a window whose menu buttons write the variable (a combo box of its enum strings), or whose message buttons write display indices to it (_index_writers).
A window whose filePv is a real PV switches on the PV's value the same way: it becomes the switched displays, all hidden until the PV's first value, as EDM opens nothing until then (pip.cc).
skip_widgets is the site's set of EDM classes to drop; pairing rewrites both widgets together, so a site dropping either one leaves the tree untouched.
Source code in pydmconverter/edm/converter_helpers.py
1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 | |
parse_font_string(font_str)
Parse an EDM font string like 'helvetica-bold-r-12.0' into a dictionary for a PyDM widget. This is just an example parser—adjust as needed.
Source code in pydmconverter/edm/converter_helpers.py
2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 | |
pip_source_file(obj)
The file a non-menu embedded window opens (EDM pip.cc) and the channel whose value names it, each None for none.
A "file" window opens its file attribute and shows nothing when that is blank. A "stringPV" window (the default displaySource) reads its filePv as a string (pip_readUpdate) and opens the file the value names, again on every non-blank change. The channel drives the display's Filename rule; a loc:// string variable's initial value is also the file it opens with.
Source code in pydmconverter/edm/converter_helpers.py
1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 | |
populate_tab_bar(obj, widget)
Build the pages of a choice button that absorbed a menu embedded window (see pair_menu_pips).
Source code in pydmconverter/edm/converter_helpers.py
1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 | |
resolve_widget_type(obj)
Determine the PyDM widget type for a given EDM object.
Returns the widget type class, or None if unsupported. May mutate obj.properties for special cases (e.g. activechoicebuttonclass without tabs).
Source code in pydmconverter/edm/converter_helpers.py
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 | |
shown_display_index(obj)
The EDM index of the displayFileName/symbols entry an embedded window shows when it opens: a menu window starts at its filePv's initial value (EDM shows displayFileName[value]), any other at its lowest-numbered entry.
Source code in pydmconverter/edm/converter_helpers.py
1720 1721 1722 1723 1724 1725 1726 1727 1728 | |
start_rules_at_loc_inits(ui_element)
Start every Visible or Enable rule that reads only loc:// variables at the value it has for their initial values.
PyDM's local plugin sends a joining listener the variable's value and only then tells it the channel is connected (local_plugin.py add_listener), and the rules engine skips a value from a channel that is not connected yet (rules.py callback_value) and does not evaluate on connecting (callback_conn). So the last rule to join a variable is not evaluated until the value changes, and shows its initial_value, false, rather than what the variable selects. Rules join in document order, and after the widgets' channels when PyDM's Back and Forward bring a display back.
PyDM configures a variable from the first address that joins it with both type and init, so the first declaration in the document wins here too, also over a later one with a different init. A widget joins with its channel and its rules' channels, which PyDM's .ui loader sets in document order (a widget's properties before its children); the channel of a widget without a channel property, such as an embedded display, never joins. Waveform curves are not read.
Source code in pydmconverter/edm/converter_helpers.py
1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 | |
transform_edm_to_pydm(edm_x, edm_y, edm_width, edm_height, container_height, scale=1.0, offset_x=0, offset_y=0)
Transform coordinates from an EDM coordinate system (bottom-left origin) to a PyDM coordinate system (top-left origin) at the root level.
Source code in pydmconverter/edm/converter_helpers.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |
transform_nested_widget(child_edm_x, child_edm_y, child_edm_width, child_edm_height, parent_edm_x, parent_edm_y, parent_edm_height, scale=1.0)
Transform child widget coordinates relative to its parent. If EDM uses absolute coordinates for nested widgets, subtract parent position.
Source code in pydmconverter/edm/converter_helpers.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | |
traverse_group(edm_group, color_list_dict, used_classes, skip_widgets=None, parent_pydm_group=None, pydm_widgets=None, container_height=None, scale=1.0, offset_x=0, offset_y=0, central_widget=None, parent_vispvs=None)
Recursively traverse an EDM group and convert each object to a PyDM widget.
Parameters
edm_group : EDMGroup The EDM group to traverse. color_list_dict : dict Parsed color list data for color conversion. used_classes : set Accumulator for tracking which PyDM widget classes are used. skip_widgets : set, optional Set of widget class names (lowercase) to skip during conversion.
Source code in pydmconverter/edm/converter_helpers.py
1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 | |
widgets_overlap(widget1, widget2)
Check if two widgets overlap based on their geometry (x, y, width, height).
Parameters
widget1, widget2 : PyDM widget instances Widgets with x, y, width, height attributes
Returns
bool True if widgets overlap, False otherwise
Source code in pydmconverter/edm/converter_helpers.py
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 | |