latest pushes

This commit is contained in:
2024-12-04 12:01:08 -05:00
parent 00da7c29fc
commit 13708076cf
2 changed files with 38 additions and 28 deletions

View File

@ -1,12 +1,15 @@
# Copyright (C) 2024 Bellande Robotics Sensors Research Innovation Center, Ronaldson Bellande # Copyright (C) 2024 Bellande Robotics Sensors Research Innovation Center, Ronaldson Bellande
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or # the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.

View File

@ -1,12 +1,15 @@
// Copyright (C) 2024 Bellande Robotics Sensors Research Innovation Center, Ronaldson Bellande // Copyright (C) 2024 Bellande Robotics Sensors Research Innovation Center, Ronaldson Bellande
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
@ -16,34 +19,38 @@ use std::error::Error;
use structopt::StructOpt; use structopt::StructOpt;
#[derive(StructOpt, Debug)] #[derive(StructOpt, Debug)]
#[structopt(name = "bellande_probability", about = "Bellande Probability Tool")] #[structopt(
name = "bellande_probability",
about = "Bellande Distribution Probability Tool"
)]
struct Opt { struct Opt {
#[structopt(long, help = "First coordinate as JSON-formatted list")] #[structopt(long, help = "mu function as string")]
node0: String, mu_func: String,
#[structopt(long, help = "Second coordinate as JSON-formatted list")] #[structopt(long, help = "sigma function as string")]
node1: String, sigma_func: String,
#[structopt(long, help = "Probability threshold value")] #[structopt(long, help = "Input vector as JSON-formatted list")]
threshold: f64, x: String,
#[structopt(long, help = "Number of dimensions")] #[structopt(long, help = "Number of dimensions")]
dimensions: i32, dimensions: i32,
#[structopt(long, help = "Use full authentication")] #[structopt(long, help = "Use full authentication")]
full_auth: bool, full_auth: bool,
} }
async fn make_bellande_probability_request( async fn make_bellande_probability_request(
node0: Value, mu_func: String,
node1: Value, sigma_func: String,
threshold: f64, x: Value,
dimensions: i32, dimensions: i32,
full_auth: bool, full_auth: bool,
) -> Result<Value, Box<dyn Error>> { ) -> Result<Value, Box<dyn Error>> {
let client = reqwest::Client::new(); let client = reqwest::Client::new();
let base_url = "https://bellande-robotics-sensors-research-innovation-center.org/api/Bellande_Probability"; let base_url =
"https://bellande-robotics-sensors-research-innovation-center.org/api/Bellande_Probability";
let endpoint = if full_auth { let endpoint = if full_auth {
format!("{}/bellande_probability_full_auth", base_url) format!("{}/bellande_probability_full_auth", base_url)
} else { } else {
@ -61,9 +68,9 @@ async fn make_bellande_probability_request(
}; };
let payload = json!({ let payload = json!({
"node0": node0, "mu_func": mu_func,
"node1": node1, "sigma_func": sigma_func,
"threshold": threshold, "x": x,
"dimensions": dimensions, "dimensions": dimensions,
"auth": auth "auth": auth
}); });
@ -85,18 +92,18 @@ async fn make_bellande_probability_request(
async fn main() -> Result<(), Box<dyn Error>> { async fn main() -> Result<(), Box<dyn Error>> {
let opt = Opt::from_args(); let opt = Opt::from_args();
let node0: Value = serde_json::from_str(&opt.node0) let x: Value =
.map_err(|e| format!("Error parsing node0: {}", e))?; serde_json::from_str(&opt.x).map_err(|e| format!("Error parsing x values: {}", e))?;
let node1: Value = serde_json::from_str(&opt.node1)
.map_err(|e| format!("Error parsing node1: {}", e))?;
match make_bellande_probability_request( match make_bellande_probability_request(
node0, opt.mu_func,
node1, opt.sigma_func,
opt.threshold, x,
opt.dimensions, opt.dimensions,
opt.full_auth opt.full_auth,
).await { )
.await
{
Ok(result) => { Ok(result) => {
println!("{}", serde_json::to_string_pretty(&result)?); println!("{}", serde_json::to_string_pretty(&result)?);
} }