Skip to content

Commit

Permalink
rename services
Browse files Browse the repository at this point in the history
  • Loading branch information
sshane committed Sep 15, 2023
1 parent ff3dbaa commit 60df619
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions messaging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from collections import deque

from cereal import log
from cereal.services import service_list
from cereal.services import SERVICES

assert MultiplePublishersError
assert MessagingError
Expand Down Expand Up @@ -180,7 +180,7 @@ def __init__(self, services: List[str], poll: Optional[List[str]] = None,
if addr is not None:
p = self.poller if s not in self.non_polled_services else None
self.sock[s] = sub_sock(s, poller=p, addr=addr, conflate=True)
self.freq[s] = service_list[s].frequency
self.freq[s] = SERVICES[s].frequency

try:
data = new_message(s)
Expand Down
4 changes: 2 additions & 2 deletions messaging/tests/test_messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

from cereal import log, car
import cereal.messaging as messaging
from cereal.services import service_list
from cereal.services import SERVICES

events = [evt for evt in log.Event.schema.union_fields if evt in service_list.keys()]
events = [evt for evt in log.Event.schema.union_fields if evt in SERVICES.keys()]

def random_sock():
return random.choice(events)
Expand Down
8 changes: 4 additions & 4 deletions messaging/tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
from parameterized import parameterized

import cereal.services as services
from cereal.services import service_list, RESERVED_PORT, STARTING_PORT
from cereal.services import SERVICES, RESERVED_PORT, STARTING_PORT


class TestServices(unittest.TestCase):

@parameterized.expand(service_list.keys())
@parameterized.expand(SERVICES.keys())
def test_services(self, s):
service = service_list[s]
service = SERVICES[s]
self.assertTrue(service.port != RESERVED_PORT)
self.assertTrue(service.port >= STARTING_PORT)
self.assertTrue(service.frequency <= 104)

def test_no_duplicate_port(self):
ports: Dict[int, str] = {}
for name, service in service_list.items():
for name, service in SERVICES.items():
self.assertFalse(service.port in ports.keys(), f"duplicate port {service.port}")
ports[service.port] = name

Expand Down
6 changes: 3 additions & 3 deletions services.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def __init__(self, port: int, should_log: bool, frequency: float, decimation: Op
"livestreamRoadEncodeData": (False, 20.),
"livestreamDriverEncodeData": (False, 20.),
}
service_list = {name: Service(new_port(idx), *vals) for # type: ignore
idx, (name, vals) in enumerate(services.items())}
SERVICES = {name: Service(new_port(idx), *vals) for # type: ignore
idx, (name, vals) in enumerate(services.items())}


def build_header():
Expand All @@ -111,7 +111,7 @@ def build_header():

h += "struct service { std::string name; int port; bool should_log; int frequency; int decimation; };\n"
h += "static std::map<std::string, service> services = {\n"
for k, v in service_list.items():
for k, v in SERVICES.items():
should_log = "true" if v.should_log else "false"
decimation = -1 if v.decimation is None else v.decimation
h += ' { "%s", {"%s", %d, %s, %d, %d}},\n' % \
Expand Down

0 comments on commit 60df619

Please sign in to comment.