Skip to content

Commit 7595d38

Browse files
author
timothy.tamm
committed
update mocks and messages
1 parent 93649f4 commit 7595d38

6 files changed

+93
-6
lines changed

messages/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
protobuf: mockMsg.proto
2+
protoc -I=./ --python_out=./ ./mockMsg.proto

messages/__init__.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from enum import Enum
2+
from .mockMsg_pb2 import MockMsg
3+
4+
class MsgType(Enum):
5+
MOCK_MSG = 0
6+
7+
message_buffers = {
8+
MsgType.MOCK_MSG: MockMsg
9+
}
10+
11+
12+
__all__ = ['MsgType', 'message_buffers', 'MockMsg']

messages/mockMsg.proto

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
syntax = "proto2";
2+
3+
package mateROV;
4+
5+
message MockMsg {
6+
7+
required int32 mockValue = 1;
8+
}

messages/mockMsg_pb2.py

+69
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mockDisplayModule.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class MockGuiModule(rm.ProtoModule):
1313
def __init__(self, addr, port):
1414
self.subscriptions = [MsgType.MOCK_MSG]
15-
super().__init__(addr, port, message_buffers, MsgType, self.subscriptions)
15+
super().__init__(addr, port, message_buffers, MsgType, FREQUENCY, self.subscriptions)
1616
self.value = -1
1717
self.sub_ticks = 0
1818
self.subbed = True
@@ -24,8 +24,6 @@ def msg_received(self, msg, msg_type):
2424

2525
def tick(self):
2626
# this function will get called in a loop with FREQUENCY frequency
27-
self.loop.call_later(1.0/FREQUENCY, self.tick)
28-
2927
# for this mock module we will print out the current value
3028
print('Current value: {}'.format(self.value))
3129

mockSensorModule.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class MockSensorModule(rm.ProtoModule):
1313
def __init__(self, addr, port):
1414
self.subscriptions = []
15-
super().__init__(addr, port, message_buffers, MsgType, self.subscriptions)
15+
super().__init__(addr, port, message_buffers, MsgType, FREQUENCY)
1616

1717
def msg_received(self, msg, msg_type):
1818
# This gets called whenever any message is received
@@ -21,8 +21,6 @@ def msg_received(self, msg, msg_type):
2121

2222
def tick(self):
2323
# this function will get called in a loop with FREQUENCY frequency
24-
self.loop.call_later(1.0/FREQUENCY, self.tick)
25-
2624
# for this mock module we will just send a random int
2725
msg = MockMsg()
2826
msg.mockValue = random.randint(1, 9)

0 commit comments

Comments
 (0)