• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SpiNNakerManchester / SpiNNMan / 6574804013

19 Oct 2023 12:47PM UTC coverage: 51.937% (+1.2%) from 50.777%
6574804013

Pull #327

github

Christian-B
typing changes
Pull Request #327: Type Annotations and Checking

105 of 1288 branches covered (0.0%)

Branch coverage included in aggregate %.

2375 of 2375 new or added lines in 180 files covered. (100.0%)

4775 of 8108 relevant lines covered (58.89%)

0.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.0
/spinnman/messages/scp/impl/send_signal.py
1
# Copyright (c) 2014 The University of Manchester
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
#     https://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14
from typing import cast
1✔
15
from spinn_utilities.overrides import overrides
1✔
16
from spinnman.exceptions import SpinnmanInvalidParameterException
1✔
17
from spinnman.messages.scp import SCPRequestHeader
1✔
18
from spinnman.messages.scp.abstract_messages import AbstractSCPRequest
1✔
19
from spinnman.messages.scp.enums import SCPCommand, Signal
1✔
20
from spinnman.messages.sdp import SDPFlag, SDPHeader
1✔
21
from .check_ok_response import CheckOKResponse
1✔
22

23
_ALL_CORE_MASK = 0xFFFF
1✔
24
_APP_MASK = 0xFF
1✔
25

26

27
def _get_data(app_id: int, signal: Signal) -> int:
1✔
28
    data = (_APP_MASK << 8) | app_id
×
29
    data += cast(int, signal.value) << 16
×
30
    return data
×
31

32

33
class SendSignal(AbstractSCPRequest[CheckOKResponse]):
1✔
34
    """
35
    An SCP Request to send a signal to cores.
36
    """
37
    __slots__ = ()
1✔
38

39
    def __init__(self, app_id: int, signal: Signal):
1✔
40
        """
41
        :param int app_id: The ID of the application, between 0 and 255
42
        :param Signal signal: The signal to send
43
        :raise SpinnmanInvalidParameterException: If app_id is out of range
44
        """
45

46
        if app_id < 0 or app_id > 255:
×
47
            raise SpinnmanInvalidParameterException(
×
48
                "app_id", str(app_id), "Must be between 0 and 255")
49

50
        super().__init__(
×
51
            SDPHeader(
52
                flags=SDPFlag.REPLY_EXPECTED, destination_port=0,
53
                destination_cpu=0,
54
                destination_chip_x=self.DEFAULT_DEST_X_COORD,
55
                destination_chip_y=self.DEFAULT_DEST_Y_COORD),
56
            SCPRequestHeader(command=SCPCommand.CMD_SIG),
57
            argument_1=signal.signal_type.value,
58
            argument_2=_get_data(app_id, signal),
59
            argument_3=_ALL_CORE_MASK)
60

61
    @overrides(AbstractSCPRequest.get_scp_response)
1✔
62
    def get_scp_response(self) -> CheckOKResponse:
1✔
63
        return CheckOKResponse("Send Signal", "CMD_SIG")
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc