sean.zhou
2022-03-21 17835b967b48f2676cce3bbed081c6580602ee1c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package com.dji.sample.manage.service;
 
import com.dji.sample.component.mqtt.model.CommonTopicResponse;
import com.dji.sample.component.websocket.config.ConcurrentWebSocketSession;
import com.dji.sample.manage.model.dto.DeviceDTO;
import com.dji.sample.manage.model.dto.TopologyDeviceDTO;
import com.dji.sample.manage.model.param.DeviceQueryParam;
import com.dji.sample.manage.model.receiver.StatusGatewayReceiver;
 
import java.util.Collection;
import java.util.List;
import java.util.Optional;
 
/**
 * @author sean.zhou
 * @date 2021/11/10
 * @version 0.1
 */
public interface IDeviceService {
 
    /**
     * The device goes online.
     * @param deviceGateway gateway
     * @return Whether the online is successful.
     */
    Boolean deviceOnline(StatusGatewayReceiver deviceGateway);
 
    /**
     * The device goes offline.
     * @param gatewaySn
     * @return Whether the offline is successful.
     */
    Boolean deviceOffline(String gatewaySn);
 
    /**
     * The aircraft goes offline.
     * @param deviceSn aircraft's SN
     * @return Whether the offline is successful.
     */
    Boolean subDeviceOffline(String deviceSn);
 
    /**
     * When the device goes online, it needs to subscribe to topics.
     * @param sn device's SN
     */
    void subscribeTopicOnline(String sn);
 
    /**
     * When the device goes offine, it needs to cancel the subscribed topics.
     * @param sn device's SN
     */
    void unsubscribeTopicOffline(String sn);
 
    /**
     * Delete all device data according to the SN of the device.
     * @param ids device's SN
     * @return
     */
    Boolean delDeviceByDeviceSns(List<String> ids);
 
    /**
     * Obtain device data according to different query conditions.
     * @param param query parameters
     * @return
     */
    List<DeviceDTO> getDevicesByParams(DeviceQueryParam param);
 
    /**
     * When you receive a status topic message, you need to reply to it.
     * @param sn   the target of sn
     * @param response
     */
    void publishStatusReply(String sn, CommonTopicResponse<Object> response);
 
    /**
     * The business interface on the web side. Get all information about all devices in this workspace.
     * @param workspaceId
     * @return
     */
    List<DeviceDTO> getDevicesTopoForWeb(String workspaceId);
 
    /**
     * Set the remote controller and payloads information of the drone.
     * @param device
     */
    void spliceDeviceTopo(DeviceDTO device);
 
    /**
     * Push the topology information to the pilot after one device is online.
     * @param sessions  The collection of connection objects on the pilot side.
     * @param sn
     */
    void pushDeviceOnlineTopo(Collection<ConcurrentWebSocketSession> sessions, String sn);
 
    /**
     * Query the information of the device according to the sn of the device.
     * @param sn device sn
     * @return
     */
    Optional<TopologyDeviceDTO> getDeviceTopoForPilot(String sn);
 
    /**
     * Convert individual device information into topology objects.
     * @param device
     * @return
     */
    TopologyDeviceDTO deviceConvertToTopologyDTO(DeviceDTO device);
 
    /**
     * When the server receives the request of any device online, offline and topology update in the same workspace,
     * it also broadcasts a push of device online, offline and topology update to PILOT via websocket,
     * and PILOT will get the device topology list again after receiving the push.
     * @param workspaceId
     * @param gatewaySn
     */
    void pushDeviceOfflineTopo(String workspaceId, String gatewaySn);
 
    /**
     * When the server receives the request of any device online, offline and topology update in the same workspace,
     * it also broadcasts a push of device online, offline and topology update to PILOT via websocket,
     * and PILOT will get the device topology list again after receiving the push.
     * @param workspaceId
     * @param deviceSn
     * @param gatewaySn
     */
    void pushDeviceOnlineTopo(String workspaceId, String deviceSn, String gatewaySn);
 
    /**
     * Handle messages from the osd topic.
     * @param topic     osd
     * @param payload
     */
    void handleOSD(String topic, byte[] payload);
 
}