1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//! # sac-base (Signal And Control)
//! sac-base is the base crate of its two child crates sac-control and sac-signal.
//! This crate is still under heavy construction and not finished.
//!
//! ---
//!
//! # Idea
//! The sac-* crates help to implement signal processing and control systems in a network based
//! approach. Similar to to Simulink as example.
//! The project is designed for a primary usage on embedded systems and is therefore a [no_std]
//! crate. A generic solution such as the used network based approach will never be as fast as a
//! custom system implementation for a specific problem. But it will allow to directly and quickly
//! implement and change systems in code instead of designing it Matlab and exporting it to C.
//! Generation the network and building the topology is relatively expensive. Therefore the crate
//! does all the allocations and setup before the normal operation starts.
//!
//! This base crate is designed in a way that allows the Signal and the Control crate to easily
//! extend it, and allow the operations to be interchangeable between each other.
//!
//! Both the sac-control and the sac-signal are under construction and are not available yet.
//!
//! ## Base crate
//! The base crate provides the following features:
//! - Network description.
//! - Base node implementation which the operations are based on.
//! - Simple math operations such as adding, subtraction. Generally operations that will be used in both the Signal and Control crates.
//! - Generic elements such as buffers.
//!
//! # Example
//! The following example, can be build by the code given below:
//!
//! ```rust
//! //
//! //    +----+
//! //    |    |
//! // +--+ In +----+
//! //    |    |    |   +-----+
//! //    +----+    +---+     |
//! //                  | Add +----+-------------+
//! //    +----+    +---+     |    |             |
//! //    |    |    |   +-----+    |             |     +-----+
//! // +--+ In +----+              |             +-----+     |
//! //    |    |                   |                   | Mul +------+---+
//! //    +----+                   |             +-----+     |      |
//! //                             |  +-----+    |     +-----+      |
//! //    +----+                   +--+     |    |                  |
//! //    |    |                      | Add |    |                  |
//! // +--+ In +----------------------+     +----+                  |
//! //    |    |                      |     |                       |
//! //    +----+                +-----+     |                       |
//! //                          |     +-----+                       |
//! //                          |                                   |
//! //                          |                                   |
//! //                          +-----------------------------------+
//!
//! use sac_base::network::network::Network;
//! use sac_base::operations::math::add::Add;
//! use sac_base::operations::miscellaneous::buffer::Buffer;
//! use sac_base::operations::math::multiply::Multiply;
//!
//! // Generate the network
//! let mut network: Network<f32> = Network::new();
//!
//! // Generate some operations
//! let add1 = network.add_operation(Add::new());
//! let mul1 = network.add_operation(Multiply::new());
//! let add2 = network.add_operation(Add::new());
//!
//! // Add some inputs
//! let in1 = network.add_input(Buffer::new());
//! let in2 = network.add_input(Buffer::new());
//! let in3 = network.add_input(Buffer::new());
//!
//! // Connect the operations with each other
//! network.add_connection(&in1, &add1).unwrap();
//! network.add_connection(&in2, &add1).unwrap();
//!
//! network.add_connection(&add1, &add2).unwrap();
//! network.add_connection(&in3, &add2).unwrap();
//!
//! network.add_connection(&add1, &mul1).unwrap();
//! network.add_connection(&add2, &mul1).unwrap();
//!
//! // Register the multiplication as an output
//! network.as_output(&mul1);
//!
//! // Insert a closed loop (Positive feedback loop)
//! network.close_loop(&mul1, &add2);
//!
//! // Generate the network
//! network.build();
//!
//! // Main loop operation
//!
//! // Update the inputs
//! network.set_inputs(|input, index | {
//!    *input = 5.0;
//! });
//! // Iterate over the network
//! network.process();
//! let res = network.get_outputs();
//!
//! // Update the inputs
//! network.set_inputs(|input, index | {
//!    *input = 10.0;
//! });
//! // Process twice to let the closed loop propagate
//! network.process();
//! let res = network.get_outputs();
//! ```
//!
//! # Outlook
//! Following features are planned before the first release:
//! 1. Signal and Control crates.
//! 2. Subnetworks to allow different time bases
//!

#![feature(type_alias_impl_trait)]
#![no_std]
pub mod operations;
pub mod network;

extern crate alloc;
extern crate graphlib;
extern crate assert_approx_eq;