Import LinuxCNC source tree

This commit is contained in:
Wang Dequan
2026-08-20 06:17:39 +08:00
commit 2c814634c3
9429 changed files with 10556013 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
# GTK Mesa tests screen
Embedded panel for PC and Mesa tests by zz912
This screen allows the user to verify whether they have a suitable and well-tuned PC for their Mesa card.
Based on the design of Mesa Configuration Tool II
https://github.com/jethornton/mesact
Copyright (c) 2022 jethornton
---
### Load with gladevcp command:
```bash
gladevcp gtk_mesa_tests
```
---
## Modification INI file for embedded panel in Gmoccapy:
```ini
EMBED_TAB_NAME = Mesa PC
EMBED_TAB_LOCATION = ntb_setup
EMBED_TAB_COMMAND = gladevcp -x {XID} gtk_mesa_tests
```

View File

@@ -0,0 +1,936 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkAdjustment" id="adj_read_tmax">
<property name="upper">1000000000000</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="adj_servo_thread_period">
<property name="upper">1000000000000</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="adj_servo_thread_period_nic">
<property name="upper">1000000000000</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="adj_servo_thread_tmax">
<property name="upper">1000000000000</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="adj_write_tmax">
<property name="upper">1000000000000</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkWindow" id="window1">
<property name="can-focus">False</property>
<child>
<object class="GtkNotebook" id="ntb_tests">
<property name="visible">True</property>
<property name="can-focus">True</property>
<child>
<object class="GtkBox" id="box_servothread">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="label-xalign">0</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<!-- n-columns=3 n-rows=3 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="label" translatable="yes">Servo Thread</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="sbtn_servo_thread_tmax">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="valign">center</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="width-chars">10</property>
<property name="xalign">1</property>
<property name="adjustment">adj_servo_thread_tmax</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="label" translatable="yes">Servo Thread</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btn_servo_thread_tmax">
<property name="label" translatable="yes"> Get tmax</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="valign">center</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<signal name="released" handler="on_btn_servo_thread_tmax_released" swapped="no"/>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btn_servo_thread_period">
<property name="label" translatable="yes">Get period</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="valign">center</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<signal name="released" handler="on_btn_servo_thread_period_released" swapped="no"/>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="sbtn_servo_thread_period">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="valign">center</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="width-chars">10</property>
<property name="text" translatable="yes">0</property>
<property name="xalign">1</property>
<property name="adjustment">adj_servo_thread_period</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btn_calc_servo">
<property name="label" translatable="yes">Calculate</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="valign">center</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<signal name="released" handler="on_btn_calc_servo_released" swapped="no"/>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">center</property>
<property name="label-xalign">0</property>
<child>
<object class="GtkLabel" id="lbl_result_servo">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">%</property>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Under 70% is good, over 70% try
increasing Thread Period</property>
<property name="justify">center</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;Servo Thread Test&lt;/b&gt;</property>
<property name="use-markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">start</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="label-xalign">0</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">The Default Packet Time Timeout
is 80% of the Servo Thread Period</property>
<property name="justify">center</property>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkTextView" id="textview_servo">
<property name="name">textview_servo</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="wrap-mode">word</property>
<property name="accepts-tab">False</property>
<property name="monospace">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child type="tab">
<object class="GtkLabel" id="lbl_servothread">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Servo Thread</property>
</object>
<packing>
<property name="tab-fill">False</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box_nic">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="label-xalign">0</property>
<child>
<!-- n-columns=3 n-rows=5 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkButton" id="btn_read_tmax">
<property name="label" translatable="yes">Get read.tmax</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="valign">center</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<signal name="released" handler="on_btn_read_tmax_released" swapped="no"/>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btn_write_tmax">
<property name="label" translatable="yes">Get write.tmax</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="valign">center</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<signal name="released" handler="on_btn_write_tmax_released" swapped="no"/>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btn_nic_calculate">
<property name="label" translatable="yes">Calculate</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="valign">center</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<signal name="released" handler="on_btn_nic_calculate_released" swapped="no"/>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btn_servo_thread_period_nic">
<property name="label" translatable="yes">Get period</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="valign">center</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<signal name="released" handler="on_btn_servo_thread_period_nic_released" swapped="no"/>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">start</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="label-xalign">0</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="label" translatable="yes">Packet Time is in units of servo thread period.
If the Packet Time is greater than 50%
try increasing the thread period.</property>
<property name="justify">center</property>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
<property name="width">3</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="sbtn_read_tmax">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="valign">center</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="width-chars">10</property>
<property name="xalign">1</property>
<property name="adjustment">adj_read_tmax</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="sbtn_write_tmax">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="valign">center</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="width-chars">10</property>
<property name="xalign">1</property>
<property name="adjustment">adj_write_tmax</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="sbtn_servo_thread_period_nic">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="valign">center</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="width-chars">10</property>
<property name="text" translatable="yes">0</property>
<property name="xalign">1</property>
<property name="adjustment">adj_servo_thread_period_nic</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">center</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="label-xalign">0</property>
<child>
<object class="GtkLabel" id="lbl_result_nic">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">%</property>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="label" translatable="yes">Servo Thread</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;NIC test&lt;/b&gt;</property>
<property name="use-markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="label-xalign">0</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkButton" id="btn_packet_error">
<property name="label" translatable="yes">Get Packet error</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="valign">center</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<signal name="released" handler="on_btn_packet_error_released" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">center</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="label-xalign">0</property>
<child>
<object class="GtkLabel" id="lbl_packet_error">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Click on Get packet error</property>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">start</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="label-xalign">0</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="label" translatable="yes">The ideal state is when the packet error is 0</property>
<property name="justify">center</property>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;Packet&lt;/b&gt;</property>
<property name="use-markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkTextView" id="textview_nic">
<property name="name">textview_nic</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="wrap-mode">word</property>
<property name="accepts-tab">False</property>
<property name="monospace">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="lbl_nic">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">NIC</property>
</object>
<packing>
<property name="position">1</property>
<property name="tab-fill">False</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box_pc">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkTextView" id="textview_pc_info">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="wrap-mode">word</property>
<property name="accepts-tab">False</property>
<property name="monospace">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkButton" id="btn_mb_info">
<property name="label" translatable="yes">Motherboard Info</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<signal name="released" handler="on_btn_mb_info_released" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btn_cpu_info">
<property name="label" translatable="yes">CPU Info</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<signal name="released" handler="on_btn_cpu_info_released" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btn_nic_info">
<property name="label" translatable="yes">NIC Info</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<signal name="released" handler="on_btn_nic_info_released" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btn_copy">
<property name="label" translatable="yes">Copy</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<signal name="released" handler="on_btn_copy_released" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack-type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="lbl_pc">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">PC info</property>
</object>
<packing>
<property name="position">2</property>
<property name="tab-fill">False</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box_ip">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkTextView" id="textview_ip_info">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="editable">False</property>
<property name="wrap-mode">word</property>
<property name="accepts-tab">False</property>
<property name="monospace">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btn_ip_nic">
<property name="label" translatable="yes">IP and NIC Info</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<signal name="released" handler="on_btn_ip_nic_released" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack-type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="lbl_ip">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">IP info</property>
</object>
<packing>
<property name="position">3</property>
<property name="tab-fill">False</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@@ -0,0 +1,450 @@
#!/usr/bin/env python3
"""
GTK Mesa tests screen
Embedded panel for PC and Mesa tests by zz912
Based on the design of Mesa Configuration Tool II
https://github.com/jethornton/mesact
Copyright (c) 2022 jethornton
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any laforter version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from gi.repository import Gtk
from gi.repository import Gdk
import subprocess # Used to run external system commands and capture their output
from subprocess import Popen, PIPE
class MesaTests:
def __init__(self, halcomp,builder,useropts):
self.builder = builder
self.password = None # cache for sudo password
textview_servo = self.builder.get_object("textview_servo")
buffer_servo = textview_servo.get_buffer()
buffer_servo.connect("changed", self.on_textbuffer_changed)
textview_nic = self.builder.get_object("textview_nic")
buffer_nic = textview_nic.get_buffer()
buffer_nic.connect("changed", self.on_textbuffer_changed)
def ask_sudo_password(self, gtkbutton):
"""
Show a simple dialog asking for the sudo password.
Returns the password string or None if cancelled.
"""
parent = gtkbutton.get_toplevel()
dialog = Gtk.Dialog(
title="sudo password",
transient_for=parent,
modal=True,
)
# Set dialog default size (width x height)
dialog.set_default_size(300, 100)
# Center dialog buttons horizontally
action_area = dialog.get_action_area()
action_area.set_halign(Gtk.Align.CENTER)
# Add dialog buttons
dialog.add_button("_OK", Gtk.ResponseType.OK)
dialog.add_button("_Cancel", Gtk.ResponseType.CANCEL)
# Get the dialog content area
box = dialog.get_content_area()
box.set_spacing(10)
# Create UI elements
label = Gtk.Label(label="Please enter sudo password:")
label.set_halign(Gtk.Align.START) # Align label to the left
entry = Gtk.Entry()
entry.set_visibility(False) # Hide text (password mode)
entry.set_activates_default(True) # Enter key triggers default button
# Pack UI elements into the dialog
box.add(label)
box.add(entry)
box.show_all()
dialog.set_default_response(Gtk.ResponseType.OK)
response = dialog.run()
password = None
if response == Gtk.ResponseType.OK:
password = entry.get_text()
dialog.destroy()
return password or None
def on_btn_ip_nic_released(self, gtkbutton):
ip = subprocess.check_output(['ip', '-br', 'addr', 'show'], text=True)
textview = self.builder.get_object("textview_ip_info")
buffer = textview.get_buffer()
buffer.set_text(ip)
def on_btn_mb_info_released(self, gtkbutton):
# Get / cache sudo password
if not self.password:
self.password = self.ask_sudo_password(gtkbutton)
# Get the TextView for output
textview = self.builder.get_object("textview_pc_info")
buffer = textview.get_buffer()
if self.password is None:
buffer.set_text("Operation cancelled. No password provided.")
return
try:
# Run dmidecode -t 2 with sudo
p = Popen(
['sudo', '-S', 'dmidecode', '-t', '2'],
stdin=PIPE,
stdout=PIPE,
stderr=PIPE,
text=True,
)
stdout, stderr = p.communicate(self.password + '\n')
if p.returncode == 0:
output = stdout
else:
output = stderr
result_text = f"Return Code: {p.returncode}\n{output}"
buffer.set_text(result_text)
except Exception as e:
buffer.set_text(f"Error running dmidecode:\n{e}")
def on_btn_cpu_info_released(self, gtkbutton):
result = subprocess.check_output("lscpu",shell=True, text=True)
textview = self.builder.get_object("textview_pc_info")
buffer = textview.get_buffer()
buffer.set_text(result)
def on_btn_nic_info_released(self, gtkbutton):
result = subprocess.check_output("lspci | grep -i 'ethernet'",shell=True, text=True)
textview = self.builder.get_object("textview_pc_info")
buffer = textview.get_buffer()
buffer.set_text(result)
def on_btn_copy_released(self, gtkbutton):
"""
Copy the content of textview_pc_info to the system clipboard
and replace the content with a confirmation message.
"""
# Get the TextView and its buffer
textview = self.builder.get_object("textview_pc_info")
buffer = textview.get_buffer()
# Read current text from the buffer
start_iter = buffer.get_start_iter()
end_iter = buffer.get_end_iter()
text = buffer.get_text(start_iter, end_iter, True)
# Access the system clipboard
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
# Set clipboard text
clipboard.set_text(text, -1)
# Replace TextView content with notification message
buffer.set_text("Output copied to clipboard")
def on_btn_servo_thread_tmax_released(self, gtkbutton):
result = subprocess.check_output("halcmd show param servo-thread.tmax",shell=True, text=True)
# Remove empty lines
result = "\n".join(
line for line in result.splitlines()
if line.strip() # keeps only non-empty lines
)
textview = self.builder.get_object("textview_servo")
buffer = textview.get_buffer()
if buffer.get_char_count() > 0:
buffer.insert(buffer.get_end_iter(), "\n\n")
buffer.insert(buffer.get_end_iter(), result)
value = None
for line in result.splitlines():
line = line.strip()
if line.endswith("servo-thread.tmax"):
parts = line.split()
value = int(parts[3]) # 4. column is Value
break
spin_thread_tmax = self.builder.get_object("sbtn_servo_thread_tmax")
spin_thread_tmax.set_value(value)
def on_btn_servo_thread_period_released(self, combo):
result = subprocess.check_output("halcmd show thread servo-thread",shell=True, text=True)
# Remove empty lines
result = "\n".join(
line for line in result.splitlines()
if line.strip() # keeps only non-empty lines
)
textview = self.builder.get_object("textview_servo")
buffer = textview.get_buffer()
if buffer.get_char_count() > 0:
buffer.insert(buffer.get_end_iter(), "\n\n")
buffer.insert(buffer.get_end_iter(), result)
value = None
for line in result.splitlines():
line = line.strip()
if "servo-thread" in line:
parts = line.split()
value = int(parts[0]) # 1. column is Value
break
spin_thread_period = self.builder.get_object("sbtn_servo_thread_period")
spin_thread_period.set_value(value)
def on_btn_calc_servo_released(self, gtkbutton):
# Get UI objects
textview = self.builder.get_object("textview_servo")
buffer = textview.get_buffer()
spin_thread_tmax = self.builder.get_object("sbtn_servo_thread_tmax")
t_max = spin_thread_tmax.get_value()
spin_thread_period = self.builder.get_object("sbtn_servo_thread_period")
period = spin_thread_period.get_value()
label_result = self.builder.get_object("lbl_result_servo")
# Conditions
if t_max <= 0:
if buffer.get_char_count() > 0:
buffer.insert(buffer.get_end_iter(), "\n\n")
buffer.insert(buffer.get_end_iter(), "Servo Thread tmax must be greater than 0")
return
if period <= 0:
if buffer.get_char_count() > 0:
buffer.insert(buffer.get_end_iter(), "\n\n")
buffer.insert(buffer.get_end_iter(), "Servo Thread period must be greater than 0")
return
# Calculation
result = t_max / period * 100
label_result.set_text(f'{result:.0f}%')
def on_btn_read_tmax_released(self, gtkbutton):
result = subprocess.check_output("halcmd show param hm2*read.tmax",shell=True, text=True)
# Remove empty lines
result = "\n".join(
line for line in result.splitlines()
if line.strip() # keeps only non-empty lines
)
textview = self.builder.get_object("textview_nic")
buffer = textview.get_buffer()
if buffer.get_char_count() > 0:
buffer.insert(buffer.get_end_iter(), "\n\n")
buffer.insert(buffer.get_end_iter(), result)
value = None
for line in result.splitlines():
line = line.strip()
if "read.tmax" in line:
parts = line.split()
value = int(parts[3]) # 4. column is Value
break
spin_thread_period = self.builder.get_object("sbtn_read_tmax")
spin_thread_period.set_value(value)
def on_btn_write_tmax_released(self, gtkbutton):
result = subprocess.check_output("halcmd show param hm2*write.tmax",shell=True, text=True)
# Remove empty lines
result = "\n".join(
line for line in result.splitlines()
if line.strip() # keeps only non-empty lines
)
textview = self.builder.get_object("textview_nic")
buffer = textview.get_buffer()
if buffer.get_char_count() > 0:
buffer.insert(buffer.get_end_iter(), "\n\n")
buffer.insert(buffer.get_end_iter(), result)
value = None
for line in result.splitlines():
line = line.strip()
if "write.tmax" in line:
parts = line.split()
value = int(parts[3]) # 4. column is Value
break
spin_thread_period = self.builder.get_object("sbtn_write_tmax")
spin_thread_period.set_value(value)
def on_btn_servo_thread_period_nic_released(self, combo):
result = subprocess.check_output("halcmd show thread servo-thread",shell=True, text=True)
# Remove empty lines
result = "\n".join(
line for line in result.splitlines()
if line.strip() # keeps only non-empty lines
)
textview = self.builder.get_object("textview_nic")
buffer = textview.get_buffer()
if buffer.get_char_count() > 0:
buffer.insert(buffer.get_end_iter(), "\n\n")
buffer.insert(buffer.get_end_iter(), result)
value = None
for line in result.splitlines():
line = line.strip()
if "servo-thread" in line:
parts = line.split()
value = int(parts[0]) # 1. column is Value
break
spin_thread_period = self.builder.get_object("sbtn_servo_thread_period_nic")
spin_thread_period.set_value(value)
def on_btn_nic_calculate_released(self, gtkbutton):
# Get UI objects
textview = self.builder.get_object("textview_nic")
buffer = textview.get_buffer()
spin_read_tmax = self.builder.get_object("sbtn_read_tmax")
read_tmax = spin_read_tmax.get_value()
spin_write_tmax = self.builder.get_object("sbtn_write_tmax")
write_tmax = spin_write_tmax.get_value()
spin_thread_period = self.builder.get_object("sbtn_servo_thread_period_nic")
period = spin_thread_period.get_value()
label_result = self.builder.get_object("lbl_result_nic")
# Conditions
if read_tmax <= 0:
if buffer.get_char_count() > 0:
buffer.insert(buffer.get_end_iter(), "\n\n")
buffer.insert(buffer.get_end_iter(), "Parameter read.tmax must be greater than 0")
return
if write_tmax <= 0:
if buffer.get_char_count() > 0:
buffer.insert(buffer.get_end_iter(), "\n\n")
buffer.insert(buffer.get_end_iter(), "Parameter write.tmax must be greater than 0")
return
if period <= 0:
if buffer.get_char_count() > 0:
buffer.insert(buffer.get_end_iter(), "\n\n")
buffer.insert(buffer.get_end_iter(), "Servo Thread period must be greater than 0")
return
# Calculation
rw_tmax = read_tmax + write_tmax
result = rw_tmax / period * 100
label_result.set_text(f'{result:.0f}%')
def on_btn_packet_error_released(self, gtkbutton):
result = subprocess.check_output("halcmd show pin hm2*packet-error-total",shell=True, text=True)
# Remove empty lines
result = "\n".join(
line for line in result.splitlines()
if line.strip() # keeps only non-empty lines
)
textview = self.builder.get_object("textview_nic")
buffer = textview.get_buffer()
if buffer.get_char_count() > 0:
buffer.insert(buffer.get_end_iter(), "\n\n")
buffer.insert(buffer.get_end_iter(), result)
value = None
for line in result.splitlines():
line = line.strip()
if "packet-error-total" in line:
parts = line.split()
value = int(parts[3],16) # 4. column is Value
break
label_packet = self.builder.get_object("lbl_packet_error")
label_packet.set_text(str(value))
# Automatic scroll for both text views
def on_textbuffer_changed(self, buffer):
# Get both textviews and their buffers
textview_servo = self.builder.get_object("textview_servo")
buffer_servo = textview_servo.get_buffer()
textview_nic = self.builder.get_object("textview_nic")
buffer_nic = textview_nic.get_buffer()
# Decide which textview this buffer belongs to
if buffer is buffer_servo:
textview = textview_servo
attr_name = "end_mark_servo"
elif buffer is buffer_nic:
textview = textview_nic
attr_name = "end_mark_nic"
else:
# Unknown buffer, do nothing
return
end_iter = buffer.get_end_iter()
# Get existing mark or create a new one lazily
mark = getattr(self, attr_name, None)
if mark is None:
mark = buffer.create_mark(attr_name, end_iter, False)
setattr(self, attr_name, mark)
# Move mark to the end
buffer.move_mark(mark, end_iter)
# Scroll to the bottom
textview.scroll_to_mark(
mark,
0.0, # within_margin
True, # use_align
0.0, # xalign
1.0 # yalign
)
def get_handlers(halcomp,builder,useropts):
return [MesaTests(halcomp,builder,useropts)]