telem icon indicating copy to clipboard operation
telem copied to clipboard

Add Router API

Open cyberbit opened this issue 10 months ago • 0 comments

Currently, backplane cycles read all inputs and write to all outputs. The Router API would allow custom mappings between inputs and outputs.

Example (loose concept, not final):

backplane
    -- inputs
    :addInput('fission', fissionReactor('right'))
    :addInput('fusion', fusionReactor('left'))
    :addInput('turbine', industrialTurbine('back'))
    :addInput('induction', inductionMatrix('bottom'))
    :addInput('securemodem', secureModem('top', 'abc123='))
    
    -- routes
    :routes(
        route.from('fission', 'fusion')                -- filter by adapter name
            :match('*:status')                         -- pattern match metric names
            :addOutput('status_board', indicatorGrid)  -- add route-scoped output
            :slow(),                                   -- preferred cycle ring; backplane will update this route less frequently
        
        route.from('*')                                -- process all adapters
            :match('*:production_rate')
            :addOutput('line', labelGrid)
            
        route.from('induction')
            :only('mekinduction:energy')               -- match list of metrics exactly
            :middleware(mw.calcDelta():interval('1t')) -- add route-scoped middleware
            :fast()                                    -- backplane will update this route more frequently
    )
    
    -- global outputs
    :addOutput('log', helloWorld)

-- cycle scheduler with defined fast, normal, and slow ring speeds
backplane:cycleEvery('5t', '5s', '1m')

cyberbit avatar Mar 13 '25 03:03 cyberbit