Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: prepare for documentation improvements #6909

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs: enable systems_wasm docs
  • Loading branch information
davidwalschots committed Mar 13, 2022
commit 7b05a699d67d7dcd6c922f7828eddb8187b8f396
4 changes: 1 addition & 3 deletions src/systems/systems_wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ edition = "2018"

[lib]
test = false
doctest = false
doc = false

[dependencies]
uom = "0.30.0"
systems = { path = "../systems" }
msfs = { git = "https://github.com/flybywiresim/msfs-rs", branch = "main" }
fxhash = "0.2.1"
enum_dispatch = "0.3.7"
enum_dispatch = "0.3.7"
4 changes: 2 additions & 2 deletions src/systems/systems_wasm/src/aspects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ pub(super) trait Aspect {
}
}

/// Type used to configure and build an [Aspect].
/// Type used to configure an aspect of the connectivity between MSFS and the simulation.
///
/// It should be noted that the resulting [Aspect] executes its tasks in the order in which they
/// It should be noted that the resulting aspect executes its tasks in the order in which they
/// were declared. Declaration order is important when one action depends on another action.
/// When e.g. a variable that is mapped should then be written to an event, be sure to
/// declare the mapping before the event writing.
Expand Down
7 changes: 5 additions & 2 deletions src/systems/systems_wasm/src/electrical.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use std::error::Error;
#[cfg(not(target_arch = "wasm32"))]
use crate::msfs::legacy::execute_calculator_code;
#[cfg(target_arch = "wasm32")]
use msfs::legacy::execute_calculator_code;

use crate::{ExecuteOn, MsfsAspectBuilder, Variable};
use msfs::legacy::execute_calculator_code;
use std::error::Error;
use systems::shared::{to_bool, ElectricalBusType};

pub(super) fn electrical_buses<const N: usize>(
Expand Down
6 changes: 5 additions & 1 deletion src/systems/systems_wasm/src/failures.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use fxhash::FxHashMap;
#[cfg(not(target_arch = "wasm32"))]
use crate::msfs::legacy::NamedVariable;
#[cfg(target_arch = "wasm32")]
use msfs::legacy::NamedVariable;

use fxhash::FxHashMap;

use systems::failures::FailureType;

pub(super) struct Failures {
Expand Down
14 changes: 9 additions & 5 deletions src/systems/systems_wasm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
#![cfg(any(target_arch = "wasm32", doc))]
#[macro_use]
pub mod aspects;
mod electrical;
mod failures;
mod msfs;

#[cfg(not(target_arch = "wasm32"))]
use crate::msfs::legacy::{AircraftVariable, NamedVariable};
#[cfg(target_arch = "wasm32")]
use ::msfs::legacy::{AircraftVariable, NamedVariable};

use crate::aspects::{Aspect, ExecuteOn, MsfsAspectBuilder};
use crate::electrical::{auxiliary_power_unit, electrical_buses};
use failures::Failures;
use fxhash::FxHashMap;
use msfs::{
legacy::{AircraftVariable, NamedVariable},
use ::msfs::{
sim_connect::{data_definition, Period, SimConnect, SimConnectRecv, SIMCONNECT_OBJECT_ID_USER},
MSFSEvent,
};
use failures::Failures;
use fxhash::FxHashMap;
use std::fmt::{Display, Formatter};
use std::{error::Error, time::Duration};
use systems::shared::ElectricalBusType;
Expand Down
47 changes: 47 additions & 0 deletions src/systems/systems_wasm/src/msfs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
///! Module declared to be able to compile documentation.
///! Does not provide any meaningful functionality.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) mod legacy {
use std::cell::Cell;
use std::rc::Rc;

pub fn execute_calculator_code<T>(_code: &str) {}

#[derive(Debug)]
pub struct AircraftVariable {}

impl AircraftVariable {
pub fn from(
_name: &str,
_units: &str,
_index: usize,
) -> Result<Self, Box<dyn std::error::Error>> {
Ok(Self {})
}

pub fn get(&self) -> f64 {
0.
}
}

#[derive(Debug)]
pub struct NamedVariable {
value: Rc<Cell<f64>>,
}

impl NamedVariable {
pub fn from(_name: &str) -> Self {
Self {
value: Rc::new(Cell::new(0.)),
}
}

pub fn get_value(&self) -> f64 {
self.value.get()
}

pub fn set_value(&self, value: f64) {
self.value.set(value);
}
}
}