Apply staged Midra geometry after sending layer changes
This commit is contained in:
parent
baaf41057c
commit
649222026b
|
|
@ -223,12 +223,23 @@ trait Transport {
|
|||
fn pause(&self) {}
|
||||
}
|
||||
fn execute(plan: &Plan, transport: &mut impl Transport) -> Result<Snapshot, String> {
|
||||
if plan.changes.is_empty() {
|
||||
return transport.read();
|
||||
}
|
||||
for (i, change) in plan.changes.iter().enumerate() {
|
||||
transport.write(change).map_err(|e| format!("Send stopped after {i}/{} confirmed socket writes. Device may be partially changed; refresh before retrying. {e}", plan.changes.len()))?;
|
||||
}
|
||||
// WebRCS commits staged preset edits with a false -> true edge.
|
||||
// Always pulse, even if values already match the server's staging store.
|
||||
for value in [false, true] {
|
||||
let apply = Change {
|
||||
path: ["device", "preset", "control", "pp", "xUpdate"]
|
||||
.map(str::to_owned)
|
||||
.to_vec(),
|
||||
before: json!(!value),
|
||||
after: json!(value),
|
||||
};
|
||||
transport
|
||||
.write(&apply)
|
||||
.map_err(|e| format!("Layer values sent, but applying preset updates failed: {e}"))?;
|
||||
}
|
||||
for _ in 0..10 {
|
||||
transport.pause();
|
||||
let snapshot = transport.read().map_err(|e| format!("Commands sent, but readback failed; outcome uncertain. Refresh before retrying. {e}"))?;
|
||||
|
|
@ -274,7 +285,7 @@ impl Transport for Connection {
|
|||
std::thread::sleep(Duration::from_millis(200));
|
||||
}
|
||||
}
|
||||
/// Explicit send only. Checks reviewed fields, writes once, verifies readback.
|
||||
/// Explicit send: write fields, pulse preset xUpdate, then verify geometry readback.
|
||||
/// Banks are pinned; another controller's TAKE can change their on-air role.
|
||||
pub fn send(host: &str, plan: &Plan) -> Result<Snapshot, String> {
|
||||
let mut connection = Connection {
|
||||
|
|
@ -289,7 +300,7 @@ mod tests {
|
|||
use super::*;
|
||||
fn snapshot() -> Snapshot {
|
||||
let layer = json!({"position":{"pp":{"posH":500,"posV":300}},"size":{"pp":{"sizeH":640,"sizeV":360}},"source":{"pp":{"input":"INPUT_4"}},"status":{"pp":{"contentWidth":1920,"contentHeight":1080}},"crop":{"pp":{"left":0,"right":0,"top":0,"bottom":0,"aspectOverride":"GLOBAL_SETTING"}},"mask":{"pp":{"left":0,"right":0,"top":0,"bottom":0}}});
|
||||
let raw = json!({"device": {"transition":{"screenList":{"items":{"1":{"status":{"pp":{"transition":"AT_DOWN"}}}}}},"screenList":{"items":{"1":{"canvas":{"status":{"size":{"pp":{"sizeH":1920,"sizeV":1080}}}},"presetList":{"items":{"UP":{"liveLayerList":{"items":{"1":layer,"2":layer}}},"DOWN":{"liveLayerList":{"items":{"1":layer,"2":layer}}}}}}}}}});
|
||||
let raw = json!({"device": {"preset":{"control":{"pp":{"xUpdate":true,"enableAutoUpdate":false}}},"transition":{"screenList":{"items":{"1":{"status":{"pp":{"transition":"AT_DOWN"}}}}}},"screenList":{"items":{"1":{"canvas":{"status":{"size":{"pp":{"sizeH":1920,"sizeV":1080}}}},"presetList":{"items":{"UP":{"liveLayerList":{"items":{"1":layer,"2":layer}}},"DOWN":{"liveLayerList":{"items":{"1":layer,"2":layer}}}}}}}}}});
|
||||
Snapshot::parse(
|
||||
&json!({"type":"Eikos 4K","version":{"major":3,"minor":3,"patch":10}}),
|
||||
&raw,
|
||||
|
|
@ -369,6 +380,7 @@ mod tests {
|
|||
writes: usize,
|
||||
fail_at: Option<usize>,
|
||||
ignore: bool,
|
||||
writes_log: Vec<(Vec<String>, Value)>,
|
||||
}
|
||||
impl Transport for Mock {
|
||||
fn read(&mut self) -> Result<Snapshot, String> {
|
||||
|
|
@ -379,6 +391,7 @@ mod tests {
|
|||
return Err("Connection lost".into());
|
||||
}
|
||||
self.writes += 1;
|
||||
self.writes_log.push((c.path.clone(), c.after.clone()));
|
||||
if !self.ignore {
|
||||
*self
|
||||
.state
|
||||
|
|
@ -499,6 +512,7 @@ mod tests {
|
|||
writes: 0,
|
||||
fail_at: None,
|
||||
ignore: false,
|
||||
writes_log: vec![],
|
||||
};
|
||||
let result = execute(&plan, &mut mock).unwrap();
|
||||
let imported = Snapshot::parse(
|
||||
|
|
@ -545,6 +559,7 @@ mod tests {
|
|||
writes: 0,
|
||||
fail_at: None,
|
||||
ignore: false,
|
||||
writes_log: vec![],
|
||||
};
|
||||
*mock
|
||||
.state
|
||||
|
|
@ -552,7 +567,7 @@ mod tests {
|
|||
.pointer_mut("/device/screenList/items/1/canvas/status/size/pp")
|
||||
.unwrap() = json!(null);
|
||||
assert!(plan.verified(&execute(&plan, &mut mock).unwrap()));
|
||||
assert_eq!(mock.writes, plan.changes.len());
|
||||
assert_eq!(mock.writes, plan.changes.len() + 2);
|
||||
mock.state = state;
|
||||
mock.writes = 0;
|
||||
mock.fail_at = Some(2);
|
||||
|
|
@ -562,9 +577,16 @@ mod tests {
|
|||
.contains("partially changed")
|
||||
);
|
||||
assert_eq!(mock.writes, 2);
|
||||
mock.writes = 0;
|
||||
mock.fail_at = Some(plan.changes.len());
|
||||
assert!(
|
||||
execute(&plan, &mut mock)
|
||||
.unwrap_err()
|
||||
.contains("applying preset updates failed")
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
fn success_requires_matching_readback_and_noop_sends_nothing() {
|
||||
fn success_requires_readback_and_unchanged_values_still_apply() {
|
||||
let state = snapshot();
|
||||
let mut plan = Plan::prepare(
|
||||
&state,
|
||||
|
|
@ -580,9 +602,22 @@ mod tests {
|
|||
writes: 0,
|
||||
fail_at: None,
|
||||
ignore: false,
|
||||
writes_log: vec![],
|
||||
};
|
||||
assert!(plan.verified(&execute(&plan, &mut mock).unwrap()));
|
||||
assert_eq!(mock.writes, plan.changes.len());
|
||||
assert_eq!(mock.writes, plan.changes.len() + 2);
|
||||
let pulse = ["device", "preset", "control", "pp", "xUpdate"]
|
||||
.map(str::to_owned)
|
||||
.to_vec();
|
||||
assert_eq!(
|
||||
&mock.writes_log[plan.changes.len()..],
|
||||
&[(pulse.clone(), json!(false)), (pulse, json!(true))]
|
||||
);
|
||||
assert!(
|
||||
mock.writes_log[..plan.changes.len()]
|
||||
.iter()
|
||||
.all(|(path, _)| path.last().unwrap() != "xUpdate")
|
||||
);
|
||||
mock.state = state;
|
||||
mock.writes = 0;
|
||||
mock.ignore = true;
|
||||
|
|
@ -591,10 +626,10 @@ mod tests {
|
|||
.unwrap_err()
|
||||
.contains("did not match")
|
||||
);
|
||||
assert_eq!(mock.writes, plan.changes.len());
|
||||
assert_eq!(mock.writes, plan.changes.len() + 2);
|
||||
plan.changes.clear();
|
||||
mock.writes = 0;
|
||||
execute(&plan, &mut mock).unwrap();
|
||||
assert_eq!(mock.writes, 0);
|
||||
assert_eq!(mock.writes, 2);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,8 @@ impl DeviceUi {
|
|||
Ok(snapshot) => {
|
||||
if was_sending {
|
||||
self.message =
|
||||
"Send complete. All changed fields verified by device readback.".into();
|
||||
"Send complete. Preset update sent; geometry verified by device readback."
|
||||
.into();
|
||||
}
|
||||
self.screen = self.screen.min(snapshot.screens.len() - 1);
|
||||
self.destinations =
|
||||
|
|
@ -172,11 +173,7 @@ impl Editor {
|
|||
}
|
||||
pub(super) fn midra_send_button(&mut self, ui: &mut egui::Ui, all: bool) {
|
||||
let plans = self.device.linked_plans(&self.layout, all);
|
||||
let enabled = self.device.online()
|
||||
&& self.device.pending.is_none()
|
||||
&& plans
|
||||
.as_ref()
|
||||
.map_or(true, |plans| plans.iter().any(|p| !p.changes.is_empty()));
|
||||
let enabled = self.device.online() && self.device.pending.is_none();
|
||||
let tooltip = match &plans {
|
||||
Ok(plans) => format!(
|
||||
"Send {} linked screen(s) to {:?} using saved layer destinations.",
|
||||
|
|
@ -501,11 +498,11 @@ fn send_review(
|
|||
));
|
||||
}
|
||||
});
|
||||
if apply_button(ui, "Send mapped layers", !busy && !plan.changes.is_empty()).clicked() {
|
||||
if apply_button(ui, "Send mapped layers", !busy).clicked() {
|
||||
return Some(plan);
|
||||
}
|
||||
if plan.changes.is_empty() {
|
||||
ui.weak("These values already match the device snapshot.");
|
||||
ui.weak("Geometry matches the stored values. Send applies them to the hardware.");
|
||||
}
|
||||
}
|
||||
Err(error) => {
|
||||
|
|
|
|||
|
|
@ -67,14 +67,28 @@ Only an explicit Send click creates a worker. Read/refresh, editing, project loa
|
|||
import, undo and redo never write. Requests run off the UI thread with bounded
|
||||
socket operations. After preflight, changed fields are written sequentially once. Crop decreases precede increases
|
||||
to avoid temporarily exhausting the retained area while moving a crop.
|
||||
Readback checks every changed field. No-op plans are disabled. Failure reports
|
||||
Readback checks every changed field. Valid plans remain sendable even when stored geometry matches: sending still applies staged values. Failure reports
|
||||
partial/uncertain outcomes without blind retries or automatic rollback.
|
||||
|
||||
Program selection is explicit. The application defaults to Preview and hides Program unless the persisted `allow_sending_to_program` preference is enabled. Turning it off resets the exporter to Preview, including quick Apply. Layer screen/destination links are saved in project version 5. Plans and raw snapshots are not saved in projects or preferences. The device address is saved in [application settings](midra-layout-settings.md), never in projects. Refresh and screen changes preserve saved links. Physical display
|
||||
validation remains separate from the successful device-field and import round trips.
|
||||
|
||||
The status-bar and Export-menu **Apply to Midra** actions prepare a fresh plan for the current editor selection using saved layer links and the session target and sizing mode. Valid changed plans send immediately with readback verification, without a preflight refusal. Missing or invalid mappings open the configuration window without writing; no-op plans and busy/offline actions are disabled. No persistent schema changes are involved.
|
||||
The status-bar and Export-menu **Apply to Midra** actions prepare a fresh plan for the current editor selection using saved layer links and the session target and sizing mode. Valid changed plans send immediately with readback verification, without a preflight refusal. Missing or invalid mappings open the configuration window without writing; busy/offline actions are disabled; unchanged stored geometry can still be explicitly applied. No persistent schema changes are involved.
|
||||
|
||||
Snapshot layer lists omit unassigned source slots (`NONE` or empty), before geometry validation. Assigned layers remain available even when OFF.
|
||||
|
||||
**Send all linked layers** includes all linked document layers, even unselected, hidden or locked ones. Plans are grouped by saved screen ID and all groups are validated before starting. Screen groups send sequentially with readback; on failure later groups are not sent, and the result reports the failed screen and completed-group count. Links never auto-send and are not tied to an IP address.
|
||||
|
||||
## Preset apply pulse
|
||||
|
||||
After the geometry writes, send two DEVICE WebSocket messages at
|
||||
`device/preset/control/pp/xUpdate`: `false`, then `true`, matching WebRCS's
|
||||
`DEVICE_PRESET_CONTROL_SET_ONE` action sequence. This commits staged preset edits
|
||||
when `enableAutoUpdate` is false. Do not change `enableAutoUpdate` or issue TAKE.
|
||||
The pulse is global and may apply other pending preset edits; it is not scoped to
|
||||
an individual screen/layer. Each screen send currently ends with this pulse.
|
||||
Always pulse on an explicit valid send, even if the staged geometry already
|
||||
matches and the change list is empty. A pulse-write failure is reported separately
|
||||
from geometry-write failure. Geometry readback follows the pulse; a readable store
|
||||
alone does not prove the physical video output updated. The trigger itself is not
|
||||
included in geometry comparisons, because it is a command rather than geometry.
|
||||
|
|
|
|||
|
|
@ -138,3 +138,16 @@ The manufacturer's [REST API guide v3.0.13](https://s3.eu-west-3.amazonaws.com/a
|
|||
was inspected. It documents logical Preview source assignment, but not geometry
|
||||
writes; this implementation therefore uses the installed WebRCS WebSocket protocol.
|
||||
The physical bank is captured in the review and remains fixed across the send.
|
||||
|
||||
## Missing preset apply diagnosed
|
||||
|
||||
The operator reported that WebRCS geometry changed while the physical multiviewer
|
||||
Preview did not. The bundled WebRCS code calls `z1()` after geometry edits, which
|
||||
dispatches `DEVICE_PRESET_CONTROL_SET_ONE` for `xUpdate` false, then true.
|
||||
The device snapshot had `device/preset/control/pp/enableAutoUpdate: false`.
|
||||
Earlier tests checked only staging-store readback and therefore did not establish
|
||||
that geometry had reached video processing. The exporter now sends this apply
|
||||
pulse after geometry writes, even when no geometry fields differ. A direct pulse
|
||||
was sent to the connected Eikos to apply its already-staged layout. The operator confirmed that the physical multiviewer Preview then matched WebRCS, establishing the missing apply pulse as the cause. Layer status `OFF` is not
|
||||
sufficient evidence that the operator's layers are disabled, and must not be used
|
||||
as that diagnosis.
|
||||
|
|
|
|||
|
|
@ -528,7 +528,7 @@ After connecting, open **Export → Configure Midra export…**. Choose editor l
|
|||
map each to a Midra layer, select **Preview** or **Program**, and select a container
|
||||
strategy: **Output-sized** or **Source aspect**. Expand **Exact device changes** to
|
||||
review sizes, centers, crop values and aspect, then click **Send mapped layers**.
|
||||
The button is disabled when the snapshot already matches or a send is in progress.
|
||||
The button is disabled while a send is in progress. Matching stored values can still be sent to apply staged geometry to hardware.
|
||||
The source's native dimensions must match the destination's current content.
|
||||
|
||||
The target bank is fixed when configured. Sending starts immediately without a stale-state check. Writes are sequential;
|
||||
|
|
@ -618,7 +618,7 @@ and disabled in these pickers; choosing layers changes no geometry. Full project
|
|||
save/load and screen reference images are document-wide operations, so they have
|
||||
no layer mapping.
|
||||
|
||||
**Apply to Midra**, beside ONLINE/OFFLINE and in **Export**, sends the selected layers using the current destination mappings, screen, Preview/Program target and sizing strategy. If mapping is incomplete, it opens the send window first. Configure these choices in **Export → Configure Midra export…**. The action is disabled offline, during transfers, or when values already match the last snapshot. Sending writes directly and verifies readback; results appear in the send window. Only applied editor values are sent.
|
||||
**Apply to Midra**, beside ONLINE/OFFLINE and in **Export**, sends the selected layers using the current destination mappings, screen, Preview/Program target and sizing strategy. If mapping is incomplete, it opens the send window first. Configure these choices in **Export → Configure Midra export…**. The action is disabled offline or during transfers. Sending writes geometry, pulses the WebRCS preset-update command, and verifies geometry readback; results appear in the send window. Only applied editor values are sent.
|
||||
|
||||
Layer rows use padlock and eye icon buttons for locking and visibility, with tooltips and highlighted locked/hidden states. Double-click a layer name in the right-hand list to rename it. Enter saves, Escape or Cancel discards the edit; names must contain 1–128 characters. Renaming preserves the layer ID and folder and supports Undo.
|
||||
|
||||
|
|
@ -627,3 +627,5 @@ Snapping also applies to side and corner resizing, including with aspect ratio l
|
|||
Midra layer lists omit unassigned source slots (`NONE` or empty). Assigned inputs remain listed even if the layer is off. The exporter defaults to Preview and hides Program until **Preferences → Midra integration → Allow sending to Program** is checked. This preference is saved automatically; turning it off returns the exporter and quick Apply action to Preview.
|
||||
|
||||
Destination choices in **Configure Midra export…** now save immediately on the editor layer and support Undo. Save the project JSON to keep links across sessions. Links include screen and layer IDs and survive refreshes and selection changes. Choose the empty destination on the linked screen to unlink. **Send all linked layers** is available beside Apply, in Export and in the send window; it includes unselected, hidden and locked linked layers, grouped by screen. The usual Apply action sends selected linked layers. Preview/Program and sizing still use the current export options.
|
||||
|
||||
Every explicit send now includes WebRCS’s preset apply pulse (`xUpdate` false → true). This applies staged geometry when automatic updates are disabled, including a repeat send where WebRCS already shows the desired values.
|
||||
|
|
|
|||
Loading…
Reference in New Issue