stationeers_ic10/heating_cooling.ic10

95 lines
1.8 KiB
Plaintext
Raw Normal View History

alias GasSensor d0
2021-11-10 16:29:01 +00:00
# d1= Logic Switch, Dial variant (Max=30)
alias Thermostat d1
2021-11-10 16:29:01 +00:00
# d2 = Logic Memory, must be more than 0
alias TempVariance d2
2021-11-10 16:29:01 +00:00
# d3 = Console, LED Display variant, optional
alias TempDisplay d3
# d4 = Wall Cooler
alias WallCooler d4
# d5 = Wall Heater
alias WallHeater d5
2021-11-10 16:29:01 +00:00
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 TEMPCONVERT 273.15
move CoolingActive 0
move HeatingActive 0
l Cooler WallCooler PrefabHash
l Heater WallHeater PrefabHash
start:
yield
# establish min- and max-temps to registry
l Variance TempVariance Setting
l TargetTemp Thermostat Setting
2022-10-23 11:05:50 +00:00
sub MinTemp TargetTemp Variance
add MaxTemp TargetTemp Variance
2021-11-15 13:32:10 +00:00
# get current temperature
jal temp_read
2021-11-10 16:29:01 +00:00
# update display
2022-10-23 11:05:50 +00:00
bdseal TempDisplay display
2021-11-10 16:29:01 +00:00
# compare current temp to max/min temp and
# initiate cooling or heating if needed
bgt CurrentTemp MaxTemp cooling
blt CurrentTemp MinTemp heating
2022-10-23 11:05:50 +00:00
# Ensure coolers and heaters are off when not needed
sb Cooler On CoolingActive
sb Heater On HeatingActive
j start
temp_read:
l CurrentTemp GasSensor Temperature
sub CurrentTemp CurrentTemp TEMPCONVERT
j ra
2021-11-10 16:29:01 +00:00
display:
s TempDisplay Setting CurrentTemp
2021-11-10 16:29:01 +00:00
j ra
2021-11-10 16:29:01 +00:00
cooling:
2021-11-10 17:52:25 +00:00
yield
jal temp_read
# test if coolers need to be on or not
sgt CoolingActive CurrentTemp TargetTemp
2022-10-23 11:05:50 +00:00
# update display
bdseal TempDisplay display
2021-11-10 16:29:01 +00:00
# send state to coolers
sb Cooler On CoolingActive
bgtz CoolingActive cooling
j start
heating:
2021-11-10 17:52:25 +00:00
yield
jal temp_read
# test if heaters need to be on or not
slt HeatingActive CurrentTemp TargetTemp
2022-10-23 11:05:50 +00:00
# update display
bdseal TempDisplay display
2021-11-10 16:29:01 +00:00
# send state to heaters
sb Heater On HeatingActive
bgtz HeatingActive heating
j start