RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
SchedulerProto.java
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5package org.wpilib.command3.proto;
6
7import org.wpilib.command3.Command;
8import org.wpilib.command3.Scheduler;
9import org.wpilib.command3.proto.ProtobufCommands.ProtobufScheduler;
10import org.wpilib.util.protobuf.Protobuf;
11import us.hebi.quickbuf.Descriptors;
12
19public class SchedulerProto implements Protobuf<Scheduler, ProtobufScheduler> {
20 @Override
21 public Class<Scheduler> getTypeClass() {
22 return Scheduler.class;
23 }
24
25 @Override
26 public Descriptors.Descriptor getDescriptor() {
27 return ProtobufScheduler.getDescriptor();
28 }
29
30 @Override
31 public ProtobufScheduler createMessage() {
32 return ProtobufScheduler.newInstance();
33 }
34
35 @Override
36 public Scheduler unpack(ProtobufScheduler msg) {
37 throw new UnsupportedOperationException("Deserialization not supported");
38 }
39
40 @Override
41 public void pack(ProtobufScheduler msg, Scheduler scheduler) {
42 msg.clear();
43
44 var commandProto = new CommandProto(scheduler);
45
46 Protobuf.packArray(
47 msg.getMutableQueuedCommands(),
48 scheduler.getQueuedCommands().toArray(new Command[0]),
49 commandProto);
50
51 Protobuf.packArray(
52 msg.getMutableRunningCommands(),
53 scheduler.getRunningCommands().toArray(new Command[0]),
54 commandProto);
55
56 msg.setLastTimeMs(scheduler.lastRuntimeMs());
57 }
58}
Collection< Command > getQueuedCommands()
Collection< Command > getRunningCommands()