Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
Aeon

Advanced BR reactor/turbine management program

Question

Heyo OC community!

 

Description:

I finally got my OC network up and running and I'd like to go a bit advanced now. I'm currently using Vexatos' BR program but I'd like to add a few features to it. My computer is connected to my BR reactor, 3 BR turbines (but I'll expand to max 6 turbines) and an EnderIO capacitor bank.

My current system:

- Tier 3 case

- Tier 3 CPU

- Tier 3 graphics card

- 2x tier 3.5 memory card

- Tier 3 HDD

- 3x3 tier 3 screen

- 3x3 tier 1 screen

 

Function:

I would like the following functions:

- Vexatos' BR turbine startup and stabilizing function

- Ability to turn each turbine on/off individually

- Automatically adjust BR reactor's fuel rod insertion depending on how many turbines are running (from the array {85, 70, 55, 39, 23, 5} which equals to roughly 2000, 4000, 6000, 8000, 10000 and 12000 mB/t in my reactor configuration)

- Display the relevant data on the tier 3 screen (such as which turbines are running, how many turbines are starting up, current turbine speeds, total count of running turbines, total current RF output, current reactor fuel consumption, current steam production)

- Display total input, output, current storage and max storage of the EnderIO capacitor bank on the tier 1 screen

 

Optional (not really needed but would be cool):

- Dynamically start/stop turbines depending on how much RF is stored in the capacitor bank (e.g. start all turbines if RF level is below 50%, turn off half of the turbines if RF level was at 99% in the last 30 seconds; or turn turbines on/off depending on the RF consumption)

 

Deadline:

I don't mind.

 

Additional Information:

None but simply ask me if you have other questions.

 

 

Thank you in advance!

 

Cheers,

Aeon

Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

This is a project I've been meaning to undertake for a few weeks now, then couple days ago i found a loophole in EnderIO Photo-voltaic Panels that turns everything into OP energy :-) BUT! it never hurts to have a project to work on, so still dabbling with this in my free time.

 

Couple of questions though:

 

Turbine Questions:

--What Size? (outer shell dimensions please)

--Coil block count?

--Coil block type?

--How are you routing steam between reactor/turbines (specifically which mod set of pipes, or direct contact?)?

 

General Questions:

--What Minecraft/Forge/Mod versions are you working with?

--Don't you need a second graphics card to use both screens at once? or did i miss a recent change?

--Does it need to be on two screens, or would one be acceptable, perhaps able to switch between a 'summary' and a 'detail' view of the system?

Link to post
Share on other sites
  • 0

This thread is really old and I already made a program on my own. I use my custom-made modpack, running Minecraft 1.7.10.
If you are still interested, here is what I did (some code parts are in comments due to simplifications):

--===== SETTINGS =====
--The desired rotations per minute of a turbine if the program runs in turbine mode
local desiredSpeed = 1790
--The amount the turbine's rotation speed may vary from the desired speed before the program starts reacting
local acceptedSpeed = 50
--The amount of steam one turbine can take per tick, in milibuckets
local neededTurbineSteam = 2000
--The maximum amount of energy a reactor can store
local maxEnergyReactor = 10000000
--The maximum amount of energy a turbine can store
local maxEnergyTurbine = 1000000
--The level of the control rods, first index is for no active turbines
local rodlevels = {100, 85, 70, 55, 39, 23, 5}



--===== GENERAL FUNCTIONS =====
--Error provider
local function serror(msg, msg2)
  msg2 = msg2 or msg
  if silent then
    error(msg, 2)
  else
    io.stderr:write(msg2)
    os.exit()
  end
end

--Displays long numbers with commas
local function fancyNumber(n)
  return tostring(math.floor(n)):reverse():gsub("(%d%d%d)", "%1,"):gsub("%D$",""):reverse()
end

--Displays numbers with a special offset
local function offset(num, d, ext)
  if num == nil then return "" end
  if type(num) ~= "string" then
    if type(num) == "number" then
      if ext then
        return offset(tostring(math.floor(num * 100) / 100), d)
      else
        return offset(tostring(math.floor(num)), d)
      end
    end
    return offset(tostring(num), d)
  end
  if d <= #num then return num end
  return string.rep(" ", d - #num) .. num
end



--===== MAIN =====
--Libraries
local component = require("component")
local keyboard = require("keyboard")
local term = require("term")

--Check whether there is a Reactor Computer Port to access
if not component.isAvailable("br_reactor") then
  serror("No connected Reactor Computer Port found.", "This program requires a connected Reactor Computer Port to run.")
end

--Set screen resolution
do
  component.gpu.setResolution(component.gpu.maxResolution())
  term.clear()

  print("Press Ctrl+W to stop.")
end

--Get the current y position of the cursor for the RF display
local y, h
do
  local x,w
  x,y = term.getCursor()
  w,h = component.gpu.getResolution()
end

--Reactor setup
local reactor = component.br_reactor
local turbines = {}
local maxEnergy = 0

if reactor.isActivelyCooled() then
  if not component.isAvailable("br_turbine") then
    serror("Reactor has coolant ports but no connected turbine found.")
  end
  for addr in component.list("br_turbine") do
    table.insert(turbines, component.proxy(addr))
  end
  local activeTurbines = 0
  for _, turbine in ipairs(turbines) do
    if turbine.getActive() then
      activeTurbines = activeTurbines + 1
    end
  end
  reactor.setAllControlRodLevels(rodlevels[activeTurbines + 1])
  maxEnergy = maxEnergyTurbine * #turbines
else
  reactor.setAllControlRodLevels(0)
  maxEnergy = maxEnergyReactor
end

--The interface offset
local offs = #tostring(maxEnergy) + 5

--Reactor handling
local function handleReactor()
  local stored = reactor.getEnergyStored()
  local state = reactor.getActive()
  local produced = reactor.getEnergyProducedLastTick()
  
  if state then
    state = "On"
  else
    state = "Off"
  end

  do
    term.setCursor(1, y)
    term.clearLine()
    term.write("Reactor state:      " .. offset(state, offs) .. "\n", false)
    term.clearLine()
    term.write("Energy stored:      " .. offset(fancyNumber(stored), offs) .. " RF\n", false)
    term.clearLine()
    term.write("Stored percentage:  " .. offset(stored / maxEnergy * 100, offs) .. " %\n", false)
    term.clearLine()
    term.write("Energy production:  " .. offset(fancyNumber(produced), offs) .. " RF/t", false)
    term.clearLine()
    term.write("Fuel consumption:   " .. offset(reactor.getFuelConsumedLastTick(), offs, true) .. " mB/t\n", false)
    term.clearLine()
    term.write("Control rod level:  " .. offset(reactor.getControlRodLevel(1), offs) .. " %\n", false)
  end
end

--Turbine handling
local benchmark, madeSteamMax = 0, 0
local oldActiveTurbines, smoothRodLevel = 0, 0
local activeTurbinesChanged = false
--local countDelay = 0

local function handleTurbines()
  local stored, produced, engagedCoils, shutPorts, activeTurbines = 0, 0, 0, 0, 0
  local rotations = {}

  for _, turbine in ipairs(turbines) do
    stored = stored + turbine.getEnergyStored()
    produced = produced + turbine.getEnergyProducedLastTick()
    local speed = turbine.getRotorSpeed()
    table.insert(rotations, speed)

    if turbine.getActive() then
      activeTurbines = activeTurbines + 1

      local flowRate = turbine.getFluidFlowRateMax()
      local flowMax = turbine.getFluidFlowRateMaxMax()

      if speed > (desiredSpeed + acceptedSpeed) then
        if flowRate > 0 then
          turbine.setFluidFlowRateMax(0)
        end
        shutPorts = shutPorts + 1
      else
        if flowRate < flowMax then
          turbine.setFluidFlowRateMax(flowMax)
        end
      end
      if turbine.getInductorEngaged() then
        if speed < (desiredSpeed - acceptedSpeed) then
          turbine.setInductorEngaged(false)
        end
        engagedCoils = engagedCoils + 1
      end
      if speed > desiredSpeed then
        if not turbine.getInductorEngaged() then
          turbine.setInductorEngaged(true)
        end
      end
    end
  end
    
  --if oldActiveTurbines ~= activeTurbines then
  --  activeTurbinesChanged = true
  --  smoothRodLevel = 0
  --end
  --if activeTurbinesChanged then
  --  if smoothRodLevel < rodlevels[activeTurbines + 1] then
  --    reactor.setAllControlRodLevels(smoothRodLevel)
  --    smoothRodLevel = smoothRodLevel + 1
  --  else
  --    activeTurbinesChanged = false
  --  end
  --else
  --  reactor.setAllControlRodLevels(rodlevels[activeTurbines + 1])
  --end

  local madeSteam = reactor.getHotFluidProducedLastTick()
  neededSteam = neededTurbineSteam * activeTurbines
  reactor.setAllControlRodLevels(rodlevels[activeTurbines + 1])
  --oldActiveTurbines = activeTurbines

  --if madeSteam < neededSteam then
  --  smoothRodLevel = smoothRodLevel - 5
  --  reactor.setAllControlRodLevels(rodlevels[activeTurbines + 1] + smoothRodLevel)
  --else
  --  if reactor.getControlRodLevel(1) < rodlevels[activeTurbines + 1] then
  --    smoothRodLevel = smoothRodLevel + 1
  --    reactor.setAllControlRodLevels(rodlevels[activeTurbines + 1] + smoothRodLevel)
  --  elseif reactor.getControlRodLevel(1) == rodlevels[activeTurbines + 1] then
  --    smoothRodLevel = 0
  --  end
  --end

  local state = reactor.getActive()
  if state then
    state = "On"
  else
    state = "Off"
  end

  do
    term.setCursor(1, y)
    term.clearLine()
    term.write("Reactor state:      " .. offset(state, offs) .. "\n", false)
    term.clearLine()
    term.write("Energy stored:      " .. offset(fancyNumber(stored), offs) .. " RF\n", false)
    term.clearLine()
    term.write("Stored percentage:  " .. offset(stored / maxEnergy * 100, offs) .. " %\n", false)
    term.clearLine()
    term.write("Energy production:  " .. offset(fancyNumber(produced), offs) .. " RF/t\n", false)
    term.clearLine()
    term.write("Fuel consumption:   " .. offset(reactor.getFuelConsumedLastTick(), offs, true) .. " mB/t\n", false)
    term.clearLine()
    term.write("Control rod level:  " .. offset(reactor.getControlRodLevel(1), offs) .. " %\n", false)
    term.clearLine()
    term.write("Steam production:   " .. offset(fancyNumber(madeSteam), offs) .. " mB/t\n", false)
    term.clearLine()
    term.write("Steam consumption:  " .. offset(fancyNumber(neededSteam), offs) .. " mB/t\n", false)
    term.clearLine()
    term.write("Active turbines:    " .. offset(activeTurbines, offs) .. "\n", false)
    term.clearLine()
    term.write("Engaged coils:      " .. offset(engagedCoils, offs) .. "\n", false)
    term.clearLine()
    term.write("Shut fluid ports:   " .. offset(shutPorts, offs) .. "\n", false)
    term.clearLine()
    term.write("Turbine speed:      ", false)
    if #rotations >= 1 then
      term.write(offset(rotations[1], offs) .. " RPM\n", false)
    end
    if #rotations >= 2 then
      local _, currentY = term.getCursor()
      for i = 2, math.min(#rotations, 1 + h - currentY) do
        term.clearLine()
        term.write(offset(rotations[i], offs + 20) .. " RPM\n", false)
      end
    end
  end
end 

--Main Program
while true do
  reactor.setActive(true)

  if reactor.isActivelyCooled() then
    handleTurbines()
  else
    handleReactor()
  end

  --Check if the program has been terminated
  if keyboard.isKeyDown(keyboard.keys.w) and keyboard.isControlDown() then
    --Shut down the reactor, place cursor in a new line and exit
    term.write("\nReactor shut down.\n")
    reactor.setActive(false)
    for _, turbine in ipairs(turbines) do
      turbine.setFluidFlowRateMax(turbine.getFluidFlowRateMaxMax())
      turbine.setInductorEngaged(true)
    end
    os.exit()
  end
  os.sleep(1)
end

Cheers,
Aeon

Link to post
Share on other sites
  • 0

not bad.  apart from some much needed code-rearranging (drove me nuts reading Vex's original code) you just nerfed the reactor calibration for your own function, yay simple :)  Seems you still dont have it checking your EIO cap bank yet though.

 

for myself, custom modpack 1.7.10 forge 1614, because it still has all the best mods!

 

I just tore apart XyFreaks BRGC, which is a nice beginning point for a Gui, but his reactor controller could use a few more features for my liking.  

https://oc.cil.li/index.php?/topic/918-big-reactors-grid-control/?hl=reactors

Link to post
Share on other sites
  • 0

Yea I basically needed the computer to automatically manage my reactors in the basement of my mountain base, so the GUI wasn't that necessary. And yes, you're right, I didn't include a EnderIO Cap bank display.

I just needed a working system which I can rely on without blowing my base up. Therefore i simply took the program and tweaked it a bit in my needs. Nothing fancy, as you mentioned.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.