feat: Program input command
This commit is contained in:
parent
476a24ded9
commit
f0ee6a0444
|
@ -138,18 +138,18 @@ checksum = "0c5905670fd9c320154f3a4a01c9e609733cd7b753f3c58777ab7d5ce26686b3"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 1.0.74",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive-new"
|
||||
version = "0.5.9"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3418329ca0ad70234b9735dc4ceed10af4df60eff9c8e7b06cb5e520d92c3535"
|
||||
checksum = "d150dea618e920167e5973d70ae6ece4385b7164e0d799fe7c122dd0a5d912ad"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -352,18 +352,18 @@ checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443"
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.28"
|
||||
version = "1.0.78"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612"
|
||||
checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.9"
|
||||
version = "1.0.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
|
||||
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
@ -441,6 +441,17 @@ dependencies = [
|
|||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.48"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.2"
|
||||
|
@ -467,7 +478,7 @@ checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 1.0.74",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -507,7 +518,7 @@ checksum = "c9efc1aba077437943f7515666aa2b882dfabfbfdf89c819ea75a8d6e9eaba5e"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 1.0.74",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -530,7 +541,7 @@ checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 1.0.74",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -563,6 +574,12 @@ dependencies = [
|
|||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.2"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[workspace]
|
||||
|
||||
resolver = "2"
|
||||
members = [
|
||||
"atem-connection-rs",
|
||||
"atem-test"
|
||||
|
|
|
@ -5,7 +5,7 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
derive-getters = "0.2.0"
|
||||
derive-new = "0.5.9"
|
||||
derive-new = "0.6.0"
|
||||
log = "0.4.14"
|
||||
thiserror = "1.0.30"
|
||||
tokio = { version = "1.13.0", features = ["full"] }
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
use super::command_base::{BasicWritableCommand, SerializableCommand};
|
||||
|
||||
#[derive(new)]
|
||||
pub struct ProgramInput {
|
||||
mix_effect: u8,
|
||||
source: u16,
|
||||
}
|
||||
|
||||
impl SerializableCommand for ProgramInput {
|
||||
fn payload(&self, _version: crate::enums::ProtocolVersion) -> Vec<u8> {
|
||||
let mut buf = vec![0; 4];
|
||||
buf[..1].copy_from_slice(&self.mix_effect.to_be_bytes());
|
||||
buf[2..].copy_from_slice(&self.source.to_be_bytes());
|
||||
|
||||
buf
|
||||
}
|
||||
}
|
||||
|
||||
impl BasicWritableCommand for ProgramInput {
|
||||
fn get_raw_name(&self) -> &'static str {
|
||||
"CPgI"
|
||||
}
|
||||
|
||||
fn get_minimum_version(&self) -> crate::enums::ProtocolVersion {
|
||||
crate::enums::ProtocolVersion::Unknown
|
||||
}
|
||||
}
|
|
@ -1 +1,2 @@
|
|||
pub mod command_base;
|
||||
pub mod mix_effects;
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use atem_connection_rs::atem_lib::atem_socket::AtemSocket;
|
||||
use atem_connection_rs::{
|
||||
atem_lib::atem_socket::AtemSocket,
|
||||
commands::{
|
||||
command_base::{BasicWritableCommand, SerializableCommand},
|
||||
mix_effects::ProgramInput,
|
||||
},
|
||||
};
|
||||
|
||||
use color_eyre::Report;
|
||||
use tokio::time::sleep;
|
||||
|
@ -9,9 +15,8 @@ use tokio::time::sleep;
|
|||
async fn main() {
|
||||
setup_logging().unwrap();
|
||||
|
||||
let switch_raw_name: &str = "CPgI";
|
||||
let switch_source_to_1: [u8; 4] = [0, 0, 0, 1];
|
||||
let switch_source_to_2: [u8; 4] = [0, 0, 0, 2];
|
||||
let switch_to_source_1 = ProgramInput::new(0, 1);
|
||||
let switch_to_source_2 = ProgramInput::new(0, 2);
|
||||
|
||||
let mut atem = AtemSocket::new();
|
||||
atem.connect("127.0.0.1".to_string(), 9910).await.ok();
|
||||
|
@ -19,12 +24,20 @@ async fn main() {
|
|||
let mut tracking_id = 0;
|
||||
loop {
|
||||
sleep(Duration::from_millis(5000)).await;
|
||||
atem.send_command(&switch_source_to_1, switch_raw_name, tracking_id)
|
||||
.await;
|
||||
atem.send_command(
|
||||
&switch_to_source_1.payload(atem_connection_rs::enums::ProtocolVersion::Unknown),
|
||||
switch_to_source_1.get_raw_name(),
|
||||
tracking_id,
|
||||
)
|
||||
.await;
|
||||
tracking_id += 1;
|
||||
sleep(Duration::from_millis(5000)).await;
|
||||
atem.send_command(&switch_source_to_2, switch_raw_name, tracking_id)
|
||||
.await;
|
||||
atem.send_command(
|
||||
&switch_to_source_2.payload(atem_connection_rs::enums::ProtocolVersion::Unknown),
|
||||
switch_to_source_2.get_raw_name(),
|
||||
tracking_id,
|
||||
)
|
||||
.await;
|
||||
tracking_id += 1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue