From 0a3d430f366c80de39b893a74b8e09973e418079 Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Tue, 16 Jun 2020 16:35:40 +0200 Subject: [PATCH] =?UTF-8?q?Refactoris=C3=A9=20le=20http=5Fpost,=20comment?= =?UTF-8?q?=C3=A9=20toutes=20les=20lignes=20utilis=C3=A9es=20pour=20le=20d?= =?UTF-8?q?ebug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../transfo_courant_clip_1p_1/0_http_post.lua | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/Mesures/energy/transfo_courant_clip_1p_1/0_http_post.lua b/Mesures/energy/transfo_courant_clip_1p_1/0_http_post.lua index 9562107..9e08a5e 100644 --- a/Mesures/energy/transfo_courant_clip_1p_1/0_http_post.lua +++ b/Mesures/energy/transfo_courant_clip_1p_1/0_http_post.lua @@ -1,21 +1,19 @@ -- Petit script pour envoyer en // es valeurs sur un serveur WEB (InfluxDB) -- via un http POST à travers un FIFO -if verbose then print("\n 0_http_post.lua zf200610.1822 \n") end +if verbose then print("\n 0_http_post.lua zf200616.1633 \n") end t_zurl={} t_zarg={} f_zpost=false -function tprint(t) - for key,value in pairs(t) do print(key, value) end -end +-- function tprint(t) +-- for key,value in pairs(t) do print(key, value) end +-- end function zpost() - f_zpost=true zurl=t_zurl[1] zarg=t_zarg[1] - zarg=zarg.."\n".."energy,value=nb_waiting_"..yellow_id.." val="..#t_zurl + f_zpost=true local zurl=t_zurl[1] local zarg=t_zarg[1] + -- zarg=zarg.."\n".."energy,value=nb_waiting_"..yellow_id.." val="..#t_zurl zarg=zarg.."\n".."energy,memory=zpost_"..yellow_id.." ram="..node.heap() - - if verbose then print("zurl: "..zurl) end if verbose then print("zarg: "..zarg) end - + -- if verbose then print("zurl: "..zurl) end if verbose then print("zarg: "..zarg) end http.post(zurl, 'Content-Type: application/x-www-form-urlencoded\r\n', zarg, function(code, data) if (code < 0) then print("HTTP request failed") @@ -23,28 +21,24 @@ function zpost() else if verbose then print(code, data) end end - table.remove(t_zurl, 1) table.remove(t_zarg, 1) if t_zurl[1]==nil then f_zpost=false else zpost() end - if verbose then print("End zpost:") end + -- if verbose then print("End zpost:") end collectgarbage() - if verbose then print(node.heap()) end - + -- if verbose then print(node.heap()) end end) - - zurl=nil zarg=nil end function http_post(zurl,zarg) if #t_zurl <=10 then table.insert(t_zurl, zurl) table.insert(t_zarg, zarg) end - if verbose then print("Nb wait: "..#t_zurl) print(node.heap()) end - if verbose then print("t_zurl:") tprint(t_zurl) print("t_zarg:") tprint(t_zarg) end + -- if verbose then print("Nb wait: "..#t_zurl) print(node.heap()) end + -- if verbose then print("t_zurl:") tprint(t_zurl) print("t_zarg:") tprint(t_zarg) end if f_zpost==false then zpost() end - if verbose then print("End http_post:") end + -- if verbose then print("End http_post:") end collectgarbage() - if verbose then print(node.heap()) end + -- if verbose then print(node.heap()) end end