Advertisement
ordenix

Untitled

May 30th, 2015
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.22 KB | None | 0 0
  1. local r=peripheral.wrap("BigReactors-Reactor_136")
  2. --dpr
  3. local z=50
  4. local w=60
  5. local pp=4
  6. local ppr=0
  7. local wyster=100
  8. local zadane=50
  9. local k=60
  10. local ki=0.4
  11. local kd=0.9
  12. local u=0
  13. local up=0
  14. local su=0
  15. local prw=0
  16. local il=0
  17. local rotate=0
  18. local kbj=0
  19. local kbd=0
  20. local kbt=0
  21. local kbc=0
  22.  
  23. local m=peripheral.wrap("monitor_339")
  24. local szer,wys=m.getSize()
  25. function pozycja(z,l)
  26. m.setCursorPos(z,l)
  27. end
  28. function piszp(str)
  29. m.write(str)
  30. sleep(0.5)
  31. end
  32. function pisz(str)
  33. m.write(str)
  34. end
  35.  
  36.  
  37. -- funkcja wlancz
  38. function spr(ppr)
  39. --wlancz
  40. --wylancz
  41. if ppr==1 then
  42. r.setActive(true)
  43. else
  44. r.setActive(false)
  45. end
  46. end
  47. --Glowna penta programu
  48. while true do
  49. local moc=r.getEnergyStored()/100000
  50. --function round(num, idp)
  51. -- local mult = 10^(idp or 0)
  52. -- mocz=math.floor(num * mult + 0.5) / mult
  53. --end
  54. --round(moc,2)
  55. --print(mocz)
  56. --sleep(10)
  57.  
  58. if pp==2 then
  59. if moc<z then
  60. spr(1)
  61. end
  62. if moc>w then
  63. spr(0)
  64. end
  65. end --end2
  66. if pp==1 then
  67. end --end pp1
  68. if pp==0 then
  69. end --pp0
  70. if pp==3 then --sterowanie PID
  71.  
  72.  
  73.  
  74. --poczĥA5A585tki
  75. function round(num, idp)
  76. local mult = 10^(idp or 0)
  77. mocz=math.floor(num * mult + 0.5) / mult
  78. end
  79. round(moc,3)
  80. --print(mocz)
  81. --sleep(10)
  82. --pobranie danych
  83. moc1=mocz
  84. sleep(1,1)
  85. local moc=r.getEnergyStored()/100000
  86. round(moc,3)
  87.  
  88.  
  89. moc2=mocz
  90. if moc1<moc2 and moc2>zadane then
  91. wyster=wyster+1
  92. print("c1")
  93. end
  94.  
  95.  
  96. if moc1>moc2 and moc2<zadane then
  97. wyster=wyster-1
  98. print("c2")
  99. end
  100. if moc1==moc2 and moc2==zadane then
  101. wyster=wyster
  102. print("c3")
  103. end
  104. if moc1<moc2 and moc2==zadane then
  105. wyster=wyster
  106. print("c4")
  107. end
  108. if moc1==moc2 and moc2<zadane then
  109. wyster=wyster-1
  110. print("c5")
  111. end
  112. if moc1>moc2 and moc2==zadane then
  113. wyster=wyster
  114. print("c7")
  115. end
  116. if moc1==moc2 and moc2>zadane then
  117. wyster=wyster+1
  118. print("c9")
  119. end
  120. if wyster>100 then
  121. wyster=100
  122. end
  123. if wyster<0 then
  124. wyster=0
  125. end
  126. print(wyster)
  127. print("1")
  128. print(moc1)
  129. print("2")
  130. print(moc2)
  131. r.setAllControlRodLevels(wyster)
  132.  
  133.  
  134. end
  135.  
  136.  
  137.  
  138. if pp==4 then
  139. r.setActive(true)
  140. local izpp=2
  141.  
  142. local mult = 10^(izpp or 0)
  143. local moc=r.getEnergyStored()/100000
  144. moco=math.floor(moc * mult + 0.5) / mult
  145. u=zadane-moco
  146. p=k*u
  147. su=su+u
  148. i=ki*su
  149. d=kd*(u-up)
  150. up=u
  151. il=il+1
  152.  
  153. print("MOCo:")
  154. print(moco)
  155. print("zwyster")
  156. print(wyster)
  157. print(il)
  158. --print("suma")
  159. --print(su)
  160. --print(i)
  161. print("--------")
  162. sleep(0,5)
  163.  
  164. pwr=p+i+d
  165. wyster=100-pwr
  166.  
  167.  
  168. if wyster>100 then
  169. wyster=100
  170. end
  171. if wyster<0 then
  172. wyster=0
  173. end
  174.  
  175. r.setAllControlRodLevels(wyster)
  176.  
  177. end
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196. sleep(0,1)
  197.  
  198.  
  199. m.clear()
  200. m.setTextColor(colors.cyan)
  201. pozycja(1,wys)
  202. pisz("Inteligentny dom Otavi.pl v0,1")
  203. m.setTextColor(colors.orange)
  204. for i=1,39 do
  205. pozycja(i,wys-1)
  206. pisz("-")
  207. pozycja(i,wys-3)
  208. pisz("-")
  209. pozycja(i,2)
  210. pisz("-")
  211. pozycja(i,9)
  212. pisz("-")
  213. pozycja(i,11)
  214. pisz("-")
  215. pozycja(i,13)
  216. pisz("-")
  217. end
  218. pozycja(1,wys-2)
  219. m.setTextColor(colors.green)
  220. pisz("RBMK-1000")
  221. pozycja(39,wys-2)
  222.  
  223.  
  224.  
  225. pozycja(1,1)
  226. pisz("Current parameters of reactor")
  227. m.setCursorPos(1,3)
  228. --local status=r.getActive()
  229. m.write("Status:")
  230. if r.getActive() then
  231. m.setTextColor(colors.lime)
  232. pisz("working")
  233. else
  234. m.setTextColor(colors.red)
  235. pisz("przerwa")
  236. end
  237.  
  238. m.setTextColor(colors.green)
  239. pozycja(1,4);
  240. pisz("Wartosc zadana:")
  241. pozycja(21,4);
  242. pisz("[")
  243. krok=zadane/10
  244.  
  245.  
  246. local mult = 10^(0 or 0)
  247. krokr=math.floor(krok * mult + 0.5) / mult
  248. --pisz(krokr)
  249. if krokr<0 then
  250. krokr=0
  251. end
  252. if krokr>10 then
  253. krokr=10
  254. end
  255. for ttt=1, krokr do
  256. m.setTextColor(colors.red)
  257. pisz("|")
  258. end
  259. okrokr=10-krokr
  260.  
  261. for ttt=1, okrokr do
  262. m.setTextColor(colors.white)
  263. pisz("|")
  264. end
  265. m.setTextColor(colors.green)
  266. pisz("] ")
  267. local mult = 10^(0 or 0)
  268. procent=math.floor(zadane * mult + 0.5) / mult
  269. if procent>100 then
  270. procent=100
  271. end
  272. if procent<0 then
  273. procent=0
  274. end
  275. pisz(procent)
  276. pisz("%")
  277. ----------------------------------
  278.  
  279.  
  280. m.setTextColor(colors.green)
  281. pozycja(1,5);
  282. pisz("Wartosc zmierzona:")
  283. pozycja(21,5);
  284. pisz("[")
  285. krok=moc/10
  286.  
  287.  
  288. local mult = 10^(0 or 0)
  289. krokr=math.floor(krok * mult + 0.5) / mult
  290. --pisz(krokr)
  291. if krokr<0 then
  292. krokr=0
  293. end
  294. if krokr>10 then
  295. krokr=10
  296. end
  297. for ttt=1, krokr do
  298. m.setTextColor(colors.red)
  299. pisz("|")
  300. end
  301. okrokr=10-krokr
  302.  
  303. for ttt=1, okrokr do
  304. m.setTextColor(colors.white)
  305. pisz("|")
  306. end
  307. m.setTextColor(colors.green)
  308. pisz("] ")
  309. local mult = 10^(0 or 0)
  310. procent=math.floor(moc * mult + 0.5) / mult
  311. if procent>100 then
  312. procent=100
  313. end
  314. if procent<0 then
  315. procent=0
  316. end
  317. pisz(procent)
  318. pisz("%")
  319.  
  320.  
  321. -------------------
  322.  
  323. m.setTextColor(colors.green)
  324. pozycja(1,6);
  325. pisz("Wysterowanie:")
  326. pozycja(21,6);
  327. pisz("[")
  328. krok=pwr/10
  329.  
  330.  
  331. local mult = 10^(0 or 0)
  332. krokr=math.floor(krok * mult + 0.5) / mult
  333. --pisz(krokr)
  334. if krokr<0 then
  335. krokr=0
  336. end
  337. if krokr>10 then
  338. krokr=10
  339. end
  340. for ttt=1, krokr do
  341. m.setTextColor(colors.red)
  342. pisz("|")
  343. end
  344. okrokr=10-krokr
  345.  
  346. for ttt=1, okrokr do
  347. m.setTextColor(colors.white)
  348. pisz("|")
  349. end
  350. m.setTextColor(colors.green)
  351. pisz("] ")
  352. local mult = 10^(0 or 0)
  353. procent=math.floor(pwr * mult + 0.5) / mult
  354. if procent>100 then
  355. procent=100
  356. end
  357. if procent<0 then
  358. procent=0
  359. end
  360. pisz(procent)
  361. pisz("%")
  362.  
  363. ------------------------------
  364. m.setTextColor(colors.green)
  365. pozycja(1,7);
  366. pisz("Zuzycie:")
  367. pozycja(21,7);
  368. pisz("[")
  369. local kkk=r.getFuelConsumedLastTick()
  370.  
  371. krok=kkk*10
  372.  
  373.  
  374. local mult = 10^(0 or 0)
  375. krokr=math.floor(krok * mult + 0.5) / mult
  376. --pisz(krokr)
  377. if krokr<0 then
  378. krokr=0
  379. end
  380. if krokr>10 then
  381. krokr=10
  382. end
  383. for ttt=1, krokr do
  384. m.setTextColor(colors.red)
  385. pisz("|")
  386. end
  387. okrokr=10-krokr
  388.  
  389. for ttt=1, okrokr do
  390. m.setTextColor(colors.white)
  391. pisz("|")
  392. end
  393. m.setTextColor(colors.green)
  394. pisz("] ")
  395. local mult = 10^(0 or 0)
  396. procent=math.floor(kkk*100 * mult + 0.5) / mult
  397. if procent>100 then
  398. procent=100
  399. end
  400. if procent<0 then
  401. procent=0
  402. end
  403. pisz(procent)
  404. pisz("%")
  405.  
  406.  
  407. ------------------------------
  408. m.setTextColor(colors.green)
  409. pozycja(1,8);
  410. pisz("Il. paliwa:")
  411. pozycja(21,8);
  412. pisz("[")
  413. local kkk=r.getFuelAmount()
  414.  
  415. krok=((kkk/1600))/10
  416.  
  417.  
  418. local mult = 10^(0 or 0)
  419. krokr=math.floor(krok * mult + 0.5) / mult
  420. --pisz(krokr)
  421. if krokr<0 then
  422. krokr=0
  423. end
  424. if krokr>10 then
  425. krokr=10
  426. end
  427. for ttt=1, krokr do
  428. m.setTextColor(colors.red)
  429. pisz("|")
  430. end
  431. okrokr=10-krokr
  432.  
  433. for ttt=1, okrokr do
  434. m.setTextColor(colors.white)
  435. pisz("|")
  436. end
  437. m.setTextColor(colors.green)
  438. pisz("] ")
  439. local mult = 10^(0 or 0)
  440. procent=math.floor((kkk/1600) * mult + 0.5) / mult
  441. if procent>100 then
  442. procent=100
  443. end
  444. if procent<0 then
  445. procent=0
  446. end
  447. pisz(procent)
  448. pisz("%")
  449. -----------------------------------------
  450. --pozycja(1,9)
  451. --pisz(kkks)
  452.  
  453. if procent<5 then
  454. kbj=1
  455. else
  456. kbj=0
  457. end
  458.  
  459. ---------------------------------
  460.  
  461.  
  462. if u<-4 then
  463. kbd=1
  464. else
  465. kbd=0
  466. end
  467.  
  468. if u>4 and wyster==0 then
  469. kbt=1
  470. else
  471. kbt=0
  472. end
  473.  
  474. if u>4 and wyster==100 then
  475. kbc=1
  476. else
  477. kbc=0
  478. end
  479. ------
  480. --bledy
  481. -------
  482.  
  483. m.setTextColor(colors.red)
  484. pozycja(1,10)
  485. pisz("Bledy:")
  486. m.setTextColor(colors.orange)
  487. pozycja(19,12)
  488. pisz("|")
  489. pozycja(19,13)
  490. pisz("|")
  491. pozycja(19,14)
  492. pisz("|")
  493. pozycja(19,15)
  494. pisz("|")
  495.  
  496.  
  497.  
  498. if kbj==0 then
  499. pozycja(1,12)
  500. m.setTextColor(colors.gray)
  501. pisz("Malo paliwa")
  502. else
  503. pozycja(1,12)
  504. m.setTextColor(colors.white)
  505. pisz("Malo paliwa")
  506. end
  507. if kbd==0 then
  508. m.setTextColor(colors.gray)
  509. pozycja(20,12)
  510. pisz("Przesterowanie")
  511. else
  512. m.setTextColor(colors.white)
  513. pozycja(20,12)
  514. pisz("Przesterowanie")
  515. end
  516. if kbt==0 then
  517. m.setTextColor(colors.gray)
  518. pozycja(1,14)
  519. pisz("Brak")
  520. pozycja(1,15)
  521. pisz("Zdolnosci Mocy")
  522. else
  523. m.setTextColor(colors.white)
  524. pozycja(1,14)
  525. pisz("Brak")
  526. pozycja(1,15)
  527. pisz("Zdolnosci Mocy")
  528. end
  529.  
  530. if kbc==0 then
  531. m.setTextColor(colors.gray)
  532. pozycja(20,14)
  533. pisz("Brak")
  534. pozycja(20,15)
  535. pisz("Wysterowania")
  536. else
  537. m.setTextColor(colors.white)
  538. pozycja(20,14)
  539. pisz("Brak")
  540. pozycja(20,15)
  541. pisz("Wysterowania")
  542. end
  543.  
  544. if kbj==0 then
  545. redstone.setBundledOutput("top", 0)
  546. else
  547. redstone.setBundledOutput("top", colors.red)
  548. sleep(0.8)
  549. redstone.setBundledOutput("top", colors.white)
  550. sleep(0.8)
  551. redstone.setBundledOutput("top", colors.black)
  552. sleep(0.8)
  553. redstone.setBundledOutput("top", 0)
  554. sleep(0.8)
  555. redstone.setBundledOutput("top", colors.black)
  556. sleep(0.8)
  557. redstone.setBundledOutput("top", 0)
  558. sleep(0.8)
  559. end
  560.  
  561.  
  562. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement