Restrict Midra mappings to actively allocated layers
This commit is contained in:
parent
06ee4e8cf8
commit
c8b4201d2c
|
|
@ -88,11 +88,22 @@ impl Snapshot {
|
|||
{
|
||||
return Err(format!("Invalid canvas for screen {id}"));
|
||||
}
|
||||
let count_path = format!(
|
||||
"/preconfig/status/stateList/items/CURRENT/screenList/items/{id}/pp/layerCount"
|
||||
);
|
||||
let count = value(device, &count_path)?
|
||||
.as_u64()
|
||||
.filter(|count| *count <= 8)
|
||||
.ok_or_else(|| format!("Invalid allocated layer count for screen {id}"))?;
|
||||
let entries = value(s, &format!("/presetList/items/{bank}/liveLayerList/items"))?
|
||||
.as_object()
|
||||
.ok_or("Invalid layer list")?;
|
||||
let mut layers = Vec::new();
|
||||
for (id, layer) in entries {
|
||||
// Firmware stores eight slots even when only one or two are allocated.
|
||||
if !id.parse::<u64>().is_ok_and(|id| id >= 1 && id <= count) {
|
||||
continue;
|
||||
}
|
||||
// Routing does not determine whether a live-layer slot exists.
|
||||
let source = layer
|
||||
.pointer("/source/pp/input")
|
||||
|
|
@ -263,7 +274,7 @@ impl Screen {
|
|||
shapes,
|
||||
svg: false,
|
||||
note: format!(
|
||||
"Preview screen {} ({} × {}). Centered layers include visible bounds and framing. Other aspect modes use container geometry only. Routing, shared input crop and effects are not imported. Device slots may include unavailable layers. Review mapping before applying.",
|
||||
"Preview screen {} ({} × {}). Centered layers include visible bounds and framing. Other aspect modes use container geometry only. Routing, shared input crop and effects are not imported. Only currently allocated live layers are listed. Review mapping before applying.",
|
||||
self.id, self.resolution[0], self.resolution[1]
|
||||
),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -331,7 +331,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": {"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}}}}}}}}}});
|
||||
let raw = json!({"device": {"preconfig":{"status":{"stateList":{"items":{"CURRENT":{"screenList":{"items":{"1":{"pp":{"layerCount":2}}}}}}}}},"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,
|
||||
|
|
@ -362,6 +362,48 @@ mod tests {
|
|||
l
|
||||
}
|
||||
#[test]
|
||||
fn allocated_layers_only_are_valid_send_destinations() {
|
||||
let mut raw = snapshot().raw;
|
||||
for bank in ["UP", "DOWN"] {
|
||||
let entries = raw
|
||||
.pointer_mut(&format!(
|
||||
"/device/screenList/items/1/presetList/items/{bank}/liveLayerList/items"
|
||||
))
|
||||
.unwrap();
|
||||
entries["8"] = entries["1"].clone();
|
||||
}
|
||||
let state = Snapshot::parse(
|
||||
&json!({"type":"Eikos 4K","version":{"major":3,"minor":3,"patch":10}}),
|
||||
&raw,
|
||||
)
|
||||
.unwrap();
|
||||
let editor = layout();
|
||||
for target in [Target::Preview, Target::Program] {
|
||||
assert!(
|
||||
Plan::prepare(
|
||||
&state,
|
||||
&editor,
|
||||
0,
|
||||
&[(2, "2".into())],
|
||||
target,
|
||||
Sizing::OutputBox
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
Plan::prepare(
|
||||
&state,
|
||||
&editor,
|
||||
0,
|
||||
&[(2, "8".into())],
|
||||
target,
|
||||
Sizing::OutputBox
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn unassigned_existing_layers_accept_geometry_without_routing_changes() {
|
||||
let identity = json!({"type":"Eikos 4K","version":{"major":3,"minor":3,"patch":10}});
|
||||
for input in ["NONE", ""] {
|
||||
|
|
|
|||
|
|
@ -1005,7 +1005,7 @@ mod tests {
|
|||
use super::*;
|
||||
fn linked_test_snapshot() -> device::Snapshot {
|
||||
let layer = serde_json::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 = serde_json::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 = serde_json::json!({"device": {"preconfig":{"status":{"stateList":{"items":{"CURRENT":{"screenList":{"items":{"1":{"pp":{"layerCount":2}}}}}}}}},"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}}}}}}}}}});
|
||||
device::Snapshot::parse(
|
||||
&serde_json::json!({"type":"Eikos 4K","version":{"major":3,"minor":3,"patch":10}}),
|
||||
&raw,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ fn fixture() -> (Value, Value) {
|
|||
"presetList": {"items": {"UP": {"liveLayerList": {"items": {"1": layer}}}}}
|
||||
});
|
||||
let raw = json!({"device": {
|
||||
"preconfig":{"status":{"stateList":{"items":{"CURRENT":{"screenList":{"items":{"2":{"pp":{"layerCount":2}}}}}}}}},
|
||||
"transition": {"screenList": {"items": {"2": {"status": {"pp": {"transition": "AT_DOWN"}}}}}},
|
||||
"screenList": {"items": {"2": screen}}
|
||||
}});
|
||||
|
|
@ -147,19 +148,48 @@ fn existing_layers_remain_available_without_source_assignment() {
|
|||
.pointer_mut("/device/screenList/items/2/presetList/items/UP/liveLayerList/items")
|
||||
.unwrap();
|
||||
entries["1"]["status"] = json!({"pp": {"state": "OFF"}});
|
||||
for (id, input) in [("2", "NONE"), ("3", "")] {
|
||||
entries[id] = entries["1"].clone();
|
||||
entries[id]["source"]["pp"]["input"] = json!(input);
|
||||
entries[id]["crop"]["pp"]["aspectOverride"] = json!("CENTERED");
|
||||
entries[id]["status"]["pp"]["contentWidth"] = json!(0);
|
||||
entries[id]["status"]["pp"]["contentHeight"] = json!(0);
|
||||
entries["2"] = entries["1"].clone();
|
||||
entries["2"]["crop"]["pp"]["aspectOverride"] = json!("CENTERED");
|
||||
entries["2"]["status"]["pp"]["contentWidth"] = json!(0);
|
||||
entries["2"]["status"]["pp"]["contentHeight"] = json!(0);
|
||||
for input in [json!("NONE"), json!(""), Value::Null] {
|
||||
raw["device"]["screenList"]["items"]["2"]["presetList"]["items"]["UP"]["liveLayerList"]["items"]
|
||||
["2"]["source"]["pp"]["input"] = input;
|
||||
let snapshot = Snapshot::parse(&identity, &raw).unwrap();
|
||||
let screen = &snapshot.screens[0];
|
||||
assert_eq!(screen.layers.len(), 2);
|
||||
assert!(screen.layers.iter().all(|l| l.unsupported.is_none()));
|
||||
assert_eq!(screen.import(&[0, 1]).unwrap().shapes.len(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allocation_filters_firmware_slots_independently_of_input_routing() {
|
||||
let (identity, mut raw) = fixture();
|
||||
let entries = raw
|
||||
.pointer_mut("/device/screenList/items/2/presetList/items/UP/liveLayerList/items")
|
||||
.unwrap();
|
||||
for id in 2..=8 {
|
||||
entries[id.to_string()] = entries["1"].clone();
|
||||
}
|
||||
// Ignore staged NEW configuration and use only the active CURRENT allocation.
|
||||
raw["device"]["preconfig"]["status"]["stateList"]["items"]["NEW"] =
|
||||
json!({"screenList":{"items":{"2":{"pp":{"layerCount":8}}}}});
|
||||
for count in [0, 1, 2] {
|
||||
raw["device"]["preconfig"]["status"]["stateList"]["items"]["CURRENT"]["screenList"]["items"]
|
||||
["2"]["pp"]["layerCount"] = json!(count);
|
||||
let snapshot = Snapshot::parse(&identity, &raw).unwrap();
|
||||
assert_eq!(snapshot.screens[0].layers.len(), count);
|
||||
assert!(
|
||||
snapshot.screens[0]
|
||||
.layers
|
||||
.iter()
|
||||
.all(|l| l.id.parse::<usize>().unwrap() <= count)
|
||||
);
|
||||
}
|
||||
for invalid in [Value::Null, json!(-1), json!(2.5), json!(9)] {
|
||||
raw["device"]["preconfig"]["status"]["stateList"]["items"]["CURRENT"]["screenList"]["items"]
|
||||
["2"]["pp"]["layerCount"] = invalid;
|
||||
assert!(Snapshot::parse(&identity, &raw).is_err());
|
||||
}
|
||||
entries["4"] = entries["1"].clone();
|
||||
entries["4"].as_object_mut().unwrap().remove("source");
|
||||
let snapshot = Snapshot::parse(&identity, &raw).unwrap();
|
||||
let screen = &snapshot.screens[0];
|
||||
assert_eq!(screen.layers.len(), 4);
|
||||
assert!(screen.layers.iter().all(|l| l.unsupported.is_none()));
|
||||
assert_eq!(screen.import(&[0, 1, 2, 3]).unwrap().shapes.len(), 4);
|
||||
assert!(!screen.layers.iter().any(|l| l.id == "5"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,9 +78,14 @@ validation remains separate from the successful device-field and import round tr
|
|||
|
||||
The status-bar and Export-menu **Midra mapping & transfer…** actions only open export configuration, even when current layers have valid saved links. They never start a write. The user chooses a transfer scope, mappings, target and sizing, then explicitly clicks **Send mapped layers** for the displayed screen. Empty/unlinked rows are skipped. The load button uses all saved links in the scope, including links to other screens. Busy/offline actions are disabled. **Send all linked layers** remains a separate direct-send action using saved links. No persistent schema changes are involved.
|
||||
|
||||
Snapshot layer lists include every existing live-layer entry, independently of
|
||||
input assignment (`NONE`, empty or absent) and OFF state. Missing layer IDs are
|
||||
not synthesized. Input routing is informational and is never changed by geometry
|
||||
Snapshot layer lists include only allocated live-layer entries, independently of
|
||||
input assignment (`NONE`, empty or absent) and OFF state. The active allocation comes from
|
||||
`device/preconfig/status/stateList/items/CURRENT/screenList/items/{screen}/pp/layerCount`.
|
||||
Only numeric live-layer IDs 1 through that count are listed or accepted as send
|
||||
destinations, even though the firmware stores eight slots. The staged NEW
|
||||
configuration, physical input count, background and foreground planes do not
|
||||
determine this list. Missing/invalid allocation metadata produces a connection
|
||||
error rather than exposing all slots. Missing layer IDs are not synthesized. Input routing is informational and is never changed by geometry
|
||||
transfers. A Centered layer without usable content dimensions and with zero crop/
|
||||
mask imports its container geometry without inferred source framing; nonzero crops
|
||||
still require valid dimensions for visible-bound reconstruction. This changes
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
- Filter Midra destinations by each screen's CURRENT allocated layer count, not the eight firmware storage slots or physical inputs. Keep allocated layers available without assigned sources; exclude unallocated slots from import, mapping and sends, including saved links. Regression checks cover active versus staged allocation and Preview/Program sends.
|
||||
|
||||
- Keep existing Midra layers available for mapping, import and send regardless of input assignment or OFF state. Uncropped layers without content dimensions import their container; sends use editor dimensions when hardware content dimensions are unavailable, preserving routing. Regression tests cover unassigned layers and both send strategies/targets.
|
||||
|
||||
- Use absolute Gitea main-branch URLs for repository file links in the root README; verify linked files exist.
|
||||
|
|
|
|||
|
|
@ -166,3 +166,15 @@ The implementation fetches a still only on demand, limits concurrent requests
|
|||
to one and enforces a five-second minimum interval. It does not change snapshot
|
||||
enable/size, input routing, capture-library commands or any preset.
|
||||
See [input preview interface](../interfaces/midra-input-preview.md).
|
||||
|
||||
|
||||
### Allocated layers versus firmware slots
|
||||
|
||||
The snapshot contains eight live-layer slots per screen, even when the active
|
||||
configuration allocates only one or two. The Rust adapter reads
|
||||
`device/preconfig/status/stateList/items/CURRENT/screenList/items/{screen}/pp/layerCount`
|
||||
and exposes only IDs 1 through that count for import, mapping and sending.
|
||||
The cached Eikos state reported one allocated layer for screen 1 and two for
|
||||
screen 2; other screen allocations were zero. This is independent of input routing,
|
||||
signal presence, OFF state and the number of physical inputs. Background and
|
||||
foreground are not live-layer destinations. Staged NEW configuration is ignored.
|
||||
|
|
|
|||
Loading…
Reference in New Issue