Differences From
Artifact [5db02bfe42]:
27 27 local job_t = starlit.store.compilerJob
28 28 local conf = state.pgm.file.body.conf
29 29 table.insert(conf, {
30 30 key='job', value=job_t.enc {
31 31 schematic = scm.id;
32 32 cyclesLeft = scm.sw.cost and scm.sw.cost.cycles or 0;
33 33 timeLeft = (fab.time and fab.time.print or 0);
34 + powerLeft = cost.power;
35 + numinaLeft = cost.numina;
34 36 }
35 37 })
36 38 end
37 39
38 40 local function compilerCanPrint(user, cpl, scm)
39 41 local E = starlit.mod.electronics
40 42 local output = ItemStack(scm.sw.output):get_definition()
................................................................................
44 46 user.entity:get_inventory():get_list 'main';
45 47 }
46 48
47 49 local cost = {
48 50 fab = fab, output = output;
49 51 consume = consume, unsat = unsat, leftover = leftover, itemSpec = itemSpec;
50 52 runtimeEstimate = scm.speed + cpl.speed + (fab.time and fab.time.print or 0);
51 - power = cpl.powerCost + scm.powerCost;
53 + power = cpl.powerCost + scm.powerCost
54 + + (sw.input.cost and sw.input.cost.power);
52 55 ram = (cpl.cost and cpl.cost.ram or 0)
53 56 + (scm.cost and scm.cost.ram or 0);
54 57 cycles = (cpl.cost and cpl.cost.cycles or 0)
55 58 + (scm.cost and scm.cost.cycles or 0);
59 + numina = fab.cost and fab.cost.numina or 0;
56 60 }
57 61
58 62 local userComp = E.chip.sumCompute(
59 63 user.entity:get_inventory():get_list 'starlit_suit_chips'
60 64 )
61 65
62 66 if ok and cost.power <= user:suitCharge() and cost.ram <= userComp.ram then
................................................................................
265 269 end
266 270 end
267 271 end
268 272
269 273 end;
270 274
271 275 render = function(state, user)
272 - local sel, pgmSelector = state.select, {}
276 + local sel, pgmSelector = state.select, {kind = 'vert'}
273 277 state.fetch()
274 278 state.ctx.pullConf()
275 279
276 - local function pushSelector(id, item, label, desc, req)
280 + local function pushSelector(tbl, id, item, label, desc, req, w)
281 + w = w or 12
277 282 local rh = .5
278 - local label = {kind = 'text', w = 10-1.5, h=1.5;
279 - text = '<global valign=middle>'..lib.str.htsan(label) }
283 + local label = {kind = 'text', w = w-1.5, h=1.6;
284 + text = '<global valign=middle>'..lib.str.htsan(label) }
280 285 if req then
281 286 label.h = label.h - rh - .2
282 287
283 288 local imgs = {}
284 289 for ci,c in ipairs(req) do
285 290 for ei, e in ipairs(c.list) do
286 291 table.insert(imgs, {kind = 'img', w=rh, h=rh, img=e.img})
287 292 end
288 293 end
289 - label = {kind = 'vert', w = 10-1.5, h=1.5;
294 + label = {kind = 'vert', w = w-1.5, h=1.8;
290 295 label;
291 - {kind ='hztl', w=10-1.5, h=rh; unpack(imgs); }
296 + {kind ='hztl', w=w-1.5, h=rh; unpack(imgs); }
292 297 }
293 298 end
294 - table.insert(pgmSelector, {kind = 'hztl', w=10,h=1.5;
299 + table.insert(tbl, {kind = 'hztl', w=w,h=1.8;
295 300 {kind = 'contact', id=id, w=1.5, h=1.5;
296 301 item = item;
297 302 color = {hue=220, sat=0, lum=0};
298 303 desc = desc;
299 304 };
300 305 label;
301 306 })
302 307 end
303 308
304 - local back = {kind = 'button', id='back', label = '<- Back', w=10,h=1.2}
309 + local back = {kind = 'button', id='back', label = '<- Back', w=12,h=1.2}
305 310 if sel.chips == nil then
306 311 table.insert(pgmSelector, {kind = 'img', img = 'starlit-ui-alert.png', w=2, h=2})
307 312 elseif sel.chip == nil then
308 313 for i, c in ipairs(sel.chips.order) do
309 314 -- TODO filter out chips without schematics?
310 - pushSelector('chip_' .. c.data.uuid, c.stack, c.data.label)
315 + pushSelector(pgmSelector, 'chip_' .. c.data.uuid, c.stack, c.data.label)
311 316 end
312 317 if next(sel.chips.order) then
313 - table.insert(pgmSelector, {kind = 'hztl', w=10,h=1.5;
314 - {kind = 'button', w=5,h=1.5; id='showAll', label='Show All'};
315 - {kind = 'button', w=5,h=1.5; id='find', label='Find'};
318 + table.insert(pgmSelector, {kind = 'hztl', w=12,h=1.5;
319 + {kind = 'button', w=6,h=1.5; id='showAll', label='Show All'};
320 + {kind = 'button', w=6,h=1.5; id='find', label='Find'};
316 321 })
317 322 end
318 323 else
319 324 if sel.scm == nil then
325 + -- l m a o
326 +-- pgmSelector.kind = 'hwrap'
327 +-- pgmSelector.cols = 2
328 + local wrap = {kind='hwrap',cols=2,w=12}
320 329 for idx, ent in ipairs(sel.scms) do
321 330 local fab = ent.sw.input
322 331 if fab.flag and fab.flag.print then
323 332 local req = fab:visualize()
324 - pushSelector('scm_' .. idx, ent.sw.output, ent.sw.name, nil, req)
333 + pushSelector(wrap,'scm_' .. idx, ent.sw.output, ent.sw.name, nil, req,6)
325 334 end
326 335 end
336 + table.insert(pgmSelector, wrap)
327 337 table.insert(pgmSelector, back)
328 338 else
329 339 local scm = sel.scms[sel.scm]
330 340 local output = ItemStack(scm.sw.output):get_definition()
331 341 local fab = scm.sw.input
332 342 local sw = scm.sw
333 343 local function unmet(str)
334 344 return lib.color(1,.3,.3):fmt(str)
335 345 end
336 - table.insert(pgmSelector, {kind = 'hztl', w=10, h=1.2;
346 + table.insert(pgmSelector, {kind = 'hztl', w=12, h=1.2;
337 347 {kind = 'img', item = sw.output, w=1.2, h=1.2, desc=output.description};
338 - {kind = 'text', text = string.format('<global valign=middle><b>%s</b>', lib.str.htsan(sw.name)), w=10-1.2,h=1.2};
348 + {kind = 'text', text = string.format('<global valign=middle><b>%s</b>', lib.str.htsan(sw.name)), w=12-1.2,h=1.2};
339 349 })
340 - local inputTbl = {kind = 'vert', w=5,h=0;
341 - {kind = 'hbar', w=5, h=.5, text=sel.input and 'Input Plan' or 'Input'}};
342 - local costTbl = {kind = 'vert', w=5,h=0;
343 - {kind = 'hbar', w=5, h=.5, text=sel.input and 'Process Plan' or 'Process'}};
344 - local reqPane = {kind = 'pane', id='reqPane', w=10, h=7;
345 - {kind = 'hztl', w=10,h=0; inputTbl, costTbl}
350 + local inputTbl = {kind = 'vert', w=6,h=0;
351 + {kind = 'hbar', w=6, h=.5, text=sel.input and 'Input Plan' or 'Input'}};
352 + local costTbl = {kind = 'vert', w=6,h=0;
353 + {kind = 'hbar', w=6, h=.5, text=sel.input and 'Process Plan' or 'Process'}};
354 + local reqPane = {kind = 'pane', id='reqPane', w=12, h=8;
355 + {kind = 'hztl', w=12,h=0; inputTbl, costTbl}
346 356 }
347 357 local function pushCost(x, t, val)
348 - table.insert(costTbl, {kind='label', w=4.5,h=.5,x=x;
358 + table.insert(costTbl, {kind='label', w=5.5,h=.5,x=x;
349 359 text=string.format('%s: %s',t,val);
350 360 })
351 361 end
352 362 local function pushComputeCosts(header, p)
353 363 if p then
354 - table.insert(costTbl, {kind = 'label', w=5, h=.5, x=0; text=header});
364 + table.insert(costTbl, {kind = 'label', w=6, h=.5, x=0; text=header});
355 365 if p.cycles then
356 366 pushCost(.5, 'Compute', lib.math.siUI({'cycle','cycles'}, p.cycles, true))
357 367 end
358 368 if p.power then
359 369 local str = lib.math.siUI('J', p.power)
360 370 if p.power > user:suitCharge() then str = unmet(str) end
361 371 pushCost(.5, 'Power', str)
................................................................................
368 378 pushCost(.5, 'Memory', str)
369 379 end
370 380 end
371 381 end
372 382
373 383 local function fabToUI(x, inputTbl, req)
374 384 for ci,c in ipairs(req) do
375 - table.insert(inputTbl, {kind = 'label', w=5-x, h=.5, x=x;
385 + table.insert(inputTbl, {kind = 'label', w=6-x, h=.5, x=x;
376 386 text=lib.str.capitalize(c.header)});
377 387 for ei,e in ipairs(c.list) do
378 - table.insert(inputTbl, {kind = 'hztl', w=4.5-x, h=.5, x=x+.5;
388 + table.insert(inputTbl, {kind = 'hztl', w=5.5-x, h=.5, x=x+.5;
379 389 {kind='img', w=.5,h=.5, img=e.img};
380 - {kind='label', w=3.3,h=.5,x=.2, text=lib.str.capitalize(e.label)};
390 + {kind='label', w=4.3,h=.5,x=.2, text=lib.str.capitalize(e.label)};
381 391 });
382 392 end
383 393 end
384 394 end
385 395
386 396 local commitHue, commitLabel = 120
387 397 if not sel.input then
................................................................................
427 437 end
428 438 fabToUI(0, inputTbl, vis)
429 439 end
430 440 if not ok then commitHue = 0 end
431 441 end
432 442 table.insert(pgmSelector, reqPane)
433 443 table.insert(pgmSelector, {kind = 'hztl', w=10,h=1.2;
434 - {kind = 'button', id='back', label = '← Back', w=5,h=1.2};
435 - {kind = 'button', id='commit', label = commitLabel .. ' →', w=5,h=1.2, color={hue=commitHue,sat=0,lum=0}};
444 + {kind = 'button', id='back', label = '← Back', w=6,h=1.2};
445 + {kind = 'button', id='commit', label = commitLabel .. ' →', w=6,h=1.2, color={hue=commitHue,sat=0,lum=0}};
436 446 })
437 447 end
438 448 end
439 449
440 450 local rec = getRecentJobs(state)
441 451 local recentList = {kind = 'hwrap', cols=3}
442 452 if rec then
443 453 for i,id in ipairs(rec) do
444 454 local out = ItemStack(starlit.item.sw.db[id].output)
445 455 table.insert(recentList, {kind='contact',w=1.5,h=1.5,id=string.format('recent_%s',i), item = out})
446 456 end
447 457 end
448 458 local queue = {kind='pane', w=5, h=9.5}
459 + local cst = state.ctx.availableChips()
449 460 for i,v in ipairs(state.pgm.file.body.conf) do
450 461 if v.key == 'job' then
451 462 local job = starlit.store.compilerJob.dec(v.value)
452 - local scm = starlit.item.sw.db[job.schematic]
453 - local cycTotal = (scm.cost and scm.cost.cycles or 0)
454 - local secTotal = (scm.input.time and scm.input.time.print or 0)
455 - local cycPct = cycTotal == 0 and 1 or (1 - job.cyclesLeft/cycTotal)
456 - local secPct = secTotal == 0 and 1 or (1 - job.timeLeft/secTotal)
457 - local out = ItemStack(scm.output)
458 - local cycBar = {kind = 'hbar', fac = cycPct, w=5-1.5, h = .5;
459 - color={hue=150,sat=0,lum=0}; text=string.format("Compute %s%%", math.floor(cycPct*100));
463 + local scm = starlit.mod.electronics.chip.usableSoftware(cst, {{
464 + id = job.schematic;
465 + sw = starlit.item.sw.db[job.schematic];
466 + }})[1]
467 + if scm == nil then goto badJob end
468 + local steps = {
469 + {label = 'Compute', n = job.cyclesLeft, color=lib.color(0,1,0);
470 + total = scm.sw.cost and scm.sw.cost.cycles or 0};
471 + {label = 'Energize', n = job.powerLeft, color=lib.color(0,.5,1);
472 + total = (scm.powerCost or 0)
473 + + (state.pgm.powerCost or 0)
474 + + (scm.sw.input.cost and scm.sw.input.cost.power or 0)};
475 + {label = 'Assemble', n = job.timeLeft, color=lib.color(1,.2,0);
476 + total = scm.sw.input.time and scm.sw.input.time.print or 0};
477 + {label = 'Numenize', n = job.numinaLeft, color=lib.color(1,0,1);
478 + total = scm.sw.cost and scm.sw.cost.numina or 0};
460 479 }
461 - local secBar = {kind = 'hbar', fac = secPct, w=5-1.5, h = .5;
462 - color={hue=50,sat=0,lum=0}; text=string.format("Assemble %s%%", math.floor(secPct*100));
463 - }
464 - table.insert(queue, {kind='hztl'; w=5, h=1.5;
480 + local bar = {kind = 'hbar', text = 'Complete', fac=1, w=5-1.5, h = .5}
481 + for i, s in ipairs(steps) do
482 + if s.n > 0 then
483 + local pct = 1 - s.n/s.total
484 + bar.color = s.color
485 + bar.fac = pct
486 + bar.text = string.format("%s %s%%", s.label, math.floor(pct*100))
487 + break
488 + end
489 + end
490 +
491 + local out = ItemStack(scm.sw.output)
492 + table.insert(queue, {kind='hztl'; w=6, h=1.5;
465 493 {kind = 'contact', w=1.5,h=1.5, id=string.format('cancel_%s', i), item = out};
466 - {kind = 'vert', w=5-1.5, h=1.5;
467 - {kind = 'label', text=out:get_definition().short_description, w=5-1.5, h=.75};
468 - (cycPct < 1 and cycBar or secBar);
494 + {kind = 'vert', w=6-1.5, h=1.5;
495 + {kind = 'label', text=out:get_definition().short_description, w=6-1.5, h=.75};
496 + bar;
469 497 }
470 498 })
471 499 end
500 + ::badJob::
472 501 end
473 502
474 503 return starlit.ui.build {
475 - kind = 'hztl', padding = 0.5; w = 20, h = 10, mode = 'sw';
476 - {kind = 'vert', w = 5, h = 5;
504 + kind = 'hztl', padding = 0.5; w = 22, h = 11, mode = 'sw';
505 + {kind = 'vert', w = 5, h = 15;
477 506 {kind = 'hbar', fac=0, w = 5, h = .5, text = '<b><left>Recent Prints</left></b>'};
478 507 recentList;
479 508 };
480 - {kind = 'vert', w = 10, h = 10;
481 - {kind = 'hbar', fac=0, w = 10, h = .5, text = '<b>Program Select</b>'};
482 - {kind = 'pane', w = 10, h = 9.5, id='pgmSelect';
483 - unpack(pgmSelector)
509 + {kind = 'vert', w = 12, h = 11;
510 + {kind = 'hbar', fac=0, w = 12, h = .5, text = '<b>Program Select</b>'};
511 + {kind = 'pane', w = 12, h = 10.5, id='pgmSelect';
512 + pgmSelector
484 513 };
485 514 };
486 - {kind = 'vert', w = 5, h = 10;
515 + {kind = 'vert', w = 5, h = 11;
487 516 {kind = 'hbar', fac=0, w = 5, h = .5, text = '<b><right>Print Queue</right></b>'};
488 517 queue;
489 518 };
490 519 }
491 520 end;
492 521 };
493 522 };
494 523 })