Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modemC = peripheral.wrap('top') --cable
- modemW = peripheral.wrap('left')--wifi
- modemW.open(51)
- EUn1 = 0
- EUn2 = 0
- RFn1 = 0
- RFn2 = 0
- EU2n1 = 0
- EU2n2 = 0
- RF2n1 = 0
- RF2n2 = 0
- moni = peripheral.wrap("monitor_4")
- moni.setBackgroundColor(colors.black)
- moni.setTextScale(1)
- mfe = nil
- mfe2 = nil
- mfeMax = nil
- mfe2Max = nil
- cube2 = nil
- cube = nil
- cubeMax = nil
- function recevoir()
- e, s, frequency, reply, m, d = os.pullEvent("modem_message")
- if frequency == 51 then
- if reply == 52 then
- RFStored = m
- elseif reply == 53 then
- RF2Stored = m
- elseif reply == 54 then
- EUStored = m
- elseif reply == 55 then
- EU2Stored = m
- elseif reply == 56 then
- cubeMax = m
- elseif reply == 57 then
- cube2Max = m
- elseif reply == 58 then
- mfeMax = m
- elseif reply == 59 then
- mfe2Max = m
- end
- end
- end
- function quelColor(energy)
- if energy < 20 then c = colors.red end
- if energy >20 and energy < 70 then c = colors.yellow end
- if energy > 70 then c = colors.green end
- return(c)
- end
- function titre (x,y,titre,c)
- moni.setTextColor(c)
- moni.setCursorPos(x,y)
- moni.write (titre)
- end
- function etat (x,y,n1,n2)
- e = (n1 - n2)/100
- e = math.floor (e)/10
- if e < 0 then c = colors.red
- else c = colors.green end
- moni.setTextColor(c)
- moni.setCursorPos(x,y)
- moni.write (e)
- moni.write ('K')
- end
- function barre (x,y,ener,col)
- moni.setCursorPos(x,y)
- I = ener /8
- for i =1,I do
- moni.setBackgroundColor(col)
- moni.write(" ")
- end
- moni.setBackgroundColor(colors.black)
- end
- while true do
- recevoir()
- if EUStored ~= nil and mfeMax ~= nil then
- EU = math.floor(((EUStored ) / mfeMax ) *1000)/10
- EUn1 = EUStored
- end
- if EU2Stored ~= nil and mfe2Max ~= nil then
- EU2 = math.floor(((EU2Stored ) / mfe2Max ) *1000)/10
- EU2n1 = EU2Stored
- end
- if RFStored ~= nil and cubeMax ~= nil then
- RF = math.floor((RFStored / cubeMax ) *1000)/10
- RFn1 = RFStored
- end
- if RF2Stored ~= nil and cube2Max ~= nil then
- RF2 = math.floor((RF2Stored / cube2Max ) *1000)/10
- RF2n1 = RF2Stored
- end
- moni.clear()
- titre(8,1,"Monitoring -> le Porc",colors.yellow)
- titre(2,3,"RF Principal",colors.white)
- titre(2,8,"RF Secondaire",colors.white)
- titre(16,3,"EU Principal",colors.white)
- titre (16,8,"EU Secondaire",colors.white)
- if EU ~= nil then
- titre(20,4,EU,quelColor(EU))
- moni.write("%")
- barre(16,5,EU,quelColor(EU))
- etat(19,6,EUn1,EUn2)
- else
- titre (20,4,"indisponible",colors.red)
- titre (20,5,"indisponible",colors.red)
- titre (20,6,"indisponible",colors.red)
- end
- if EU2 ~= nil then
- titre(20,9,EU2,quelColor(EU2))
- moni.write("%")
- barre(16,10,EU2,quelColor(EU2))
- etat(19,11,EU2n1,EU2n2)
- else
- titre (20,9,"indisponible",colors.red)
- titre (20,10,"indisponible",colors.red)
- titre (20,11,"indisponible",colors.red)
- end
- if RF ~= nil then
- titre(6,4,RF,quelColor(RF))
- moni.write("%")
- barre(2,5,RF,quelColor(RF))
- etat(5,6,RFn1,RFn2)
- else
- titre (20,4,"indisponible",colors.red)
- titre (20,5,"indisponible",colors.red)
- titre (20,6,"indisponible",colors.red)
- end
- if RF2 ~= nil then
- titre(6,9,RF2,quelColor(RF2))
- moni.write("%")
- barre(2,10,RF2,quelColor(RF2))
- etat(5,11,RF2n1,RF2n2)
- else
- titre (20,9,"indisponible",colors.red)
- titre (20,10,"indisponible",colors.red)
- titre (20,11,"indisponible",colors.red)
- end
- moni.setBackgroundColor(colors.black)
- EUn2 = EUn1
- EU2n2 = EU2n1
- RFn2 = RFn1
- RF2n2 = RF2n1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement