GUI Module
In this module includes all classes that handle and controll the different plots and the GUI. The most important class is the HeliostatUI class.
This is the main class of the controll software and connects the frontend to the backend. This class handels the main window from which all functions and plots are controlled. Beside the initialization of the buttons and the variables it also has the function update state which can be seen as the main function.
This function is called every second and first of all asks for the current position of the mirrors and then switches the motors on depending on the current mode that the operator wants to execute. It calls the corresponding functions which in the end all calculate the speed for the two motors. Afterwards this data is sent to the motor and written into a log file via the Logger.log() function from the Logger class. Furthermore it updates the various plots which will be explained later. To prevent the motor from running into a position that could damage the cables or mirrors a limit check is done in the end. In case the motor reaches one of these positions it is turned of immediately.
In the following parts the different functions from the Heliostat are explained. To get further information visit the code.
Class documentation
Bases: QMainWindow
This class represents the main user interface for controlling a heliostat system. It provides functionalities for controlling the heliostat's motion, tracking celestial objects, displaying real-time data plots, and accessing diagnostic information.
Attributes:
| Name | Type | Description |
|---|---|---|
latitude |
float
|
The latitude of the heliostat's location. |
longitude |
float
|
The longitude of the heliostat's location. |
altitude |
float
|
The altitude of the heliostat's location. |
target_ra |
float
|
The right ascension (RA) of the target celestial object. |
target_dec |
float
|
The declination (DEC) of the target celestial object. |
trafoA |
float
|
Transformation factor for azimuth axis. |
trafoE |
float
|
Transformation factor for elevation axis. |
home_pos |
dict
|
Dictionary containing the home position angles for both axes. |
passive_speed |
dict
|
Dictionary containing the passive tracking speeds for both axes. |
M |
dict
|
Dictionary containing the motion parameters for both axes. |
low_limit_A |
float
|
Lower limit for azimuth axis. |
high_limit_A |
float
|
Upper limit for azimuth axis. |
low_limit_E |
float
|
Lower limit for elevation axis. |
high_limit_E |
float
|
Upper limit for elevation axis. |
target_offset |
dict
|
Dictionary containing the offset for the target position for both axes. |
cycle_time |
int
|
Time interval for updating the state in milliseconds. |
M_max |
int
|
Maximum speed for motion parameters. |
M_slow_fixed_target |
float
|
Speed for fixed target tracking. |
M_slow_rel |
float
|
Relative speed for passive tracking. |
M_slow_rel_Az |
float
|
Relative speed for passive tracking in azimuth axis. |
M_fine_rel |
dict
|
Dictionary containing relative speed for fine tracking for both axes. |
M_fine_I |
dict
|
Dictionary containing I value for passive tracking for both axes. |
M_fine_active |
dict
|
Dictionary containing active fine tracking speeds for both axes. |
M_fine_active_I |
dict
|
Dictionary containing I value for active tracking for both axes. |
active_frame |
int
|
Maximum allowed error for active tracking. |
update_period |
int
|
Time interval for updating plots in seconds. |
t0 |
float
|
Initial time for calculating time component. |
timer_count |
int
|
Counter for timer ticks. |
t_vector |
list
|
List containing time values for plotting. |
grad2step |
float
|
Conversion factor from degrees to motor steps. |
E |
dict
|
Dictionary containing error values for both axes. |
diagnose |
Diagnose
|
Instance of Diagnose class for diagnostics plotting. |
motion_params |
MotionParams
|
Instance of MotionParams class for motion parameters plotting. |
q_params |
FourQ
|
Instance of FourQ class for 4Q sensor data plotting. |
spatial_view |
SpatialView
|
Instance of SpatialView class for spatial view plotting. |
real_time_data_window |
RealTimeData
|
Instance of RealTimeData class for real-time data plotting. |
passivPI_E |
PI
|
Instance of PI class for passive tracking in elevation axis. |
passivPI_A |
PI
|
Instance of PI class for passive tracking in azimuth axis. |
activePI_E |
PI
|
Instance of PI class for active tracking in elevation axis. |
activePI_A |
PI
|
Instance of PI class for active tracking in azimuth axis. |
fourq |
Q4
|
Instance of Q4 class for handling 4Q sensor data. |
io |
IO
|
Instance of IO class for input/output operations. |
current_date |
str
|
Current date in "YYYY-MM-DD" format. |
log_file_path |
str
|
Path for log file. |
logger |
WorkerLogger
|
Instance of WorkerLogger class for logging data. |
thread_receiving |
QThread
|
Thread for receiving data from CAN Bus. |
worker_receiving |
WorkerReceiving
|
Worker for receiving data from CAN Bus. |
timer |
QTimer
|
Timer for updating state. |
timer_fourq |
QTimer
|
Timer for updating 4Q data. |
Source code in GUI.py
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 690 691 692 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 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 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 1185 1186 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 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 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 1328 1329 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 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 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 1446 1447 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 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 | |
__init__()
Initializes the HeliostatUI instance and the main window
Source code in GUI.py
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 690 691 692 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 798 799 800 801 802 803 804 805 | |
active_tracking(pos)
This function implements active tracking, which adjusts the system's motion based on feedback from the 4Q sensor. It calculates the differences ('DA' and 'DE') between the current position ('pos') and a reference position adjusted with an offset. It computes the orientation angles ('DAO' and 'DEO') from the 4Q sensor feedback and adjusts the system's motion using proportional-integral (PI) controllers for both azimuth and elevation axes, taking into account the active sensor feedback and the system's state. The function evaluates whether the system is within the active tracking frame and updates the tracking mode accordingly. If the system is out of frame, it switches to passive tracking. It then adjusts the system's motion based on the calculated speeds and updates the motion parameters ('M'). Finally, it updates the error values for logging purposes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pos |
dict
|
Current position of the system. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in GUI.py
1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 | |
closeEvent(event)
This function handls the close event of the main window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event |
The close event triggered by closing the main window. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in GUI.py
fixed_target()
This function calculates the motion required to move the system towards a fixed target position. It uses the 'go_to_target' function to initiate movement towards the target position based on the current position ('pos') and the target position ('target'). It updates the motion parameters in ('M') and updates the real-time data window to indicate that the system is moving towards the target position.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The motion parameters required to move towards the fixed target position. |
Source code in GUI.py
get_angles(time)
This function calculates the solar azimuth and zenith angles based on the given time. It uses the 'get_solarposition' function to obtain the solar position for the specified time and location. The azimuth and zenith angles are extracted from the solar position data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time |
datetime
|
The time at which the solar angles are to be calculated. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
A tuple containing the solar azimuth and zenith angles. |
Source code in GUI.py
get_angles_star(target_ra, target_dec)
This function calculates the azimuth and zenith angles for a celestial object based on its right ascension (RA) and declination (Dec). It creates a SkyCoord object for the specified RA and Dec, transforms it to an AltAz frame, and obtains the azimuth and altitude angles. The calculated azimuth and zenith angles are returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_ra |
float
|
Right ascension of the target celestial object (in degrees). |
required |
target_dec |
float
|
Declination of the target celestial object (in degrees). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
A tuple containing the azimuth and zenith angles of the celestial object. |
Source code in GUI.py
go_to_target(POS, TA, TE)
This function calculates the motion parameters required to move the system from its current position ('POS') towards a target position specified by the target angles ('TA' for primary axis and 'TE' for secondary axis). It computes the differences between the current position and the target position for both axes ('DA' and 'DE'). Based on these differences, it determines the motion required for each axis ('M['A']' and 'M['E']'). If the difference in position is significant (> 2 degrees), the maximum speed ('M_max') is used. Otherwise, a slower speed ('M_slow_fixed_target') is calculated proportionally to the difference. If the difference is very small (< 0.01 degrees), the motion for that axis is set to 0. The calculated motion parameters are returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
POS |
dict
|
Current position of the system |
required |
TA |
float
|
Target angle for the primary axis. |
required |
TE |
float
|
Target angle for the secondary axis. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The motion parameters required to move towards the target position. |
Source code in GUI.py
home(pos)
This function checks if the system is at the home position by comparing the current position with the predefined home position with a tolerance of +/- 0.1 degrees for both primary and secondary axes. If the system is at the home position, it sets the state to 0 (stopped) and updates the real-time data window to indicate that the home position is reached and the motors are off. If the system is not at the home position, it initiates movement towards the home position using the 'go_to_target' function and updates the real-time data window to indicate that the system is moving towards the home position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pos |
dict
|
Current position of the system. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in GUI.py
manual_control()
This function enables manual control of the system based on user input. It requests manual input from the input/output interface and adjusts the system's motion accordingly. It checks the status of each motor and adjusts the system's motion speed based on the received commands. The motion parameters ('M') are updated accordingly for both azimuth ('A') and elevation ('E') axes.
Returns:
| Type | Description |
|---|---|
|
None |
Source code in GUI.py
passive_tracking(pos)
This function implements passive tracking, which adjusts the system's motion based on the difference between the current position and a reference position (position that directs the beam of the sun into the laboratory). It calculates the differences ('DA' and 'DE') between the current position ('pos') and the reference position adjusted with an offset. It then adjusts the system's motion using proportional-integral (PI) controllers for both azimuth and elevation axes, taking into account the passive speed settings and the current state of the system. The system adjusts its motion differently based on whether the differences are significant or within fine-tuning thresholds. It updates the system's state and motion parameters accordingly and updates the real-time data window to indicate the tracking mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pos |
dict
|
Current position of the system. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in GUI.py
1181 1182 1183 1184 1185 1186 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 | |
pos_and_speed()
This function calculates the current position and speed of the system based on the current time. It obtains the azimuth and zenith angles at two consecutive time points and converts them into the system's coordinate system using polar rotation. It then calculates the speed of the system by taking the difference in position between the two time points which is further used in passive tracking.
Returns:
| Type | Description |
|---|---|
|
None |
Source code in GUI.py
set_active_frame(value)
Set the maximum aloud error for active tracking
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value |
float
|
The maximum error to set for active tracking |
required |
Returns:
| Type | Description |
|---|---|
|
None |
set_dec(value)
Set the declination (DEC) target value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value |
float
|
The value to set as the target DEC. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
set_ra(value)
Set the right ascension (RA) target value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value |
float
|
The value to set as the target RA. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
set_speed(value)
Set the speed for manual remote controll
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value |
float
|
The speed to set for the manual remote mode |
required |
Returns:
| Type | Description |
|---|---|
|
None |
set_target_pos_a(value)
Set the target position for the primary axis
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value |
float
|
The position to set for the primary axis |
required |
Returns:
| Type | Description |
|---|---|
|
None |
set_target_pos_e(value)
Set the target position for the secondary axis
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value |
float
|
The position to set for the second axis |
required |
Returns:
| Type | Description |
|---|---|
|
None |
star_tracking(pos)
This function implements star tracking, which adjusts the system's motion to track a celestial object based on its right ascension (RA) and declination (Dec). It calculates the azimuth and zenith angles of the star using the target RA and Dec and transforms them into the system's coordinate system. The function then calculates the differences ('DA' and 'DE') between the current position ('pos') and the calculated position of the star. Based on these differences, it adjusts the system's motion to track the star using proportional control. The motion parameters ('M') are updated accordingly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pos |
dict
|
Current position of the system. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in GUI.py
stop()
toggle_active_tracking()
Toggle to change the current mode to active tracking
Returns:
| Type | Description |
|---|---|
|
None |
toggle_camera()
Toggle to open the site with access to the camera that is installed remotly.
Returns:
| Type | Description |
|---|---|
|
None |
Source code in GUI.py
toggle_diagnose()
toggle_go_to()
Toggle to change the current mode to going to a certain position
Returns:
| Type | Description |
|---|---|
|
None |
toggle_home()
toggle_manual_remote()
toggle_motion_params()
Toggle for the motion parameters plot.
Returns:
| Type | Description |
|---|---|
|
None |
toggle_passive_star_tracking()
Toggle to change the current mode to star tracking
Returns:
| Type | Description |
|---|---|
|
None |
toggle_passive_tracking()
Toggle to change the current mode to passive tracking
Returns:
| Type | Description |
|---|---|
|
None |
toggle_q_params()
toggle_real_time_data_window()
Toggles for the real time data plot.
Returns:
| Type | Description |
|---|---|
|
None |
toggle_stop()
toggle_view()
update_plots()
This function updates the plots displayed in different widgets with new data. It appends the current time value to the time vector and updates the diagnose plot, motion parameters plot, 4Q plot, and spatial view plot with the updated data.
Returns:
| Type | Description |
|---|---|
|
None |
Source code in GUI.py
update_state()
This function updates the state of the system according to the current state value. It performs various actions based on the state, such as stopping motion, going to the home position, going to a fixed target, passive sun tracking, active sun tracking, star tracking, manual remote control, and logging data. It also updates real-time data plots, sends speed data to the motor and performs limit checks to prevent reaching limit positions which could damage the mirror or cables.
Returns:
| Type | Description |
|---|---|
|
None |
Source code in GUI.py
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 | |