From 7dcc3a3c2bc53a47b03f7ab26248a8e065c417c3 Mon Sep 17 00:00:00 2001 From: Samuel Shi Date: Tue, 19 Nov 2024 03:25:58 -0500 Subject: [PATCH] Small fix in readme and further implemented isolated logic --- .../FrontController/vehicle_control_system | 1 + .../vehicle_control_system | 1 + scripts/can_errgo/README.md | 2 +- scripts/can_errgo/error_tui.go | 117 ++++++++++++------ 4 files changed, 80 insertions(+), 41 deletions(-) create mode 160000 firmware/projects/EV5/FrontController/vehicle_control_system create mode 160000 firmware/projects/debug/FrontControllerSimple/vehicle_control_system diff --git a/firmware/projects/EV5/FrontController/vehicle_control_system b/firmware/projects/EV5/FrontController/vehicle_control_system new file mode 160000 index 000000000..4fddb9369 --- /dev/null +++ b/firmware/projects/EV5/FrontController/vehicle_control_system @@ -0,0 +1 @@ +Subproject commit 4fddb9369730a8cee4e74f83d71d3b1e33b8d5ea diff --git a/firmware/projects/debug/FrontControllerSimple/vehicle_control_system b/firmware/projects/debug/FrontControllerSimple/vehicle_control_system new file mode 160000 index 000000000..a04e3a93f --- /dev/null +++ b/firmware/projects/debug/FrontControllerSimple/vehicle_control_system @@ -0,0 +1 @@ +Subproject commit a04e3a93f0def3d748ca7c636cb0f226328c0a10 diff --git a/scripts/can_errgo/README.md b/scripts/can_errgo/README.md index 496301231..9a9ee40b3 100644 --- a/scripts/can_errgo/README.md +++ b/scripts/can_errgo/README.md @@ -4,7 +4,7 @@ This is a Tangible User Interface program designed to track CAN Errors including Users can: -- Acknowledge the error ( Hide the error until it is sent again) +- Acknowledge the error ( Hide and resets the error until it is sent again) - Ignore the error ( Hides, resets, and stops reading all future occurrences of the error) - View ignored errors and choose to unignore those errors diff --git a/scripts/can_errgo/error_tui.go b/scripts/can_errgo/error_tui.go index 0b8a180c2..36df8151e 100644 --- a/scripts/can_errgo/error_tui.go +++ b/scripts/can_errgo/error_tui.go @@ -48,7 +48,7 @@ func toTableRows(r []ErrorData) []table.MetaRow { var rows []table.MetaRow for _, v := range r { // Check if the ErrorData is "non-empty" and Active - if v.Error != "" && v.Count != 0 && !v.Ignored{ + if v.Count != 0 && !v.Ignored{ rows = append(rows, RowValuesToRow(v)) } } @@ -75,7 +75,7 @@ func SortRowValuesByRecency(r []ErrorData) []ErrorData { func findError(errorIndex int, rowValues []ErrorData) int { cnt := 0 for i ,row := range rowValues{ - if row.Error == "" || row.Ignored{ + if row.Count == 0 || row.Ignored{ cnt += 1 } if row.ErrorIndex == errorIndex{ @@ -102,6 +102,7 @@ type ErrorData struct{ Recency int Description string Ignored bool + // This is used for keeping track of the error bit after sorting ErrorIndex int } @@ -153,15 +154,6 @@ func tickEvery(t time.Duration) tea.Cmd { } } -// Increment the recency of all errors -func (m *model) refresh() { - for i := range m.errorData { // Use index to modify the original slice - if m.errorData[i].Count != 0 { - m.errorData[i].Recency += 1 - } - } -} - func (m model) Init() tea.Cmd { return tickEvery(m.t) } // Table and ignore subtable update loop. @@ -190,13 +182,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { newRows := m.getIgnoredRows() m.submenuTable.SetRows(newRows) - // May be unnecessary, but just in case we update the cursor. - if m.submenuTable.Cursor() == 0{ - m.submenuTable.MoveDown(1) - }else{ - m.submenuTable.MoveUp(1) - } - case key.Matches(msg, m.submenuKeys.s): m.submenuActive = false // Hide submenu m.table.Focus() // Refocus the main table @@ -230,14 +215,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.errorData[errorIndex].Count = 0 newRows := toTableRows(m.errorData) m.table.SetRows(newRows) - - - // May be unnecessary, but just in case we update the cursor. - if m.table.Cursor() == 0{ - m.table.MoveDown(1) - }else{ - m.table.MoveUp(1) - } return m, nil case key.Matches(msg, m.tableKeys.i): @@ -260,8 +237,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { //Set add the ignored rows to submenu ignoredRows := m.getIgnoredRows() m.submenuTable.SetRows(ignoredRows) - // May be unnecessary, but just in case we update the cursor. - m.table.MoveDown(1) return m, nil case key.Matches(msg, m.tableKeys.s): @@ -289,17 +264,11 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.isTimeout = false // Perform bitwise AND to filter out the bits that are not of interest msg.Value = msg.Value & m.ignoreMask - // Update the freshness of the errors - m.refresh() - for k := 0; k < 64; k++ { // Iterate through all 64 bits - if msg.Value&(1<