protobuf messages

This commit is contained in:
2026-09-30 12:33:15 +02:00
parent 236030c99a
commit 4618c500c9
4 changed files with 226 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
find_package(Qt6 REQUIRED COMPONENTS Protobuf Grpc)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_library(proto-ui STATIC)
set_target_properties(
proto-ui
PROPERTIES
AUTOMOC ON
POSITION_INDEPENDENT_CODE ON
)
qt_add_protobuf(proto-ui
PROTO_FILES
${CMAKE_CURRENT_LIST_DIR}/m_ui_items.proto
${CMAKE_CURRENT_LIST_DIR}/messages.proto
)
target_link_libraries(proto-ui PUBLIC Qt6::Protobuf)
add_library(proto-ui-client STATIC)
set_target_properties(
proto-ui-client
PROPERTIES
AUTOMOC ON
POSITION_INDEPENDENT_CODE ON
)
qt_add_grpc(proto-ui-client CLIENT
PROTO_FILES
${CMAKE_CURRENT_LIST_DIR}/messages.proto
)
target_link_libraries(proto-ui-client PUBLIC Qt6::Protobuf Qt6::Grpc proto-ui)
# add_library(proto-ui-server STATIC)
# set_target_properties(
# proto-ui-server
# PROPERTIES
# AUTOMOC ON
# POSITION_INDEPENDENT_CODE ON
# )
# qt_add_grpc(proto-ui-server SERVER
# PROTO_FILES
# ${CMAKE_CURRENT_LIST_DIR}/messages.proto
# )
# target_link_libraries(proto-ui-server PUBLIC Qt6::Protobuf Qt6::Grpc proto-ui)
+131
View File
@@ -0,0 +1,131 @@
syntax = "proto3";
enum UI_type {
undef = 0;
ui_button = 1;
ui_can = 2;
ui_checkbox = 3;
ui_combobox = 4;
ui_dial = 5;
ui_double_spinbox = 6;
ui_hex_spinbox = 7;
ui_label = 8;
ui_led = 9;
ui_plot = 10;
ui_slider = 11;
ui_spinbox = 12;
ui_stacked_widget = 13;
ui_status_bar = 14;
ui_tab_widget = 15;
ui_table = 16;
ui_textbox = 17;
ui_thermo = 18;
}
message CAN_Frame_m {
uint32 sid = 1;
int64 dlc = 2;
bytes payload = 3;
}
message UI_color {
uint32 fg_color = 1;
uint32 bg_color = 2;
}
message UI_label_m {
UI_color color = 1;
string text = 2;
}
message UI_can_m {
UI_color color = 1;
repeated CAN_Frame_m send_frames = 2;
repeated CAN_Frame_m recv_frames = 3;
}
message UI_checkbox_m {
UI_color color = 1;
string text = 2;
bool checked = 3;
}
message UI_combobox_m {
int64 selected = 1;
repeated string options = 2;
}
message UI_range_m {
double min = 1;
double max = 2;
double value = 3;
string unit = 4;
string text = 5;
}
message UI_spinbox_m {
double min = 1;
double max = 2;
double value = 3;
}
message UI_plot_m {
UI_color color = 1;
string text = 2;
string x_label = 3;
string y_label = 4;
repeated double x_vals = 5;
repeated double y_vals = 6;
}
message UI_stacked_widget_m {
int64 tab_count = 1;
int64 current_tab = 2;
}
message UI_tab_widget_m {
int64 selecte_tab = 1;
repeated string tab_names = 2;
repeated bool tab_visible = 3;
}
message UI_status_bar_m {
uint64 timeout = 1;
string message = 2;
}
message UI_table_m {
int64 row_count = 1;
int64 column_count = 2;
repeated string row_labels = 3;
repeated string column_labels = 4;
repeated string table = 5;
}
message UI_textbox_m {
UI_color color = 1;
string text = 2;
string hint = 3;
}
message UI_item_m {
uint64 id = 1;
UI_type type = 2;
bool enabled = 3;
bool visible = 4;
oneof kind {
UI_label_m label = 5;
UI_can_m can = 6;
UI_checkbox_m checkbox = 7;
UI_combobox_m combobox = 8;
UI_range_m range = 9;
UI_spinbox_m spinbox = 10;
UI_plot_m plot = 11;
UI_stacked_widget_m stacked_widget = 12;
UI_tab_widget_m tab_widget = 13;
UI_status_bar_m status_bar = 14;
UI_table_m table = 15;
UI_textbox_m textbox = 16;
}
}
+50
View File
@@ -0,0 +1,50 @@
syntax = "proto3";
import "m_ui_items.proto";
message Empty {}
message UI_id_m { uint32 id = 1; }
message UI_items_m { repeated UI_item_m item = 1; }
message Simulator_m { string simuator = 1;}
message Simulators_m { repeated string simulator = 1; }
message Clicked_m {}
message Value_changed_m { double value = 1; }
message Text_changed_m { string text = 1; }
message Selected_m { uint32 selected = 1; }
message CAN_send_m { CAN_Frame_m frame = 1; }
message Clear_m {}
message Event_m {
uint32 id = 1;
oneof kind {
Clicked_m clicked = 2;
Value_changed_m value_changed = 3;
Text_changed_m text_changed = 4;
Selected_m selected = 5;
CAN_send_m can_send = 6;
Clear_m clear = 7;
}
}
service RemoteUiService {
// Commands
rpc Command_get_ui_element (UI_id_m) returns (UI_items_m);
rpc Command_get_ui_elements (Empty) returns (UI_items_m);
rpc Command_switch_simulator (Simulator_m) returns (Empty);
rpc Command_get_active_simulator (Empty) returns (Simulator_m);
rpc Command_get_simulators (Empty) returns (Simulators_m);
// Events
rpc SendEvent (Event_m) returns (Empty);
// Broadcasting
rpc SubscribeUIChanges (Empty) returns (stream UI_items_m);
}