mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
changed ppm to not wrap under ppm() function
This commit is contained in:
parent
ea84563bb4
commit
a0b2c1f3e2
@ -4,7 +4,6 @@
|
|||||||
-- Protected Peripheral Manager
|
-- Protected Peripheral Manager
|
||||||
--
|
--
|
||||||
|
|
||||||
function ppm()
|
|
||||||
local self = {
|
local self = {
|
||||||
mounts = {}
|
mounts = {}
|
||||||
}
|
}
|
||||||
@ -28,7 +27,7 @@ function ppm()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- mount all available peripherals (clears mounts first)
|
-- mount all available peripherals (clears mounts first)
|
||||||
local mount_all = function ()
|
function mount_all()
|
||||||
local ifaces = peripheral.getNames()
|
local ifaces = peripheral.getNames()
|
||||||
|
|
||||||
self.mounts = {}
|
self.mounts = {}
|
||||||
@ -41,7 +40,7 @@ function ppm()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- mount a particular device
|
-- mount a particular device
|
||||||
local mount = function (name)
|
function mount(name)
|
||||||
local ifaces = peripheral.getNames()
|
local ifaces = peripheral.getNames()
|
||||||
local pm_dev = nil
|
local pm_dev = nil
|
||||||
|
|
||||||
@ -62,7 +61,7 @@ function ppm()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- handle peripheral_detach event
|
-- handle peripheral_detach event
|
||||||
local unmount_handler = function (iface)
|
function unmount_handler(iface)
|
||||||
-- what got disconnected?
|
-- what got disconnected?
|
||||||
local lost_dev = self.mounts[iface]
|
local lost_dev = self.mounts[iface]
|
||||||
local type = lost_dev.type
|
local type = lost_dev.type
|
||||||
@ -73,22 +72,22 @@ function ppm()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- list all available peripherals
|
-- list all available peripherals
|
||||||
local list_avail = function ()
|
function list_avail()
|
||||||
return peripheral.getNames()
|
return peripheral.getNames()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- list mounted peripherals
|
-- list mounted peripherals
|
||||||
local list_mounts = function ()
|
function list_mounts()
|
||||||
return self.mounts
|
return self.mounts
|
||||||
end
|
end
|
||||||
|
|
||||||
-- get a mounted peripheral by side/interface
|
-- get a mounted peripheral by side/interface
|
||||||
local get_periph = function (iface)
|
function get_periph(iface)
|
||||||
return self.mounts[iface].device
|
return self.mounts[iface].device
|
||||||
end
|
end
|
||||||
|
|
||||||
-- get a mounted peripheral by type
|
-- get a mounted peripheral by type
|
||||||
local get_device = function (name)
|
function get_device(name)
|
||||||
local device = nil
|
local device = nil
|
||||||
|
|
||||||
for side, data in pairs(self.mounts) do
|
for side, data in pairs(self.mounts) do
|
||||||
@ -102,7 +101,7 @@ function ppm()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- list all connected monitors
|
-- list all connected monitors
|
||||||
local list_monitors = function ()
|
function list_monitors()
|
||||||
local monitors = {}
|
local monitors = {}
|
||||||
|
|
||||||
for side, data in pairs(self.mounts) do
|
for side, data in pairs(self.mounts) do
|
||||||
@ -113,15 +112,3 @@ function ppm()
|
|||||||
|
|
||||||
return monitors
|
return monitors
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
|
||||||
mount_all = mount_all,
|
|
||||||
mount = mount,
|
|
||||||
umount = unmount_handler,
|
|
||||||
list_avail = list_avail,
|
|
||||||
list_mounts = list_mounts,
|
|
||||||
get_periph = get_periph,
|
|
||||||
get_device = get_device,
|
|
||||||
list_monitors = list_monitors
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user