Join our "Ask Me About" community webinar on May 20th at 9 AM CET and 5 PM CET to explore cybersecurity and monitoring for Data Center and edge IT. Learn about market trends, cutting-edge technologies, and best practices from industry experts.
Register and secure your Critical IT infrastructure
Gateways and Energy Servers
Schneider Electric support forum to share knowledge about product selection, installation and troubleshooting for EcoStruxure Panel Server, PowerTag, Com'X, Link150…
User | Count |
---|---|
98 | |
46 | |
43 | |
30 |
Link copied. Please paste this link to share this article on your social media post.
Even though, we do have the great article from , many people have been asking for this old post from the defunct energyoperation.info blog. So there it is:
In our second topic about the StruxureWare Lite offer, we’ll show you how, thanks to the Lua scripting languague, you can create native EO file format (or any file format) and send them to Energy Operation.
First you need to identify the data you want to send and create the metes in Energy Operation. Again, since it’s all scripted in Lua, you could use whatever you want, but in our case, I decided to use the Name of the objects. You can see that in your explorer window:
For the temperature sensors, just select the sensor in the tree, and it will also appear in the grid.
Log in to Energy Operation, and create your metering tags where you want to see the data:
Now Energy Operation is ready to receive the data.
Next, we need to create the actual csv file in the StruxureWare Lite box. To do that, we need to create a Lua script.
In the explorer view, click on Add Objects (the little + green icon):
Then in the filter, select “Lua Program”. Select of of the available program which will then appear as selected in the right list, and click on Add Objects.
Now your script will appear in the Explorer windows for your SmartStruxure Controller.
Select the newly created script, and rename it to whatever makes sense to you. In our case, it’s “Create EO File Lua Program”.
Here is the code you need to put:
if createEOFileInit == nil then -- Initialization
createEOFileInit = true
-- Interval Length in minutes
intervalLenght = 5
-- Initialize list of devices.topics (tags) to be trended
-- The Object Name is the Unique ID in Energy Operation and should be unique to the implementation.
tags = {"AI44", "AV3"}
-- File name
fileName = scl.getserial() .. "_" .. scl.getmac():gsub(":", "") .. "_" .. ME.CFG1_Node_Instance.value .. ".csv"
-- File Header
header = "## ACTION:UPDATE ENTITY:MeterData SCHEMA:Default VERSION:1.0.0".."\r\n" .. "AcquisitionDateTime,Value,MeterLocalId\r\n"
else
-- This section will read points at every interval and write to the CSV file
timer = os.date("*t")
if timer.min % intervalLenght == 0 and flag == 0 then -- Run at every intervals
buffer = ""
for tagIndex = 1, #tags do -- Generate string with all arguments to be written to CSV
timestamp = string.sub(os.date(),0,10) .. "T" .. string.sub(os.date(),12,19) .. ".0000000+00:00,"
arglist = scl.nodes["ME"][tags[tagIndex] .. "_Present_Value"].value .. "," .. scl.nodes["ME"][tags[tagIndex] .. "_Object_Name"].value
buffer = buffer .. timestamp .. arglist .. "\r\n"
end
file, info = io.open(fileName, "a+") -- write to CSV
if file then
size = file:seek("end")
if (size == 0) then
-- file is empty. Ensure to add the header
file:write(header)
end
file:write(buffer)
file:close()
end
arglist = ""
flag = 1 -- Action completed once, no need to run more until the next interval
end
if timer.min % intervalLenght ~= 0 then
flag = 0
end
end
-- --------------------
As specified in the header, there are two parameters that you need to modify. The interval lenght (in minutes) which you should try to match to your utility. In addition, the list of objects that you want to export.
Once you run it, after the first interval is passed, you will start to see a file in the upload manager of your controller.
Now we only have to send the file. To do so, we will create another Lua script. Here is the code for it:
if sendToEOInit == nil then -- Initialization
sendToEOInit = true
-- Send filename to EO ftp server
function ftpFile()
now = os.date("*t")
ftpResult, ftpError = ftp.put{
host = "10.0.0.5",
user = "yourUsername",
password = "password",
argument = "can2go_" .. now.hour .. now.min .. "_" .. fileName,
source = ltn12.source.file(io.open(fileName, "r"))
}
end
-- Is it time to try to send again?
function isItTime()
this_time = scl.sysclock()
if (this_time - last_time >= frequency) then
last_time = this_time
return true;
else
return false;
end
end
-- debug function
function writeToDebug(str)
print(os.date() .. ": " .. str)
end
-- Initialize a few more variables
fileName = scl.getserial() .. "_" .. scl.getmac():gsub(":", "") .. "_" .. ME.CFG1_Node_Instance.value .. ".csv"
frequency = 0 -- First run happens now. Subsequent run happens depending on result of FTP (every minutes or hourly)
last_time = scl.sysclock()
else
if (isItTime()) then
writeToDebug("Initiating FTP transfer.")
ftpFile()
if ftpResult >= 1 then -- success
writeToDebug(fileName .. " File succesfully sent.")
if (io.open("previous_" .. fileName) ~= nil) then
os.remove("previous_" .. fileName)
end
os.rename(fileName, "previous_" .. fileName) -- Create a new backup with current file
frequency = 3600
elseif ftp_err ~= nil then -- error
print("ftp put error : " .. ftp_err)
frequency = 60
end
end
end
-- -------------------------
The script will by default send data every hour, but you can change this, by changing the frequency at the end of the script from 3600seconds to whatever you would like. Be sensible about it though!
Finally, make sure to change the host, username and password to send the data to the right implementation.
That’s it! What thing we need to highlight though. The box currently does not support SSL encryption. You are sending data over FTP which means the data is not encrypted. After talking to the team, they seem to have a plan to add support for HTTPS, so more good things to come.
Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.
With achievable small steps, users progress and continually feel satisfaction in task accomplishment.
Usetiful Onboarding Checklist remembers the progress of every user, allowing them to take bite-sized journeys and continue where they left.
of