Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local r=peripheral.wrap("BigReactors-Reactor_136")
- --dpr
- local z=50
- local w=60
- local pp=4
- local ppr=0
- local wyster=100
- local zadane=50
- local k=60
- local ki=0.4
- local kd=0.9
- local u=0
- local up=0
- local su=0
- local prw=0
- local il=0
- local rotate=0
- local kbj=0
- local kbd=0
- local kbt=0
- local kbc=0
- local m=peripheral.wrap("monitor_339")
- local szer,wys=m.getSize()
- function pozycja(z,l)
- m.setCursorPos(z,l)
- end
- function piszp(str)
- m.write(str)
- sleep(0.5)
- end
- function pisz(str)
- m.write(str)
- end
- -- funkcja wlancz
- function spr(ppr)
- --wlancz
- --wylancz
- if ppr==1 then
- r.setActive(true)
- else
- r.setActive(false)
- end
- end
- --Glowna penta programu
- while true do
- local moc=r.getEnergyStored()/100000
- --function round(num, idp)
- -- local mult = 10^(idp or 0)
- -- mocz=math.floor(num * mult + 0.5) / mult
- --end
- --round(moc,2)
- --print(mocz)
- --sleep(10)
- if pp==2 then
- if moc<z then
- spr(1)
- end
- if moc>w then
- spr(0)
- end
- end --end2
- if pp==1 then
- end --end pp1
- if pp==0 then
- end --pp0
- if pp==3 then --sterowanie PID
- --poczĥA5A585tki
- function round(num, idp)
- local mult = 10^(idp or 0)
- mocz=math.floor(num * mult + 0.5) / mult
- end
- round(moc,3)
- --print(mocz)
- --sleep(10)
- --pobranie danych
- moc1=mocz
- sleep(1,1)
- local moc=r.getEnergyStored()/100000
- round(moc,3)
- moc2=mocz
- if moc1<moc2 and moc2>zadane then
- wyster=wyster+1
- print("c1")
- end
- if moc1>moc2 and moc2<zadane then
- wyster=wyster-1
- print("c2")
- end
- if moc1==moc2 and moc2==zadane then
- wyster=wyster
- print("c3")
- end
- if moc1<moc2 and moc2==zadane then
- wyster=wyster
- print("c4")
- end
- if moc1==moc2 and moc2<zadane then
- wyster=wyster-1
- print("c5")
- end
- if moc1>moc2 and moc2==zadane then
- wyster=wyster
- print("c7")
- end
- if moc1==moc2 and moc2>zadane then
- wyster=wyster+1
- print("c9")
- end
- if wyster>100 then
- wyster=100
- end
- if wyster<0 then
- wyster=0
- end
- print(wyster)
- print("1")
- print(moc1)
- print("2")
- print(moc2)
- r.setAllControlRodLevels(wyster)
- end
- if pp==4 then
- r.setActive(true)
- local izpp=2
- local mult = 10^(izpp or 0)
- local moc=r.getEnergyStored()/100000
- moco=math.floor(moc * mult + 0.5) / mult
- u=zadane-moco
- p=k*u
- su=su+u
- i=ki*su
- d=kd*(u-up)
- up=u
- il=il+1
- print("MOCo:")
- print(moco)
- print("zwyster")
- print(wyster)
- print(il)
- --print("suma")
- --print(su)
- --print(i)
- print("--------")
- sleep(0,5)
- pwr=p+i+d
- wyster=100-pwr
- if wyster>100 then
- wyster=100
- end
- if wyster<0 then
- wyster=0
- end
- r.setAllControlRodLevels(wyster)
- end
- sleep(0,1)
- m.clear()
- m.setTextColor(colors.cyan)
- pozycja(1,wys)
- pisz("Inteligentny dom Otavi.pl v0,1")
- m.setTextColor(colors.orange)
- for i=1,39 do
- pozycja(i,wys-1)
- pisz("-")
- pozycja(i,wys-3)
- pisz("-")
- pozycja(i,2)
- pisz("-")
- pozycja(i,9)
- pisz("-")
- pozycja(i,11)
- pisz("-")
- pozycja(i,13)
- pisz("-")
- end
- pozycja(1,wys-2)
- m.setTextColor(colors.green)
- pisz("RBMK-1000")
- pozycja(39,wys-2)
- pozycja(1,1)
- pisz("Current parameters of reactor")
- m.setCursorPos(1,3)
- --local status=r.getActive()
- m.write("Status:")
- if r.getActive() then
- m.setTextColor(colors.lime)
- pisz("working")
- else
- m.setTextColor(colors.red)
- pisz("przerwa")
- end
- m.setTextColor(colors.green)
- pozycja(1,4);
- pisz("Wartosc zadana:")
- pozycja(21,4);
- pisz("[")
- krok=zadane/10
- local mult = 10^(0 or 0)
- krokr=math.floor(krok * mult + 0.5) / mult
- --pisz(krokr)
- if krokr<0 then
- krokr=0
- end
- if krokr>10 then
- krokr=10
- end
- for ttt=1, krokr do
- m.setTextColor(colors.red)
- pisz("|")
- end
- okrokr=10-krokr
- for ttt=1, okrokr do
- m.setTextColor(colors.white)
- pisz("|")
- end
- m.setTextColor(colors.green)
- pisz("] ")
- local mult = 10^(0 or 0)
- procent=math.floor(zadane * mult + 0.5) / mult
- if procent>100 then
- procent=100
- end
- if procent<0 then
- procent=0
- end
- pisz(procent)
- pisz("%")
- ----------------------------------
- m.setTextColor(colors.green)
- pozycja(1,5);
- pisz("Wartosc zmierzona:")
- pozycja(21,5);
- pisz("[")
- krok=moc/10
- local mult = 10^(0 or 0)
- krokr=math.floor(krok * mult + 0.5) / mult
- --pisz(krokr)
- if krokr<0 then
- krokr=0
- end
- if krokr>10 then
- krokr=10
- end
- for ttt=1, krokr do
- m.setTextColor(colors.red)
- pisz("|")
- end
- okrokr=10-krokr
- for ttt=1, okrokr do
- m.setTextColor(colors.white)
- pisz("|")
- end
- m.setTextColor(colors.green)
- pisz("] ")
- local mult = 10^(0 or 0)
- procent=math.floor(moc * mult + 0.5) / mult
- if procent>100 then
- procent=100
- end
- if procent<0 then
- procent=0
- end
- pisz(procent)
- pisz("%")
- -------------------
- m.setTextColor(colors.green)
- pozycja(1,6);
- pisz("Wysterowanie:")
- pozycja(21,6);
- pisz("[")
- krok=pwr/10
- local mult = 10^(0 or 0)
- krokr=math.floor(krok * mult + 0.5) / mult
- --pisz(krokr)
- if krokr<0 then
- krokr=0
- end
- if krokr>10 then
- krokr=10
- end
- for ttt=1, krokr do
- m.setTextColor(colors.red)
- pisz("|")
- end
- okrokr=10-krokr
- for ttt=1, okrokr do
- m.setTextColor(colors.white)
- pisz("|")
- end
- m.setTextColor(colors.green)
- pisz("] ")
- local mult = 10^(0 or 0)
- procent=math.floor(pwr * mult + 0.5) / mult
- if procent>100 then
- procent=100
- end
- if procent<0 then
- procent=0
- end
- pisz(procent)
- pisz("%")
- ------------------------------
- m.setTextColor(colors.green)
- pozycja(1,7);
- pisz("Zuzycie:")
- pozycja(21,7);
- pisz("[")
- local kkk=r.getFuelConsumedLastTick()
- krok=kkk*10
- local mult = 10^(0 or 0)
- krokr=math.floor(krok * mult + 0.5) / mult
- --pisz(krokr)
- if krokr<0 then
- krokr=0
- end
- if krokr>10 then
- krokr=10
- end
- for ttt=1, krokr do
- m.setTextColor(colors.red)
- pisz("|")
- end
- okrokr=10-krokr
- for ttt=1, okrokr do
- m.setTextColor(colors.white)
- pisz("|")
- end
- m.setTextColor(colors.green)
- pisz("] ")
- local mult = 10^(0 or 0)
- procent=math.floor(kkk*100 * mult + 0.5) / mult
- if procent>100 then
- procent=100
- end
- if procent<0 then
- procent=0
- end
- pisz(procent)
- pisz("%")
- ------------------------------
- m.setTextColor(colors.green)
- pozycja(1,8);
- pisz("Il. paliwa:")
- pozycja(21,8);
- pisz("[")
- local kkk=r.getFuelAmount()
- krok=((kkk/1600))/10
- local mult = 10^(0 or 0)
- krokr=math.floor(krok * mult + 0.5) / mult
- --pisz(krokr)
- if krokr<0 then
- krokr=0
- end
- if krokr>10 then
- krokr=10
- end
- for ttt=1, krokr do
- m.setTextColor(colors.red)
- pisz("|")
- end
- okrokr=10-krokr
- for ttt=1, okrokr do
- m.setTextColor(colors.white)
- pisz("|")
- end
- m.setTextColor(colors.green)
- pisz("] ")
- local mult = 10^(0 or 0)
- procent=math.floor((kkk/1600) * mult + 0.5) / mult
- if procent>100 then
- procent=100
- end
- if procent<0 then
- procent=0
- end
- pisz(procent)
- pisz("%")
- -----------------------------------------
- --pozycja(1,9)
- --pisz(kkks)
- if procent<5 then
- kbj=1
- else
- kbj=0
- end
- ---------------------------------
- if u<-4 then
- kbd=1
- else
- kbd=0
- end
- if u>4 and wyster==0 then
- kbt=1
- else
- kbt=0
- end
- if u>4 and wyster==100 then
- kbc=1
- else
- kbc=0
- end
- ------
- --bledy
- -------
- m.setTextColor(colors.red)
- pozycja(1,10)
- pisz("Bledy:")
- m.setTextColor(colors.orange)
- pozycja(19,12)
- pisz("|")
- pozycja(19,13)
- pisz("|")
- pozycja(19,14)
- pisz("|")
- pozycja(19,15)
- pisz("|")
- if kbj==0 then
- pozycja(1,12)
- m.setTextColor(colors.gray)
- pisz("Malo paliwa")
- else
- pozycja(1,12)
- m.setTextColor(colors.white)
- pisz("Malo paliwa")
- end
- if kbd==0 then
- m.setTextColor(colors.gray)
- pozycja(20,12)
- pisz("Przesterowanie")
- else
- m.setTextColor(colors.white)
- pozycja(20,12)
- pisz("Przesterowanie")
- end
- if kbt==0 then
- m.setTextColor(colors.gray)
- pozycja(1,14)
- pisz("Brak")
- pozycja(1,15)
- pisz("Zdolnosci Mocy")
- else
- m.setTextColor(colors.white)
- pozycja(1,14)
- pisz("Brak")
- pozycja(1,15)
- pisz("Zdolnosci Mocy")
- end
- if kbc==0 then
- m.setTextColor(colors.gray)
- pozycja(20,14)
- pisz("Brak")
- pozycja(20,15)
- pisz("Wysterowania")
- else
- m.setTextColor(colors.white)
- pozycja(20,14)
- pisz("Brak")
- pozycja(20,15)
- pisz("Wysterowania")
- end
- if kbj==0 then
- redstone.setBundledOutput("top", 0)
- else
- redstone.setBundledOutput("top", colors.red)
- sleep(0.8)
- redstone.setBundledOutput("top", colors.white)
- sleep(0.8)
- redstone.setBundledOutput("top", colors.black)
- sleep(0.8)
- redstone.setBundledOutput("top", 0)
- sleep(0.8)
- redstone.setBundledOutput("top", colors.black)
- sleep(0.8)
- redstone.setBundledOutput("top", 0)
- sleep(0.8)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement