Skip to content

Commit

Permalink
get rid of dummy types, use distinct message types everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
SillyFreak committed Sep 25, 2019
1 parent 351f525 commit 0070cb1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
12 changes: 6 additions & 6 deletions hedgehog/protocol/messages/motor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class ConfigAction extends Message {
// <GSL customizable: ConfigAction-serialize-config>
switch(this.config.kind) {
case ConfigKind.DC:
msg.setDc(new motor_pb.Dummy());
msg.setDc(new motor_pb.DcConfig());
break;
case ConfigKind.ENCODER:
let config = new motor_pb.EncoderConfig();
Expand All @@ -105,7 +105,7 @@ export class ConfigAction extends Message {
msg.setEncoder(config);
break;
case ConfigKind.STEPPER:
msg.setStepper(new motor_pb.Dummy());
msg.setStepper(new motor_pb.StepperConfig());
break;
// istanbul ignore next
default:
Expand Down Expand Up @@ -145,7 +145,7 @@ export class CommandReply extends Message {
// <GSL customizable: CommandReply-serialize-config>
switch(this.config.kind) {
case ConfigKind.DC:
msg.setDc(new motor_pb.Dummy());
msg.setDc(new motor_pb.DcConfig());
break;
case ConfigKind.ENCODER:
let config = new motor_pb.EncoderConfig();
Expand All @@ -154,7 +154,7 @@ export class CommandReply extends Message {
msg.setEncoder(config);
break;
case ConfigKind.STEPPER:
msg.setStepper(new motor_pb.Dummy());
msg.setStepper(new motor_pb.StepperConfig());
break;
// istanbul ignore next
default:
Expand Down Expand Up @@ -199,7 +199,7 @@ export class CommandUpdate extends Message {
// <GSL customizable: CommandUpdate-serialize-config>
switch(this.config.kind) {
case ConfigKind.DC:
msg.setDc(new motor_pb.Dummy());
msg.setDc(new motor_pb.DcConfig());
break;
case ConfigKind.ENCODER:
let config = new motor_pb.EncoderConfig();
Expand All @@ -208,7 +208,7 @@ export class CommandUpdate extends Message {
msg.setEncoder(config);
break;
case ConfigKind.STEPPER:
msg.setStepper(new motor_pb.Dummy());
msg.setStepper(new motor_pb.StepperConfig());
break;
// istanbul ignore next
default:
Expand Down
12 changes: 7 additions & 5 deletions proto/hedgehog/protocol/proto/motor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ enum MotorState {
VELOCITY = 2;
}

message Dummy {}
message DcConfig {}

message EncoderConfig {
uint32 encoder_a_port = 1;
uint32 encoder_b_port = 2;
}

message StepperConfig {}
// </GSL customizable: module-extras>

// Command for one motor. By setting a relative or absolute goal position,
Expand Down Expand Up @@ -61,9 +63,9 @@ message MotorAction {
message MotorConfigAction {
uint32 port = 1;
oneof config {
Dummy dc = 2;
DcConfig dc = 2;
EncoderConfig encoder = 3;
Dummy stepper = 4;
StepperConfig stepper = 4;
}
}

Expand All @@ -77,9 +79,9 @@ message MotorConfigAction {
message MotorCommandMessage {
uint32 port = 1;
oneof config {
Dummy dc = 5;
DcConfig dc = 5;
EncoderConfig encoder = 6;
Dummy stepper = 7;
StepperConfig stepper = 7;
}
MotorState state = 2;
sint32 amount = 3;
Expand Down
12 changes: 6 additions & 6 deletions test/protocol.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ describe('Protocol', () => {
let wire = makeWire(_wire => {
let proto = new motor_pb.MotorConfigAction();
proto.setPort(0);
proto.setDc(new motor_pb.Dummy());
proto.setDc(new motor_pb.DcConfig());
_wire.setMotorConfigAction(proto);
});

Expand Down Expand Up @@ -572,7 +572,7 @@ describe('Protocol', () => {
let wire = makeWire(_wire => {
let proto = new motor_pb.MotorConfigAction();
proto.setPort(0);
proto.setStepper(new motor_pb.Dummy());
proto.setStepper(new motor_pb.StepperConfig());
_wire.setMotorConfigAction(proto);
});

Expand Down Expand Up @@ -627,7 +627,7 @@ describe('Protocol', () => {
let wire = makeWire(_wire => {
let proto = new motor_pb.MotorCommandMessage();
proto.setPort(0);
proto.setDc(new motor_pb.Dummy());
proto.setDc(new motor_pb.DcConfig());
proto.setState(motor.MotorState.POWER);
proto.setAmount(1000);
_wire.setMotorCommandMessage(proto);
Expand Down Expand Up @@ -662,7 +662,7 @@ describe('Protocol', () => {
let wire = makeWire(_wire => {
let proto = new motor_pb.MotorCommandMessage();
proto.setPort(0);
proto.setStepper(new motor_pb.Dummy());
proto.setStepper(new motor_pb.StepperConfig());
proto.setState(motor.MotorState.POWER);
proto.setAmount(1000);
_wire.setMotorCommandMessage(proto);
Expand All @@ -680,7 +680,7 @@ describe('Protocol', () => {
let wire = makeWire(_wire => {
let proto = new motor_pb.MotorCommandMessage();
proto.setPort(0);
proto.setDc(new motor_pb.Dummy());
proto.setDc(new motor_pb.DcConfig());
proto.setState(motor.MotorState.POWER);
proto.setAmount(1000);
proto.setSubscription(sub);
Expand Down Expand Up @@ -725,7 +725,7 @@ describe('Protocol', () => {
let wire = makeWire(_wire => {
let proto = new motor_pb.MotorCommandMessage();
proto.setPort(0);
proto.setStepper(new motor_pb.Dummy());
proto.setStepper(new motor_pb.StepperConfig());
proto.setState(motor.MotorState.POWER);
proto.setAmount(1000);
proto.setSubscription(sub);
Expand Down

0 comments on commit 0070cb1

Please sign in to comment.