Advertisement
ozybrum

Brum's System Monitor Client - Current Build

Aug 3rd, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.43 KB | None | 0 0
  1. --====== Brum's System Monitor Client Program ======--
  2. -- Author: OzyBrum
  3. -- Pastebin:
  4. -- Updater/Autorun pastebin:
  5. -- Licence: GPL v3
  6.  
  7.  
  8.  
  9.  
  10. -- Network Peripheral Function
  11. local sides = {
  12.     [1] = "front",
  13.     [2] = "back",
  14.     [3] = "left",
  15.     [4] = "right",
  16.     [5] = "top",
  17.     [6] = "bottom"
  18. }
  19. function peripherals()
  20.     for i = 1, 6 do
  21.         if peripheral.getType(sides[i]) == "modem" then
  22.             modem = peripheral.wrap(sides[i])
  23.             rednet.open(sides[i])
  24.             modemSide = (sides[i])
  25.         end
  26.         if peripheral.getType(sides[i]) == "monitor" then
  27.             monitor = peripheral.wrap(sides[i])
  28.             monitorConnected = true
  29.         end
  30.     end
  31. end
  32. peripherals()
  33.  
  34.  
  35.  
  36.  
  37. --========== USER VARIABLES ==========--
  38. local myName = "System Monitor Client"
  39. local alert = 5                     --Power level (%) at which you will revive an alert.
  40. local xpos = 5                      --X and Y position of the display on your screen.
  41. local ypos = 30                     --Note increasing the Y value will move the display down.
  42. local textBack = colors.blue        --Set the text highLighter color
  43. local backGround = colors.blue      --Set the background color of the monitor
  44. monitor.setTextColor(colors.white)      --Set the monitors text color
  45. --====================================--
  46.  
  47.  
  48.  
  49.  
  50. -- System Variables
  51. local devList = modem.getNamesRemote()
  52. local w, h = 0
  53. local w, h = monitor.getSize()
  54. local myID = os.getComputerID()
  55. local version = 0.7
  56. local connected = false
  57. local messageReceived = false
  58. local rednetColours = {
  59.     [1] = "colors.white",
  60.     [2] = "colors.orange",
  61.     [3] = "colors.magenta",
  62.     [4] = "colors.lightBlue",
  63.     [5] = "colors.yellow",
  64.     [6] = "colors.lime",
  65.     [7] = "colors.pink",
  66.     [8] = "colors.gray",
  67.     [9] = "colors.lightGray",
  68.     [10] = "colors.cyan",
  69.     [11] = "colors.purple",
  70.     [12] = "colors.blue",
  71.     [13] = "colors.brown",
  72.     [14] = "colors.green",
  73.     [15] = "colors.red",
  74.     [16] = "colors.black"
  75. }
  76. local capEu = 0
  77. local storedEu = 0
  78. local capMj = 0
  79. local storedMj = 0
  80. local percent = 0
  81. local percent2 = 0
  82. local MFSUs = {}
  83. local rsCells = {}
  84. local tanks = {}
  85. local mfsuCount = 0
  86. local cellCount = 0
  87. local tankCount = 0
  88. local tankData = {}
  89. local tankInfo = {}
  90. local timer = 0
  91. local updateSpeed = 5
  92. monitor.setTextScale(1)
  93.  
  94.  
  95.  
  96.  
  97. -- Miscellaneous Functions
  98.     -- Timers
  99. function pingRequestTimer() -- Time with no signal form server before the client declares itself 'loosing connection'
  100.     timerA = os.startTimer(15)
  101. end
  102. function severTimeoutTimer() -- Time with no signal form server before the client declares itself 'disconnected'
  103.     timerB = os.startTimer(30)
  104. end
  105.     -- Get Current In-Game Time
  106. function osTime()
  107.     local time = os.time()
  108.     formattedTime = textutils.formatTime(time, true)
  109. end
  110.     -- Rounder Function
  111. function round(number,decimal)
  112.     local multiplier = 10^(decimal or 0)
  113.     return math.floor(number * multiplier + 0.5) / multiplier
  114. end
  115.  
  116.  
  117.  
  118.  
  119. -- Peripheral/Devices Functions
  120.     -- Sort devices into their types.
  121. function sortDevs()
  122.     for k,v in pairs(devList) do
  123.         if peripheral.getType(v) == "batbox" then
  124.             MFSUs[k] = devList[k]
  125.             mfsuCount = mfsuCount + 1
  126.         elseif peripheral.getType(v) == "redstone_energy_cell" then
  127.             rsCells[k] = devList[k]
  128.             cellCount = cellCount + 1
  129.         elseif peripheral.getType(v) == "steel_tank_valve" or peripheral.getType(v) == "iron_tank_valve" then
  130.             tanks[k] = devList[k]
  131.             tankCount = tankCount + 1
  132.         end
  133.     end
  134.     for k,v in pairs(MFSUs) do
  135.             --print(tostring(k).." "..tostring(v))
  136.     end
  137.     for k,v in pairs(rsCells) do
  138.             --print(tostring(k).." "..tostring(v))
  139.     end
  140. end
  141.     -- Calculate the Eu and Mj capacity.
  142. function getCap()
  143.     capEu = 0
  144.     capMj = 0
  145.     for k,v in pairs(MFSUs) do
  146.         capEu = capEu + modem.callRemote(tostring(v),"getCapacity")
  147.         --print(tostring(k).." | "..tostring(v))
  148.     end
  149.     for k,v in pairs(rsCells) do
  150.         capMj = capMj + modem.callRemote(tostring(v),"getMaxEnergyStored")
  151.     end
  152.     osTime()
  153.     print(formattedTime.." - EUCap "..capEu)
  154.     print(formattedTime.." - MJCap "..capMj)
  155. end
  156.     -- Get Energy Currently Stored in connected devices.
  157. function getStored()
  158.     storedEu = 0
  159.     storedMj = 0
  160.     for k,v in pairs(MFSUs) do
  161.         storedEu = storedEu + modem.callRemote(v,"getStored")
  162.     end
  163.     for k,v in pairs(rsCells) do
  164.         storedMj = storedMj + modem.callRemote(v,"getEnergyStored")
  165.     end
  166. end
  167.     -- Get connected tank information and store it.
  168. function getTanks()
  169.     i = 0
  170.     for k,v in pairs(tanks) do
  171.         i = i + 1
  172.         tankData[i] = modem.callRemote(v,"getTanks","unknown")
  173.     end
  174.     i = 0
  175.     for k,v in pairs(tankData) do
  176.         i = i + 1
  177.         tankInfo[i] = v[3],v[4],v[5]
  178. --      for k2, v2 in pairs(tankData[k][1]) do
  179. --          print(k2.." = "..v2)
  180. --      end
  181.     end
  182. end
  183.  
  184.  
  185.  
  186.  
  187.  
  188. --[[ Low power alert to bridge disabled
  189.     note: when low power alert is activated send a message to network controller containing
  190.     the id of the computer to activate a redstone signal, side, colour ect.
  191.    
  192. function lowPowerAlert()
  193.   timer = timer + updateSpeed
  194.   if timer >= 1 then
  195.     if toggle then
  196.       toggle = false
  197.       timer = 0
  198.     else
  199.       toggle = true
  200.       timer = 0
  201.     end
  202.   end
  203.   if toggle then
  204.     bridge.addText(xpos,ypos + 75,"WARNING ENERGY LOW",0xFF0000)
  205.   end
  206. end
  207. --]]
  208.  
  209.  
  210.  
  211.  
  212. -- Monitor Display Functions
  213.     -- Gather all info and send it to the monitor
  214. function display()
  215.     monitor.setBackgroundColor(backGround)
  216.     monitor.clear()
  217.     monitor.setBackgroundColor(textBack)
  218.     heading()
  219.     displayOutput()
  220.     displayTanks()
  221. end
  222.     -- Display the Current Energy Storage Levels
  223. function displayOutput()
  224.     if mfsuCount > 0 then  
  225.         monitor.setCursorPos(1,2)
  226.         monitor.write("MFSUs: "..tostring(round(storedEu / capEu * 100, 2)).."%")
  227.         monitor.setCursorPos(22,2)
  228.         monitor.write("Storage Units:"..tostring(mfsuCount))
  229.         monitor.setCursorPos(1,4)
  230.         monitor.write("EU Storage:"..tostring(round(storedEu/1000000,3)).."M")   
  231.         monitor.setCursorPos(22,4)
  232.         monitor.write("Max:"..tostring(round(capEu/1000000,3)).."M")       
  233.     end
  234.     if cellCount > 0 then
  235.         monitor.setCursorPos(1,3)
  236.         monitor.write("RSCells: "..tostring(round(storedMj / capMj * 100, 2)).."%")
  237.         monitor.setCursorPos(22,3)
  238.         monitor.write("Storage Units:"..tostring(cellCount))       
  239.         monitor.setCursorPos(1,5)
  240.         monitor.write("MJ Storage:"..tostring(round(storedMj/1000000,3)).."M")   
  241.         monitor.setCursorPos(22,5)
  242.         monitor.write("Max:"..tostring(round(capMj/1000000,3)).."M")       
  243.     end
  244. end
  245.     -- Monitor Heading
  246. function heading()
  247.     ln2 = "------Tank Stats------"
  248.     monitor.setCursorPos((w-string.len(" Universal Storage Monitor "))/2+1,1)
  249.     monitor.write(" Universal Storage Monitor ")
  250.     monitor.setCursorPos(1,h)
  251.     --monitor.write(version.." by Brandon3055")
  252.     monitor.setCursorPos((w-string.len(ln2))/2+1,6)
  253.     monitor.write(ln2)
  254. end
  255.     -- Function to Display Tanks on Monitor
  256. function displayTanks()
  257.     width = 0
  258.     lines = h - 7
  259.     linesUsed = 0
  260.     lnx = 1
  261.     for i = 1, tankCount do
  262.         name = tankData[i][1]["name"] if name == nil then name = "Empty" end
  263.         capacity = tonumber(tankData[i][1]["capacity"])
  264.         amount = tonumber(tankData[i][1]["amount"]) if amount == nil then amount = 0 end
  265.         percent = round(amount / capacity * 100, 2)
  266.         --print(name.." | "..percent.." | "..amount.." | "..capacity)
  267.         if linesUsed < lines - 4 then
  268.             monitor.setCursorPos(lnx,7 + linesUsed)
  269.             monitor.write(name)
  270.             monitor.setCursorPos(lnx,7 + linesUsed + 1)
  271.             monitor.write(percent.."%")
  272.             monitor.setCursorPos(lnx,7 + linesUsed + 2)
  273.             monitor.write(tostring(amount / 1000).."B")
  274.             monitor.setCursorPos(lnx,7 + linesUsed + 3)
  275.             monitor.write("/"..tostring(capacity / 1000).."B")
  276.             linesUsed = linesUsed + 5
  277.         else
  278.             lnx = lnx + width + 2
  279.             width = 0
  280.             linesUsed = 0
  281.             monitor.setCursorPos(lnx,7 + linesUsed)
  282.             monitor.write(name)
  283.             monitor.setCursorPos(lnx,7 + linesUsed + 1)
  284.             monitor.write(percent.."%")
  285.             monitor.setCursorPos(lnx,7 + linesUsed + 2)
  286.             monitor.write(tostring(amount / 1000).."B")
  287.             monitor.setCursorPos(lnx,7 + linesUsed + 3)
  288.             monitor.write("/"..tostring(capacity / 1000).."B")
  289.             linesUsed = linesUsed + 5
  290.         end
  291.         if string.len(name) > width then
  292.             width = string.len(name)
  293.         end
  294.         if string.len("/"..tostring(capacity / 1000).."B") > width then
  295.             width = string.len("/"..tostring(capacity / 1000).."B")
  296.         end
  297.         if string.len(percent.."%") > width then
  298.             width = string.len(percent)
  299.         end
  300.         if string.len(tostring(amount / 1000).."B") > width then
  301.             width = string.len(tostring(amount / 1000).."B")
  302.         end
  303.     end
  304. end
  305.  
  306.  
  307.  
  308.  
  309. -- Connection Functions
  310. function loosingConnection()
  311.         print(formattedTime.." - No message received from server in 15s")
  312.         print(formattedTime.." - Loosing connection to server...")
  313.         messageReceived = false
  314. end
  315. function lostConnection()
  316.     if messageReceived == false then
  317.     print(formattedTime.." - Lost connection to server.")
  318.     print(formattedTime.." - Waiting for server message.")
  319.     connected = false
  320.     end
  321. end
  322.  
  323.  
  324.  
  325.  
  326. -- Message Protocol Functions
  327.     -- connectionMessages
  328. function broadcastMessage()
  329.     if connected == false then
  330.         serverID = senderID
  331.         print(formattedTime.." - Found Server!")
  332.         print(formattedTime.." - Server ID: "..serverID)
  333.         print(formattedTime.." - Connecting...")
  334.         rednet.send(senderID,"1~2")
  335.     else
  336.         --print(formattedTime.." - Broadcast from server received, already connected, Ignoring...")
  337.     end
  338. end
  339. function clientNameRequest()
  340.     local sendMessage = "1~4~"..myName
  341.         rednet.send(serverID,sendMessage)
  342.         print(formattedTime.." - Sent my name to server.")
  343.         print(formattedTime.." - Connected!")
  344.         messageReceived = true
  345.         connected = true
  346.         pingRequestTimer()
  347.         severTimeoutTimer()
  348. end
  349. function ping()
  350.     if connected == true then
  351.         if messageReceived == false then
  352.             print(formattedTime.." - Server reconnected.")
  353.         end
  354.         rednet.send(serverID,"1~6")
  355.         messageReceived = true
  356.         pingRequestTimer()
  357.         severTimeoutTimer()
  358.     end
  359. end
  360.     -- rednetOutputMessages
  361. function rednetOutputOn()
  362.     local side = sides[packetLayer2]
  363.     local colour = rednetColours[packetLayer3]
  364.     print(formattedTime.." - rednetOutput Message received.")
  365.     print("side = "..side..", colour = "..colour..", state = on")
  366.     if colour == "colors.white" then
  367.         rs.setBundledOutput(side,rs.getBundledOutput(side)+colors.white)
  368.     elseif colour == "colors.orange" then
  369.         rs.setBundledOutput(side,rs.getBundledOutput(side)+colors.orange)
  370.     elseif colour == "colors.magenta" then
  371.         rs.setBundledOutput(side,rs.getBundledOutput(side)+colors.magenta)
  372.     elseif colour == "colors.lightBlue" then
  373.         rs.setBundledOutput(side,rs.getBundledOutput(side)+colors.lightBlue)
  374.     elseif colour == "colors.yellow" then
  375.         rs.setBundledOutput(side,rs.getBundledOutput(side)+colors.yellow)
  376.     elseif colour == "colors.lime" then
  377.         rs.setBundledOutput(side,rs.getBundledOutput(side)+colors.lime)
  378.     elseif colour == "colors.pink" then
  379.         rs.setBundledOutput(side,rs.getBundledOutput(side)+colors.pink)
  380.     elseif colour == "colors.gray" then
  381.         rs.setBundledOutput(side,rs.getBundledOutput(side)+colors.gray)
  382.     elseif colour == "colors.lightGray" then
  383.         rs.setBundledOutput(side,rs.getBundledOutput(side)+colors.lightGray)
  384.     elseif colour == "colors.cyan" then
  385.         rs.setBundledOutput(side,rs.getBundledOutput(side)+colors.cyan)
  386.     elseif colour == "colors.purple" then
  387.         rs.setBundledOutput(side,rs.getBundledOutput(side)+colors.purple)
  388.     elseif colour == "colors.blue" then
  389.         rs.setBundledOutput(side,rs.getBundledOutput(side)+colors.blue)
  390.     elseif colour == "colors.brown" then
  391.         rs.setBundledOutput(side,rs.getBundledOutput(side)+colors.brown)
  392.     elseif colour == "colors.green" then
  393.         rs.setBundledOutput(side,rs.getBundledOutput(side)+colors.green)
  394.     elseif colour == "colors.red" then
  395.         rs.setBundledOutput(side,rs.getBundledOutput(side)+colors.red)
  396.     elseif colour == "colors.black" then
  397.         rs.setBundledOutput(side,rs.getBundledOutput(side)+colors.black)
  398.     end
  399. end
  400. function rednetOutputOff()
  401.     local side = sides[packetLayer2]
  402.     local colour = rednetColours[packetLayer3]
  403.     print(formattedTime.." - rednetOutput Message received.")
  404.     print("side = "..side..", colour = "..colour..", state = off")
  405.     if colour == "colors.white" then
  406.         rs.setBundledOutput(side,rs.getBundledOutput(side)-colors.white)
  407.     elseif colour == "colors.orange" then
  408.         rs.setBundledOutput(side,rs.getBundledOutput(side)-colors.orange)
  409.     elseif colour == "colors.magenta" then
  410.         rs.setBundledOutput(side,rs.getBundledOutput(side)-colors.magenta)
  411.     elseif colour == "colors.lightBlue" then
  412.         rs.setBundledOutput(side,rs.getBundledOutput(side)-colors.lightBlue)
  413.     elseif colour == "colors.yellow" then
  414.         rs.setBundledOutput(side,rs.getBundledOutput(side)-colors.yellow)
  415.     elseif colour == "colors.lime" then
  416.         rs.setBundledOutput(side,rs.getBundledOutput(side)-colors.lime)
  417.     elseif colour == "colors.pink" then
  418.         rs.setBundledOutput(side,rs.getBundledOutput(side)-colors.pink)
  419.     elseif colour == "colors.gray" then
  420.         rs.setBundledOutput(side,rs.getBundledOutput(side)-colors.gray)
  421.     elseif colour == "colors.lightGray" then
  422.         rs.setBundledOutput(side,rs.getBundledOutput(side)-colors.lightGray)
  423.     elseif colour == "colors.cyan" then
  424.         rs.setBundledOutput(side,rs.getBundledOutput(side)-colors.cyan)
  425.     elseif colour == "colors.purple" then
  426.         rs.setBundledOutput(side,rs.getBundledOutput(side)-colors.purple)
  427.     elseif colour == "colors.blue" then
  428.         rs.setBundledOutput(side,rs.getBundledOutput(side)-colors.blue)
  429.     elseif colour == "colors.brown" then
  430.         rs.setBundledOutput(side,rs.getBundledOutput(side)-colors.brown)
  431.     elseif colour == "colors.green" then
  432.         rs.setBundledOutput(side,rs.getBundledOutput(side)-colors.green)
  433.     elseif colour == "colors.red" then
  434.         rs.setBundledOutput(side,rs.getBundledOutput(side)-colors.red)
  435.     elseif colour == "colors.black" then
  436.         rs.setBundledOutput(side,rs.getBundledOutput(side)-colors.black)
  437.     end
  438. end
  439.     -- Message Protocol Table
  440.             local rednetOutputState = {
  441.             [1] = rednetOutputOn,
  442.             [2] = rednetOutputOff
  443.             }
  444.         local rednetOutputColour = {
  445.         [1] = rednetOutputState,
  446.         [2] = rednetOutputState,
  447.         [3] = rednetOutputState,
  448.         [4] = rednetOutputState,
  449.         [5] = rednetOutputState,
  450.         [6] = rednetOutputState,
  451.         [7] = rednetOutputState,
  452.         [8] = rednetOutputState,
  453.         [9] = rednetOutputState,
  454.         [10] = rednetOutputState,
  455.         [11] = rednetOutputState,
  456.         [12] = rednetOutputState,
  457.         [13] = rednetOutputState,
  458.         [14] = rednetOutputState,
  459.         [15] = rednetOutputState,
  460.         [16] = rednetOutputState
  461.         }
  462.     local rednetOutputSide = {
  463.     [1] = rednetOutputColour,
  464.     [2] = rednetOutputColour,
  465.     [3] = rednetOutputColour,
  466.     [4] = rednetOutputColour,
  467.     [5] = rednetOutputColour,
  468.     [6] = rednetOutputColour
  469.     }
  470.     local connectionMessages = {
  471.     [1] = broadcastMessage,
  472.     [2] = broadcastResponse,
  473.     [3] = clientNameRequest,
  474.     [4] = clientNameResponse,
  475.     [5] = ping,
  476.     [6] = pingResponse
  477.     }
  478. local protocol = {
  479. [1] = connectionMessages,
  480. [2] = rednetOutputSide
  481. }
  482.  
  483.  
  484.  
  485.  
  486. -- Watch-out Functions (always running/waiting)
  487.     -- Event Handler, detects system events such as timers going off and key presses.
  488. function sysEvents()
  489.     while true do
  490.         local event, parameter = os.pullEvent()
  491.         if event == "key" then
  492.             if parameter == 50 then -- Keycode 50 = 'M' Key
  493.                 menu()
  494.             else
  495.                 print(formattedTime.." - You did not enter one of the required keystrokes.")
  496.                 print(formattedTime.." - Press 'M' to return to the menu.")
  497.             end
  498.         end
  499.         if event == "timer" then
  500.             if parameter == timerA then -- If pingRequestTimer timer goes  off, run loosingConnection().
  501.             loosingConnection()
  502.             end
  503.             if parameter == timerB then -- If severTimeoutTimer timer goes  off, run lostConnection().
  504.             lostConnection()
  505.             end
  506.         end
  507.     end
  508. end
  509.     -- Incoming Message handler, decodes and decides what to do with incoming messages from network controller.
  510. function messageRecieved()
  511.     while true do
  512.         senderID, message = rednet.receive()
  513.         osTime()
  514.         local _, count = string.gsub(message, "%~", "")
  515.         --print(formattedTime.." - Number of times '~' occurs in message = "..count)
  516.         if count == 1 then
  517.             --print(formattedTime.." - 2 Layers of Protocol exist in message")
  518.             packetLayer1, packetLayer2 = string.match(message, "(.+)~(.+)")
  519.             --print(formattedTime.." - packetLayer1 = "..packetLayer1)
  520.             --print(formattedTime.." - packetLayer2 = "..packetLayer2)
  521.             packetLayer1 = tonumber(packetLayer1)
  522.             packetLayer2 = tonumber(packetLayer2)
  523.             protocol[packetLayer1][packetLayer2]()
  524.         end
  525.         if count == 2 then
  526.             --print(formattedTime.." - 3 Layers of Protocol exist in message")
  527.             packetLayer1, packetLayer2, packetLayer3 = string.match(message, "(.+)~(.+)~(.+)")
  528.             --print(formattedTime.." - packetLayer1 = "..packetLayer1)
  529.             --print(formattedTime.." - packetLayer2 = "..packetLayer2)
  530.             --print(formattedTime.." - packetLayer3 = "..packetLayer3)
  531.             packetLayer1 = tonumber(packetLayer1)
  532.             packetLayer2 = tonumber(packetLayer2)
  533.             if packetLayer2 == 4 then -- If message is 'clientNameResponse' then packetLayer3 is a string/name not number.
  534.                 --print(formattedTime.." - Message is a name response from a client")
  535.                 name = packetLayer3
  536.                 clientNames[senderID] = name
  537.                 --print("Client Name = "..name)
  538.                 protocol[packetLayer1][packetLayer2]()
  539.             else
  540.                 packetLayer2 = tonumber(packetLayer3)
  541.                 print(formattedTime.." - packetLayer1 = "..packetLayer1)
  542.                 print(formattedTime.." - packetLayer2 = "..packetLayer2)
  543.                 print(formattedTime.." - packetLayer3 = "..packetLayer3)
  544.                 protocol[packetLayer1][packetLayer2][packetLayer3]()
  545.             end
  546.         end
  547.         if count == 3 then
  548.             --print(formattedTime.." - 4 Layers of Protocol exist in message")
  549.             packetLayer1, packetLayer2, packetLayer3, packetLayer4 = string.match(message, "(.+)~(.+)~(.+)~(.+)")
  550.             --print(formattedTime.." - packetLayer1 = "..packetLayer1)
  551.             --print(formattedTime.." - packetLayer2 = "..packetLayer2)
  552.             --print(formattedTime.." - packetLayer3 = "..packetLayer3)
  553.             --print(formattedTime.." - packetLayer4 = "..packetLayer4)
  554.             packetLayer1 = tonumber(packetLayer1)
  555.             packetLayer2 = tonumber(packetLayer2)
  556.             packetLayer3 = tonumber(packetLayer3)
  557.             packetLayer4 = tonumber(packetLayer4)
  558.             protocol[packetLayer1][packetLayer2][packetLayer3][packetLayer4]()
  559.         end
  560.         if count == 4 then
  561.             --print(formattedTime.." - 5 Layers of Protocol exist in message")
  562.             packetLayer1, packetLayer2, packetLayer3, packetLayer5 = string.match(message, "(.+)~(.+)~(.+)~(.+)~(.+)")
  563.             --print(formattedTime.." - packetLayer1 = "..packetLayer1)
  564.             --print(formattedTime.." - packetLayer2 = "..packetLayer2)
  565.             --print(formattedTime.." - packetLayer3 = "..packetLayer3)
  566.             --print(formattedTime.." - packetLayer4 = "..packetLayer4)
  567.             --print(formattedTime.." - packetLayer5 = "..packetLayer5)
  568.             packetLayer1 = tonumber(packetLayer1)
  569.             packetLayer2 = tonumber(packetLayer2)
  570.             packetLayer3 = tonumber(packetLayer3)
  571.             packetLayer4 = tonumber(packetLayer4)
  572.             packetLayer5 = tonumber(packetLayer5)
  573.             protocol[packetLayer1][packetLayer2][packetLayer3][packetLayer4][packetLayer5]()
  574.         end
  575.     end
  576. end
  577.     -- Functions that monitor all connected devices.
  578. function systemMonitor()
  579.     while true do
  580.         getStored()
  581.         getTanks()
  582.         display()
  583.         sleep(updateSpeed)
  584.     end
  585. end
  586.  
  587.  
  588.  
  589.  
  590.  
  591. -- Menu Function
  592. function menu()
  593.     term.clear()
  594.     term.setCursorPos(1,1)
  595.     print("--====== Brum's Client Computer ======--")
  596.     print("Version: " ..version)
  597.     print("Computer ID: " ..myID)
  598.     print("Computer Name: " ..myName)
  599.     print("Modem Side: " ..modemSide)
  600.     print("--------------------MENU---------------------------")
  601.     print("Press 'M' to show this menu at any time. ")
  602.     print("---------------------------------------------------")
  603. end
  604.  
  605.  
  606.  
  607.  
  608.  
  609. -- StartUp Function
  610. function startUp()
  611.     sleep(1)
  612.     menu()
  613.     sortDevs()
  614.     getCap()
  615.     osTime()
  616.     print(formattedTime.." - Waiting for server message...")
  617.     parallel.waitForAny(sysEvents, messageRecieved, systemMonitor)
  618. end
  619.  
  620.  
  621.  
  622.  
  623.  
  624. startUp()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement