-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/devices: parsing sensor #65
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
388a291
Color and distance device parsing
633a2e9
fix oops in consts
ae51b7f
Merge branch 'feature/devices' of github.com:nathankellenicki/node-po…
67f0836
Int32 and floats are 4 bits long
d3eb19b
Merge branch 'feature/devices' of github.com:nathankellenicki/node-po…
9d05d64
Color and distance configuration
345b34c
Apply autoparse to current sensor
3f105a7
Atempt to handle writing modes
a76a82e
reduce codebase
f694cdc
Merge branch 'feature/devices' of github.com:nathankellenicki/node-po…
3da255b
Merge remote-tracking branch 'upstream/feature/devices' into feature/…
64425a9
Very WIP attempt to improve imports and consts
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { Device } from "./devices/generic/device"; | ||
export { Device }; | ||
|
||
import { ColorDistanceSensor } from "./devices/colordistancesensor"; | ||
import { CurrentSensor } from "./devices/currentsensor"; | ||
import { DuploTrainBaseColorSensor } from "./devices/duplotrainbasecolorsensor"; | ||
import { DuploTrainBaseMotor } from "./devices/duplotrainbasemotor"; | ||
import { DuploTrainBaseSpeaker } from "./devices/duplotrainbasespeaker"; | ||
import { DuploTrainBaseSpeedometer } from "./devices/duplotrainbasespeedometer"; | ||
import { HubLED } from "./devices/hubled"; | ||
import { Light } from "./devices/light"; | ||
import { MediumLinearMotor } from "./devices/mediumlinearmotor"; | ||
import { MotionSensor } from "./devices/motionsensor"; | ||
import { MoveHubMediumLinearMotor } from "./devices/movehubmediumlinearmotor"; | ||
import { MoveHubTiltSensor } from "./devices/movehubtiltsensor"; | ||
import { PiezoBuzzer } from "./devices/piezobuzzer"; | ||
import { RemoteControlButton } from "./devices/remotecontrolbutton"; | ||
import { SimpleMediumLinearMotor } from "./devices/simplemediumlinearmotor"; | ||
import { TechnicLargeLinearMotor } from "./devices/techniclargelinearmotor"; | ||
import { TechnicMediumHubAccelerometerSensor } from "./devices/technicmediumhubaccelerometersensor"; | ||
import { TechnicMediumHubGyroSensor } from "./devices/technicmediumhubgyrosensor"; | ||
import { TechnicMediumHubTiltSensor } from "./devices/technicmediumhubtiltsensor"; | ||
import { TechnicXLargeLinearMotor } from "./devices/technicxlargelinearmotor"; | ||
import { TiltSensor } from "./devices/tiltsensor"; | ||
import { TrainMotor } from "./devices/trainmotor"; | ||
import { VoltageSensor } from "./devices/voltagesensor"; | ||
|
||
export { | ||
ColorDistanceSensor, | ||
CurrentSensor, | ||
DuploTrainBaseColorSensor, | ||
DuploTrainBaseMotor, | ||
DuploTrainBaseSpeaker, | ||
DuploTrainBaseSpeedometer, | ||
HubLED, | ||
Light, | ||
MediumLinearMotor, | ||
MotionSensor, | ||
MoveHubMediumLinearMotor, | ||
MoveHubTiltSensor, | ||
PiezoBuzzer, | ||
RemoteControlButton, | ||
SimpleMediumLinearMotor, | ||
TechnicLargeLinearMotor, | ||
TechnicMediumHubAccelerometerSensor, | ||
TechnicMediumHubGyroSensor, | ||
TechnicMediumHubTiltSensor, | ||
TechnicXLargeLinearMotor, | ||
TiltSensor, | ||
TrainMotor, | ||
VoltageSensor, | ||
}; | ||
|
||
export const devices: {[type: number]: typeof Device} = { | ||
[SimpleMediumLinearMotor.type]: SimpleMediumLinearMotor, | ||
[TrainMotor.type]: TrainMotor, | ||
[Light.type]: Light, | ||
[VoltageSensor.type]: VoltageSensor, | ||
[CurrentSensor.type]: CurrentSensor, | ||
[PiezoBuzzer.type]: PiezoBuzzer, | ||
[HubLED.type]: HubLED, | ||
[TiltSensor.type]: TiltSensor, | ||
[MotionSensor.type]: MotionSensor, | ||
[ColorDistanceSensor.type]: ColorDistanceSensor, | ||
[MediumLinearMotor.type]: MediumLinearMotor, | ||
[MoveHubMediumLinearMotor.type]: MoveHubMediumLinearMotor, | ||
[MoveHubTiltSensor.type]: MoveHubTiltSensor, | ||
[DuploTrainBaseMotor.type]: DuploTrainBaseMotor, | ||
[DuploTrainBaseSpeaker.type]: DuploTrainBaseSpeaker, | ||
[DuploTrainBaseColorSensor.type]: DuploTrainBaseColorSensor, | ||
[DuploTrainBaseSpeedometer.type]: DuploTrainBaseSpeedometer, | ||
[TechnicLargeLinearMotor.type]: TechnicLargeLinearMotor, | ||
[TechnicXLargeLinearMotor.type]: TechnicXLargeLinearMotor, | ||
[RemoteControlButton.type]: RemoteControlButton, | ||
[TechnicMediumHubAccelerometerSensor.type]: TechnicMediumHubAccelerometerSensor, | ||
[TechnicMediumHubGyroSensor.type]: TechnicMediumHubGyroSensor, | ||
[TechnicMediumHubTiltSensor.type]: TechnicMediumHubTiltSensor, | ||
}; | ||
|
||
export const deviceType: {[typeName: string]: number} = { | ||
UNKNOW: 0, | ||
}; | ||
export const deviceTypeNames: {[typeName: number]: string } = { | ||
0: "UNKNOW", | ||
}; | ||
|
||
for (const type in devices) { | ||
if (devices[+type]) { | ||
const device = devices[+type]; | ||
deviceType[device.typeName] = device.type; | ||
deviceTypeNames[device.type] = device.typeName; | ||
} | ||
} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they are no longer enum and I think it is not very good.