stationeers_ic10/heating_cooling.ic10
2021-11-15 14:32:10 +01:00

94 lines
1.8 KiB
Plaintext

alias gas_sensor d0
# d1= Logic Switch, Dial variant (Max=30)
alias thermostat d1
# d2 = Logic Memory, must be more than 0
alias temp_variance d2
# d3 = Console, LED Display variant, optional
alias temp_disp d3
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
define WALL_HEATERS 24258244
define WALL_COOLERS -739292323
define LIQUID_WALL_COOLERS -1369060582
define TEMP_CONVERT 273.15
move cooling_active 0
move heating_active 0
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 target_temp thermostat Setting
# get current temperature
jal temp_read
# update display
brdns temp_disp 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
sb WALL_COOLERS On cooling_active
sb LIQUID_WALL_COOLERS On cooling_active
sb WALL_HEATERS On heating_active
j start
temp_read:
l curr_temp gas_sensor Temperature
sub curr_temp curr_temp TEMP_CONVERT
j ra
display:
s temp_disp Setting curr_temp
j ra
cooling:
yield
jal temp_read
# test if coolers need to be on or not
sgt cooling_active curr_temp target_temp
brdns temp_disp 2
jal display
# send state to coolers
sb WALL_COOLERS On cooling_active
sb LIQUID_WALL_COOLERS On cooling_active
bgtz cooling_active cooling
j start
heating:
yield
jal temp_read
# test if heaters need to be on or not
slt heating_active curr_temp target_temp
brdns temp_disp 2
jal display
# send state to heaters
sb WALL_HEATERS On heating_active
bgtz heating_active heating
j start