I want to read no joke 100 mfsu and display current power over max.
is there a way to read them all at once or do i need to write a program that takes the current value for each mfsu current power assign it to a variable then add them all up.
openccsensors help with reading mfsu
Started by tvc, May 31 2013 09:37 PM
7 replies to this topic
#1
Posted 31 May 2013 - 09:37 PM
#2
Posted 31 May 2013 - 10:14 PM
local euSense = sensor.wrap("top") --# change to sensor side.
while true do
local total, totalCap = 0, 0
for target in pairs(euSense.getTargets()) do
if target.Capacity == 10000000 then
total = total + target.Stored
totalCap = totalCap + target.Capacity
end
end
print(total.." / "..totalCap)
sleep(0.5)
end
If you want it to only do it once, take out the very last end, the while true do, and the sleep.
#3
Posted 31 May 2013 - 10:15 PM
Methinks 100 MFSUs might be overkill, yes? An Adjustable Energy Storage Unit holds 10x what they do, while a Inter-Dimensional Storage Unit stores 100x.
#4
Posted 31 May 2013 - 10:45 PM
Lyqyd, on 31 May 2013 - 10:14 PM, said:
local euSense = sensor.wrap("top") --# change to sensor side.
while true do
local total, totalCap = 0, 0
for target in pairs(euSense.getTargets()) do
if target.Capacity == 10000000 then
total = total + target.Stored
totalCap = totalCap + target.Capacity
end
end
print(total.." / "..totalCap)
sleep(0.5)
end
If you want it to only do it once, take out the very last end, the while true do, and the sleep.
i get an error. startup:1: attempt to index ? (a nil value) and yes my sensor is on top
#5
Posted 31 May 2013 - 10:48 PM
You need to add os.loadAPI('ocs/apis/sensor') above the sensor.wrap
#7
Posted 31 May 2013 - 10:53 PM
Lyqyd, on 31 May 2013 - 10:14 PM, said:
local euSense = sensor.wrap("top") --# change to sensor side.
while true do
local total, totalCap = 0, 0
for target in pairs(euSense.getTargets()) do
if target.Capacity == 10000000 then
total = total + target.Stored
totalCap = totalCap + target.Capacity
end
end
print(total.." / "..totalCap)
sleep(0.5)
end
If you want it to only do it once, take out the very last end, the while true do, and the sleep.
all you get its a loop of 0/0
#8
Posted 01 June 2013 - 01:54 AM
That's because I did it wrong! Give this a shot:
os.loadAPI("ocs/apis/sensor")
local euSense = sensor.wrap("top") --# change to sensor side.
while true do
local total, totalCap = 0, 0
for target in pairs(euSense.getTargets()) do
local details = euSense.getTargetDetails(target)
if details.Capacity == 10000000 then
total = total + details.Stored
totalCap = totalCap + details.Capacity
end
end
print(total.." / "..totalCap)
sleep(0.5)
end
3 user(s) are reading this topic
0 members, 3 guests, 0 anonymous users











