Skip to content

Protobuf support implementation #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ env/
venv/
.idea/
logs.txt
.DS_Store
.DS_Store
*pb2.py
.venv
30 changes: 30 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,35 @@ You can always create ```config.json``` file yourself if you think writing it wi
```
> result - app publishes random int value on 'topic1' every second and random uint value on 'test/topic2'

# Protobuf
To use protobuf place compiled message files in src/protofiles.

## Custom message content

To send a message with custom contents use *.csv file. Program will look for specified file in root directory.

### Example:

Given these protobuf messages:
```protobuf
message Message1 {
int32 my_int = 1;
Message2 nested_message = 2;
}
message Message2 {
int32 my_int = 1;
}
```

example csv file for Message1 would look like this:

```csv
my_int,nested_message.my_int
123,456
456,1312
123123,45123
```

## Screenshots
Keep in mind that the look of the app is dependent on user's system - QT uses native components.
<p align="center">
Expand All @@ -125,3 +154,4 @@ Main window
<br>
Add topic window
</p>

6 changes: 6 additions & 0 deletions src/abstractdatagenerator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class DataGenerator():
def __init__(self, config):
pass

def next_message(self) -> str:
pass
11 changes: 11 additions & 0 deletions src/arbiter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from abstractdatagenerator import DataGenerator
from jsondatagenerator import JsonDataGenerator
from protogenerator import ProtoDataGenerator

def get_data_generator(config) -> DataGenerator:
if "data_format" in config:
return JsonDataGenerator(config)
elif "message" in config:
return ProtoDataGenerator(config)


169 changes: 169 additions & 0 deletions src/gui/addprototopicdialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AddProtoTopicDialog</class>
<widget class="QDialog" name="AddProtoTopicDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>457</width>
<height>337</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="windowTitle">
<string>Add topic</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item alignment="Qt::AlignmentFlag::AlignTop">
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Add topic</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="name_lbl">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="name_line_edit">
<property name="toolTip">
<string>Name of topic</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="format_lbl">
<property name="text">
<string>Message</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QListWidget" name="message_list"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="interval_lbl">
<property name="text">
<string>Interval (seconds)</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="interval_spin_box">
<property name="toolTip">
<string>Interval of incoming data</string>
</property>
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>60.000000000000000</double>
</property>
<property name="singleStep">
<double>0.500000000000000</double>
</property>
<property name="value">
<double>1.500000000000000</double>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="manual_lbl">
<property name="text">
<string>Manual</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="manual_check_box">
<property name="toolTip">
<string>If checked, the data will be automatically send every &lt;interval&gt; seconds</string>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="file_line_edit"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="path_label">
<property name="text">
<string>File (optional)</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AddProtoTopicDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AddProtoTopicDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
45 changes: 45 additions & 0 deletions src/gui/choosetopicdialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChooseTopicDialog</class>
<widget class="QDialog" name="ChooseTopicDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>319</width>
<height>153</height>
</rect>
</property>
<property name="windowTitle">
<string>Choose message type</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>9</x>
<y>19</y>
<width>291</width>
<height>121</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="choose_proto_button">
<property name="text">
<string>Protobuf</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="choose_json_button">
<property name="text">
<string>JSON</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>
Loading