Skip to content

Commit

Permalink
Add all control commands
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdewid committed Oct 1, 2024
1 parent 0a8651d commit e222668
Showing 1 changed file with 104 additions and 31 deletions.
135 changes: 104 additions & 31 deletions glonax-control/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,45 +62,70 @@ enum Command {
#[arg(short, long)]
filter: Option<ObjectFilter>,
},
/// Engine commands.
/// Engine command.
Engine {
/// RPM
rpm: u16,
},
/// Shutdown engine.
Shutdown,
/// Motion lock commands.
/// Motion lock command.
MotionLock {
/// On or off.
toggle: String,
},
/// Illumination commands.
Illumination {
/// Quick disconnect command.
HydraulicQuickDisconnect {
/// On or off.
toggle: String,
},
/// Lights commands.
Lights {
/// Hydraulic quick disconnect command.
HydraulicLock {
/// On or off.
toggle: String,
},
/// Strobe light commands.
StrobeLight {
/// Hydraulic boost command.
HydraulicBoost {
/// On or off.
toggle: String,
},
/// Travel alarm commands.
TravelAlarm {
/// Hydraulic boom conflux command.
HydraulicBoomConflux {
/// On or off.
toggle: String,
},
/// Hydraulic arm conflux command.
HydraulicArmConflux {
/// On or off.
toggle: String,
},
/// Hydraulic boom float command.
HydraulicBoomFloat {
/// On or off.
toggle: String,
},
/// Horn commands.
/// Illumination command.
Illumination {
/// On or off.
toggle: String,
},
/// Lights command.
Lights {
/// On or off.
toggle: String,
},
/// Horn command.
Horn {
/// On or off.
toggle: String,
},
/// Quick disconnect commands.
QuickDisconnect {
/// Strobe light command.
StrobeLight {
/// On or off.
toggle: String,
},
/// Travel alarm command.
TravelAlarm {
/// On or off.
toggle: String,
},
Expand Down Expand Up @@ -318,6 +343,63 @@ async fn run(config: config::Config, args: Args) -> anyhow::Result<()> {
};
client.send_packet(&motion).await?;
}
Command::HydraulicQuickDisconnect { toggle } => {
let toggle = string_to_bool(&toggle)
.ok_or_else(|| anyhow::anyhow!("Invalid value for hydraulic quick disconnect"))?;

log::info!(
"Setting hydraulic quick disconnect: {}",
bool_to_string(toggle)
);

let control = Control::HydraulicQuickDisconnect(toggle);
client.send_packet(&control).await?;
}
Command::HydraulicLock { toggle } => {
let toggle = string_to_bool(&toggle)
.ok_or_else(|| anyhow::anyhow!("Invalid value for hydraulic lock"))?;

log::info!("Setting hydraulic lock: {}", bool_to_string(toggle));

let control = Control::HydraulicLock(toggle);
client.send_packet(&control).await?;
}
Command::HydraulicBoost { toggle } => {
let toggle = string_to_bool(&toggle)
.ok_or_else(|| anyhow::anyhow!("Invalid value for hydraulic boost"))?;

log::info!("Setting hydraulic boost: {}", bool_to_string(toggle));

let control = Control::HydraulicBoost(toggle);
client.send_packet(&control).await?;
}
Command::HydraulicBoomConflux { toggle } => {
let toggle = string_to_bool(&toggle)
.ok_or_else(|| anyhow::anyhow!("Invalid value for hydraulic boom conflux"))?;

log::info!("Setting hydraulic boom conflux: {}", bool_to_string(toggle));

let control = Control::HydraulicBoomConflux(toggle);
client.send_packet(&control).await?;
}
Command::HydraulicArmConflux { toggle } => {
let toggle = string_to_bool(&toggle)
.ok_or_else(|| anyhow::anyhow!("Invalid value for hydraulic arm conflux"))?;

log::info!("Setting hydraulic arm conflux: {}", bool_to_string(toggle));

let control = Control::HydraulicArmConflux(toggle);
client.send_packet(&control).await?;
}
Command::HydraulicBoomFloat { toggle } => {
let toggle = string_to_bool(&toggle)
.ok_or_else(|| anyhow::anyhow!("Invalid value for hydraulic boom float"))?;

log::info!("Setting hydraulic boom float: {}", bool_to_string(toggle));

let control = Control::HydraulicBoomFloat(toggle);
client.send_packet(&control).await?;
}
Command::Illumination { toggle } => {
let toggle = string_to_bool(&toggle)
.ok_or_else(|| anyhow::anyhow!("Invalid value for illumination"))?;
Expand All @@ -336,6 +418,15 @@ async fn run(config: config::Config, args: Args) -> anyhow::Result<()> {
let control = Control::MachineLights(toggle);
client.send_packet(&control).await?;
}
Command::Horn { toggle } => {
let toggle =
string_to_bool(&toggle).ok_or_else(|| anyhow::anyhow!("Invalid value for horn"))?;

log::info!("Setting horn: {}", bool_to_string(toggle));

let control = Control::MachineHorn(toggle);
client.send_packet(&control).await?;
}
Command::StrobeLight { toggle } => {
let toggle = string_to_bool(&toggle)
.ok_or_else(|| anyhow::anyhow!("Invalid value for strobe light"))?;
Expand All @@ -354,24 +445,6 @@ async fn run(config: config::Config, args: Args) -> anyhow::Result<()> {
let control = Control::MachineTravelAlarm(toggle);
client.send_packet(&control).await?;
}
Command::Horn { toggle } => {
let toggle =
string_to_bool(&toggle).ok_or_else(|| anyhow::anyhow!("Invalid value for horn"))?;

log::info!("Setting horn: {}", bool_to_string(toggle));

let control = Control::MachineHorn(toggle);
client.send_packet(&control).await?;
}
Command::QuickDisconnect { toggle } => {
let toggle = string_to_bool(&toggle)
.ok_or_else(|| anyhow::anyhow!("Invalid value for quick disconnect"))?;

log::info!("Setting quick disconnect: {}", bool_to_string(toggle));

let control = Control::HydraulicQuickDisconnect(toggle);
client.send_packet(&control).await?;
}
Command::Target { x, y, z } => {
let target = Target::from_point(x, y, z);

Expand Down

0 comments on commit e222668

Please sign in to comment.