Rewrote variables to not use snake-case

Added automatic light-switch
This commit is contained in:
Snorre Selmer 2022-09-13 20:22:22 +02:00
parent e47ade1f57
commit 0eaec70c48
11 changed files with 265 additions and 232 deletions

View File

@ -1,18 +1,18 @@
alias furnace d0
alias Furnace d0
alias import_occupied r0
alias active r1
alias run_furnace r2
alias ImportOccupied r0
alias Active r1
alias RunFurnace r2
start:
yield
ls import_occupied furnace 0 Occupied
l active furnace Activate
xor run_furnace import_occupied active
bgtz run_furnace run
ls ImportOccupied Furnace 0 Occupied
l Active Furnace Activate
xor RunFurnace ImportOccupied Active
bgtz RunFurnace run
j start
run:
bgtz active start # already running = go to start
s furnace Activate 1
bgtz Active start # already running = go to start
s Furnace Activate 1
j start

View File

@ -1,33 +1,33 @@
# Runs up to six sorters that filter throughput by ItemClass
# When looking at the outputs, left = ITEMCLASS, right = everything else
alias occupied r0
alias input_class r1
alias is_class r2
alias sorter_counter r3
alias SlotOccupied r0
alias InputClass r1
alias IsClass r2
alias SorterCounter r3
move sorter_counter 0
move SorterCounter 0
define ITEMCLASS 19 # 10=ores, 19=ingots, 33=wrekage
define INPUTSLOT 0 # sorter input-slot
start:
jal sort
add sorter_counter sorter_counter 1
bgt sorter_counter 5 reset
add SorterCounter SorterCounter 1
bgt SorterCounter 5 reset
j start
sort:
bdns dr3 ra
s dr3 Mode 2 # set sorter to IC mode
ls occupied dr3 INPUTSLOT Occupied # check if anything to sort
beqz occupied ra
ls input_class dr3 INPUTSLOT Class
seq is_class input_class ITEMCLASS # change seq to sne to swap output ports
s dr3 Output is_class
ls SlotOccupied dr3 INPUTSLOT Occupied # check if anything to sort
beqz SlotOccupied ra
ls InputClass dr3 INPUTSLOT Class
seq IsClass InputClass ITEMCLASS # change seq to sne to swap output ports
s dr3 Output IsClass
j ra
reset:
yield
move sorter_counter 0
move SorterCounter 0
j start

27
auto_lights.ic10 Normal file
View File

@ -0,0 +1,27 @@
# Uses Occupancy Sensor and (optional) Daylight
# Sensor to control lights in a room.
# Can of course control other things too...
alias Detector d0
alias DaySens d1 # Optional
alias Lights d2
alias RoomOccupied r0
alias NightTime r1
alias LightHash r2
l LightHash Lights PrefabHash
move NightTime 1
check:
yield
l RoomOccupied Detector Activate
bdns DaySens light
l NightTime DaySens Activate
slt NightTime NightTime 1
j light
light:
and RoomOccupied RoomOccupied NightTime
sb LightHash On RoomOccupied
j check

View File

@ -4,56 +4,56 @@
# !!! Remember to set volume pump to no more !!!
# !!! than 10l! I have mine at 2l for safety !!!
alias canister_storage d0
alias fill_pump d1
alias evac_pump d2
alias analyzer d4
alias CanisterStorage d0
alias FillPump d1
alias EvacPump d2
alias Analyzer d4
alias canister_present r0
alias canister_hash r1
alias storage_pressure r2
alias gas_to_move r3
alias fill_pressure r4
alias pump_active r5
alias CanisterPresent r0
alias CanisterHash r1
alias StoragePressure r2
alias GasToMove r3
alias FillPressure r4
alias PumpActive r5
define CANISTER 42280099
define SMART_CANISTER -668314371
define SMARTCANISTER -668314371
start:
yield
# check if canister is present
ls canister_present canister_storage 0 Occupied
ls CanisterPresent CanisterStorage 0 Occupied
# identify canister
ls canister_hash canister_storage 0 OccupantHash
ls CanisterHash CanisterStorage 0 OccupantHash
# set safe fill-pressure
beq canister_hash CANISTER regular
beq canister_hash SMART_CANISTER smart
beq CanisterHash CANISTER regular
beq CanisterHash SMARTCANISTER smart
regular:
move fill_pressure 8000000 # regular can safe max
move FillPressure 8000000 # regular can safe max
j fill # start filling
smart:
move fill_pressure 18000000 # smart can safe max
move FillPressure 18000000 # smart can safe max
j fill # start filling
fill: # fills canister if present and <8Mpa
# get canister pressure in Pa
ls storage_pressure canister_storage 0 Pressure
ls StoragePressure CanisterStorage 0 Pressure
# is there room in the canister for more gas?
slt gas_to_move storage_pressure fill_pressure
slt GasToMove StoragePressure FillPressure
# is there a can in the slot that has room?
and pump_active gas_to_move canister_present
and PumpActive GasToMove CanisterPresent
# trigger fill pump
s fill_pump On pump_active
beqz canister_present evac# break if no can
s FillPump On PumpActive
beqz CanisterPresent evac # break if no can
j start
evac: # evacuates pipe on can removed and >0Pa
l storage_pressure analyzer Pressure
l StoragePressure Analyzer Pressure
# is there gas in the pipe?
sgt gas_to_move storage_pressure 0
sgt GasToMove StoragePressure 0
# trigger evac pump
s evac_pump On gas_to_move
bgtz gas_to_move evac
s EvacPump On GasToMove
bgtz GasToMove evac
j start

View File

@ -1,32 +1,32 @@
# Automatically evacuates cooling-tower when temp
# is below 40C (39.85C)
# is below 40C
# needs a volume pump and a gas analyzer
alias sensor d0
alias pump d1
alias Sensor d0
alias Pump d1
alias pipe_temp r0
alias pipe_press r1
alias temp_go r2
alias press_go r3
alias pump_go r4
alias PipeTemp r0
alias PipePress r1
alias TempGo r2
alias PressGo r3
alias PumpGo r4
define TEMP_THRESH 313 # 39.85C
define TEMPTHRESH 313.15
# Sets volume pump max capacity
l pipe_press pump Maximum
s pump Setting pipe_press
l PipePress Pump Maximum
s Pump Setting PipePress
start:
yield
# Loads cooling-tower pressure and temp
l pipe_temp sensor Temperature
l pipe_press sensor Pressure
l PipeTemp Sensor Temperature
l PipePress Sensor Pressure
# Checks if temp is below threshold
slt temp_go pipe_temp TEMP_THRESH
sgtz press_go pipe_press
slt TempGo PipeTemp TEMPTHRESH
sgtz PressGo PipePress
# If cooling-tower has pressure, and temp is safe..
and pump_go temp_go press_go
and PumpGo TempGo PressGo
# ...activate pump
s pump On pump_go
s Pump On PumpGo
j start

View File

@ -6,69 +6,68 @@
# filtration units, where all gasses are mixed into
# a "mud" before being filtered.
alias mud_sensor d0 # Pipe Analyzer
alias tank d1 # Tank
alias purge_button d2 # Logic (Switch)
alias purge_pump d3 # Volume (Turbo) Pump
alias filter_unit d4 # Kit (Atmospherics)
alias filter_display d5 # Kit (Console)
alias MudSensor d0 # Pipe Analyzer
alias Tank d1 # Tank
alias PurgeButton d2 # Logic (Switch)
alias PurgePump d3 # Volume (Turbo) Pump
alias FilterUnit d4 # Kit (Atmospherics)
alias FilterDisplay d5 # Kit (Console)
alias mud_temp r0
alias filter1 r1
alias filter2 r2
alias tank_press r3
alias button r4
alias filter_run r5
alias filter_test r6
alias purge_run r7
alias has_gas r8
alias MudTemp r0
alias Filter1 r1
alias Filter2 r2
alias TankPress r3
alias FilterRun r4
alias FilterTest r5
alias PurgeRun r6
alias HasGas r7
define MAX_PRESS 58000 # 58MPa
define MAX_TEMP 313 # 40C
define MAX_TEMP 313.15 # 40C
l r9 purge_pump Maximum
s purge_pump Setting r9
l r9 PurgePump Maximum
s PurgePump Setting r9
s filter_display Color 4 # red
s FilterDisplay Color 4 # red
start:
yield
s purge_pump On 0
ls filter1 filter_unit 0 Quantity
ls filter2 filter_unit 1 Quantity
beqz filter1 swap_filter_1
beqz filter2 swap_filter_2
s filter_display On 0
l purge_run purge_button Setting
bgtz purge_run purge
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
s filter_display Setting 1
s filter_display On 1
s FilterDisplay Setting 1
s FilterDisplay On 1
j filter # then continue filtering
swap_filter_2: # if left filter needs swapping
s filter_display Setting 2
s filter_display On 1
s FilterDisplay Setting 2
s FilterDisplay On 1
j filter # then continue filtering
filter:
l mud_temp mud_sensor Temperature
l tank_press tank Pressure
l has_gas mud_sensor RatioCarbonDioxide
sgtz has_gas has_gas
slt filter_run mud_temp MAX_TEMP
slt filter_test tank_press MAX_PRESS
and filter_run filter_run filter_test
and filter_run filter_run has_gas
s filter_unit On filter_run
l MudTemp MudSensor Temperature
l TankPress Tank Pressure
l HasGas MudSensor RatioCarbonDioxide
sgtz HasGas HasGas
slt FilterRun MudTemp MAX_TEMP
slt FilterTest TankPress MAX_PRESS
and FilterRun FilterRun FilterTest
and FilterRun FilterRun HasGas
s FilterUnit On FilterRun
j start
purge:
yield
s filter_unit On 0
l tank_press tank Pressure
s purge_pump On 1
bgtz tank_press purge
s FilterUnit On 0
l TankPress Tank Pressure
s PurgePump On 1
bgtz TankPress purge
j start

View File

@ -3,61 +3,61 @@
# and a Kit (Button, moment type) to trigger purge.
# Gas mixer ratio is manually set!
alias tank_a d0
alias tank_b d1
alias tank_out d2
alias mixer d3
alias pump d4
alias button d5
alias TankA d0
alias TankB d1
alias TankOut d2
alias Mixer d3
alias Pump d4
alias Button d5
alias tank_a_press r0
alias tank_b_press r1
alias tank_out_press r2
alias tank_a_ok r3
alias tank_b_ok r4
alias tank_out_ok r5
alias mixer_run r6
alias purge_activate r7
alias TankAPress r0
alias TankBPress r1
alias TankOutPress r2
alias TankAOK r3
alias TankBOK r4
alias TankOutOK r5
alias MixerRun r6
alias PurgeActivate r7
# Stops mixing if either input-gas is below 500kPa
define PRESS_IN_MIN 500
define PRESSINMIN 500
# Stops mixing if output-tank is "full"
define PRESS_OUT_MAX 58000
define PRESSOUTMAX 58000
# Sets purge pump to max output
l tank_a_press pump Maximum
s pump Setting tank_a_press
l TankAPress Pump Maximum
s Pump Setting TankAPress
start:
yield
s pump On 0 # Ensures purge pump is off
s Pump On 0 # Ensures purge pump is off
# Checks is purge is activated
l purge_activate button Setting
bgtz purge_activate purge
l PurgeActivate Button Setting
bgtz PurgeActivate purge
# Loads tank pressures
l tank_a_press tank_a Pressure
l tank_b_press tank_b Pressure
l tank_out_press tank_out Pressure
l TankAPress TankA Pressure
l TankBPress TankB Pressure
l TankOutPress TankOut Pressure
# Checks if pressures are within tolerances
sgt tank_a_ok tank_a_press PRESS_IN_MIN
sgt tank_b_ok tank_b_press PRESS_IN_MIN
slt tank_out_ok tank_out_press PRESS_OUT_MAX
sgt TankAOK TankAPress PRESSINMIN
sgt TankBOK TankBPress PRESSINMIN
slt TankOutOK TankOutPress PRESSOUTMAX
and mixer_run tank_a_ok tank_b_ok
and mixer_run tank_out_ok mixer_run
and MixerRun TankAOK TankBOK
and MixerRun TankOutOK MixerRun
# Activates mixer if all is ok
s mixer On mixer_run
s Mixer On MixerRun
j start
purge:
yield
s mixer On 0 # Turns mixer off
s Mixer On 0 # Turns mixer off
# Gets output tank pressure
l tank_out_press tank_out Pressure
s pump On 1 # Activates purge pump
l TankOutPress TankOut Pressure
s Pump On 1 # Activates purge pump
# Runs pump until tank is empty
bgtz tank_out_press purge
bgtz TankOutPress purge
j start

View File

@ -1,68 +1,68 @@
alias gas_sensor d0
alias GasSensor d0
# d1= Logic Switch, Dial variant (Max=30)
alias thermostat d1
alias Thermostat d1
# d2 = Logic Memory, must be more than 0
alias temp_variance d2
alias TempVariance d2
# d3 = Console, LED Display variant, optional
alias temp_disp d3
alias TempDisplay d3
# d4 = Wall Cooler
alias w_cooler d4
alias WallCooler d4
# d5 = Wall Heater
alias w_heater d5
alias WallHeater d5
alias curr_temp r0
alias target_temp r1
alias variance r2
alias min_temp r3
alias max_temp r4
alias cooling_active r5
alias heating_active r6
alias cooler r7
alias heater r8
alias CurrentTemp r0
alias TargetTemp r1
alias Variance r2
alias MinTemp r3
alias MaxTemp r4
alias CoolingActive r5
alias HeatingActive r6
alias Cooler r7
alias Heater r8
define TEMP_CONVERT 273.15
define TEMPCONVERT 273.15
move cooling_active 0
move heating_active 0
move CoolingActive 0
move HeatingActive 0
l cooler w_cooler PrefabHash
l heater w_heater PrefabHash
l Cooler WallCooler PrefabHash
l Heater WallHeater PrefabHash
start:
yield
# establish min- and max-temps to registry
l variance temp_variance Setting
l min_temp thermostat Setting
sub min_temp min_temp variance
l max_temp thermostat Setting
add max_temp max_temp variance
l Variance TempVariance Setting
l MinTemp Thermostat Setting
sub MinTemp MinTemp Variance
l MaxTemp Thermostat Setting
add MaxTemp MaxTemp Variance
l target_temp thermostat Setting
l TargetTemp Thermostat Setting
# get current temperature
jal temp_read
# update display
brdns temp_disp 2
brdns TempDisplay 2
jal display
# compare current temp to max/min temp and
# initiate cooling or heating if needed
bgt curr_temp max_temp cooling
blt curr_temp min_temp heating
bgt CurrentTemp MaxTemp cooling
blt CurrentTemp MinTemp heating
sb cooler On cooling_active
sb heater On heating_active
sb Cooler On CoolingActive
sb Heater On HeatingActive
j start
temp_read:
l curr_temp gas_sensor Temperature
sub curr_temp curr_temp TEMP_CONVERT
l CurrentTemp GasSensor Temperature
sub CurrentTemp CurrentTemp TEMPCONVERT
j ra
display:
s temp_disp Setting curr_temp
s TempDisplay Setting CurrentTemp
j ra
cooling:
@ -70,15 +70,15 @@ yield
jal temp_read
# test if coolers need to be on or not
sgt cooling_active curr_temp target_temp
sgt CoolingActive CurrentTemp TargetTemp
brdns temp_disp 2
brdns TempDisplay 2
jal display
# send state to coolers
sb cooler On cooling_active
sb Cooler On CoolingActive
bgtz cooling_active cooling
bgtz CoolingActive cooling
j start
heating:
@ -86,13 +86,13 @@ yield
jal temp_read
# test if heaters need to be on or not
slt heating_active curr_temp target_temp
slt HeatingActive CurrentTemp TargetTemp
brdns temp_disp 2
brdns TempDisplay 2
jal display
# send state to heaters
sb heater On heating_active
sb Heater On HeatingActive
bgtz heating_active heating
bgtz HeatingActive heating
j start

View File

@ -1,23 +1,20 @@
alias dial d0
alias order_display d1
alias remaining_display d2
alias printer d3
alias Dial d0
alias DisplayOrder d1
alias DisplayExport d2
alias Printer d3
alias order_count r0
alias export_count r1
alias remaining_count r2
move remaining_count 0
alias CountOrder r0
alias CountExport r1
start:
yield
l order_count dial Setting
s order_display Setting order_count
l export_count printer ExportCount
sub remaining_count order_count export_count
s remaining_display Setting remaining_count
bgtz remaining_count start
s printer ClearMemory 1
s dial Setting 0
s printer Activate 0
l CountOrder Dial Setting
s DisplayOrder Setting CountOrder
l CountExport Printer ExportCount
s DisplayExport Setting CountExport
blt CountExport CountOrder start
s Printer Activate 0
s Printer ClearMemory 1
sleep 1
s Dial Setting 0
j start

View File

@ -9,7 +9,8 @@ alias AngleHorizontal r1
alias CorrectionAngle r2
alias Panel1Hash r3
alias Panel2Hash r4
alias PanelEfficiency r5
alias PanelOutput1 r5
alias PanelOutput2 r6
# define directions of sensor and panel power ports
define SENSORDATAANGLE 0
@ -24,6 +25,10 @@ l Panel1Hash PanelType1 PrefabHash
bdns PanelType2 start
l Panel2Hash PanelType2 PrefabHash
# set Display to Power-mode
bdns Display start
s Display Mode 2
start:
yield
l AngleVertical Sensor Vertical
@ -32,8 +37,13 @@ l AngleHorizontal Sensor Horizontal
add AngleHorizontal AngleHorizontal CorrectionAngle
bdns Display panelmove
lb PanelEfficiency Panel1Hash Ratio Average
s Display Setting PanelEfficiency
lb PanelOutput1 Panel1Hash Charge Sum
bdns PanelType2 paneldisplay
lb PanelOutput2 Panel2Hash Charge Sum
add PanelOutput1 PanelOutput1 PanelOutput2
paneldisplay:
s Display Setting PanelOutput1
panelmove:
sb Panel1Hash Vertical AngleVertical

View File

@ -2,42 +2,42 @@
# a siren and an announcer (2x Kit (Speaker))
# and a display of some sort (Kit (Console))
alias weather d0 # Weather Station
alias readout d1 # Kit (Console)
alias announcer d2 # Kit (Speaker)
alias siren d3 # Kit (Speaker)
alias Weather d0 # Weather Station
alias Readout d1 # Kit (Console)
alias Announcer d2 # Kit (Speaker)
alias Siren d3 # Kit (Speaker)
alias storm_mode r0
alias minutes r1
alias siren_high r2
alias siren_low r3
alias siren_on r4
alias StormMode r0
alias Minutes r1
alias SirenHigh r2
alias SirenLow r3
alias SirenOn r4
s announcer Mode 18 # "StormIncoming"
s siren Mode 10 # "Alarm8"
s Announcer Mode 18 # "StormIncoming"
s Siren Mode 10 # "Alarm8"
start:
yield
l storm_mode weather Mode # check weather
s announcer On 0 # reset announcer
beq storm_mode 1 countdown # countdown if incoming
l StormMode Weather Mode # check weather
s Announcer On 0 # reset Announcer
beq StormMode 1 countdown # countdown if incoming
j start # else return to start
countdown:
yield
l storm_mode weather Mode # check weather
s announcer On 1 # announce storm
l StormMode Weather Mode # check weather
s Announcer On 1 # announce storm
# get countdown value
l minutes weather NextWeatherEventTime
div minutes minutes 60 # convert to minutes
trunc minutes minutes # drop decimals
s readout Setting minutes # send to display
l Minutes Weather NextWeatherEventTime
div Minutes Minutes 60 # convert to minutes
trunc Minutes Minutes # drop decimals
s Readout Setting Minutes # send to display
j warning
warning:
slt siren_high minutes 3 # got less than 3m?
sgt siren_low minutes 0 # got more than 60s?
and siren_on siren_high siren_low # sound siren?
s siren On siren_on # start siren if 1<minutes<3
beq storm_mode 1 countdown # still waiting? go back
slt SirenHigh Minutes 3 # got less than 3m?
sgt SirenLow Minutes 0 # got more than 60s?
and SirenOn SirenHigh SirenLow # sound siren?
s Siren On SirenOn # start siren if 1<minutes<3
beq StormMode 1 countdown # still waiting? go back
j start # reset and start waiting again