forked from M-Labs/ionpak-thermostat
report measurements on HTTP page
This commit is contained in:
parent
5d4a223800
commit
93d0401b71
|
@ -85,11 +85,3 @@ impl Electrometer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ElectrometerStatus {
|
|
||||||
pub fn debug_print(&self) {
|
|
||||||
if self.ic.is_some() {
|
|
||||||
println!("ion: {}nA", 1e9*self.ic.unwrap());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -21,13 +21,25 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="w3-container">
|
<div class="w3-container">
|
||||||
<p>Pressure:</p>
|
<h3>Pressure</h3>
|
||||||
|
<div class="w3-card w3-xxlarge">
|
||||||
|
{pressure:.1e} mbar
|
||||||
</div>
|
</div>
|
||||||
<div class="w3-container w3-xxlarge">
|
|
||||||
2.3×10<sup>-7</sup> mbar
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="w3-container">
|
<div class="w3-container">
|
||||||
|
<h3>Details</h3>
|
||||||
|
<table class="w3-table">
|
||||||
|
<tr><th>Parameter</th><th>Current</th><th>Target</th></tr>
|
||||||
|
<tr><td>Anode regulator ready</td><td>{anode_ready}</td></tr>
|
||||||
|
<tr><td>Anode voltage</td><td>{anode_av:.1}V</td></tr>
|
||||||
|
<tr><td>Cathode regulator ready</td><td>{cathode_ready}</td></tr>
|
||||||
|
<tr><td>Electron current</td><td>{cathode_fbi:.0}μA</td></tr>
|
||||||
|
<tr><td>Filament voltage</td><td>{cathode_fv:.2}V</td><td>{cathode_fv_target:.2}V</td></tr>
|
||||||
|
<tr><td>Cathode bias</td><td>{cathode_fbv:.1}V</td></tr>
|
||||||
|
<tr><td>Ion current</td><td>{ion_current:.5}nA</td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
At local time:
|
At local time:
|
||||||
<script language="Javascript">
|
<script language="Javascript">
|
||||||
|
|
|
@ -67,12 +67,3 @@ impl Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ControllerStatus {
|
|
||||||
pub fn debug_print(&self) {
|
|
||||||
println!("anode rdy: {}", self.ready);
|
|
||||||
if self.av.is_some() {
|
|
||||||
println!("voltage: {}V", self.av.unwrap());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -157,18 +157,3 @@ impl Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ControllerStatus {
|
|
||||||
pub fn debug_print(&self) {
|
|
||||||
println!("cathode rdy: {}", self.ready);
|
|
||||||
if self.fbi.is_some() {
|
|
||||||
println!("emi: {}mA", 1000.0*self.fbi.unwrap());
|
|
||||||
}
|
|
||||||
if self.fv.is_some() {
|
|
||||||
println!("fil: {}V", self.fv.unwrap());
|
|
||||||
}
|
|
||||||
if self.fbv.is_some() {
|
|
||||||
println!("bias: {}V", self.fbv.unwrap());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ macro_rules! println {
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[lang = "panic_fmt"]
|
#[lang = "panic_fmt"]
|
||||||
fn panic_fmt(args: core::fmt::Arguments, file: &'static str, line: u32) -> ! {
|
pub fn panic_fmt(args: core::fmt::Arguments, file: &'static str, line: u32) -> ! {
|
||||||
println!("panic at {}:{}: {}", file, line, args);
|
println!("panic at {}:{}: {}", file, line, args);
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,6 @@ fn main() {
|
||||||
board::start_adc();
|
board::start_adc();
|
||||||
|
|
||||||
let mut next_blink = 0;
|
let mut next_blink = 0;
|
||||||
let mut next_info = 0;
|
|
||||||
let mut led_state = true;
|
let mut led_state = true;
|
||||||
let mut latch_reset_time = None;
|
let mut latch_reset_time = None;
|
||||||
loop {
|
loop {
|
||||||
|
@ -211,7 +210,7 @@ fn main() {
|
||||||
match request_status {
|
match request_status {
|
||||||
Ok(true) => {
|
Ok(true) => {
|
||||||
if socket.can_send() {
|
if socket.can_send() {
|
||||||
pages::serve(socket, &request);
|
pages::serve(socket, &request, &LOOP_ANODE, &LOOP_CATHODE, &ELECTROMETER);
|
||||||
}
|
}
|
||||||
request.reset();
|
request.reset();
|
||||||
socket.close();
|
socket.close();
|
||||||
|
@ -239,27 +238,6 @@ fn main() {
|
||||||
board::set_led(1, led_state);
|
board::set_led(1, led_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
if time >= next_info {
|
|
||||||
let (anode, cathode, electrometer) = cortex_m::interrupt::free(|cs| {
|
|
||||||
(LOOP_ANODE.borrow(cs).borrow().get_status(),
|
|
||||||
LOOP_CATHODE.borrow(cs).borrow().get_status(),
|
|
||||||
ELECTROMETER.borrow(cs).borrow().get_status())
|
|
||||||
});
|
|
||||||
|
|
||||||
println!("");
|
|
||||||
anode.debug_print();
|
|
||||||
cathode.debug_print();
|
|
||||||
electrometer.debug_print();
|
|
||||||
if cathode.fbi.is_some() && electrometer.ic.is_some() {
|
|
||||||
let fbi = cathode.fbi.unwrap();
|
|
||||||
let ic = electrometer.ic.unwrap();
|
|
||||||
let pressure = ic/fbi/18.75154;
|
|
||||||
println!("{:.1e} mbar", pressure);
|
|
||||||
}
|
|
||||||
|
|
||||||
next_info = next_info + 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
board::process_errors();
|
board::process_errors();
|
||||||
if board::error_latched() {
|
if board::error_latched() {
|
||||||
match latch_reset_time {
|
match latch_reset_time {
|
||||||
|
|
|
@ -1,13 +1,65 @@
|
||||||
|
use core::fmt;
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
|
use core::cell::RefCell;
|
||||||
|
use cortex_m;
|
||||||
|
use cortex_m::interrupt::Mutex;
|
||||||
use smoltcp::socket::TcpSocket;
|
use smoltcp::socket::TcpSocket;
|
||||||
use http;
|
|
||||||
|
|
||||||
pub fn serve(output: &mut TcpSocket, request: &http::Request) {
|
use http;
|
||||||
|
use loop_anode;
|
||||||
|
use loop_cathode;
|
||||||
|
use electrometer;
|
||||||
|
|
||||||
|
struct OpnFmt(Option<f32>);
|
||||||
|
|
||||||
|
impl fmt::Display for OpnFmt {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
match self.0 {
|
||||||
|
None => f.write_str("ERROR"),
|
||||||
|
Some(x) => x.fmt(f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::LowerExp for OpnFmt {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
match self.0 {
|
||||||
|
None => f.write_str("ERROR"),
|
||||||
|
Some(x) => x.fmt(f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn serve(output: &mut TcpSocket, request: &http::Request,
|
||||||
|
loop_anode_m: &Mutex<RefCell<loop_anode::Controller>>,
|
||||||
|
loop_cathode_m: &Mutex<RefCell<loop_cathode::Controller>>,
|
||||||
|
electrometer_m: &Mutex<RefCell<electrometer::Electrometer>>) {
|
||||||
match request.get_path().unwrap() {
|
match request.get_path().unwrap() {
|
||||||
b"/" => {
|
b"/" => {
|
||||||
let data = include_str!("index.html");
|
let (anode, cathode, electrometer) = cortex_m::interrupt::free(|cs| {
|
||||||
|
(loop_anode_m.borrow(cs).borrow().get_status(),
|
||||||
|
loop_cathode_m.borrow(cs).borrow().get_status(),
|
||||||
|
electrometer_m.borrow(cs).borrow().get_status())
|
||||||
|
});
|
||||||
|
|
||||||
|
let pressure = electrometer.ic.and_then(|ic| {
|
||||||
|
if ic > 1.0e-12 {
|
||||||
|
cathode.fbi.and_then(|fbi| Some(ic/fbi/18.75154))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
});
|
||||||
http::write_reply_header(output, 200, "text/html; charset=utf-8", false).unwrap();
|
http::write_reply_header(output, 200, "text/html; charset=utf-8", false).unwrap();
|
||||||
output.write_str(data).unwrap();
|
write!(output, include_str!("index.html"),
|
||||||
|
pressure=OpnFmt(pressure),
|
||||||
|
anode_ready=anode.ready,
|
||||||
|
anode_av=OpnFmt(anode.av),
|
||||||
|
cathode_ready=cathode.ready,
|
||||||
|
cathode_fbi=OpnFmt(cathode.fbi.and_then(|x| Some(x*1.0e6))),
|
||||||
|
cathode_fv=OpnFmt(cathode.fv),
|
||||||
|
cathode_fv_target=OpnFmt(cathode.fv_target),
|
||||||
|
cathode_fbv=OpnFmt(cathode.fbv),
|
||||||
|
ion_current=OpnFmt(electrometer.ic.and_then(|x| Some(x*1.0e9)))).unwrap();
|
||||||
},
|
},
|
||||||
b"/style.css" => {
|
b"/style.css" => {
|
||||||
let data = include_bytes!("style.css.gz");
|
let data = include_bytes!("style.css.gz");
|
||||||
|
|
Loading…
Reference in New Issue