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

IO COMMANDs feedback state in the GUI #284

Merged
merged 5 commits into from Dec 11, 2018
Merged

IO COMMANDs feedback state in the GUI #284

merged 5 commits into from Dec 11, 2018

Conversation

ghost
Copy link

@ghost ghost commented Dec 3, 2018

I made a few changes so the gui can give better feedback about the state of the commands it has sent to the connected phidgets output devices. In this code, toggle() now updates the button style to indicate the state of the digital output, and a new command button() updates the style of a given button (not necessarily the one that was pressed) to indicate the state of a digital output, and slider() updates a slider position.

I also added input devices slider_01 and slider_23 to get the slider positions for plotting and csv output. In my case the sliders are controlling analog voltages, which control the motors and the modulating gas valve and wanted a graphical record of slider positions saved to the graph and csv output.

Since I am doing a lot of control with the sliders, I found it helpful to make them bigger. To make it easier for any user to configure the slider stylesheet, I moved this into its own file that gets included.

Mike Furlotti added 3 commits December 2, 2018 21:41
…ed and exported to csv, add signal to catch ctrl-c from command line, and move the slider stylesheet to an imported file to make using an alternate style easier
1) Add analog output out(c,v), duplicating the function from VOUT
COMMAND. Now the command list of IO COMMAND can contain both analog and
digital output commands.

2) Update the command parsing to use regular expressions. This makes it
easier to validate the user input and improve error handling.

3) Update the toggle(c) command so it causes the style of the button
that was clicked to toggle.

4) Add a new command button(b,c,v). This sets the button number (b) to
style (v) and also the output of channel (c) to (v).

5) Add a new command slider(c,v). This updates the position of slider
(c) to value (v)
Ubuntu is shipping with numpy 1.14.5, so this change is for backwards compatibility.
@MAKOMO MAKOMO self-requested a review December 10, 2018 16:45
@MAKOMO
Copy link
Member

MAKOMO commented Dec 10, 2018

Sorry for my late answering this one. I have the feeling that your changes are addressing rather specific use-cases. Could you share more details on those?

Still the changes might be of use for others. Thanks for sharing your work and preparing this pull request together with the useful explanations.

I have some general questions. The code looks good.

  1. Why do we need a device for sliders?

Sliders in Artisan are foremost a convenient way to add custom event values. Note that custom events and temperature curve data is kind of separated, but connected via the quantifier mechanism to turn incoming sampled data into events.

  1. add signal to catch ctrl-c from command line

What are the consequences of this exactly per supported platform, especially if running from builds?

  1. move the slider stylesheet to an imported file to make using an alternate style easier

Excellent! Will you share your stylesheets?

  1. Add analog output out(c,v), duplicating the function from VOUT COMMAND. Now the command list of IO COMMAND can contain both analog and
    digital output commands.
  • Why do we need out(c,v) emitting vout under "IO Command" while we have "VOUT Command"?
  • What is the exact reason for this duplication?
  1. Update the command parsing to use regular expressions. This makes it
    easier to validate the user input and improve error handling.

Excellent contribution!

  1. Update the toggle(c) command so it causes the style of the button
    that was clicked to toggle.

The button style is changed here before sending the command to the Phidget and in 7) after. The button style change also happens on failure to change the Phidget state. Should we potentially not change the button style if the state in the Phidget was not changed successfully? Same for 7).

  1. Add a new command button(b,c,v). This sets the button number (b) to
    style (v) and also the output of channel (c) to (v).

What is the use-case to change the stye of a different button?

  1. Add a new command slider(c,v). This updates the position of slider
    (c) to value (v)

Hm. So a button that updates the slider position!? What for exactly?

*) One final remark

Would you support me in documentation those additions in the form of a short blog post?

@ghost
Copy link
Author

ghost commented Dec 11, 2018

Yes, this code is specific to anyone driving their roaster with phidgets outputs. I'm hopeful more people mod their roaster and can use these changes. Initially I started a separate module for my roaster but figured I'd see how far I could get by extending the existing commands. Other drivers might also benefit, such as the Hottop driver. It returns its gpio states when it sends its 36 bytes every second, so that could update the style of user event buttons. The biggest issue for users will probably be mapping the button ids and gpio channel numbers.

1) Why do we need a device for sliders?

Well this is kind of a workaround, this is an easy way to get the analog voltage ouptut into the CSV file that can be exported. I also wanted to be able to scale the analog voltage for plotting because when roasting in F, including the 0-100 F range on the y axis uses up a lot of space. Since the slider position is the value that is sent to the analog output, it is a fast way to read the analog voltage setpoint. A new device could instead read the setpoint back from the analog out device, but this would add latency. This might be better implemented as features in the events system.

2) ctrl-c

This gives the python interpreter a way to kill the qt loop if the user sends a SIGINT signal, most likely by pressing ctrl-c in the terminal. Currently if the user presses ctrl-c in the terminal on Linux or Mac OS X, after there is another qt event such as a mouse movement, an exception message pops over the artisan gui warning the user that an unhandled exception has occurred, and the application continues running. This signal handler just kills the qt loop immediately.

It looks like Windows uses CTRL_C_EVENT instead of SIGINT so this won't work on windows as it is written. I don't know if windows users will expect to use ctrl-c in any event, but the code can be updated to work on windows.

3) slider stylesheet

Yea, I'll check it into my fork. I overwrite the default stylesheet after I check out the repo to use the new stylesheet but this is not user friendly. There's probably a better way to handle this.

4) Analog output out(c,v) duplication

I want to set both analog and digital outputs in one list of commands. For instance, my DROP button command list contains a number of commands -- including setting the blower speed (analog out) and turning on the cooling tray stirring motor (digital out). Having the command list passed to either the VOUT or IO command parser prevents this behaviour. I agree having a duplicate analog output command is not good, but I'd probably phase out the VOUT command type.

6) only change the button style if the state in the Phidget is changed successfully

Yes, this is a good idea, I'll take a look.

7) What is the use-case to change the style of a different button

In my config I have a user defined button for each thing that is switched with a relay, like the cooling tray motor, and the burner solenoid. I am also using the built in event buttons to control the state of the roaster. The DROP button turns on the cooling tray motor and with the button() command it can also update the style of the cooling tray user defined button.

8) Updates the slider position

My DROP command adjusts analog voltages, it sets the gas to off and turns the blower motor speed up. So I include the slider() command in the list of commands that DROP calls.

9) blog post?

Absolutely.

Mike Furlotti added 2 commits December 10, 2018 23:43
@MAKOMO MAKOMO merged commit 8e200a2 into artisan-roaster-scope:master Dec 11, 2018
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.

1 participant