pub struct Turnout { /* private fields */ }
Expand description
Turnout track struct
Implementations§
Source§impl Turnout
impl Turnout
Sourcepub fn new(
layer: u32,
options: u32,
postion: u32,
scale: Scale,
flags: u32,
origx: f64,
origy: f64,
elev: u32,
angle: f64,
tablist: String,
adjopt: Option<(f64, f64)>,
pieropt: Option<(f64, String)>,
body: TurnoutBody,
) -> Self
pub fn new( layer: u32, options: u32, postion: u32, scale: Scale, flags: u32, origx: f64, origy: f64, elev: u32, angle: f64, tablist: String, adjopt: Option<(f64, f64)>, pieropt: Option<(f64, String)>, body: TurnoutBody, ) -> Self
Initialize a new turnout
§Parameters:
- layer the layer the turnout is on
- options its options
- postion the position of the points
- scale the model scale
- flags its flags
- origx org X
- origy org Y
- elev elevation
- angle its angle
- tablist tab separated list of strings
- adjopt optional adjustments
- pieropt optiona pier
- body its body (track ends. etc.)
Returns a fresh new Turnout struct
pub fn Layer(&self) -> u32
pub fn Options(&self) -> u32
pub fn Postion(&self) -> u32
pub fn Scale(&self) -> Scale
pub fn Flags(&self) -> u32
pub fn OrigX(&self) -> f64
pub fn OrigY(&self) -> f64
pub fn Elev(&self) -> u32
pub fn Angle(&self) -> f64
Sourcepub fn Tablist(&self) -> String
pub fn Tablist(&self) -> String
Examples found in repository?
examples/PrintAllControlScripts/main.rs (line 153)
80fn main() {
81 let args: Vec<String> = env::args().collect();
82 let program = args[0].clone();
83
84 let mut opts = Options::new();
85 opts.optflag("b", "blocks", "print Blocks");
86 opts.optflag("m", "switchmotors", "print Switchmotors");
87 opts.optflag("s", "signals", "print Signals ");
88 opts.optflag("c", "controls", "print Controls");
89 opts.optflag("x", "sensors", "print Sensors");
90 opts.optflag("a", "all", "print all (this is the default)");
91 opts.optflag("h", "help", "print this help menu");
92 let matches = match opts.parse(&args[1..]) {
93 Ok(m) => { m },
94 Err(f) => { panic!("{}", f.to_string()); },
95 };
96 if matches.opt_present("h") {
97 print_usage(&program, opts);
98 return ();
99 };
100 let mut blocks: bool = false;
101 let mut switchmotors: bool = false;
102 let mut signals: bool = false;
103 let mut controls: bool = false;
104 let mut sensors: bool = false;
105 let mut all: bool = true;
106 if matches.opt_present("b") {
107 blocks = true;
108 all = false;
109 }
110 if matches.opt_present("m") {
111 switchmotors = true;
112 all = false;
113 }
114 if matches.opt_present("s") {
115 signals = true;
116 all = false;
117 }
118 if matches.opt_present("c") {
119 controls = true;
120 all = false;
121 }
122 if matches.opt_present("x") {
123 sensors = true;
124 all = false;
125 }
126 if matches.opt_present("a") {
127 all = true;
128 }
129 let layoutfile = if !matches.free.is_empty() {
130 matches.free[0].clone()
131 } else {
132 print_usage(&program, opts);
133 panic!("Missing layout file!");
134 };
135 let layout = match Layout::new(layoutfile) {
136 Ok(l) => { l },
137 Err(message) => { panic!("{}",message.to_string()); },
138 };
139 println!("{}",layout);
140 if blocks || all {
141 for (index, block) in layout.BlockIter() {
142 println!("Block # {}:",*index);
143 println!("\tName: {}",block.Name());
144 println!("\tScript: {}",block.Script());
145 println!("\tTrack list: {}",block.Tracklist());
146 }
147 }
148 if switchmotors || all {
149 for (index, switchmotor) in layout.SwitchMotorIter() {
150 println!("SwitchMotor # {}:",*index);
151 println!("\tName: {}",switchmotor.Name());
152 let turnout = layout.Turnout(switchmotor.Turnout()).expect("Should not happen");
153 let tablist = turnout.Tablist();
154 let tabelts: Vec<&str> = tablist.split('\t').collect();
155 println!("\tTurnout #{} ({})",switchmotor.Turnout(),tabelts[1]);
156 println!("\tNormal: {}",switchmotor.Normal());
157 println!("\tReverse: {}",switchmotor.Reverse());
158 println!("\tPoint Sense: {}",switchmotor.Pointsense());
159 }
160 }
161 if signals || all {
162 for (index, signal) in layout.SignalIter() {
163 println!("Signal # {}:",*index);
164 println!("\tName: {}",signal.Name());
165 println!("\tHeads: {}",signal.Numheads());
166 let aspects = signal.Aspectlist();
167 if aspects.len() > 0 {
168 println!("\tAspects:");
169 for ia in 0..aspects.len() {
170 let aspect = &aspects[ia];
171 println!("\t\t{}: {}",aspect.Name(), aspect.Script());
172 }
173 }
174 }
175 }
176 if sensors || all {
177 for (index, sensor) in layout.SensorIter() {
178 println!("Sensor # {}",*index);
179 println!("\tName: {}",sensor.Name());
180 println!("\tScript: {}",sensor.Script());
181 }
182 }
183 if controls || all {
184 for (index, control) in layout.ControlIter() {
185 println!("Control # {}",*index);
186 println!("\tName: {}",control.Name());
187 println!("\tOn Script: {}",control.OnScript());
188 println!("\tOff Script: {}",control.OffScript());
189 }
190 }
191}
pub fn AdjOpt(&self) -> Option<(f64, f64)>
pub fn PierOpt(&self) -> Option<(f64, String)>
pub fn Body(&self) -> TurnoutBody
Trait Implementations§
impl StructuralPartialEq for Turnout
Auto Trait Implementations§
impl Freeze for Turnout
impl RefUnwindSafe for Turnout
impl Send for Turnout
impl Sync for Turnout
impl Unpin for Turnout
impl UnwindSafe for Turnout
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more