-
Notifications
You must be signed in to change notification settings - Fork 5
/
bundles.rs
117 lines (100 loc) · 3.5 KB
/
bundles.rs
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
use crate::components::*;
use crate::transform::*;
use crate::visibility::*;
use bevy_ecs::prelude::*;
/// A Port is a connection point for an Endpoint. For sub-Circuits,
/// it also connects to an Input or Output Symbol in the child Circuit.
///
/// Ports have a Symbol or SymbolKind as a Parent
///
/// Ports optionally can have some of these additional components:
/// - EndpointID - the Endpoint that the Port is connected to (Symbol Ports only)
/// - Name - the name of the Port
/// - Number - the pin number of the Port
///
#[derive(Debug, Bundle)]
pub struct PortBundle {
// The marker that this is a Port
pub port: Port,
// The name of the Port
pub name: Name,
/// The bit width of the Port. This must match the bit width of any
/// connected subnet.
pub bit_width: BitWidth,
pub transform: TransformBundle,
pub visibility: VisibilityBundle,
pub bounds: BoundingBoxBundle,
pub directions: DirectionsBundle,
}
/// A Symbol is an instance of a SymbolKind. It has Port Children which
/// are its input and output Ports. It represents an all or part of an
/// electronic component.
///
/// Symbols have a Circuit as a Parent, and Ports as Children
///
/// Symbols optionally can have some of these additional components:
/// - DesignatorSuffix - the suffix for the Reference Designator
/// - PartOf - if the Symbol is part of a set of Symbols (ie one gate of a chip with many)
#[derive(Debug, Bundle)]
pub struct SymbolBundle {
/// The marker that this is a Symbol
pub symbol: Symbol,
/// The name of the Symbol
pub name: Name,
/// The designator prefix of the Symbol, cloned from SymbolKind
pub designator_prefix: DesignatorPrefix,
/// The designator number of the Symbol
pub designator_number: DesignatorNumber,
/// The SymbolKind that the Symbol is an instance of
pub symbol_kind: SymbolKind,
pub shape: Shape,
pub transform: TransformBundle,
pub visibility: VisibilityBundle,
pub bounds: BoundingBoxBundle,
}
/// An Endpoint is a connection point for a Net. It connects to a Port
/// in a Symbol. Its Parent is the Net that the Endpoint is part of.
/// It has Waypoint Children.
///
/// Endpoints have a Parent that is a Net and Waypoints as Children
///
/// Endpoints optionally can have some of these additional components:
/// - PortID - the Port that the Endpoint is connected to
#[derive(Debug, Bundle, Default)]
pub struct EndpointBundle {
/// The marker that this is an Endpoint
pub endpoint: Endpoint,
pub transform: TransformBundle,
pub visibility: VisibilityBundle,
pub bounds: BoundingBoxBundle,
}
/// A Net is a set of Endpoints that are connected together.
///
/// Nets have a Circuit as a Parent, and Endpoints as Children
///
/// Nets optionally can have some of these additional components:
/// - ???
#[derive(Debug, Bundle)]
pub struct NetBundle {
/// The marker that this is a Net
pub net: Net,
/// The name of the Net
pub name: Name,
/// The bit width of the Net
pub bit_width: BitWidth,
pub visibility: VisibilityBundle,
}
/// A Circuit is a set of Symbols and Nets forming an Electronic Circuit.
/// It has Symbol and Net Children, and a SymbolKind
///
/// Circuits have a Children component that contains the Symbols and Nets
///
/// Circuits optionally can have some of these additional components:
/// - ???
#[derive(Debug, Bundle, Default)]
pub struct CircuitBundle {
/// The marker that this is a Circuit
pub circuit: Circuit,
/// The name of the circuit
pub name: Name,
}