Comple rewrite based on CAE's script
This commit is contained in:
parent
76aba2ce1a
commit
ab47a290cf
151
filtration.ic10
151
filtration.ic10
@ -1,73 +1,102 @@
|
|||||||
# Complete filtration circuit that controls filter-
|
# Automated Filtration Control
|
||||||
# unit, checks filters, maintains safe temperature
|
# Based on code by CowsAreEvil
|
||||||
# and pressure.
|
# Designed for use in filtration IC slot only
|
||||||
#
|
# Designed for parallel filtration setups only
|
||||||
# "Mud pipe" is the shared input-pipe for all
|
# Will fill storage tank to MAXPRESSUE (set below)
|
||||||
# filtration units, where all gasses are mixed into
|
# Will detect filter cartridge and activate when
|
||||||
# a "mud" before being filtered.
|
# INPUTAMOUNT moles of gas is detected (set below)
|
||||||
|
|
||||||
alias MudSensor d0 # Pipe Analyzer
|
alias filtration db
|
||||||
alias Tank d1 # Tank
|
alias diode d0 # Optional
|
||||||
alias PurgeButton d2 # Logic (Switch)
|
|
||||||
alias PurgePump d3 # Volume (Turbo) Pump
|
|
||||||
alias FilterUnit d4 # Kit (Atmospherics)
|
|
||||||
alias FilterDisplay d5 # Kit (Console)
|
|
||||||
|
|
||||||
alias MudTemp r0
|
alias filterLeft r0
|
||||||
alias Filter1 r1
|
alias filterRight r1
|
||||||
alias Filter2 r2
|
alias filterMin r2
|
||||||
alias TankPress r3
|
alias filterMax r3
|
||||||
alias FilterRun r4
|
alias filterRemain r4
|
||||||
alias FilterTest r5
|
alias filterLight r5
|
||||||
alias PurgeRun r6
|
alias filterHash r6
|
||||||
alias HasGas r7
|
alias filterMols r7
|
||||||
|
alias filterActive r8
|
||||||
|
alias inMolsCheck r9
|
||||||
|
alias inMolsCompare r10
|
||||||
|
alias totalMols r11
|
||||||
|
alias outPressure r12
|
||||||
|
|
||||||
define MAX_PRESS 58000 # 58MPa
|
define MAXPRESSURE 58000 #Storage pressure kPa
|
||||||
define MAX_TEMP 313.15 # 40C
|
define INPUTAMOUNT 2 #Moles to activate
|
||||||
|
|
||||||
l r9 PurgePump Maximum
|
|
||||||
s PurgePump Setting r9
|
|
||||||
|
|
||||||
s FilterDisplay Color 4 # red
|
|
||||||
|
|
||||||
start:
|
start:
|
||||||
yield
|
yield
|
||||||
s PurgePump On 0
|
|
||||||
ls Filter1 FilterUnit 0 Quantity
|
|
||||||
ls Filter2 FilterUnit 1 Quantity
|
|
||||||
beqz Filter1 swap_filter_1
|
|
||||||
beqz Filter2 swap_filter_2
|
|
||||||
s FilterDisplay On 0
|
|
||||||
l PurgeRun PurgeButton Setting
|
|
||||||
bgtz PurgeRun purge
|
|
||||||
j filter
|
|
||||||
|
|
||||||
swap_filter_1: # if right filter needs swapping
|
#Check filters and set diodes
|
||||||
s FilterDisplay Setting 1
|
ls filterLeft filtration 0 Quantity
|
||||||
s FilterDisplay On 1
|
ls filterRight filtration 1 Quantity
|
||||||
j filter # then continue filtering
|
or filterActive filterLeft filterRight
|
||||||
|
min filterMin filterLeft filterRight
|
||||||
|
seqz filterLight filterMin
|
||||||
|
bdseal diode slideActivate
|
||||||
|
max filterMax filterLeft filterRight
|
||||||
|
select filterRemain filterMin filterMin filterMax
|
||||||
|
div filterRemain filterRemain 100
|
||||||
|
bdseal diode slideSetting
|
||||||
|
|
||||||
swap_filter_2: # if left filter needs swapping
|
#Check storage pressure
|
||||||
s FilterDisplay Setting 2
|
l outPressure filtration PressureOutput
|
||||||
s FilterDisplay On 1
|
slt outPressure outPressure MAXPRESSURE
|
||||||
j filter # then continue filtering
|
and filterActive filterActive outPressure
|
||||||
|
|
||||||
filter:
|
#Check filters and available gas
|
||||||
l MudTemp MudSensor Temperature
|
l totalMols filtration TotalMolesInput
|
||||||
l TankPress Tank Pressure
|
ls filterHash filtration 0 PrefabHash
|
||||||
l HasGas MudSensor RatioCarbonDioxide
|
jal checkfilter
|
||||||
sgtz HasGas HasGas
|
move inMolsCompare inMolsCheck
|
||||||
slt FilterRun MudTemp MAX_TEMP
|
ls filterHash filtration 1 PrefabHash
|
||||||
slt FilterTest TankPress MAX_PRESS
|
jal checkfilter
|
||||||
and FilterRun FilterRun FilterTest
|
max filterMols inMolsCheck inMolsCompare
|
||||||
and FilterRun FilterRun HasGas
|
mul totalMols totalMols filterMols
|
||||||
s FilterUnit On FilterRun
|
sgt totalMols totalMols INPUTAMOUNT
|
||||||
|
and filterActive filterActive totalMols
|
||||||
|
#Activate filtration if required
|
||||||
|
s filtration Mode filterActive
|
||||||
j start
|
j start
|
||||||
|
|
||||||
purge:
|
slideActivate:
|
||||||
yield
|
s diode On filterLight
|
||||||
s FilterUnit On 0
|
j ra
|
||||||
l TankPress Tank Pressure
|
|
||||||
s PurgePump On 1
|
slideSetting:
|
||||||
bgtz TankPress purge
|
s diode Setting filterRemain
|
||||||
|
j ra
|
||||||
|
|
||||||
|
checkfilter:
|
||||||
|
l inMolsCheck filtration RatioOxygenInput
|
||||||
|
beq filterHash -1067319543 ra
|
||||||
|
beq filterHash -1217998945 ra
|
||||||
|
beq filterHash -721824748 ra
|
||||||
|
l inMolsCheck filtration RatioNitrogenInput
|
||||||
|
beq filterHash -632657357 ra
|
||||||
|
beq filterHash -1387439451 ra
|
||||||
|
beq filterHash 632853248 ra
|
||||||
|
l inMolsCheck filtration RatioCarbonDioxideInput
|
||||||
|
beq filterHash 416897318 ra
|
||||||
|
beq filterHash 1876847024 ra
|
||||||
|
beq filterHash 1635000764 ra
|
||||||
|
l inMolsCheck filtration RatioVolatilesInput
|
||||||
|
beq filterHash 1037507240 ra
|
||||||
|
beq filterHash 1255156286 ra
|
||||||
|
beq filterHash 15011598 ra
|
||||||
|
l inMolsCheck filtration RatioPollutantInput
|
||||||
|
beq filterHash 63677771 ra
|
||||||
|
beq filterHash 1959564765 ra
|
||||||
|
beq filterHash 1915566057 ra
|
||||||
|
l inMolsCheck filtration RatioNitrousOxideInput
|
||||||
|
beq filterHash 1824284061 ra
|
||||||
|
beq filterHash 465267979 ra
|
||||||
|
beq filterHash -1247674305 ra
|
||||||
|
move inMolsCheck 0
|
||||||
|
beqz filterHash ra
|
||||||
|
|
||||||
|
#if you are still here then it is an error so end
|
||||||
|
s filtration On 0
|
||||||
j start
|
j start
|
Loading…
Reference in New Issue
Block a user