Commit 926c47af authored by Dan Sheppard's avatar Dan Sheppard
Browse files

Better error reporting.

parent 3b41e281
......@@ -5,7 +5,7 @@ const MAX_PENDING : i32 = 0;
const CACHE_SIZE : usize = 10;
use composit::{
ActiveSource, Leaf, Carriage, AllSourceResponseBuilder
ActiveSource, Leaf, Traveller, AllSourceResponseBuilder
};
pub struct ComponentManager {
......@@ -30,8 +30,8 @@ impl ComponentManager {
self.components.remove(k);
}
pub fn make_comp_carriages(&mut self, c: &ActiveSource, leaf: &Leaf) -> Vec<Carriage> {
let mut lcomps = Vec::<Carriage>::new();
pub fn make_comp_carriages(&mut self, c: &ActiveSource, leaf: &Leaf) -> Vec<Traveller> {
let mut lcomps = Vec::<Traveller>::new();
let asrb = AllSourceResponseBuilder::new(&c.list_parts());
let mut source = c.get_source().clone();
lcomps.push(c.make_carriage(&asrb,&None,&leaf));
......@@ -43,8 +43,8 @@ impl ComponentManager {
lcomps
}
pub fn make_leaf_carriages(&mut self, leaf: Leaf) -> Vec<Carriage> {
let mut lcomps = Vec::<Carriage>::new();
pub fn make_leaf_carriages(&mut self, leaf: Leaf) -> Vec<Traveller> {
let mut lcomps = Vec::<Traveller>::new();
debug!("redraw","make_carriages {:?}",leaf);
let comps : Vec<ActiveSource> = self.components.values().cloned().collect();
for c in &comps {
......
......@@ -24,7 +24,7 @@ pub use self::combinedstickmanager::CombinedStickManager;
pub use self::componentset::ComponentSet;
pub use self::compositor::{ Compositor, register_compositor_ticks };
pub use self::compmanager::{ ComponentManager };
pub use self::train::{ Train, TrainManager, Carriage, CarriageSet, StaleCarriages };
pub use self::train::{ Train, TrainManager, Traveller, TravellerSet, OldTravellers };
pub use self::stage::{ Stage };
pub use self::stick::Stick;
pub use self::stickmanager::StickManager;
......
......@@ -7,7 +7,7 @@ use std::rc::Rc;
use composit::state::StateExpr;
use composit::{
AllLandscapes, Landscape, Source,
Carriage, Leaf, AllSourceResponseBuilder, StateManager,
Traveller, Leaf, AllSourceResponseBuilder, StateManager,
StateValue
};
......@@ -43,9 +43,9 @@ impl ActiveSource {
self.parts.keys().filter(|x| x.is_some()).map(|x| x.as_ref().unwrap().clone()).collect()
}
pub fn make_carriage(&self, asrb: &AllSourceResponseBuilder, part: &Option<String>, leaf: &Leaf) -> Carriage {
pub fn make_carriage(&self, asrb: &AllSourceResponseBuilder, part: &Option<String>, leaf: &Leaf) -> Traveller {
let srr = asrb.get_srr(part);
Carriage::new(self.clone(),part,leaf,srr)
Traveller::new(self.clone(),part,leaf,srr)
}
pub fn populate(&mut self, resp: AllSourceResponseBuilder, leaf: &Leaf) {
......
mod carriage;
mod carriageset;
mod stalecarriages;
mod traveller;
mod travellerset;
mod oldtravellers;
mod train;
mod trainmanager;
pub use self::train::Train;
pub use self::trainmanager::TrainManager;
pub use self::carriage::Carriage;
pub use self::carriageset::CarriageSet;
pub use self::stalecarriages::StaleCarriages;
pub use self::traveller::Traveller;
pub use self::travellerset::TravellerSet;
pub use self::oldtravellers::OldTravellers;
use std::collections::HashMap;
use composit::Leaf;
pub struct StaleCarriages {
pub struct OldTravellers {
done_seen: HashMap<Leaf,u32>,
done_now: u32
}
impl StaleCarriages {
pub(in super) fn new() -> StaleCarriages {
StaleCarriages {
impl OldTravellers {
pub(in super) fn new() -> OldTravellers {
OldTravellers {
done_seen: HashMap::<Leaf,u32>::new(),
done_now: 1
}
}
pub(in super) fn all_stale(&mut self) {
pub(in super) fn all_old(&mut self) {
self.done_now += 1;
}
pub(in super) fn is_stale(&self, leaf: &Leaf) -> bool {
pub(in super) fn is_old(&self, leaf: &Leaf) -> bool {
let done_seen = *self.done_seen.get(leaf).unwrap_or(&0);
done_seen < self.done_now
}
pub(in super) fn not_stale(&mut self, leaf: &Leaf) {
pub(in super) fn not_old(&mut self, leaf: &Leaf) {
self.done_seen.insert(leaf.clone(),self.done_now);
}
pub(in super) fn set_stale(&mut self, leaf: &Leaf) {
pub(in super) fn set_old(&mut self, leaf: &Leaf) {
self.done_seen.remove(&leaf.clone());
}
}
use std::collections::HashSet;
use composit::{
Leaf, Carriage, StateManager, Scale,
ComponentManager, ActiveSource, Stick, CarriageSet, StaleCarriages
Leaf, Traveller, StateManager, Scale,
ComponentManager, ActiveSource, Stick, TravellerSet, OldTravellers
};
use composit::state::ComponentRedo;
const MAX_FLANK : i32 = 3;
pub struct Train {
carriages: CarriageSet,
stale: StaleCarriages,
carriages: TravellerSet,
stale: OldTravellers,
stick: Stick,
scale: Scale,
ideal_flank: i32,
......@@ -27,8 +27,8 @@ impl Train {
scale, preload: true,
ideal_flank: 0,
middle_leaf: 0,
carriages: CarriageSet::new(),
stale: StaleCarriages::new(),
carriages: TravellerSet::new(),
stale: OldTravellers::new(),
position_bp: None,
active: true
}
......@@ -74,7 +74,7 @@ impl Train {
let lcomps = cm.make_comp_carriages(c,&leaf);
self.add_carriages_to_leaf(leaf,lcomps);
}
self.stale.all_stale();
self.stale.all_old();
}
/* *****************************************************************
......@@ -93,7 +93,7 @@ impl Train {
}
/* add leafs created below */
fn add_carriages_to_leaf(&mut self, leaf: Leaf, mut cc: Vec<Carriage>) {
fn add_carriages_to_leaf(&mut self, leaf: Leaf, mut cc: Vec<Traveller>) {
for lc in cc.drain(..) {
self.carriages.add_carriage(&leaf,lc);
}
......@@ -126,7 +126,7 @@ impl Train {
for d in doomed {
debug!("trains","removing {}",d.get_index());
self.carriages.remove_leaf(&d);
self.stale.set_stale(&d);
self.stale.set_old(&d);
}
}
......@@ -165,7 +165,7 @@ impl Train {
}
/* used in LEAFPRINTER to get actual data to print from components */
pub fn get_carriages(&mut self, leaf: &Leaf) -> Option<Vec<&mut Carriage>> {
pub fn get_carriages(&mut self, leaf: &Leaf) -> Option<Vec<&mut Traveller>> {
if !self.is_done() { return None; }
Some(self.carriages.leaf_carriages(leaf))
}
......@@ -178,15 +178,15 @@ impl Train {
redo = redo | c.update_state(oom);
}
if redo == ComponentRedo::Major && self.is_done() {
self.stale.not_stale(&leaf);
self.stale.not_old(&leaf);
}
if redo != ComponentRedo::None {
debug!("redraw","{:?} {:?}",leaf,redo);
}
/* Any change due to availability? */
if self.stale.is_stale(&leaf) {
if self.stale.is_old(&leaf) {
if self.is_done() {
self.stale.not_stale(&leaf);
self.stale.not_old(&leaf);
debug!("redraw","stale {:?}",leaf);
return ComponentRedo::Major;
}
......
......@@ -8,7 +8,7 @@ use composit::{
use composit::state::{ StateManager, StateValue, ComponentRedo };
use drawing::DrawingSession;
pub struct Carriage {
pub struct Traveller {
comp: ActiveSource,
prev_value: StateValue,
cur_value: StateValue,
......@@ -18,9 +18,9 @@ pub struct Carriage {
leaf: Leaf
}
impl Carriage {
pub fn new(comp: ActiveSource, part: &Option<String>, leaf: &Leaf, srr: SourceResponseResult) -> Carriage {
Carriage {
impl Traveller {
pub fn new(comp: ActiveSource, part: &Option<String>, leaf: &Leaf, srr: SourceResponseResult) -> Traveller {
Traveller {
response: None,
prev_value: StateValue::OffCold(),
cur_value: StateValue::OffCold(),
......@@ -83,7 +83,7 @@ impl Carriage {
}
}
impl fmt::Debug for Carriage {
impl fmt::Debug for Traveller {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f,"{:?}:{:?}({:?})",self.comp,self.leaf,self.part)
}
......
use std::collections::HashMap;
use composit::{ Carriage, Leaf, ActiveSource };
use composit::{ Traveller, Leaf, ActiveSource };
#[derive(Debug)]
pub struct CarriageSet {
carriages: HashMap<Leaf,HashMap<(ActiveSource,Option<String>),Carriage>>
pub struct TravellerSet {
carriages: HashMap<Leaf,HashMap<(ActiveSource,Option<String>),Traveller>>
}
impl CarriageSet {
pub(in super) fn new() -> CarriageSet {
CarriageSet {
carriages: HashMap::<Leaf,HashMap<(ActiveSource,Option<String>),Carriage>>::new()
impl TravellerSet {
pub(in super) fn new() -> TravellerSet {
TravellerSet {
carriages: HashMap::<Leaf,HashMap<(ActiveSource,Option<String>),Traveller>>::new()
}
}
pub(in super) fn add_carriage(&mut self, leaf: &Leaf, carriage: Carriage) {
pub(in super) fn add_carriage(&mut self, leaf: &Leaf, carriage: Traveller) {
let lcc = self.carriages.entry(leaf.clone()).or_insert_with(||
HashMap::<(ActiveSource,Option<String>),Carriage>::new()
HashMap::<(ActiveSource,Option<String>),Traveller>::new()
);
lcc.insert((carriage.get_source().clone(),
carriage.get_part().clone()),carriage);
......@@ -33,8 +33,8 @@ impl CarriageSet {
self.carriages.keys().collect()
}
pub(in super) fn all_carriages(&self) -> Vec<&Carriage> {
let mut out = Vec::<&Carriage>::new();
pub(in super) fn all_carriages(&self) -> Vec<&Traveller> {
let mut out = Vec::<&Traveller>::new();
for lcc in self.carriages.values() {
for lc in lcc.values() {
out.push(lc);
......@@ -43,7 +43,7 @@ impl CarriageSet {
out
}
pub(in super) fn leaf_carriages(&mut self, leaf: &Leaf) -> Vec<&mut Carriage> {
pub(in super) fn leaf_carriages(&mut self, leaf: &Leaf) -> Vec<&mut Traveller> {
if let Some(lcc) = self.carriages.get_mut(leaf) {
lcc.values_mut().collect()
} else {
......
......@@ -39,7 +39,7 @@ impl EventListener<()> for StartupEventListener {
if config_url.is_none() {
console!("BROWSER APP REFUSING TO START UP! No config-url supplied");
}
let config_url = expect!(Url::parse(&expect!(config_url)).ok());
let config_url = expectok!(Url::parse(&expect!(config_url)));
g.register_app(&key,&expect!(cx.target().try_into()),false,&config_url);
},
_ => ()
......
......@@ -10,7 +10,7 @@ use rand::rngs::SmallRng;
use rand::SeedableRng;
use composit::{
StateFixed, StateValue, StateAtom, Leaf, Carriage,
StateFixed, StateValue, StateAtom, Leaf, Traveller,
AllSourceResponseBuilder, Stick
};
......
use std::collections::HashMap;
use std::collections::hash_map::Entry;
use composit::Carriage;
use composit::Traveller;
use drawing::{ OneCanvasManager, FlatCanvas, AllCanvasAllocator };
use program::{ CanvasCache, CanvasWeave };
......
......@@ -2,7 +2,7 @@ use std::rc::Rc;
use print::{ Programs, PrintEdition };
use program::ProgramType;
use composit::{ Carriage, Leaf, Stage, ComponentRedo, Train };
use composit::{ Traveller, Leaf, Stage, ComponentRedo, Train };
use drawing::{ DrawingSession, AllCanvasAllocator };
use dom::webgl::WebGLRenderingContext as glctx;
......@@ -31,7 +31,7 @@ impl LeafPrinter {
PrintEdition::new(&mut self.ds)
}
fn redraw_drawings(&mut self, alloc: &mut AllCanvasAllocator, comps: &mut Vec<&mut Carriage>) {
fn redraw_drawings(&mut self, alloc: &mut AllCanvasAllocator, comps: &mut Vec<&mut Traveller>) {
self.ds.finish(alloc);
self.ds = alloc.make_drawing_session();
for mut c in comps.iter_mut() {
......@@ -40,7 +40,7 @@ impl LeafPrinter {
self.ds.finalise(alloc);
}
fn redraw_objects(&mut self, comps: &mut Vec<&mut Carriage>,
fn redraw_objects(&mut self, comps: &mut Vec<&mut Traveller>,
e: &mut PrintEdition) {
for c in comps.iter_mut() {
if c.is_on() {
......@@ -60,7 +60,7 @@ impl LeafPrinter {
e.go(&mut self.progs);
}
fn redraw_carriages(&mut self, comps: &mut Vec<&mut Carriage>, aca: &mut AllCanvasAllocator, do_drawings: bool) {
fn redraw_carriages(&mut self, comps: &mut Vec<&mut Traveller>, aca: &mut AllCanvasAllocator, do_drawings: bool) {
self.init();
let mut e = self.new_edition();
if do_drawings {
......
......@@ -37,6 +37,13 @@ macro_rules! vec_s {
}}
}
macro_rules! console_error {
($($arg:tt)*) => {{
let s = format!($($arg)*);
js! { console.error(@{s}); };
}}
}
macro_rules! console_force {
($($arg:tt)*) => {{
let s = format!($($arg)*);
......@@ -67,3 +74,14 @@ macro_rules! expect {
$x.expect(&s)
}}
}
macro_rules! expectok {
($x: expr) => {{
let s = format!("ENSEMBL ERROR LOCATION {}/{}/{}",file!(),line!(),column!());
let x = $x;
if let Err(ref msg) = x {
console_error!("OK Failed: {}",&msg);
}
x.expect(&s)
}}
}
......@@ -620,6 +620,9 @@ Module.STDWEB_PRIVATE.acquire_tmp = function( dummy ) {
"__cargo_web_snippet_31f6071b77215fa0db4e2754d20833403f06a364": function($0) {
var r = Module.STDWEB_PRIVATE.acquire_js_reference( $0 );return (r instanceof DOMException) && (r.name === "InvalidAccessError");
},
"__cargo_web_snippet_329384458774100c384d2588238c10f110e8f7b6": function($0, $1) {
$1 = Module.STDWEB_PRIVATE.to_js($1);Module.STDWEB_PRIVATE.from_js($0, (function(){console.error(($1));})());
},
"__cargo_web_snippet_32f73e1a10ada3bafa29a60084c3c7200043017d": function($0, $1) {
$1 = Module.STDWEB_PRIVATE.to_js($1);Module.STDWEB_PRIVATE.from_js($0, (function(){return($1).top;})());
},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment