better render queue multi
This commit is contained in:
@@ -3,6 +3,9 @@ const RenderQueue = {
|
||||
nb_total_render_ms: 0,
|
||||
nb_completed_renders: 0,
|
||||
nb_last_current: 0,
|
||||
list_machine_avgs: [],
|
||||
nb_local_avg_ms: 0,
|
||||
str_hostname: "",
|
||||
|
||||
init: () => {
|
||||
// Initialized on demand
|
||||
@@ -13,6 +16,9 @@ const RenderQueue = {
|
||||
RenderQueue.nb_total_render_ms = 0;
|
||||
RenderQueue.nb_completed_renders = 0;
|
||||
RenderQueue.nb_last_current = 0;
|
||||
RenderQueue.list_machine_avgs = [];
|
||||
RenderQueue.nb_local_avg_ms = 0;
|
||||
RenderQueue.str_hostname = "";
|
||||
|
||||
let list_enabled = [];
|
||||
for (let obj_cam of list_cameras) {
|
||||
@@ -32,6 +38,7 @@ const RenderQueue = {
|
||||
str_image_path: null,
|
||||
obj_dom_el: null,
|
||||
obj_dom_icon: null,
|
||||
obj_dom_result: null,
|
||||
str_dom_status: null,
|
||||
is_click_bound: false,
|
||||
});
|
||||
@@ -60,6 +67,7 @@ const RenderQueue = {
|
||||
str_image_path: null,
|
||||
obj_dom_el: null,
|
||||
obj_dom_icon: null,
|
||||
obj_dom_result: null,
|
||||
str_dom_status: null,
|
||||
is_click_bound: false,
|
||||
});
|
||||
@@ -101,12 +109,20 @@ const RenderQueue = {
|
||||
obj_frame.classList.add("text-light-emphasis");
|
||||
obj_frame.textContent = "F" + obj_item.nb_frame;
|
||||
|
||||
let obj_result = document.createElement("small");
|
||||
obj_result.classList.add("text-light-emphasis", "queue-item-result");
|
||||
obj_result.style.minWidth = "140px";
|
||||
obj_result.style.textAlign = "right";
|
||||
obj_result.style.fontSize = "0.75em";
|
||||
|
||||
obj_el.appendChild(obj_icon);
|
||||
obj_el.appendChild(obj_name);
|
||||
obj_el.appendChild(obj_frame);
|
||||
obj_el.appendChild(obj_result);
|
||||
|
||||
obj_item.obj_dom_el = obj_el;
|
||||
obj_item.obj_dom_icon = obj_icon;
|
||||
obj_item.obj_dom_result = obj_result;
|
||||
obj_item.str_dom_status = "pending";
|
||||
|
||||
obj_fragment.appendChild(obj_el);
|
||||
@@ -115,7 +131,21 @@ const RenderQueue = {
|
||||
obj_container.appendChild(obj_fragment);
|
||||
},
|
||||
|
||||
update_progress: (nb_current, nb_last_render_ms, str_last_image_path, list_skipped, list_stopped, list_skipped_paths) => {
|
||||
update_progress: (obj_data) => {
|
||||
let nb_current = obj_data.nb_current || 0;
|
||||
let nb_last_render_ms = obj_data.nb_last_render_ms || 0;
|
||||
let str_last_image_path = obj_data.str_last_image_path || null;
|
||||
let list_skipped = obj_data.list_skipped || [];
|
||||
let list_stopped = obj_data.list_stopped || [];
|
||||
let list_skipped_paths = obj_data.list_skipped_paths || [];
|
||||
let list_rendering_remote = obj_data.list_rendering_remote || [];
|
||||
let list_item_results = obj_data.list_item_results || [];
|
||||
let list_machine_avgs = obj_data.list_machine_avgs || [];
|
||||
|
||||
RenderQueue.str_hostname = obj_data.str_hostname || "";
|
||||
RenderQueue.nb_local_avg_ms = obj_data.nb_avg_render_ms || 0;
|
||||
RenderQueue.list_machine_avgs = list_machine_avgs;
|
||||
|
||||
if (nb_current > RenderQueue.nb_last_current && nb_last_render_ms > 0) {
|
||||
RenderQueue.nb_total_render_ms += nb_last_render_ms;
|
||||
RenderQueue.nb_completed_renders++;
|
||||
@@ -134,9 +164,17 @@ const RenderQueue = {
|
||||
}
|
||||
}
|
||||
|
||||
// Build result map for quick lookup
|
||||
let map_results = {};
|
||||
for (let obj_r of list_item_results) {
|
||||
map_results[obj_r.nb_index] = obj_r;
|
||||
}
|
||||
|
||||
for (let nb_i = 0; nb_i < RenderQueue.list_items.length; nb_i++) {
|
||||
if (list_stopped && list_stopped.indexOf(nb_i) !== -1) {
|
||||
RenderQueue.list_items[nb_i].str_status = "stopped";
|
||||
} else if (list_rendering_remote && list_rendering_remote.indexOf(nb_i) !== -1) {
|
||||
RenderQueue.list_items[nb_i].str_status = "rendering_remote";
|
||||
} else if (list_skipped && list_skipped.indexOf(nb_i) !== -1) {
|
||||
RenderQueue.list_items[nb_i].str_status = "skipped";
|
||||
} else if (nb_i < nb_current) {
|
||||
@@ -146,6 +184,11 @@ const RenderQueue = {
|
||||
} else {
|
||||
RenderQueue.list_items[nb_i].str_status = "pending";
|
||||
}
|
||||
|
||||
// Store result info on item
|
||||
if (map_results[nb_i]) {
|
||||
RenderQueue.list_items[nb_i].obj_result = map_results[nb_i];
|
||||
}
|
||||
}
|
||||
|
||||
RenderQueue._update_time_display();
|
||||
@@ -163,7 +206,9 @@ const RenderQueue = {
|
||||
let is_needs_click = (obj_item.str_status === "done" || obj_item.str_status === "skipped")
|
||||
&& obj_item.str_image_path && !obj_item.is_click_bound;
|
||||
|
||||
if (obj_item.str_status === obj_item.str_dom_status && !is_needs_click) {
|
||||
let is_status_changed = obj_item.str_status !== obj_item.str_dom_status;
|
||||
|
||||
if (!is_status_changed && !is_needs_click) {
|
||||
if (obj_item.str_status === "rendering") {
|
||||
obj_rendering_el = obj_item.obj_dom_el;
|
||||
}
|
||||
@@ -189,10 +234,18 @@ const RenderQueue = {
|
||||
} else if (obj_item.str_status === "stopped") {
|
||||
str_icon = "mdi-stop-circle";
|
||||
str_color = "text-warning";
|
||||
} else if (obj_item.str_status === "rendering_remote") {
|
||||
str_icon = "mdi-desktop-classic";
|
||||
str_color = "text-warning";
|
||||
}
|
||||
|
||||
obj_item.obj_dom_icon.className = "mdi " + str_icon + " " + str_color;
|
||||
|
||||
// Update result column
|
||||
if (obj_item.obj_dom_result) {
|
||||
RenderQueue._update_result_cell(obj_item);
|
||||
}
|
||||
|
||||
if (is_needs_click) {
|
||||
obj_item.obj_dom_el.classList.add("queue-item-clickable");
|
||||
let str_path = obj_item.str_image_path;
|
||||
@@ -210,6 +263,45 @@ const RenderQueue = {
|
||||
}
|
||||
},
|
||||
|
||||
_update_result_cell: (obj_item) => {
|
||||
let obj_r = obj_item.obj_result;
|
||||
if (!obj_r) {
|
||||
obj_item.obj_dom_result.textContent = "";
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj_r.str_type === "done") {
|
||||
let str_date = "";
|
||||
if (obj_r.str_date) {
|
||||
let obj_d = new Date(obj_r.str_date);
|
||||
let str_day = String(obj_d.getDate()).padStart(2, "0");
|
||||
let str_month = String(obj_d.getMonth() + 1).padStart(2, "0");
|
||||
let str_hours = String(obj_d.getHours()).padStart(2, "0");
|
||||
let str_minutes = String(obj_d.getMinutes()).padStart(2, "0");
|
||||
str_date = str_day + "/" + str_month + " " + str_hours + ":" + str_minutes;
|
||||
}
|
||||
let str_res = obj_r.str_resolution || "";
|
||||
obj_item.obj_dom_result.textContent = str_date + (str_date && str_res ? " | " : "") + str_res;
|
||||
obj_item.obj_dom_result.className = "text-success queue-item-result";
|
||||
obj_item.obj_dom_result.style.minWidth = "140px";
|
||||
obj_item.obj_dom_result.style.textAlign = "right";
|
||||
obj_item.obj_dom_result.style.fontSize = "0.75em";
|
||||
} else if (obj_r.str_type === "rendering_remote") {
|
||||
let str_host = obj_r.str_remote_hostname || "?";
|
||||
let str_avg = "";
|
||||
if (obj_r.nb_remote_avg_ms > 0) {
|
||||
str_avg = " ~" + RenderQueue._format_duration(obj_r.nb_remote_avg_ms) + "/i";
|
||||
}
|
||||
obj_item.obj_dom_result.textContent = str_host + str_avg;
|
||||
obj_item.obj_dom_result.className = "text-warning queue-item-result";
|
||||
obj_item.obj_dom_result.style.minWidth = "140px";
|
||||
obj_item.obj_dom_result.style.textAlign = "right";
|
||||
obj_item.obj_dom_result.style.fontSize = "0.75em";
|
||||
} else {
|
||||
obj_item.obj_dom_result.textContent = "";
|
||||
}
|
||||
},
|
||||
|
||||
mark_existing: (list_existing) => {
|
||||
for (let obj_existing of list_existing) {
|
||||
if (obj_existing.nb_index < RenderQueue.list_items.length) {
|
||||
@@ -226,22 +318,55 @@ const RenderQueue = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (RenderQueue.nb_completed_renders === 0) {
|
||||
let nb_local_avg = RenderQueue.nb_local_avg_ms;
|
||||
if (nb_local_avg === 0 && RenderQueue.nb_completed_renders > 0) {
|
||||
nb_local_avg = Math.round(RenderQueue.nb_total_render_ms / RenderQueue.nb_completed_renders);
|
||||
}
|
||||
|
||||
if (nb_local_avg === 0) {
|
||||
obj_label.innerHTML = "";
|
||||
return;
|
||||
}
|
||||
|
||||
let nb_avg_ms = RenderQueue.nb_total_render_ms / RenderQueue.nb_completed_renders;
|
||||
let nb_remaining_count = 0;
|
||||
for (let obj_item of RenderQueue.list_items) {
|
||||
if (obj_item.str_status !== "done" && obj_item.str_status !== "skipped") {
|
||||
if (obj_item.str_status !== "done" && obj_item.str_status !== "skipped" && obj_item.str_status !== "rendering_remote") {
|
||||
nb_remaining_count++;
|
||||
}
|
||||
}
|
||||
|
||||
let nb_remaining_ms = nb_avg_ms * nb_remaining_count;
|
||||
obj_label.innerHTML = '<i class="mdi mdi-clock-outline me-1"></i>'
|
||||
+ RenderQueue._format_duration(nb_remaining_ms);
|
||||
// Part 1 : temps moyen machine actuelle /i
|
||||
let str_local_avg = RenderQueue._format_duration(nb_local_avg) + "/i";
|
||||
|
||||
// Part 2 : temps restant si machine seule
|
||||
let nb_remaining_solo_ms = nb_local_avg * nb_remaining_count;
|
||||
let str_remaining_solo = RenderQueue._format_duration(nb_remaining_solo_ms);
|
||||
|
||||
// Part 3 : temps restant multi-machines
|
||||
let list_avgs = RenderQueue.list_machine_avgs;
|
||||
let nb_machines_with_data = 0;
|
||||
let nb_sum_avgs = 0;
|
||||
for (let obj_m of list_avgs) {
|
||||
if (obj_m.nb_avg_ms > 0) {
|
||||
nb_sum_avgs += obj_m.nb_avg_ms;
|
||||
nb_machines_with_data++;
|
||||
}
|
||||
}
|
||||
|
||||
let str_remaining_multi = "";
|
||||
if (nb_machines_with_data > 1) {
|
||||
let nb_avg_of_avgs = nb_sum_avgs / nb_machines_with_data;
|
||||
let nb_remaining_multi_ms = (nb_avg_of_avgs * nb_remaining_count) / nb_machines_with_data;
|
||||
str_remaining_multi = RenderQueue._format_duration(nb_remaining_multi_ms);
|
||||
}
|
||||
|
||||
let str_display = '<i class="mdi mdi-clock-outline me-1"></i>'
|
||||
+ str_local_avg + " | " + str_remaining_solo;
|
||||
if (str_remaining_multi) {
|
||||
str_display += " | " + str_remaining_multi;
|
||||
}
|
||||
|
||||
obj_label.innerHTML = str_display;
|
||||
},
|
||||
|
||||
_format_duration: (nb_ms) => {
|
||||
|
||||
Reference in New Issue
Block a user