fix host
This commit is contained in:
parent
740e35833b
commit
04254def4b
@ -418,36 +418,41 @@ code_change(_OldVsn, StateName, State = #state{}, _Extra) ->
|
|||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
|
|
||||||
%% 处理相关数据
|
%% 处理相关数据
|
||||||
handle_data(#data{device_uuid = DeviceUUID, service_name = ServiceName, at = Timestamp, fields = FieldsList, tags = Tags}, #state{uuid = UUID})
|
%handle_data(#data{device_uuid = DeviceUUID, service_name = ServiceName, at = Timestamp, fields = FieldsList, tags = Tags}, #state{uuid = UUID, device_map = DeviceMap})
|
||||||
when is_binary(DeviceUUID), DeviceUUID /= <<>> ->
|
% when is_binary(DeviceUUID), DeviceUUID /= <<>> ->
|
||||||
|
%
|
||||||
case iot_device:get_pid(DeviceUUID) of
|
% case maps:find(DeviceUUID, DeviceMap) of
|
||||||
undefined ->
|
%
|
||||||
lager:warning("[iot_host] host uuid: ~p, device uuid: ~p not found, fields: ~p, tags: ~p", [UUID, DeviceUUID, FieldsList, Tags]),
|
% end,
|
||||||
ok;
|
%
|
||||||
DevicePid when is_pid(DevicePid) ->
|
%
|
||||||
case iot_device:is_activated(DevicePid) of
|
% case iot_device:get_pid(DeviceUUID) of
|
||||||
true ->
|
% undefined ->
|
||||||
%% 查找终端设备对应的点位信息
|
% lager:warning("[iot_host] host uuid: ~p, device uuid: ~p not found, fields: ~p, tags: ~p", [UUID, DeviceUUID, FieldsList, Tags]),
|
||||||
iot_router:route_uuid(DeviceUUID, FieldsList, Timestamp),
|
% ok;
|
||||||
|
% DevicePid when is_pid(DevicePid) ->
|
||||||
%% 数据写入influxdb
|
% case iot_device:is_activated(DevicePid) of
|
||||||
NTags = Tags#{<<"uuid">> => UUID, <<"service_name">> => ServiceName, <<"device_uuid">> => DeviceUUID},
|
% true ->
|
||||||
influx_client:write_data(DeviceUUID, NTags, FieldsList, Timestamp),
|
% %% 查找终端设备对应的点位信息
|
||||||
|
% iot_router:route_uuid(DeviceUUID, FieldsList, Timestamp),
|
||||||
iot_device:change_status(DevicePid, ?DEVICE_ONLINE);
|
%
|
||||||
false ->
|
% %% 数据写入influxdb
|
||||||
lager:warning("[iot_host] host uuid: ~p, device_uuid: ~p not activated, fields: ~p, tags: ~p", [UUID, DeviceUUID, FieldsList, Tags])
|
% NTags = Tags#{<<"uuid">> => UUID, <<"service_name">> => ServiceName, <<"device_uuid">> => DeviceUUID},
|
||||||
end
|
% influx_client:write_data(DeviceUUID, NTags, FieldsList, Timestamp),
|
||||||
end;
|
%
|
||||||
|
% iot_device:change_status(DevicePid, ?DEVICE_ONLINE);
|
||||||
handle_data(#data{service_name = ServiceName, at = Timestamp, fields = FieldsList, tags = Tags}, #state{uuid = UUID}) ->
|
% false ->
|
||||||
%% 查找终端设备对应的点位信息
|
% lager:warning("[iot_host] host uuid: ~p, device_uuid: ~p not activated, fields: ~p, tags: ~p", [UUID, DeviceUUID, FieldsList, Tags])
|
||||||
iot_router:route_uuid(UUID, FieldsList, Timestamp),
|
% end
|
||||||
|
% end;
|
||||||
%% 数据写入influxdb
|
%
|
||||||
NTags = Tags#{<<"uuid">> => UUID, <<"service_name">> => ServiceName},
|
%handle_data(#data{service_name = ServiceName, at = Timestamp, fields = FieldsList, tags = Tags}, #state{uuid = UUID}) ->
|
||||||
influx_client:write_data(UUID, NTags, FieldsList, Timestamp).
|
% %% 查找终端设备对应的点位信息
|
||||||
|
% iot_router:route_uuid(UUID, FieldsList, Timestamp),
|
||||||
|
%
|
||||||
|
% %% 数据写入influxdb
|
||||||
|
% NTags = Tags#{<<"uuid">> => UUID, <<"service_name">> => ServiceName},
|
||||||
|
% influx_client:write_data(UUID, NTags, FieldsList, Timestamp).
|
||||||
|
|
||||||
-spec report_event(UUID :: binary(), NewStatus :: integer()) -> no_return().
|
-spec report_event(UUID :: binary(), NewStatus :: integer()) -> no_return().
|
||||||
report_event(UUID, NewStatus) when is_binary(UUID), is_integer(NewStatus) ->
|
report_event(UUID, NewStatus) when is_binary(UUID), is_integer(NewStatus) ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user