Skip to content

Commit

Permalink
ran formatter and fixed lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
PepperLola committed Aug 26, 2024
1 parent 88c551b commit e6d3522
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 24 deletions.
2 changes: 1 addition & 1 deletion fission/src/systems/simulation/wpilib_brain/SimInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class SimDIO implements SimInput {
}

public SetValue(value: boolean) {
WSSimDIO.SetValue(this._device, value);
WSSimDIO.SetValue(this._device, value)
}

public GetValue(): boolean {
Expand Down
2 changes: 1 addition & 1 deletion fission/src/systems/simulation/wpilib_brain/SimOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@ export class SimAnalogOutput extends SimOutput {
return SimAO.GetVoltage(this.name)
}

public Update(_deltaT: number) { }
public Update(_deltaT: number) {}
}
35 changes: 17 additions & 18 deletions fission/src/systems/simulation/wpilib_brain/WPILibBrain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import WPILibWSWorker from "./WPILibWSWorker?worker"
import { SimulationLayer } from "../SimulationSystem"
import World from "@/systems/World"

import { SimAnalogOutput, SimOutput, SimOutputGroup } from "./SimOutput"
import { SimAccelInput, SimInput, SimDIO as SimDIOIn, SimAnalogInput } from "./SimInput"
import { SimOutput } from "./SimOutput"
import { SimInput } from "./SimInput"

const worker: Lazy<Worker> = new Lazy<Worker>(() => new WPILibWSWorker())

Expand Down Expand Up @@ -35,7 +35,7 @@ export enum SimType {
Accel = "Accel",
DIO = "DIO",
AI = "AI",
AO = "AO"
AO = "AO",
}

enum FieldType {
Expand Down Expand Up @@ -66,10 +66,10 @@ type DeviceData = Map<string, number>
export const simMap = new Map<SimType, Map<DeviceName, DeviceData>>()

export class SimGeneric {
private constructor() { }
private constructor() {}

public static Get<T>(simType: SimType, device: string, field: string): T | undefined;
public static Get<T>(simType: SimType, device: string, field: string, defaultValue: T): T;
public static Get<T>(simType: SimType, device: string, field: string): T | undefined
public static Get<T>(simType: SimType, device: string, field: string, defaultValue: T): T
public static Get<T>(simType: SimType, device: string, field: string, defaultValue?: T): T | undefined {
const fieldType = GetFieldType(field)
if (fieldType != FieldType.Read && fieldType != FieldType.Both) {
Expand Down Expand Up @@ -130,7 +130,7 @@ export class SimGeneric {
}

export class SimPWM {
private constructor() { }
private constructor() {}

public static GetSpeed(device: string): number | undefined {
return SimGeneric.Get(SimType.PWM, device, PWM_SPEED, 0.0)
Expand All @@ -142,7 +142,7 @@ export class SimPWM {
}

export class SimCAN {
private constructor() { }
private constructor() {}

public static GetDeviceWithID(id: number, type: SimType): DeviceData | undefined {
const id_exp = /.*\[(\d+)\]/g
Expand All @@ -161,7 +161,7 @@ export class SimCAN {
}

export class SimCANMotor {
private constructor() { }
private constructor() {}

public static GetPercentOutput(device: string): number | undefined {
return SimGeneric.Get(SimType.CANMotor, device, CANMOTOR_PERCENT_OUTPUT, 0.0)
Expand All @@ -188,7 +188,7 @@ export class SimCANMotor {
}
}
export class SimCANEncoder {
private constructor() { }
private constructor() {}

public static SetVelocity(device: string, velocity: number): boolean {
return SimGeneric.Set(SimType.CANEncoder, device, CANENCODER_VELOCITY, velocity)
Expand All @@ -200,7 +200,7 @@ export class SimCANEncoder {
}

export class SimGyro {
private constructor() { }
private constructor() {}

public static SetAngleX(device: string, angle: number): boolean {
return SimGeneric.Set(SimType.Gyro, device, ">angle_x", angle)
Expand Down Expand Up @@ -228,7 +228,7 @@ export class SimGyro {
}

export class SimAccel {
private constructor() { }
private constructor() {}

public static SetX(device: string, accel: number): boolean {
return SimGeneric.Set(SimType.Accel, device, ">x", accel)
Expand All @@ -244,10 +244,10 @@ export class SimAccel {
}

export class SimDIO {
private constructor() { }
private constructor() {}

public static SetValue(device: string, value: boolean): boolean {
return SimGeneric.Set(SimType.DIO, device, "<>value", +value);
return SimGeneric.Set(SimType.DIO, device, "<>value", +value)
}

public static GetValue(device: string): boolean {
Expand All @@ -256,7 +256,7 @@ export class SimDIO {
}

export class SimAI {
constructor() { }
constructor() {}

public static SetValue(device: string, value: number): boolean {
return SimGeneric.Set(SimType.AI, device, ">voltage", value)
Expand Down Expand Up @@ -313,7 +313,7 @@ export class SimAI {
}

export class SimAO {
constructor() { }
constructor() {}

public static GetVoltage(device: string): number {
return SimGeneric.Get(SimType.AI, device, ">voltage", 0.0)
Expand All @@ -340,8 +340,7 @@ worker.getValue().addEventListener("message", (eventData: MessageEvent) => {
}
}

if (!data?.type || !(Object.values(SimType) as string[]).includes(data.type))// || data.device.split(" ")[0] != "SYN")
return
if (!data?.type || !(Object.values(SimType) as string[]).includes(data.type)) return

UpdateSimMap(data.type as SimType, data.device, data.data)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const RCConfigCANGroupModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
{drivers.map((driver, idx) => (
<Checkbox
key={`${driver.constructor.name}-${idx}`}
label={`${driver.constructor.name} ${driver.info?.name && '(' + driver.info!.name + ')'}`}
label={`${driver.constructor.name} ${driver.info?.name && "(" + driver.info!.name + ")"}`}
defaultState={false}
onClick={checked => {
if (checked && !checkedDrivers.includes(driver)) {
Expand Down
14 changes: 12 additions & 2 deletions fission/src/ui/panels/WSViewPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,23 @@ function formatMap(map: Map<string, number>): string {
}

function generateTableBody() {
const names: SimType[] = [SimType.PWM, SimType.SimDevice, SimType.CANMotor, SimType.CANEncoder, SimType.Gyro, SimType.Accel, SimType.DIO, SimType.AI, SimType.AO]
const names: SimType[] = [
SimType.PWM,
SimType.SimDevice,
SimType.CANMotor,
SimType.CANEncoder,
SimType.Gyro,
SimType.Accel,
SimType.DIO,
SimType.AI,
SimType.AO,
]

console.log(simMap)

return (
<TableBody>
{names.map(name =>
{names.map(name =>
simMap.has(name) ? (
[...simMap.get(name)!.entries()]
// most devices don't have <init field but we want to hide the ones that do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const ConfigureSubsystemsInterface: React.FC<ConfigSubsystemProps> = ({ selected
(selectedRobot.brain as SynthesisBrain).behaviors
.filter(b => b instanceof SequenceableBehavior)
.map(b => DefaultSequentialConfig(b.jointIndex, b instanceof GenericArmBehavior ? "Arm" : "Elevator")),
[]
[selectedRobot.assemblyName, selectedRobot.brain]
)

const drivers = useMemo(() => {
Expand Down

0 comments on commit e6d3522

Please sign in to comment.