From ce72f016f5a182bb48b20d05b84c650ba0c1fca7 Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Thu, 4 Jan 2018 23:12:30 +0800 Subject: [PATCH] Update transport client. AutoInstaller is updated. --- transport_client.lua | 88 +++++++++++++++++++++++++++++++------------- update.lua | 6 +-- 2 files changed, 64 insertions(+), 30 deletions(-) diff --git a/transport_client.lua b/transport_client.lua index d0a3421..bf6bad4 100644 --- a/transport_client.lua +++ b/transport_client.lua @@ -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() \ No newline at end of file +print("Transport System Client Started.") +print("Author: Kiritow") +main() +print("Transport System Client Stopped.") \ No newline at end of file diff --git a/update.lua b/update.lua index 9365fef..c1a1cae 100644 --- a/update.lua +++ b/update.lua @@ -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.")