Update transport client.

AutoInstaller is updated.
This commit is contained in:
Kirigaya Kazuto 2018-01-04 23:12:30 +08:00
parent bd44d42ab4
commit ce72f016f5
2 changed files with 64 additions and 30 deletions

View File

@ -1,17 +1,24 @@
local component=require("component")
local event=require("event")
require("libevent")
require("util")
--- Auto Configure
local digital_controller = proxy("digital_controller_box")
local digital_receiver = proxy("digital_receiver_box")
local transposer = proxy("transposer")
local routing_track = proxy("routing_track")
local out_ticket = proxy("routing_track")
--- Manually Configure
local route_in_ab = proxy("routing_switch","6")
local route_in_ba = proxy("routing_switch","a")
local route_out = proxy("routing_switch","1")
local load_detector = proxy("digital_detector","0")
local unload_detector = proxy("digital_detector","4")
local load_transposer = proxy("transposer","7")
local unload_transposer = proxy("transposer","6")
local route_ab_load = proxy("routing_switch","0c")
local route_ba_load = proxy("routing_switch","088")
local route_ab_unload = proxy("routing_switch","08c")
local route_ba_unload = proxy("routing_switch","c")
-- Value: 1 Green 2 Blinking Yello 3 Yello 4 Blinking Red 5 Red
local green=1
@ -25,6 +32,8 @@ local function setSignal(name,value)
end
local function checkDevice()
print("Checking Devices...")
local function doCheckDevice(device)
if(device==nil) then
error("Some device is nil. Please double check your configure.")
@ -33,11 +42,14 @@ local function checkDevice()
doCheckDevice(digital_controller)
doCheckDevice(digital_receiver)
doCheckDevice(transposer)
doCheckDevice(routing_track)
doCheckDevice(route_in_ab)
doCheckDevice(route_in_ba)
doCheckDevice(route_out)
doCheckDevice(out_ticket)
doCheckDevice(load_detector)
doCheckDevice(unload_detector)
doCheckDevice(route_ab_load)
doCheckDevice(route_ba_load)
doCheckDevice(route_ab_unload)
doCheckDevice(route_ba_unload)
local t=digital_controller.getSignalNames()
@ -51,23 +63,49 @@ local function checkDevice()
error("CheckSigName: Failed to check signal: " .. name)
end
checkSigName("Cart_Ctrl")
checkSigName("Lamp")
checkSigName("Box_Ctrl")
checkSigName("AInCtrl")
checkSigName("BInCtrl")
checkSigName("LoadCartCtrl")
checkSigName("LoadBoxCtrl")
checkSigName("UnloadCartCtrl")
checkSigName("UnloadBoxCtrl")
checkSigName("OutCtrl")
t=digital_receiver.getSignalNames()
checkSigName("Cart_Ready")
checkSigName("LoadCartSig")
checkSigName("UnloadCartSig")
local function checkRoutingTable(device)
if(device.getRoutingTableTitle()==false) then
error("CheckRoutingTable: Failed to check routing table. Please insert a routing table in it.")
end
end
checkRoutingTable(route_ab_load)
checkRoutingTable(route_ba_load)
checkRoutingTable(route_ab_unload)
checkRoutingTable(route_ba_unload)
local function checkRoutingTicket(device)
if(device.getDestination()==false) then
error("CheckRoutingTicket: Failed to check routing track. Please insert a golden ticket in it.")
end
end
checkRoutingTicket(out_ticket)
print("Check device pass.")
end
local function resetDevice()
digital_controller.setEveryAspect(red)
setSignal("Lamp",green)
print("Reseting Devices...")
route_in_ab.setRoutingTable({})
route_in_ba.setRoutingTable({})
route_out.setRoutingTable({})
digital_controller.setEveryAspect(red)
route_ab_load.setRoutingTable({})
route_ba_load.setRoutingTable({})
route_ab_unload.setRoutingTable({})
route_ba_unload.setRoutingTable({})
print("Device reset done.")
end
@ -75,11 +113,9 @@ end
local function main()
checkDevice()
resetDevice()
while true do
print("Please put your things in the box. Then press ENTER.")
local e=event.pull(e)
end
end
main()
print("Transport System Client Started.")
print("Author: Kiritow")
main()
print("Transport System Client Stopped.")

View File

@ -2,12 +2,10 @@
local component=require("component")
function DownloadFromGitHub(RepoName,Branch,FileAddress)
local hwtable=component.list()
local hwtable=component.list("internet")
local found=false
for k,v in pairs(hwtable) do
if(v=="internet") then
found=true
end
found=true
end
if(not found) then
error("The downloader requires an Internet card.")