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

New web UI, store highest channel number used #1739

Open
wants to merge 8 commits into
base: 0.10
Choose a base branch
from

Conversation

cmouttet
Copy link
Contributor

@cmouttet cmouttet commented Aug 1, 2021

With this fix the Fader UI and Keypad UI are able to send zeros to channels with the highest number.

Due to an optimisation the tailing zeros are cut off. With this stored highest channel number, we can fill up the DMX array with zeros until the maximum channel used.

@peternewman peternewman linked an issue Aug 4, 2021 that may be closed by this pull request
@peternewman peternewman added this to the 0.10.9 milestone Aug 4, 2021
Copy link
Member

@peternewman peternewman left a comment

Choose a reason for hiding this comment

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

Great, thanks very much for this @cmouttet .

Given https://groups.google.com/g/open-lighting/c/IvFInOVAbTE do you want to maybe add a README.developer in olad/www maybe, signposting people to the other folders?

olad/www/new/css/style.min.css Outdated Show resolved Hide resolved
javascript/new-src/src/factories/ola.js Outdated Show resolved Hide resolved
@@ -118,6 +134,7 @@ ola.factory('$ola', ['$http', '$window', 'OLA',
}
})
.then(function(response) {
updatehighestChannelNumberUsed(response.data.dmx);
Copy link
Member

Choose a reason for hiding this comment

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

I forget the exact workflow here, but all updates to the faders come via this function do they? So both local and remote stuff is covered? Ideally this would just be called to deal with the local fader/keypad stuff to let OLAD deal with LTP merges.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I saw that the faders' data is updated by polling get_dmx. Remote updates are handled by the backend code. I think get_dmx will return the correctly updated/merged content.

Copy link
Member

Choose a reason for hiding this comment

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

Ah yeah you should be fine then, I just wasn't sure if there were a few different paths on the JS side of things. The backend will indeed deal with merging a remote update.

Although that might mean that bringing up a high numbered channel in e.g. the ola_dmxconsole will ripple into the JS faders too, where it perhaps didn't before, but I can't think of an easy solution to that.

javascript/new-src/src/factories/ola.js Show resolved Hide resolved
javascript/new-src/src/factories/ola.js Outdated Show resolved Hide resolved
Copy link
Member

@peternewman peternewman left a comment

Choose a reason for hiding this comment

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

A few minor tweaks and suggestions.

Have you checked if it fixes this:

Keypad on the beta UI supports setting a concrete channel to a value. If you set the last non-zero channel to zero, the current value doesn't change.

Originally posted by @cmouttet in #1280 (comment)

Also does blackout work as intended?

README.developer Outdated Show resolved Hide resolved
README.developer Outdated Show resolved Hide resolved
AUTHORS Outdated Show resolved Hide resolved
javascript/new-src/src/factories/ola.js Outdated Show resolved Hide resolved
channel--) {

if ((dmx[channel - 1] > OLA.MIN_CHANNEL_VALUE) &&
(highestChannelNumberUsed < channel)) {
Copy link
Member

Choose a reason for hiding this comment

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

If it did say (which as below I don't think it needs to, swapping the two variables around so it matches the for loop would be less confusing).

Copy link
Contributor Author

@cmouttet cmouttet Aug 11, 2021

Choose a reason for hiding this comment

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

When using max only the > OLA.MIN_CHANNEL_VALUE part is needed. I removed the part highestChannelNumberUsed < channel.

var highestChannelNumberUsed = 0;

var updateHighestChannelNumberUsed = function(dmx) {
for (var channel = dmx.length; channel > highestChannelNumberUsed;
Copy link
Member

Choose a reason for hiding this comment

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

A comment might be nice here, just so we don't automatically assume it's iterating from dmx.length to zero as I did. Something like "we only care about checking channels higher than our existing highest" or similar maybe.

@@ -24,6 +24,7 @@ ola.controller('universeCtrl',
'use strict';
$scope.dmx = [];
$scope.Universe = $routeParams.id;
$ola.resetHighestChannelNumberUsed();
Copy link
Member

Choose a reason for hiding this comment

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

We're better off calling a function here than just initialising a scope variable then are we (like the DMX array)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not very familiar with JavaScript. My home is Java on the backend. :)
I tried to to work with something like this $scope.highestChannelNumberUsed = 0 but I failed.

Copy link
Member

Choose a reason for hiding this comment

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

So it seems like $scope should work if you change it everywhere, but only within one controller, or there's $rootScope, or our $ola might be able to take a variable.

Otherwise @daveol or @FloEdelmann might be able to help, all this whizzy JavaScript library stuff isn't really my area of expertise either unfortunately.

javascript/new-src/src/factories/ola.js Show resolved Hide resolved
Comment on lines 79 to 81
if (highestChannelNumberUsed < channel) {
highestChannelNumberUsed = channel;
}
Copy link
Member

Choose a reason for hiding this comment

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

Again would $window.Math.max be easier?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it works. Thanks.

@peternewman peternewman changed the title store highest channel number used New web UI, store highest channel number used Aug 6, 2021
Co-authored-by: Peter Newman <peternewman@users.noreply.github.com>
Copy link
Member

@peternewman peternewman left a comment

Choose a reason for hiding this comment

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

Sorry for the very delayed review @cmouttet . A few more minor comments if you've got some time? It would definitely be good to get this bugfix into 0.10.9.

Comment on lines +203 to +204
The sources for the new UI is located in javascript/new-src. The built artifacts
is copied to olad/www/new/js/app.min.js.
Copy link
Member

Choose a reason for hiding this comment

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

Fix some grammar:

Suggested change
The sources for the new UI is located in javascript/new-src. The built artifacts
is copied to olad/www/new/js/app.min.js.
The sources for the new UI are located in javascript/new-src. The built artifacts
are copied to olad/www/new/js/app.min.js.

Comment on lines 29 to 31
Stefan Krüger, added APA102 support to the SPI Plugin
Tobi Schäfer, for the MacPort files
Stefan S, improved timing with monotonic clock
Copy link
Member

Choose a reason for hiding this comment

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

Sort the file:

Suggested change
Stefan Krüger, added APA102 support to the SPI Plugin
Tobi Schäfer, for the MacPort files
Stefan S, improved timing with monotonic clock
Stefan Krüger, added APA102 support to the SPI Plugin
Stefan S, improved timing with monotonic clock
Tobi Schäfer, for the MacPort files

@@ -29,3 +29,4 @@ Contributors:
Stefan Krüger, added APA102 support to the SPI Plugin
Tobi Schäfer, for the MacPort files
Stefan S, improved timing with monotonic clock
Christian Mouttet, various fixes
Copy link
Member

Choose a reason for hiding this comment

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

Can you sort your name entry too please (which avoids any issues with who did the most).

Feel free to change the top line to be "Contributors (in alphabetical order):" or similar.

var highestChannelNumberUsed = 0;

// Search for the highest channel in the array `dmx`
// that having a value greater than MIN_CHANNEL_VALUE
Copy link
Member

Choose a reason for hiding this comment

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

Grammar wise we want either:

Suggested change
// that having a value greater than MIN_CHANNEL_VALUE
// that has a value greater than MIN_CHANNEL_VALUE

Or:

Suggested change
// that having a value greater than MIN_CHANNEL_VALUE
// having a value greater than MIN_CHANNEL_VALUE

// holds the highest channel that was used by faders or the keypad
var highestChannelNumberUsed = 0;

// Search for the highest channel in the array `dmx`
Copy link
Member

Choose a reason for hiding this comment

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

Would this help clarify your last sentence?

Suggested change
// Search for the highest channel in the array `dmx`
// Search for the new highest channel in the array `dmx`

for (var channel = dmx.length; channel > highestChannelNumberUsed;
channel--) {

var value = parseInt(dmx[channel - 1], 10);
Copy link
Member

Choose a reason for hiding this comment

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

This should probably call channelValueCheck to sanity check the value the field was set to. But then updateHighestChannelNumberUsed is just dmxConvert without the return, so perhaps we should just have one function?

@@ -24,6 +24,7 @@ ola.controller('universeCtrl',
'use strict';
$scope.dmx = [];
$scope.Universe = $routeParams.id;
$ola.resetHighestChannelNumberUsed();
Copy link
Member

Choose a reason for hiding this comment

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

So it seems like $scope should work if you change it everywhere, but only within one controller, or there's $rootScope, or our $ola might be able to take a variable.

Otherwise @daveol or @FloEdelmann might be able to help, all this whizzy JavaScript library stuff isn't really my area of expertise either unfortunately.

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.

The beta UI fader window, set all channels to zero doesn't work
2 participants