164 lines
4.0 KiB
Java
164 lines
4.0 KiB
Java
package com.ruoyi.iot.service;
|
||
|
||
|
||
import java.math.BigDecimal;
|
||
import java.util.List;
|
||
|
||
import com.ruoyi.common.constant.IotConstants;
|
||
import com.ruoyi.iot.domain.HistoryDeviceData;
|
||
import com.ruoyi.iot.domain.IotDeviceInfo;
|
||
import com.ruoyi.iot.domain.response.CommandResponse;
|
||
import com.ruoyi.iot.interfaces.IotDevice;
|
||
|
||
/**
|
||
* @author wjh
|
||
* 2024/3/20
|
||
*/
|
||
public interface IotService {
|
||
|
||
/**
|
||
* 获取设备在线状态
|
||
*
|
||
* @param deviceName OneNet设备名称(即设备表的MAC号)
|
||
* @param productId
|
||
*/
|
||
default String getOnlineStatus(String deviceName, String productId) {
|
||
return getOnlineStatus(deviceName, productId, IotConstants.ONLINE_TYPE_GET);
|
||
}
|
||
|
||
/**
|
||
* 获取设备在线状态
|
||
*
|
||
* @param deviceName OneNet设备名称(即设备表的MAC号)
|
||
* @param productId
|
||
* @param type 获取方式:1-从OneNet直接获取,2-发送命令获取
|
||
*/
|
||
String getOnlineStatus(String deviceName, String productId, String type);
|
||
|
||
/**
|
||
* 获取设备在线状态
|
||
*/
|
||
String getOnlineStatus(IotDevice device);
|
||
|
||
/**
|
||
* 通电
|
||
*/
|
||
boolean open(IotDevice device, String reason);
|
||
|
||
/**
|
||
* 断电
|
||
*/
|
||
boolean close(IotDevice device, String reason);
|
||
|
||
/**
|
||
* 设置剩余时长
|
||
*/
|
||
CommandResponse setTime(IotDevice device, long seconds, String reason);
|
||
|
||
/**
|
||
* 获取设备信息,并转为IotDeviceInfo
|
||
*/
|
||
IotDeviceInfo getDeviceInfo(IotDevice device);
|
||
|
||
/**
|
||
* 获取设备信息列表,并转换为IotDeviceInfo
|
||
*
|
||
* @param deviceList 设备名称列表
|
||
* @param productId
|
||
*/
|
||
List<IotDeviceInfo> getDeviceInfo(List<? extends IotDevice> deviceList, String productId);
|
||
|
||
/**
|
||
* 注册设备
|
||
*/
|
||
int create(String mac, String productId);
|
||
|
||
/**
|
||
* 设备添加电量(度)
|
||
*/
|
||
CommandResponse addEle(IotDevice device, BigDecimal ele, String reason);
|
||
|
||
/**
|
||
* 直接设置设备电量(度)
|
||
*/
|
||
CommandResponse setEle(IotDevice device, BigDecimal ele, String reason);
|
||
|
||
/**
|
||
* 尝试设置设备剩余时长
|
||
*
|
||
* @param device MAC
|
||
* @param seconds 时长
|
||
* @param tryCount 尝试次数
|
||
* @param reason
|
||
*/
|
||
CommandResponse trySetTime(IotDevice device, long seconds, int tryCount, String reason);
|
||
|
||
/**
|
||
* 尝试设置设备剩余时长
|
||
*
|
||
* @param device MAC
|
||
* @param ele 电量(度)
|
||
* @param tryCount 尝试次数
|
||
* @param reason
|
||
*/
|
||
CommandResponse trySetEle(IotDevice device, BigDecimal ele, int tryCount, String reason);
|
||
|
||
/**
|
||
* 设置设备WIFI
|
||
*
|
||
* @param device 设备
|
||
* @param wifiName WIFI名称
|
||
* @param wifiPwd WIFI 密码
|
||
* @param reason
|
||
*/
|
||
CommandResponse setWifi(IotDevice device, String wifiName, String wifiPwd, String reason);
|
||
|
||
/**
|
||
* 设置倒计时提醒
|
||
*
|
||
* @param device 设备
|
||
* @param seconds 倒计时(秒)
|
||
* @param reason
|
||
*/
|
||
boolean setVoice(IotDevice device, long seconds, String reason);
|
||
|
||
/**
|
||
* 设置总用电量
|
||
*
|
||
* @param device 设备
|
||
* @param totalEle 总用电量(瓦时)
|
||
* @param reason
|
||
*/
|
||
boolean setTotalEle(IotDevice device, BigDecimal totalEle, String reason);
|
||
|
||
/**
|
||
* 获取历史数据
|
||
*/
|
||
HistoryDeviceData getHistoryDataPoint(String deviceName, String productId);
|
||
|
||
/**
|
||
* 设置电压系数
|
||
*/
|
||
CommandResponse setVxs(IotDevice device, BigDecimal vxs, String reason);
|
||
|
||
/**
|
||
* 上传数据
|
||
*/
|
||
CommandResponse uploadData(IotDevice device, String reason, boolean recordLog);
|
||
|
||
/**
|
||
* 重启设备
|
||
*/
|
||
CommandResponse reboot(IotDevice device, String reason);
|
||
|
||
/**
|
||
* 设置电量系数
|
||
*/
|
||
CommandResponse setWxs(IotDevice device, BigDecimal wxs, String reason);
|
||
|
||
/**
|
||
* 设置反转参数
|
||
*/
|
||
CommandResponse setSet(IotDevice device, String set, String reason);
|
||
}
|