drabont

Stationeers - WIP solar panel full automation

May 26th, 2021 (edited)
1,056
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #= Power Plant CoS = v0.0 ============ by swagman =#
  2. #    ___     ___    ___     ___                    #
  3. #   | _ \___| _ \  / __|___/ __|   power plant     #
  4. #   |  _/ _ \  _/ | (__/ _ \__ \    automated      #
  5. #   |_| \___/_|    \___\___/___/  contrl system    #
  6. #==================================================#
  7. #         >X<           )|(          -*~*-         #
  8. #        (o o)         (o o)         (o o)         #
  9. #    ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-    #
  10. #= https://youtu.be/vbg67d6SbiA ===================#
  11. define DaySens 1076425094
  12. define SolidGen 813146305
  13. define LightSwt 1999523701 #APC def
  14.  
  15. alias LightOn d0
  16. alias LedDisp d1
  17. alias PanH r15
  18. alias PanV r14
  19. alias Shft r13
  20. alias PrkH r12
  21. alias Rsrv r11
  22. alias Hash r10
  23. alias PChrg r9
  24. alias PLght r8
  25. move sp 0
  26. loop: #============================================#
  27. yield
  28. lb PanH DaySens Horizontal Average
  29. lb PanV DaySens Vertical Average
  30. bne PanH PanH skip #NaN check
  31.  
  32. sgt r0 PanV 75 #if >85 turn on light
  33. beq r0 PLght skp
  34. bdns LightOn skp
  35. s LightOn On r0
  36. l r1 LightOn PrefabHash
  37. beq r1 LightSwt skp
  38. sb r1 On r0
  39. skp:
  40. move PLght r0
  41.  
  42. sub r0 PrkH 90
  43. sub r0 r0 Shft #sensor jump point correction
  44. brge PanH r0 2
  45. add PanH PanH 360
  46. add PanH PanH Shft #relative orient. correction
  47. brgt PanV 90 2 #store PrkH while day
  48. sub PrkH PanH 180
  49. div PrkH PrkH 90 #normalize PrkH
  50. round PrkH PrkH
  51. mul PrkH PrkH 90
  52. brle PanV 95 2 #park if V.Sol > 95 deg
  53. move PanH PrkH
  54. sub PanV 75 PanV #yeah, sol deg 2 pan perc
  55. div PanV PanV 1.5
  56.  
  57. #work wt solar panels:
  58. push -2045627372 #def
  59. push -539224550  #def dual
  60. push -934345724  #heavy
  61. push -1545574413 #heavy dual
  62. pop Hash
  63. lb r0 Hash Horizontal Average
  64. brne r0 r0 3
  65. move r1 r0 #r1 - current Hor.Angle; 4 AutoSet
  66. lb r2 Hash Ratio Average #r2 - Ratio; 4 AutoSet
  67. sb Hash Vertical PanV
  68. sb Hash Horizontal PanH
  69. brgtz sp -7
  70.  
  71. #AutoSet relative orientation
  72. bltz PanV skip #if night
  73. bgt r2 0.05 skip #if insol
  74. sub r0 r1 PanH
  75. abs r0 r0
  76. bgt r0 10 skip #if shift
  77. add Shft Shft 90
  78. mod Shft Shft 360
  79.  
  80. skip: #work wt accumulators:
  81. j loop #code below not complete
  82. push 1999523701  #APC
  83. push -1032513487 #APC rev
  84. push -400115994  #Battery
  85. push -1388288459 #Battery Large
  86. move r1 1
  87. move r2 0
  88. move r3 0
  89. move r4 0
  90. lp:
  91. pop Hash
  92. lb r0 Hash On Average
  93. bne r0 1 cnt #ignore NaN or not all on
  94. lb r0 Hash Maximum Minimum
  95. beqz r0 cnt #ignore if APC without battery
  96. lb r0 Hash Ratio Minimum
  97. min r1 r1 r0
  98. lb r0 Hash Ratio Average
  99. add r3 r3 r0
  100. lb r0 Hash Charge Sum
  101. add r2 r2 r0
  102. add r4 r4 1
  103. div r3 r3 r4
  104. cnt:
  105. bgtz sp lp
  106.  
  107. #start reserv generator
  108. select r0 Rsrv 0.10 0.05
  109. slt Rsrv r1 r0
  110. sb SolidGen On Rsrv
  111. yield #--temp
  112. sub r0 r2 PChrg
  113. move PChrg r2
  114. sgtz r1 r0
  115. select r1 r1 2 4
  116. xor r5 r5 1
  117. select r0 r5 r0 r3
  118. select r1 r5 r1 3
  119. select r3 r5 2 1
  120. brdns LedDisp 4
  121. s LedDisp Setting r0
  122. s LedDisp Color r1
  123. s LedDisp Mode r3
  124. s db 12 r3
  125.  
  126. j loop
Add Comment
Please, Sign In to add comment