feat: _MeC

This commit is contained in:
Baud 2024-03-19 23:19:07 +00:00
parent 5e5d3508f0
commit 8a3b535856
4 changed files with 48 additions and 1 deletions

View File

@ -1,3 +1,4 @@
pub mod mix_effect_block_config;
pub mod product_identifier; pub mod product_identifier;
pub mod topology; pub mod topology;
pub mod version; pub mod version;

View File

@ -0,0 +1,40 @@
use std::sync::Arc;
use crate::{
commands::command_base::{CommandDeserializer, DeserializedCommand},
state::info::MixEffectInfo,
};
pub const DESERIALIZE_MIX_EFFECT_BLOCK_CONFIG_NAME: &str = "_MeC";
#[derive(Debug)]
pub struct MixEffectBlockConfig {
mix_effect: u8,
key_count: u8,
}
impl DeserializedCommand for MixEffectBlockConfig {
fn raw_name(&self) -> &'static str {
DESERIALIZE_MIX_EFFECT_BLOCK_CONFIG_NAME
}
fn apply_to_state(&self, state: &mut crate::state::AtemState) {
state.info.mix_effects[self.mix_effect as usize] = Some(MixEffectInfo::new(self.key_count));
}
}
#[derive(Default)]
pub struct MixEffectBlockConfigDeserializer {}
impl CommandDeserializer for MixEffectBlockConfigDeserializer {
fn deserialize(
&self,
buffer: &[u8],
_version: &crate::enums::ProtocolVersion,
) -> std::sync::Arc<dyn DeserializedCommand> {
Arc::new(MixEffectBlockConfig {
mix_effect: buffer[0],
key_count: buffer[1],
})
}
}

View File

@ -8,6 +8,9 @@ use crate::{
use super::{ use super::{
command_base::{CommandDeserializer, DeserializedCommand}, command_base::{CommandDeserializer, DeserializedCommand},
device_profile::{ device_profile::{
mix_effect_block_config::{
MixEffectBlockConfigDeserializer, DESERIALIZE_MIX_EFFECT_BLOCK_CONFIG_NAME,
},
product_identifier::{ product_identifier::{
ProductIdentifierDeserializer, DESERIALIZE_PRODUCT_IDENTIFIER_RAW_NAME, ProductIdentifierDeserializer, DESERIALIZE_PRODUCT_IDENTIFIER_RAW_NAME,
}, },
@ -68,6 +71,9 @@ fn command_deserializer_from_string(command_str: &str) -> Option<Box<dyn Command
DESERIALIZE_TALLY_BY_SOURCE_RAW_NAME => Some(Box::<TallyBySourceDeserializer>::default()), DESERIALIZE_TALLY_BY_SOURCE_RAW_NAME => Some(Box::<TallyBySourceDeserializer>::default()),
DESERIALIZE_TIME_RAW_NAME => Some(Box::<TimeDeserializer>::default()), DESERIALIZE_TIME_RAW_NAME => Some(Box::<TimeDeserializer>::default()),
DESERIALIZE_TOPOLOGY_RAW_NAME => Some(Box::<TopologyDeserializer>::default()), DESERIALIZE_TOPOLOGY_RAW_NAME => Some(Box::<TopologyDeserializer>::default()),
DESERIALIZE_MIX_EFFECT_BLOCK_CONFIG_NAME => {
Some(Box::<MixEffectBlockConfigDeserializer>::default())
}
DESERIALIZE_PRODUCT_IDENTIFIER_RAW_NAME => { DESERIALIZE_PRODUCT_IDENTIFIER_RAW_NAME => {
Some(Box::<ProductIdentifierDeserializer>::default()) Some(Box::<ProductIdentifierDeserializer>::default())
} }

View File

@ -21,7 +21,7 @@ pub struct AtemCapabilites {
#[derive(Clone, PartialEq, Getters, new)] #[derive(Clone, PartialEq, Getters, new)]
pub struct MixEffectInfo { pub struct MixEffectInfo {
key_count: u64, key_count: u8,
} }
#[derive(Clone, PartialEq, Getters, new)] #[derive(Clone, PartialEq, Getters, new)]