Skip to content

Commit

Permalink
feat: change td
Browse files Browse the repository at this point in the history
  • Loading branch information
lsxredrain committed Apr 10, 2023
1 parent 2f7895d commit 5c44e8f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/dgiot_api/src/data_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export_td(SessionToken) ->
{ok, ChannelId} ->
file:make_dir(<<"/home/station/tdengine">>),
FileName = "/home/station/tdengine/tables.zip",
NewData = dgiot_tdengie_dump:export(ChannelId, #{<<"sessionToken">> => SessionToken}),
NewData = dgiot_tdengine_dump:export(ChannelId, #{<<"sessionToken">> => SessionToken}),
case zip:create(<<"tdengine">>, NewData, [memory]) of
{ok, {_, ZipFile}} ->
file:write_file(FileName, ZipFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
%% limitations under the License.
%%--------------------------------------------------------------------

-module(dgiot_tdengie_dump).
-module(dgiot_tdengine_dump).
-author("jonhl").
-include_lib("dgiot/include/logger.hrl").
-include("dgiot_tdengine.hrl").
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
%% limitations under the License.
%%--------------------------------------------------------------------

-module(dgiot_tdengie_test).
-module(dgiot_tdengine_test).
-author("jonhl").
-include_lib("dgiot/include/logger.hrl").

Expand All @@ -32,9 +32,15 @@ test(Count, ProductId, DevAddr) ->
test(ProductId, DevAddr, 1, Count).

test(Count) ->
test(<<"470cb47206">>, <<"000000624309">>, 1, Count).
test(<<"676b609811">>, <<"000010800449">>, 1, Count).
test(ProductId, DevAddr, I, Max) when I =< Max ->
Storage = #{<<"energy">> => rand:uniform(9999)},
Storage = #{
<<"energy">> => rand:uniform(9999),
<<"rate_energy01">> => rand:uniform(9999),
<<"rate_energy02">> => rand:uniform(9999),
<<"rate_energy03">> => rand:uniform(9999),
<<"rate_energy04">> => rand:uniform(9999)
},
dgiot_tdengine_adapter:save(ProductId, DevAddr, Storage),
test(ProductId, DevAddr, I + 1, Max);

Expand Down

0 comments on commit 5c44e8f

Please sign in to comment.