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

SpiNNakerManchester / JavaSpiNNaker / 6310285782

26 Sep 2023 08:47AM UTC coverage: 36.367% (-0.5%) from 36.866%
6310285782

Pull #658

github

dkfellows
Merge branch 'master' into java-17
Pull Request #658: Update Java version to 17 and JEE to 9

1675 of 1675 new or added lines in 266 files covered. (100.0%)

8368 of 23010 relevant lines covered (36.37%)

0.36 hits per line

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

0.0
/SpiNNaker-comms/src/main/java/uk/ac/manchester/spinnaker/transceiver/GetTagsProcess.java
1
/*
2
 * Copyright (c) 2018 The University of Manchester
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     https://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package uk.ac.manchester.spinnaker.transceiver;
17

18
import static java.util.stream.IntStream.range;
19

20
import java.io.IOException;
21
import java.util.Collection;
22
import java.util.Map;
23
import java.util.TreeMap;
24

25
import uk.ac.manchester.spinnaker.connections.ConnectionSelector;
26
import uk.ac.manchester.spinnaker.connections.SCPConnection;
27
import uk.ac.manchester.spinnaker.machine.tags.Tag;
28
import uk.ac.manchester.spinnaker.messages.scp.IPTagGet;
29
import uk.ac.manchester.spinnaker.messages.scp.IPTagGetInfo;
30

31
/** Gets IP tags and reverse IP tags. */
32
final class GetTagsProcess extends TxrxProcess {
33
        /**
34
         * @param connectionSelector
35
         *            How to select how to communicate.
36
         * @param retryTracker
37
         *            Object used to track how many retries were used in an
38
         *            operation. May be {@code null} if no suck tracking is
39
         *            required.
40
         */
41
        GetTagsProcess(
42
                        ConnectionSelector<? extends SCPConnection> connectionSelector,
43
                        RetryTracker retryTracker) {
44
                super(connectionSelector, retryTracker);
×
45
        }
×
46

47
        /**
48
         * Get the set of tags that are associated with a connection.
49
         *
50
         * @param connection
51
         *            The connection that the tags are associated with.
52
         * @return The allocated tags in ID order. Unallocated tags are absent.
53
         * @throws IOException
54
         *             If anything goes wrong with networking.
55
         * @throws ProcessException
56
         *             If SpiNNaker rejects a message.
57
         * @throws InterruptedException
58
         *             If the communications were interrupted.
59
         */
60
        Collection<Tag> getTags(SCPConnection connection)
61
                        throws IOException, ProcessException, InterruptedException {
62
                var tags = new TreeMap<Integer, Tag>();
×
63
                for (var tagId : range(0, getTagCount(connection)).toArray()) {
×
64
                        sendGet(new IPTagGet(connection.getChip(), tagId), info -> {
×
65
                                if (info.inUse()) {
×
66
                                        tags.put(tagId, info.tag());
×
67
                                }
68
                        });
×
69
                }
70
                finishBatch();
×
71
                return tags.values();
×
72
        }
73

74
        private int getTagCount(SCPConnection connection)
75
                        throws IOException, ProcessException, InterruptedException {
76
                var tagInfo = retrieve(new IPTagGetInfo(connection.getChip()));
×
77
                return tagInfo.poolSize() + tagInfo.fixedSize();
×
78
        }
79

80
        /**
81
         * Get the usage of each of the (active) tags associated with a connection.
82
         *
83
         * @param connection
84
         *            The connection that the tags are associated with.
85
         * @return A map from each active tag to the number of packets sent through
86
         *         that tag.
87
         * @throws IOException
88
         *             If anything goes wrong with networking.
89
         * @throws ProcessException
90
         *             If SpiNNaker rejects a message.
91
         * @throws InterruptedException
92
         *             If the communications were interrupted.
93
         */
94
        Map<Tag, Integer> getTagUsage(SCPConnection connection)
95
                        throws IOException, ProcessException, InterruptedException {
96
                var tagUsages = new TreeMap<Tag, Integer>();
×
97
                for (var tagId : range(0, getTagCount(connection)).toArray()) {
×
98
                        sendGet(new IPTagGet(connection.getChip(), tagId), info -> {
×
99
                                if (info.inUse()) {
×
100
                                        tagUsages.put(info.tag(), info.count());
×
101
                                }
102
                        });
×
103
                }
104
                finishBatch();
×
105
                return tagUsages;
×
106
        }
107
}
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

© 2026 Coveralls, Inc