Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions javascript/new-src/src/factories/ola.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@
ola.factory('$ola', ['$http', '$window', 'OLA',
function($http, $window, OLA) {
'use strict';
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.

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.

highestChannelNumberUsed = channel;
}
}
};

// TODO(Dave_o): once olad supports json post data postEncode
// can go away and the header in post requests too.
var postEncode = function(data) {
Expand Down Expand Up @@ -63,6 +76,9 @@ ola.factory('$ola', ['$http', '$window', 'OLA',
strip = false;
}
}
while (integers.length < highestChannelNumberUsed) {
integers.push(OLA.MIN_CHANNEL_VALUE);
}
return integers.join(',');
};
return {
Expand Down Expand Up @@ -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.

return response.data;
});
},
Expand Down
2 changes: 1 addition & 1 deletion olad/www/new/css/style.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading