Skip to content

Commit

Permalink
style: channel(icon name)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgiot-fe committed Mar 12, 2022
1 parent 351a6ab commit 1774987
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 34 deletions.
14 changes: 7 additions & 7 deletions apps/dgiot_bamis/src/dgiot_bamis_channel.erl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
order => 102,
type => string,
required => false,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/amis.jpg">>,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/amis.png">>,
title => #{
en => <<"channel ICO">>,
zh => <<"通道ICO"/utf8>>
Expand All @@ -82,10 +82,10 @@ init(?TYPE, ChannelId, #{
<<"search">> := Search}) ->
lists:map(fun(X) ->
case X of
{ProductId, #{<<"ACL">> := Acl, <<"nodeType">> := 1,<<"thing">> := Thing}} ->
dgiot_data:insert({amis, ChannelId}, {ProductId, Acl, maps:get(<<"properties">>,Thing,[])});
{ProductId, #{<<"ACL">> := Acl, <<"nodeType">> := 1, <<"thing">> := Thing}} ->
dgiot_data:insert({amis, ChannelId}, {ProductId, Acl, maps:get(<<"properties">>, Thing, [])});
_ ->
?LOG(info,"X ~p", [X]),
?LOG(info, "X ~p", [X]),
pass
end
end, Products),
Expand All @@ -110,17 +110,17 @@ handle_event(_EventId, _Event, State) ->
% SELECT clientid, disconnected_at FROM "$events/client_disconnected" WHERE username = 'dgiot'
% SELECT clientid, connected_at FROM "$events/client_connected" WHERE username = 'dgiot'
handle_message({rule, #{clientid := DtuAddr, connected_at := _ConnectedAt}, #{peername := PeerName} = _Context}, #state{id = ChannelId} = State) ->
?LOG(error,"DtuAddr ~p PeerName ~p",[DtuAddr,PeerName] ),
?LOG(error, "DtuAddr ~p PeerName ~p", [DtuAddr, PeerName]),
DTUIP = dgiot_utils:get_ip(PeerName),
dgiot_bamis:create_amis(DtuAddr, ChannelId, DTUIP),
{ok, State};

handle_message({rule, #{clientid := DevAddr, disconnected_at := _DisconnectedAt}, _Context}, State) ->
?LOG(error,"DevAddr ~p ",[DevAddr] ),
?LOG(error, "DevAddr ~p ", [DevAddr]),
{ok, State};

handle_message({rule, #{clientid := DevAddr, payload := Payload, topic := _Topic}, _Msg}, #state{id = ChannelId} = State) ->
?LOG(error,"DevAddr ~p Payload ~p ChannelId ~p",[DevAddr,Payload,ChannelId] ),
?LOG(error, "DevAddr ~p Payload ~p ChannelId ~p", [DevAddr, Payload, ChannelId]),
{ok, State};

handle_message(_Message, State) ->
Expand Down
14 changes: 7 additions & 7 deletions apps/dgiot_bridge/src/channel/dgiot_http_channel.erl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
order => 102,
type => string,
required => false,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/Http%E9%87%87%E9%9B%86%E5%9B%BE%E6%A0%87.png">>,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/HTTP-collection.png">>,
title => #{
en => <<"channel ICO">>,
zh => <<"通道ICO"/utf8>>
Expand All @@ -90,7 +90,7 @@ start(ChannelId, ChannelArgs) ->
init(?TYPE, ChannelId, #{<<"port">> := Port} = ChannelArgs) ->
State = #state{
id = ChannelId,
env = maps:without([<<"port">>,<<"path">>,<<"product">>,<<"behaviour">>], ChannelArgs)
env = maps:without([<<"port">>, <<"path">>, <<"product">>, <<"behaviour">>], ChannelArgs)
},
Name = dgiot_channelx:get_name(?TYPE, ChannelId),
Opts = [
Expand All @@ -112,7 +112,7 @@ init(?TYPE, ChannelId, #{<<"port">> := Port} = ChannelArgs) ->
]}
]),
CowboyOpts = #{
env =>#{
env => #{
dispatch => Dispatch
}
},
Expand All @@ -122,21 +122,21 @@ init(?TYPE, ChannelId, #{<<"port">> := Port} = ChannelArgs) ->

%% 通道消息处理,注意:进程池调用
handle_event(EventId, Event, _State) ->
?LOG(info,"channel ~p, ~p", [EventId, Event]),
?LOG(info, "channel ~p, ~p", [EventId, Event]),
ok.

handle_message(Message, State) ->
?LOG(info,"channel ~p ~p", [Message]),
?LOG(info, "channel ~p ~p", [Message]),
{ok, State}.

stop(ChannelType, ChannelId, _State) ->
?LOG(info,"channel stop ~p,~p", [ChannelType, ChannelId]),
?LOG(info, "channel stop ~p,~p", [ChannelType, ChannelId]),
ok.


%% ====== http callback ======

init(Req, #state{ id = ChannelId, env = Env} = State) ->
init(Req, #state{id = ChannelId, env = Env} = State) ->
{ok, _Type, ProductIds} = dgiot_bridge:get_products(ChannelId),
case dgiot_bridge:apply_channel(ChannelId, ProductIds, handle_info, [{http, Req}], Env) of
{ok, NewEnv} ->
Expand Down
14 changes: 7 additions & 7 deletions apps/dgiot_bridge/src/channel/dgiot_httpd_channel.erl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
order => 102,
type => string,
required => false,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/HTTP%E5%9B%BE%E6%A0%87.png">>,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/HTTPICO.png">>,
title => #{
en => <<"channel ICO">>,
zh => <<"通道ICO"/utf8>>
Expand All @@ -89,7 +89,7 @@ start(ChannelId, ChannelArgs) ->
init(?TYPE, ChannelId, #{<<"port">> := Port} = ChannelArgs) ->
State = #state{
id = ChannelId,
env = maps:without([<<"port">>,<<"path">>,<<"product">>,<<"behaviour">>], ChannelArgs)
env = maps:without([<<"port">>, <<"path">>, <<"product">>, <<"behaviour">>], ChannelArgs)
},
Name = dgiot_channelx:get_name(?TYPE, ChannelId),
Opts = [
Expand All @@ -111,7 +111,7 @@ init(?TYPE, ChannelId, #{<<"port">> := Port} = ChannelArgs) ->
]}
]),
CowboyOpts = #{
env =>#{
env => #{
dispatch => Dispatch
}
},
Expand All @@ -121,21 +121,21 @@ init(?TYPE, ChannelId, #{<<"port">> := Port} = ChannelArgs) ->

%% 通道消息处理,注意:进程池调用
handle_event(EventId, Event, _State) ->
?LOG(info,"channel ~p, ~p", [EventId, Event]),
?LOG(info, "channel ~p, ~p", [EventId, Event]),
ok.

handle_message(Message, State) ->
?LOG(info,"channel ~p ~p", [Message]),
?LOG(info, "channel ~p ~p", [Message]),
{ok, State}.

stop(ChannelType, ChannelId, _) ->
?LOG(info,"channel stop ~p,~p", [ChannelType, ChannelId]),
?LOG(info, "channel stop ~p,~p", [ChannelType, ChannelId]),
ok.


%% ====== http callback ======

init(Req, #state{ id = ChannelId, env = Env} = State) ->
init(Req, #state{id = ChannelId, env = Env} = State) ->
{ok, _Type, ProductIds} = dgiot_bridge:get_products(ChannelId),
case dgiot_bridge:apply_channel(ChannelId, ProductIds, handle_info, [{http, Req}], Env) of
{ok, NewEnv} ->
Expand Down
2 changes: 1 addition & 1 deletion apps/dgiot_bridge/src/channel/dgiot_tcp_channel.erl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
order => 102,
type => string,
required => false,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/tcp%E5%9B%BE%E6%A0%87.jpeg">>,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/TcpIcon.jpeg">>,
title => #{
en => <<"channel ICO">>,
zh => <<"通道ICO"/utf8>>
Expand Down
12 changes: 6 additions & 6 deletions apps/dgiot_bridge/src/channel/dgiot_udp_channel.erl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
order => 102,
type => string,
required => false,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/UDP%E5%9B%BE%E6%A0%87.png">>,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/UdpIcon.png">>,
title => #{
en => <<"channel ICO">>,
zh => <<"通道ICO"/utf8>>
Expand Down Expand Up @@ -93,16 +93,16 @@ init(?TYPE, ChannelId, #{<<"port">> := Port} = _ChannelArgs) ->


handle_event(EventType, Event, _State) ->
?LOG(info,"channel ~p, ~p", [EventType, Event]),
?LOG(info, "channel ~p, ~p", [EventType, Event]),
ok.


handle_message(Message, #state{ id = ChannelId, product = ProductId } = State) ->
?LOG(info,"Channel ~p, Product ~p, handle_message ~p", [ChannelId, ProductId, Message]),
handle_message(Message, #state{id = ChannelId, product = ProductId} = State) ->
?LOG(info, "Channel ~p, Product ~p, handle_message ~p", [ChannelId, ProductId, Message]),
do_product(handle_info, [Message], State).

stop(ChannelType, ChannelId, _) ->
?LOG(info,"channel stop ~p,~p", [ChannelType, ChannelId]),
?LOG(info, "channel stop ~p,~p", [ChannelType, ChannelId]),
ok.

%% =============
Expand All @@ -127,7 +127,7 @@ handle_info({datagram, _Server, Data0}, #state{env = OldEnv, log = Log} = State)
Env = OldEnv#{
<<"send">> => send_fun(State)
},
case do_product(handle_info, [{udp, Data}], State#state{ env = Env }) of
case do_product(handle_info, [{udp, Data}], State#state{env = Env}) of
{ok, NewState} ->
{noreply, NewState};
{stop, Reason, NewState} ->
Expand Down
2 changes: 1 addition & 1 deletion apps/dgiot_location/src/dgiot_location_channel.erl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
order => 102,
type => string,
required => false,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/%E4%BD%8D%E7%BD%AE%E5%AE%9A%E4%BD%8D%E9%80%9A%E9%81%93.jpg">>,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/location.jpg">>,
title => #{
en => <<"channel ICO">>,
zh => <<"通道ICO"/utf8>>
Expand Down
2 changes: 1 addition & 1 deletion apps/dgiot_parse/src/sever/dgiot_parse_channel.erl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
order => 102,
type => string,
required => false,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/parser%20sever%E5%9B%BE%E6%A0%87.jpg">>,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/parserIcon.jpg">>,
title => #{
en => <<"channel ICO">>,
zh => <<"通道ICO"/utf8>>
Expand Down
2 changes: 1 addition & 1 deletion apps/dgiot_task/src/dgiot_profile_channel.erl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
order => 102,
type => string,
required => false,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/%E6%8C%87%E4%BB%A4%E4%BB%BB%E5%8A%A1%E5%9B%BE%E6%A0%87.png">>,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/TaskIcon.png">>,
title => #{
en => <<"channel ICO">>,
zh => <<"通道ICO"/utf8>>
Expand Down
2 changes: 1 addition & 1 deletion apps/dgiot_task/src/dgiot_task_channel.erl
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
order => 102,
type => string,
required => false,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/%E6%8C%87%E4%BB%A4%E4%BB%BB%E5%8A%A1%E5%9B%BE%E6%A0%87.png">>,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/TaskIcon.png">>,
title => #{
en => <<"channel ICO">>,
zh => <<"通道ICO"/utf8>>
Expand Down
2 changes: 1 addition & 1 deletion apps/dgiot_tdengine/src/dgiot_tdengine_channel.erl
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
order => 102,
type => string,
required => false,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/TD%E5%9B%BE%E6%A0%87.png">>,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/TDIcon.png">>,
title => #{
en => <<"channel ICO">>,
zh => <<"通道ICO"/utf8>>
Expand Down
2 changes: 1 addition & 1 deletion apps/dgiot_topo/src/dgiot_topo_channel.erl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
order => 102,
type => string,
required => false,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/TOPO%E7%BB%84%E6%80%81%E9%80%9A%E9%81%93%E5%9B%BE%E6%A0%87.png">>,
default => <<"http://dgiot-1253666439.cos.ap-shanghai-fsi.myqcloud.com/shuwa_tech/zh/product/dgiot/channel/TOPOIcon.png">>,
title => #{
en => <<"channel ICO">>,
zh => <<"通道ICO"/utf8>>
Expand Down

0 comments on commit 1774987

Please sign in to comment.