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
base: 0.10
Are you sure you want to change the base?
Conversation
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.
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?
@@ -118,6 +134,7 @@ ola.factory('$ola', ['$http', '$window', 'OLA', | |||
} | |||
}) | |||
.then(function(response) { | |||
updatehighestChannelNumberUsed(response.data.dmx); |
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.
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.
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.
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.
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.
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.
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.
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?
channel--) { | ||
|
||
if ((dmx[channel - 1] > OLA.MIN_CHANNEL_VALUE) && | ||
(highestChannelNumberUsed < channel)) { |
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.
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).
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.
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; |
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.
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(); |
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.
We're better off calling a function here than just initialising a scope variable then are we (like the DMX array)?
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.
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.
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.
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.
if (highestChannelNumberUsed < channel) { | ||
highestChannelNumberUsed = channel; | ||
} |
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.
Again would $window.Math.max be easier?
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.
Yes, it works. Thanks.
Co-authored-by: Peter Newman <peternewman@users.noreply.github.com>
74061f5
to
4eacc64
Compare
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.
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.
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. |
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.
Fix some grammar:
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. |
Stefan Krüger, added APA102 support to the SPI Plugin | ||
Tobi Schäfer, for the MacPort files | ||
Stefan S, improved timing with monotonic clock |
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.
Sort the file:
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 |
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.
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 |
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.
Grammar wise we want either:
// that having a value greater than MIN_CHANNEL_VALUE | |
// that has a value greater than MIN_CHANNEL_VALUE |
Or:
// 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` |
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.
Would this help clarify your last sentence?
// 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); |
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.
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(); |
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.
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.
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.