Skip to content

Commit

Permalink
Add protos submodule (#126)
Browse files Browse the repository at this point in the history
* Add protos submodule

* Change protos path in package.json

* Change protos path to protos-main

* Add protos-main index file and change file paths

* Updating protos submodule to the newest version:

* Update build-protos command

* Regenerate protos files

Co-authored-by: ewc340 <[email protected]>
Co-authored-by: Hailey Jang <[email protected]>
  • Loading branch information
3 people authored Sep 26, 2021
1 parent 9f6c14a commit fa051e4
Show file tree
Hide file tree
Showing 26 changed files with 823 additions and 170 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "protos-main/protos"]
path = protos-main/protos
url = https://github.com/pioneers/protos.git
2 changes: 1 addition & 1 deletion fake-runtime/FakeRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

/* eslint-disable camelcase */
import { DevData, IParam, IDevice, IDevData } from '../protos/protos';
import { DevData, IParam, IDevice, IDevData } from '../protos-main';
import { createSocket, Socket as UDPSocket } from 'dgram';
import { createServer, Server as TCPServer } from 'net';

Expand Down
14 changes: 7 additions & 7 deletions main/networking/Runtime.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createSocket, Socket as UDPSocket } from 'dgram';
import { Socket as TCPSocket } from 'net';
import { ipcMain, IpcMainEvent } from 'electron';
import * as protos from '../../protos/protos';
import * as protos from '../../protos-main';

import RendererBridge from '../RendererBridge';
import { updateConsole } from '../../renderer/actions/ConsoleActions';
Expand Down Expand Up @@ -299,8 +299,8 @@ class TCPConn {
const oneWayLatency = (Date.now() - Number(decoded.dawnTimestamp)) / 2;

// TODO: we can probably do an average of n timestamps so the display doesn't change too frequently
RendererBridge.reduxDispatch(setLatencyValue(oneWayLatency))

RendererBridge.reduxDispatch(setLatencyValue(oneWayLatency));
break;
case MsgType.CHALLENGE_DATA:
// TODO: Dispatch challenge outputs to redux
Expand All @@ -326,12 +326,12 @@ class TCPConn {
if (this.socket.pending) {
return;
}

const message = createPacket(data, MsgType.TIME_STAMPS);
this.socket.write(message, () => {
this.logger.log(`Sent timestamp data to runtime: ${JSON.stringify(data)}`);
})
}
});
};

/**
* IPC Connection with ConfigBox.ts' saveChanges()
Expand Down Expand Up @@ -387,7 +387,7 @@ class TCPConn {
this.socket.write(message, () => {
this.logger.log(`Challenge inputs sent: ${textData.toString()}`);
});
}
};

sendRobotStartPos = (_event: IpcMainEvent, startPosData: protos.IStartPos) => {
// TODO: Get start pos from sagas
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@
"lint": "eslint '*/**/*.ts?(x)'",
"lintfix": "eslint '*/**/*.ts?(x)' --fix",
"postinstall": "patch-package",
"build-protos": "pbjs -t static-module -w es6 -o protos/protos.js protos/*.proto && pbts -o protos/protos.d.ts protos/protos.js ",
"build-protos": "pbjs -t static-module -w es6 -o protos-main/protos.js protos-main/protos/*.proto && pbts -o protos-main/protos.d.ts protos-main/protos.js ",
"watch": "webpack --mode development --watch --progress",
"test": "mocha --require babel-core/register --recursive renderer/**/test/*.test.js",
"release": "yarn build && ts-node release.ts",
"version": "echo $npm_package_version"
},
"betterScripts": {
"start": {
"command": "mkdirp ./build/protos && cp ./protos/*.proto ./build/protos && electron build/main.js",
"command": "mkdirp ./build/protos && cp ./protos-main/protos/*.proto ./build/protos && electron build/main.js",
"env": {
"NODE_ENV": "development"
}
},
"build": {
"command": "mkdirp ./build/protos && cp ./protos/*.proto ./build/protos && webpack --mode production --progress",
"command": "mkdirp ./build/protos && cp ./protos-main/protos/*.proto ./build/protos && webpack --mode production --progress",
"env": {
"NODE_ENV": "production"
}
Expand Down
1 change: 1 addition & 0 deletions protos-main/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './protos';
1 change: 1 addition & 0 deletions protos-main/protos
Submodule protos added at 9e52c0
233 changes: 225 additions & 8 deletions protos/protos.d.ts → protos-main/protos.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export interface IParam {

/** Param bval */
bval?: (boolean|null);

/** Param readonly */
readonly?: (boolean|null);
}

/** Represents a Param. */
Expand All @@ -36,6 +39,9 @@ export class Param implements IParam {
/** Param bval. */
public bval: boolean;

/** Param readonly. */
public readonly: boolean;

/** Param val. */
public val?: ("fval"|"ival"|"bval");

Expand Down Expand Up @@ -308,6 +314,110 @@ export class DevData implements IDevData {
public toJSON(): { [k: string]: any };
}

/** State enum. */
export enum State {
POISON_IVY = 0,
DEHYDRATION = 1,
HYPOTHERMIA_START = 2,
HYPOTHERMIA_END = 3
}

/** Properties of a GameState. */
export interface IGameState {

/** GameState state */
state?: (State|null);
}

/** Represents a GameState. */
export class GameState implements IGameState {

/**
* Constructs a new GameState.
* @param [properties] Properties to set
*/
constructor(properties?: IGameState);

/** GameState state. */
public state: State;

/**
* Creates a new GameState instance using the specified properties.
* @param [properties] Properties to set
* @returns GameState instance
*/
public static create(properties?: IGameState): GameState;

/**
* Encodes the specified GameState message. Does not implicitly {@link GameState.verify|verify} messages.
* @param message GameState message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encode(message: IGameState, writer?: $protobuf.Writer): $protobuf.Writer;

/**
* Encodes the specified GameState message, length delimited. Does not implicitly {@link GameState.verify|verify} messages.
* @param message GameState message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encodeDelimited(message: IGameState, writer?: $protobuf.Writer): $protobuf.Writer;

/**
* Decodes a GameState message from the specified reader or buffer.
* @param reader Reader or buffer to decode from
* @param [length] Message length if known beforehand
* @returns GameState
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): GameState;

/**
* Decodes a GameState message from the specified reader or buffer, length delimited.
* @param reader Reader or buffer to decode from
* @returns GameState
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): GameState;

/**
* Verifies a GameState message.
* @param message Plain object to verify
* @returns `null` if valid, otherwise the reason why it is not
*/
public static verify(message: { [k: string]: any }): (string|null);

/**
* Creates a GameState message from a plain object. Also converts values to their respective internal types.
* @param object Plain object
* @returns GameState
*/
public static fromObject(object: { [k: string]: any }): GameState;

/**
* Creates a plain object from a GameState message. Also converts values to other types if specified.
* @param message GameState
* @param [options] Conversion options
* @returns Plain object
*/
public static toObject(message: GameState, options?: $protobuf.IConversionOptions): { [k: string]: any };

/**
* Converts this GameState to JSON.
* @returns JSON object
*/
public toJSON(): { [k: string]: any };
}

/** Source enum. */
export enum Source {
GAMEPAD = 0,
KEYBOARD = 1
}

/** Properties of an Input. */
export interface IInput {

Expand Down Expand Up @@ -506,19 +616,12 @@ export class UserInputs implements IUserInputs {
public toJSON(): { [k: string]: any };
}

/** Source enum. */
export enum Source {
GAMEPAD = 0,
KEYBOARD = 1
}

/** Mode enum. */
export enum Mode {
IDLE = 0,
AUTO = 1,
TELEOP = 2,
ESTOP = 3,
CHALLENGE = 4
ESTOP = 3
}

/** Properties of a RunMode. */
Expand Down Expand Up @@ -611,6 +714,120 @@ export class RunMode implements IRunMode {
public toJSON(): { [k: string]: any };
}

/** Properties of a RuntimeStatus. */
export interface IRuntimeStatus {

/** RuntimeStatus shepConnected */
shepConnected?: (boolean|null);

/** RuntimeStatus dawnConnected */
dawnConnected?: (boolean|null);

/** RuntimeStatus mode */
mode?: (Mode|null);

/** RuntimeStatus battery */
battery?: (number|null);

/** RuntimeStatus version */
version?: (string|null);
}

/** Represents a RuntimeStatus. */
export class RuntimeStatus implements IRuntimeStatus {

/**
* Constructs a new RuntimeStatus.
* @param [properties] Properties to set
*/
constructor(properties?: IRuntimeStatus);

/** RuntimeStatus shepConnected. */
public shepConnected: boolean;

/** RuntimeStatus dawnConnected. */
public dawnConnected: boolean;

/** RuntimeStatus mode. */
public mode: Mode;

/** RuntimeStatus battery. */
public battery: number;

/** RuntimeStatus version. */
public version: string;

/**
* Creates a new RuntimeStatus instance using the specified properties.
* @param [properties] Properties to set
* @returns RuntimeStatus instance
*/
public static create(properties?: IRuntimeStatus): RuntimeStatus;

/**
* Encodes the specified RuntimeStatus message. Does not implicitly {@link RuntimeStatus.verify|verify} messages.
* @param message RuntimeStatus message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encode(message: IRuntimeStatus, writer?: $protobuf.Writer): $protobuf.Writer;

/**
* Encodes the specified RuntimeStatus message, length delimited. Does not implicitly {@link RuntimeStatus.verify|verify} messages.
* @param message RuntimeStatus message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encodeDelimited(message: IRuntimeStatus, writer?: $protobuf.Writer): $protobuf.Writer;

/**
* Decodes a RuntimeStatus message from the specified reader or buffer.
* @param reader Reader or buffer to decode from
* @param [length] Message length if known beforehand
* @returns RuntimeStatus
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): RuntimeStatus;

/**
* Decodes a RuntimeStatus message from the specified reader or buffer, length delimited.
* @param reader Reader or buffer to decode from
* @returns RuntimeStatus
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): RuntimeStatus;

/**
* Verifies a RuntimeStatus message.
* @param message Plain object to verify
* @returns `null` if valid, otherwise the reason why it is not
*/
public static verify(message: { [k: string]: any }): (string|null);

/**
* Creates a RuntimeStatus message from a plain object. Also converts values to their respective internal types.
* @param object Plain object
* @returns RuntimeStatus
*/
public static fromObject(object: { [k: string]: any }): RuntimeStatus;

/**
* Creates a plain object from a RuntimeStatus message. Also converts values to other types if specified.
* @param message RuntimeStatus
* @param [options] Conversion options
* @returns Plain object
*/
public static toObject(message: RuntimeStatus, options?: $protobuf.IConversionOptions): { [k: string]: any };

/**
* Converts this RuntimeStatus to JSON.
* @returns JSON object
*/
public toJSON(): { [k: string]: any };
}

/** Pos enum. */
export enum Pos {
LEFT = 0,
Expand Down
Loading

0 comments on commit fa051e4

Please sign in to comment.