Skip to content
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

CC #416

Draft
wants to merge 3 commits into
base: webpack-build
Choose a base branch
from
Draft

CC #416

wants to merge 3 commits into from

Conversation

rkrishnasanka
Copy link
Collaborator

Created the initial version of class that are used to model the hardware devices connected to the computer. This PR creates the base classes and the potential API class we need to create to manage this. This PR still requires the integration of websockets communication a manager that can query peripheral manager effectively.

…ripherals.

Added full peripheral manager communications API (untested beyond checking to see if connection can be established or not)
@rkrishnasanka
Copy link
Collaborator Author

@zyrrron can you please do a review of this PR, I'd like feedback on naming convention, documentation, etc.

console.log("Connecting to server...");
this.socket = io("http://localhost:3000");

this.socket.on("connect", () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does the "()" work for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This how you define lambda expressions in typescript. It allows you to do inline functions that have access to the local scope.

* @param valveid id
* @param avalve object
*/
attachAnalogValve(valveid: string, avalve: AnalogValve) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the difference between analogvalve and digitalvalve

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it depends on where you use syringe pumps or pressure control manifold to control the valves.

Analog Valve - Syringe pump - you need to specify OPEN and CLOSE values as integers.

Digital Valve - pressure manifold (what Sam is using) Boolean values.

* @param {Array<number>} args
* @memberof Setup
*/
sendCommand(deviceName: string, commandID: number, args: Array<number>) {
Copy link
Collaborator

@zyrrron zyrrron Oct 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this function send commands to hardware? and what is the difference with sendRaw

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on what firmware is on the microcontroller, sendCommand might not work. sendCommand uses an efficient binary format. Whereas sendRaw will send whatever data the user wants to send. You will need to use sendRaw to make it work with Sam's existing arduino code.

* @returns {Promise<string[]>}
* @memberof Setup
*/
async listDevices(): Promise<string[]> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the return value is a list of microfluidic devices?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns a list of devices (arduino's, microcontrollers, etc.) connect to the computer by USB.

console.log(id);
this.id = id;
this._deviceindex = deviceIndex;
this._hwshield = hwShield;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's hwShield?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an parameter necessary for the Neptune legacy hardware to function, we can modify it to be some sort of physical location address in the future

this.id = id;
this._deviceindex = deviceIndex;
this._hwshield = hwShield;
this._precision = precision;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

precision?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, this was necessary when generating the corresponding commands for the legacy neptune hardware. We should refactor this


/**
* Returns the number valves on the device
* @returns {number}
Copy link
Collaborator

@zyrrron zyrrron Oct 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we get the number of valves if we return this._valves? this._valves is an array of components. if we want to get the number of valves, we should return this._valves.length?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch will look at fixing this
TODO -

  • Fix return type for the valves function

}

/**
* Returns some kind of an object
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to return [{}, {}, {}] here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no clue, this is a bug

@@ -0,0 +1,18 @@
const THETA_MAX = Math.PI / 2;
const THETA_MIN = -THETA_MAX;
export const PWM_MAX = 255;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this file work for? What is PWM?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PWM is pulse width modulation, its you convert an analog signal into a digital signal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants