Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local MC = require("motor_controller")
- local file = io.open("moduleData", "a")
- local function all_trim(s)
- return s:match( "^%s*(.-)%s*$" )
- end
- local collector = peripheral.wrap("right")
- local monitor = peripheral.wrap("left")
- -- Initialization of testing variables
- local speed = 1
- local iterator = 1
- -- Initialization of testing module
- local belt = MC:new("6", 256, 0)
- local M_Crusher = MC:new("4", 256, 0)
- local S_Crusher = MC:new("5", 256, 0)
- --Time Initialization
- local timer = os.startTimer(15)
- local event, time = os.pullEvent()
- -- Slave specification
- M_Crusher:setSlave(S_Crusher, true)
- -- Main loop for data collection
- while speed < 16 do
- local last
- while event == "timer" and time ~= timer do
- local event, time = os.pullEvent()
- --print formatting
- last = string.format("%s,%s,%s,%d\n",
- string.gsub(all_trim(collector.getLine(1)),","," " ),
- all_trim(collector.getLine(2)),
- all_trim(collector.getLine(3)),
- belt:getSpeed())
- -- Write the same data to the file
- local file_output = string.format("%s,%s,%s,%d\n",
- string.gsub(all_trim(collector.getLine(1)),","," " ),
- all_trim(collector.getLine(2)),
- all_trim(collector.getLine(3)),
- belt:getSpeed())
- file:write(file_output)
- end
- timer = os.startTimer(15)
- -- Increment speed for next iteration
- speed = speed + 1
- print(speed)
- -- Increase speed and run motors
- M_Crusher:run(tonumber(speed))
- S_Crusher:run(-tonumber(speed))
- belt:run(tonumber(speed))
- term.clear()
- term.setCursorPos(1,1)
- print(string.format("currently on: %d",speed))
- term.setCursorPos(1,2)
- print(last)
- end
- -- Close the file
- io.close(file)
Advertisement
Add Comment
Please, Sign In to add comment