Moving waves checks the room the broker would sell: bandwidth for managed waves, and what is kept back
Managed waves need a channel as big as the wave and their bandwidth spare after your own traffic and the share kept back, on leased fiber too. A move bumps CM_V so their capacity follows them, merging needs the same size, and alien waves leave the kept-back channels alone. Pinned customers' badges share one path graph per routing result.
This commit is contained in:
parent
93d7c87dc7
commit
3554e9f700
10 changed files with 96 additions and 8 deletions
|
|
@ -8,8 +8,13 @@ const trenchOf=l=>l.kind==='vxc'?'fab:'+l.prov:(l.trench||l.id);
|
|||
const pathCity=c=>CITY[c].name,pathStr=p=>p.map(pathCity).join(' → ');
|
||||
const samePair=(l,a,b)=>(l.a===a&&l.b===b)||(l.a===b&&l.b===a);
|
||||
const fibLab=l=>tr('customer_paths.fiber_label',{name:l.cname?esc(l.cname):capName(l),km:Math.round(l.km).toLocaleString()});
|
||||
// Why this fiber cannot take this customer, in the same terms as the offers for it.
|
||||
function fiberNo(b,l){if(b.type==='wwave'){const n=b.slots||1,free=freeCh(l);return free>=n?'':tr('customer_paths.not_enough_free_channels',{free:Math.max(0,free),n});}
|
||||
// Why this fiber cannot take this customer, in the same terms as the market that sold it: waves only where the broker
|
||||
// could sell them, after the share kept back for your own traffic.
|
||||
function fiberNo(b,l){const n=b.slots||1,hold=S.cm.hold;
|
||||
if(b.type==='wwave'){const free=freeCh(l),spare=cmSpare(l,'spec');return spare>=n?'':free<n?tr('customer_paths.not_enough_free_channels',{free:Math.max(0,free),n}):tr('customer_paths.not_enough_spare_channels',{free:spare,n,hold});}
|
||||
// A managed wave rides one channel of your lit capacity, so it needs an optic that big and that many Gbps spare.
|
||||
if(b.type==='mwave'){const g=b.g||100,free=Math.max(0,cmFreeG(l));if(cmOptG(l)<g)return tr('customer_paths.needs_a_g_channel',{g:fmtCap(g)});
|
||||
return free>=n*g?'':tr('customer_paths.not_enough_spare_capacity',{free:fmtCap(free),g:fmtCap(n*g),hold});}
|
||||
if(!l.own)return tr('customer_paths.only_your_own_fiber_rents_pairs');
|
||||
if(b.type==='dfpair')return pairFree(l)?'':tr('customer_paths.its_spare_pairs_are_taken');
|
||||
return S.biz.some(x=>x!==b&&x.link===l.id&&['pairs','capfib','dfpair'].includes(x.type))?tr('customer_paths.its_spare_pairs_are_taken'):'';}
|
||||
|
|
@ -28,7 +33,10 @@ function pathWalk(G,a,b,cost){const dist={[a]:0},prev={},done=new Set();for(;;){
|
|||
for(const e of G.N[u]||[]){const v=e.a===u?e.b:e.a,nd=ud+cost(e);if(nd<(dist[v]??Infinity)){dist[v]=nd;prev[v]=u;}}}
|
||||
if(dist[b]===undefined)return null;const p=[b];while(p[0]!==a)p.unshift(prev[p[0]]);return p;}
|
||||
const pathHops=(G,p)=>{const o=[];for(let i=1;i<p.length;i++){const e=G.E[hopKey(p[i-1],p[i])];if(!e)return null;o.push(e);}return o;};
|
||||
const pinUp=b=>!!pathHops(pathEdges(),b.pin);
|
||||
// The panels ask for every pinned customer: one graph per routing (a new R), not one per customer.
|
||||
let PIN_G=null;
|
||||
const pinG=()=>{const c=PIN_G;if(!c||c.R!==R||c.S!==S||c.d!==S.day||c.n!==S.links.length)PIN_G={R,S,d:S.day,n:S.links.length,G:pathEdges()};return PIN_G.G;};
|
||||
const pinUp=b=>!!pathHops(pinG(),b.pin);
|
||||
// Where the circuit runs today. Scenic circuits remember it; the others take the shortest path of their kind.
|
||||
function pathNow(b,G){if(b.pin&&pathHops(G,b.pin))return b.pin;
|
||||
const r=R.l2route&&R.l2route[b.id+'>'+b.city+'>'+b.city2];if(r&&r[0]){const p=r[0].ns.slice();if(p[0]!==b.city)p.reverse();if(pathHops(G,p))return p;}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
Object.assign(ACT,{
|
||||
pathOpen:({id})=>{const b=S.biz.find(x=>x.id===id);if(b&&pathKind(b))pathModal(b);},
|
||||
pathMove:({id,link})=>{const b=S.biz.find(x=>x.id===id),l=b&&pathKind(b)==='fiber'&&fiberTargets(b).find(t=>t.l.id===link&&!t.no);if(!l)return;
|
||||
// A carrier already renting waves on that fiber: one contract, as when it orders more there.
|
||||
const more=b.type==='wwave'&&S.biz.find(x=>x!==b&&x.type==='wwave'&&x.link===link&&x.name===b.name);
|
||||
if(more){more.slots=(more.slots||0)+(b.slots||0);more.rate+=b.rate;more.since=Math.min(more.since??0,b.since??0);more.mood=Math.min(more.mood??100,b.mood??100);more.what=wwWhat(l.l,more.slots);S.biz=S.biz.filter(x=>x!==b);}
|
||||
else{b.link=link;if(b.type==='wwave')b.what=wwWhat(l.l,b.slots||1);}
|
||||
// A carrier already renting waves of that kind (and size) on that fiber: one contract, as when it orders more there.
|
||||
const wv=b.type==='wwave'||b.type==='mwave',what=(x,n)=>b.type==='wwave'?wwWhat(l.l,n):cmWhat(l.l,cmWP(x.g),n);
|
||||
const more=wv&&S.biz.find(x=>x!==b&&x.type===b.type&&x.link===link&&x.name===b.name&&x.g===b.g);
|
||||
if(more){more.slots=(more.slots||0)+(b.slots||0);more.rate+=b.rate;more.since=Math.min(more.since??0,b.since??0);more.mood=Math.min(more.mood??100,b.mood??100);more.what=what(more,more.slots);S.biz=S.biz.filter(x=>x!==b);}
|
||||
else{b.link=link;if(wv)b.what=what(b,b.slots||1);}
|
||||
CM_V++; // managed waves come off their fiber's capacity (mwG()), which caches by fiber
|
||||
closeModal();toast(tr('customer_paths.name_moved_to_fiber',{name:esc(b.name),fiber:fibLab(l.l)}),'good');sfx('build');after();},
|
||||
pathPin:({id,via})=>{const b=S.biz.find(x=>x.id===id);if(!b||pathKind(b)!=='circuit'||typeof via!=='string')return;const p=via.split(',');
|
||||
if(p.length<2||p[0]!==b.city||p[p.length-1]!==b.city2||new Set(p).size!==p.length||!pathHops(pathEdges(),p))return;
|
||||
|
|
|
|||
|
|
@ -1769,9 +1769,12 @@
|
|||
"customer_paths.name_follows_routing_again":"<b>{name}</b> follows routing again.",
|
||||
"customer_paths.name_moved_to_fiber":"<b>{name}</b> moved to {fiber}.",
|
||||
"customer_paths.name_now_rides_path":"<b>{name}</b> now rides {path}.",
|
||||
"customer_paths.needs_a_g_channel":"Needs a channel lit at {g} or more",
|
||||
"customer_paths.no_other_path":"There is no other working path between {a} and {b} right now.",
|
||||
"customer_paths.no_other_working_fiber":"There is no other working fiber between {a} and {b}. Build one, and you can move this customer onto it.",
|
||||
"customer_paths.not_enough_free_channels":"Not enough free channels: {free} free, needs {n}",
|
||||
"customer_paths.not_enough_spare_capacity":"Not enough spare capacity: {free} left after your own traffic and the {hold}% you keep back, needs {g}",
|
||||
"customer_paths.not_enough_spare_channels":"Not enough spare channels: {free} left after the {hold}% you keep back for your own traffic, needs {n}",
|
||||
"customer_paths.now_on":"Now on",
|
||||
"customer_paths.only_your_own_fiber_rents_pairs":"Only your own fiber can rent out pairs",
|
||||
"customer_paths.over_the_ms_budget":"Over the {ms} ms budget",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue