升级固件

master
blak-kong 2 years ago
parent 3a3d164762
commit f978e260b6

@ -0,0 +1,36 @@
.common-progress-box {
padding: 50rpx;
}
.progress {
display: flex;
margin-top: 10rpx;
font-size: 24rpx;
font-family: PingFang SC;
font-weight: 500;
color: #999999;
align-items: center;
.van-progress {
width: 440rpx;
.van-progress__portion {
background: linear-gradient(90deg, #ffe9c7, #eecda1);
border-radius: 6rpx;
height: 12rpx;
.van-progress__pivot {
display: none;
}
}
}
.percent {
margin-left: 52rpx;
}
}
.progress-tips {
font-family: PingFang SC;
font-weight: 500;
font-size: 26rpx;
color: #666666;
line-height: 60rpx;
}

@ -0,0 +1,471 @@
import Taro from "@tarojs/taro";
import classnames from "classnames";
import { Component, PropsWithChildren, useEffect, useState } from "react";
import { Block, View, Text, PageMeta } from "@tarojs/components";
import { Popup, Progress } from "@antmjs/vantui";
import { connect } from "react-redux";
import {
msg,
back,
showModal,
go,
loading,
getStorageSync,
} from "@/utils/traoAPI";
import { InstrumentInfo } from "@/utils/Interface";
import {
notifyBLECharacteristicValueChange,
writeBLECharacteristicValue,
sendCommand,
} from "@/utils/bluetoothWXAPI";
import {
ab2hex,
ccrc8,
filterBleData,
hex2int,
string2buffer,
} from "@/utils/util";
import {
Stringkit,
TResponseFromDevice,
} from "@flossom-npm/iot-translater-we100";
// 通过设备类型判断给 deviceToolKitInstance 赋值
import { DeviceToolKit as DeviceToolKitWE100 } from "@flossom-npm/iot-translater-we100";
import { DeviceToolKit as DeviceToolKitFR200 } from "@flossom-npm/iot-translater";
import OtaDeviceTypeEnum from "../OtaDeviceTypeEnum";
// 临时替代
var log = console;
let deviceToolKitInstance: any = null;
const deviceToolKitInstanceFR200 = new DeviceToolKitFR200("FR200");
deviceToolKitInstanceFR200.setDebug(true);
import "./index.less";
class UpdateIotFR200 extends Component<any, any> {
constructor(props) {
super(props);
this.state = {
name: "UpdateIotFR200",
progressbar: 1, // 进度条
currentDevice: {},
hadStartOta: false, // 是否开始ota
};
}
$instance = Taro.getCurrentInstance();
$checkTimer: any = null;
// 与页面渲染无关的数据
$otaDataGroup: any = {
// 包大小面罩设置为100主机设置为240
packageSize: 240, //每个包的大小上限(单位是字节)
otaBin: null, //固件包buffer形式从16进制字符串转换成
otaHexString: "", //固件包的16进制字符串从后端接口返回
packageLength: 0, //升级包的总长度(单位是字节)
packageCount: 0, //分包后的总包数
otaData: [], //分包数组
packageCrc8: "", //总包的校验码
versionNo: "", //包的版本号
otaCurrentPackageIndex: 0, //现在正在传输的分包索引
countDown: 7,
};
async onLoad() {
if (this.$checkTimer) clearInterval(this.$checkTimer);
}
componentDidMount() {
console.log("componentDidMount");
this.initData();
}
componentDidHide() {
console.log("componentDidHide");
this.errorFun();
}
async initData() {
console.log("UpdateIotWL200");
deviceToolKitInstance = deviceToolKitInstanceFR200;
let objStr = getStorageSync("instrument_detail");
if (objStr) {
this.setState({
currentDevice: objStr,
});
}
setTimeout(() => {
this.notifyBLECharacteristicValueChange();
this.getDeviceUpgrade();
});
}
/**
*
*/
async getUpgradeData() {
//解析获取升级包更新数据
const { otaHexString, packageSize } = this.$otaDataGroup;
if (!otaHexString?.length) {
return [];
}
let arr: any = [];
for (let i = 0, len = otaHexString.length; i < len; i += packageSize * 2) {
let index = i + packageSize * 2;
let value = otaHexString.slice(i, index);
arr.push(value);
}
return arr;
}
/**
* OTA
*/
resetOta() {
this.$otaDataGroup = {
...this.$otaDataGroup,
otaCurrentPackageIndex: 0,
otaData: [],
};
}
/**
* ota
*/
startOTA() {
this.resetOta();
let jsoncmd = {
commandType: "OTAStart",
otaDeviceType: "FR200",
versionNo: this.$otaDataGroup.versionNo,
};
console.log("startOTA jsoncmd", jsoncmd);
//@ts-ignore
const value = deviceToolKitInstance.toBleCommand(jsoncmd as any);
console.log(jsoncmd);
sendCommand({ value }).then((res) => {
this.setState({
hadStartOta: true,
});
this.createTimer();
});
}
/**
* ota
*/
preOTA() {
const { packageCount, packageLength, packageCrc8, versionNo } =
this.$otaDataGroup;
let jsoncmd = {
commandType: "OTAPrepare",
packageCount,
packageLength,
packageCrc8,
versionNo,
};
console.info("OTAPrepare json => ", jsoncmd);
//@ts-ignore
const value = deviceToolKitInstance.toBleCommand(jsoncmd as any);
sendCommand({ value });
}
/**
* ota
*/
processOTA(i, data) {
const { packageCount, packageLength } = this.$otaDataGroup;
if (!packageLength) {
this.quitOTA();
}
let jsoncmd = {
commandType: "OTAUpdating",
packageCount,
packageLength,
currentPackageNo: i + 1,
currentPackageLength: data.length / 2,
currentPackageContent: data,
};
console.info("OTAUpdating json => ", jsoncmd);
//@ts-ignore
const value = deviceToolKitInstance.toBleCommand(jsoncmd as any);
sendCommand({ value });
}
/**
* ota
*/
async finishedOTA() {
let jsoncmd = {
commandType: "OTAUpdateFinish",
versionNo: this.$otaDataGroup.versionNo,
};
clearInterval(this.$checkTimer);
log.info("ota成功日志, 清除计时器");
//@ts-ignore
const value = deviceToolKitInstance.toBleCommand(jsoncmd as any);
sendCommand({ value }).then((res) => {
this.resetOta();
});
}
/**
* ota退
*/
quitOTA(errorString = "") {
// log.info('ota失败日志', errorString);
console.log("ota失败日志", errorString);
const errorMap = {
packageError: "总包错误",
packageNumError: "包号错误",
checkedError: "校验错误",
dataLengthError: "数据总长度错误",
dataCRCError: "数据总数CRC错误",
updateTimeOut: "数据更新超时",
};
let jsoncmd = {
commandType: "OTAQuit",
};
//@ts-ignore
const value = deviceToolKitInstance.toBleCommand(jsoncmd as any);
sendCommand({ value })
.then((res) => {
this.resetOta();
// this.showError(errorMap[errorString] || tipMap[errorString] || '发生错误')
})
.catch((err) => {
if (!this.state.hadShowError) {
this.setState({
hadShowError: true,
});
// log.info('ota失败日志', '发送日志OTAQuit失败', err);
console.info("ota失败日志", "发送日志OTAQuit失败", err);
if (err.errCode === 10000) {
let isDisconnect = getStorageSync("isDisconnectUpdate");
if (isDisconnect) {
if (this.$checkTimer) clearInterval(this.$checkTimer);
}
}
}
});
setTimeout(() => {
this.errorFun();
}, 1000);
}
/**
* OTA
*/
async parseData(json) {
console.log("parseData json.commandType", json.commandType);
if (!json || !json.commandType) return;
switch (json.commandType) {
case "OTAStart":
if (json.responseStatus == "OK") {
const otaData = await this.getUpgradeData();
this.$otaDataGroup = {
...this.$otaDataGroup,
otaData,
};
this.$otaDataGroup.otaCurrentPackageIndex = 0;
this.preOTA();
} else {
this.quitOTA(json.responseStatus);
}
break;
case "OTAPrepare":
if (json.responseStatus == "OK") {
this.processOTA(0, this.$otaDataGroup.otaData[0]);
} else {
this.quitOTA(json.responseStatus);
}
break;
case "OTAUpdating":
if (json.responseStatus == "OK") {
let ota = this.$otaDataGroup;
let progressbar =
(ota.otaCurrentPackageIndex / ota.packageCount) * 100;
this.setState({
progressbar: (progressbar <= 1 ? 1 : progressbar).toFixed(0),
});
if (!json.currentPackageNo) {
return;
}
if (json.currentPackageNo < this.$otaDataGroup.packageCount) {
this.$otaDataGroup.otaCurrentPackageIndex++;
this.processOTA(
this.$otaDataGroup.otaCurrentPackageIndex,
this.$otaDataGroup.otaData[
this.$otaDataGroup.otaCurrentPackageIndex
]
);
} else {
this.finishedOTA();
}
} else {
this.quitOTA(json.responseStatus);
}
break;
case "OTAUpdateFinish":
console.log("完成OTA传输");
this.setState({
progressbar: 100,
});
this.finishFun();
// quitOTA()
break;
default:
break;
}
}
/**
* ota
*/
getDeviceUpgrade = async () => {
let res: any = await InstrumentInfo.getUpgrade({
instrumentId: this.state.currentDevice.id,
isWe200: false,
});
if (res.data.data == "解析失败") {
// this.showError('文件解析失败');
return;
}
if (res.data.code !== 200) {
return;
}
const otaHexString = res.data.data;
const otaBin = string2buffer(res.data.data);
const packageLength = otaBin?.byteLength || 0;
const packageSize = this.$otaDataGroup.packageSize;
const packageCrc8 = Stringkit.getCrc8CodeByString(otaHexString);
const packageCount = Math.ceil(packageLength / packageSize);
let { iotVersion: versionNo } = this.state.currentDevice;
this.$otaDataGroup = {
...this.$otaDataGroup,
otaHexString,
otaBin,
packageLength,
packageSize,
packageCrc8,
packageCount,
versionNo,
};
console.log("this.$otaDataGroup ", this.$otaDataGroup);
};
notifyBLECharacteristicValueChange = () => {
const bluetoothInfo = this.props.bluetoothInfo;
notifyBLECharacteristicValueChange({
deviceId: bluetoothInfo.deviceId,
servicesuuid: bluetoothInfo.servicesuuid,
characteristicsuuid1: bluetoothInfo.characteristicsuuid1,
characteristicsuuid0: bluetoothInfo.characteristicsuuid0,
}).then((res) => {
Taro.onBLECharacteristicValueChange((value) => {
// let str = ab2hex(value.value); //转为16进制字符串
// console.log('返回',str)
const jsonStatus: any = deviceToolKitInstance.toJsonStatus(value.value);
log.info("OTA页面设备响应数据打印==》", JSON.stringify(jsonStatus));
console.info("onBLECharacteristicValueChange json => ", jsonStatus);
this.$otaDataGroup.currentPackageNo = jsonStatus.currentPackageNo;
this.$otaDataGroup.countDown = 7;
this.parseData(jsonStatus);
});
setTimeout(() => {
this.startOTA();
}, 500);
});
};
createTimer() {
log.info("设备ota计时器创建成功");
this.$checkTimer = setInterval(() => {
// 超过7s没有回包, 直接断开
if (this.$otaDataGroup.countDown <= 0 && this.state.hadStartOta) {
this.quitOTA("shutDownMaskTip");
} else {
this.$otaDataGroup.countDown--;
}
console.log(this.$otaDataGroup.countDown);
}, 1000);
}
//升级销毁页面时关闭小程序蓝牙
onUnload() {
console.log("onUnload");
if (this.$checkTimer) clearInterval(this.$checkTimer);
Taro.closeBluetoothAdapter();
}
onPullDownRefresh() {
Taro.stopPullDownRefresh();
}
onClickStop = (e) => {
e.stopPropagation();
};
// 错误关闭回调
errorFun = () => {
this.resetOta();
this.props.errorFun();
};
// 升级完成回调
finishFun = () => {
this.props.finishFun();
};
render() {
let { isShow } = this.props;
let { progressbar } = this.state;
return (
<Block>
<PageMeta pageStyle={isShow ? "overflow: hidden;" : ""} />
<Popup
show={isShow}
closeOnClickOverlay={false}
round
overlayStyle="width: 100vw;padding: 0;"
onClick={this.onClickStop}
>
<View
className={classnames(
"common-box",
"common-progress-box",
"common-large"
)}
catchMove
>
<View className={classnames("common-popup-title", "margin-samll")}>
</View>
<View className="common-popup-content-box">
<View className={classnames("common-popup-content", "text-left")}>
<View className="progress">
<Progress
percentage={progressbar}
strokeWidth="12"
color="linearGradient(to right, #eecda1, #ffe9c7) !important"
/>
<View className="percent"> {progressbar}%</View>
</View>
<View className="progress-tips"></View>
<View className="progress-tips">1.</View>
<View className="progress-tips">2.</View>
</View>
</View>
</View>
</Popup>
</Block>
);
}
}
const mapStateToProps = (state) => ({
bluetoothInfo: state.deviceInfo.bluetoothInfo,
});
const mapDispatchToProps = (dispatch) => ({});
export default connect(mapStateToProps, mapDispatchToProps)(UpdateIotFR200);

@ -180,6 +180,7 @@ class IotCarePlanFR200 extends Component<any, any> {
ModeList: [],
ModeType: "all", // all 1基础护理 2专区护理 3专研促渗 4敏期护理 5智能测肤
ActiveModeItem: {
modeType: "",
openSourceData: [],
}, // 当前选中模式
SwitchActiveModeItem: {}, // 切换选中模式

@ -738,107 +738,6 @@ class IotCarePlanWE200 extends Component<any, any> {
// 如果检查失败,则报错
this.onEmitErrorTips();
};
/** 完成护理,跳转到水分 */
onsuccess = async () => {
let waterStepList = this.state.waterStepList;
this.setState({
isShowNursingSuccess: true,
});
// return;
let { currentDevice, ActiveModeItem } = this.state;
let params: any = {};
params = {
instrumentId: currentDevice.id,
instrumentName: currentDevice.name,
modeId: ActiveModeItem.id,
modeName: ActiveModeItem.modeName,
nursingTime: s_to_hms(this.elapsedTime),
nursingData: JSON.stringify({
GearData: [...waterStepList],
}),
};
// params = { ...params, ...nursingData };
let res: any = await InstrumentInfo.apiNursingLog.addLog(
JSON.stringify(params)
);
setTimeout(async () => {
this.setState({
isShowNursingSuccess: false,
});
let date = new Date();
let year = date.getFullYear();
let month = (date.getMonth() + 1).toString().padStart(2, "0");
let day = date.getDate().toString().padStart(2, "0");
let formattedDate = `${year}.${month}.${day}`;
this.moistureTest(
params.nursingData,
formattedDate,
ActiveModeItem.id,
currentDevice.id
);
}, 2000);
};
async moistureTest(
nursingData,
formattedDate,
ActiveModeItemId,
currentDeviceId
) {
let data = {
queryDate: formattedDate,
instrumentId: currentDeviceId,
};
let res = await InstrumentInfo.fr200.moistureTest(data);
let echartsData = res.data.rows;
for (let i = 0; i < echartsData.length; i++) {
for (let j = i + 1; j < echartsData.length; j++) {
if (
echartsData[i].createTime.split(" ")[0] ==
echartsData[j].createTime.split(" ")[0]
) {
let result =
Date.parse(echartsData[i].createTime) -
Date.parse(echartsData[j].createTime);
if (result < 0) {
echartsData.splice(i, 1);
} else {
echartsData.splice(j, 1);
}
}
}
}
let gears: any = [];
let eDate: any = [];
echartsData?.map((item) => {
const result = item.createTime.split(" ")[0].substring(5);
eDate.push(result);
item.nursingData = JSON.parse(item.nursingData);
let level: any = 0;
item.nursingData?.GearData?.map((gear) => {
level = level + gear.forehead;
});
level = Math.floor(level / 3);
gears.push(level);
});
echartsData = {
gears,
eDate,
};
setStorageSync("moistureEachtsData", JSON.stringify(echartsData));
let report = true;
// go(`/recoding/pages/moisture_test_report/moisture_test_report?data=${allData.nursingData}&date=${allData.createTime}&modeId=${allData.modeId}&id=${allData.instrumentId}&echartsData=${JSON.stringify(echartsData)}`);
go(
`/recoding/pages/moisture_test_report/moisture_test_report?data=${nursingData}&date=${formattedDate}&modeId=${ActiveModeItemId}&id=${currentDeviceId}&echartsData=${JSON.stringify(
echartsData
)}&report=${report}`
);
}
/**
* @name
@ -852,41 +751,6 @@ class IotCarePlanWE200 extends Component<any, any> {
this.showTips("检测到您的设备没有紧贴肌肤,请紧贴肌肤后重新尝试");
});
};
updata() {
let that = this;
let stop = 0;
let time = setInterval(function () {
stop++;
let series = JSON.parse(JSON.stringify(that.state.series));
let num = Math.floor(Math.random() * 9);
let count = 0;
series.map((item) => {
if (item.type === "line") {
item.data.splice(0, 1);
item.data.push(num);
}
if (item.type === "bar") {
count++;
item.data.splice(0, 1);
if (count <= num) {
item.data.push(1);
} else {
item.data.push(0);
}
}
});
// 更新图表数据
that.setState({ series });
if (stop >= 20) {
clearInterval(time);
}
}, 1000);
}
full() {
this.setState({ isFullScreen: !this.state.isFullScreen });
}
/** 切换光照 */
onSwitchChange = async () => {
@ -911,37 +775,6 @@ class IotCarePlanWE200 extends Component<any, any> {
isStopNurse: !isStopNurse,
});
};
/** LED切换模式 */
onSwitchChangeLED = () => {
let { isStopNurse } = this.state;
if (isStopNurse) {
// 开始光照逻辑
this.onNursingTap();
this.switchVideoPlay(); // 开始
} else {
// 暂停光照逻辑
let sendParams: any = {
...deviceCommandSamples.pause,
workMode: "led", // 使用模式
workStatus: "standby",
};
const pauseArrayBuffer = deviceToolKitInstance.toBleCommand(
sendParams as any
);
sendCommand({
value: pauseArrayBuffer,
}).then(() => {
this.workStatus = "pause";
this.resetTimer();
console.info(`发送暂停指令成功 参数为 =>`, sendParams);
});
// this.handleWorkStatus(false, MODE_WORKING_ENUM.PAUSE);
this.switchVideoPause(); // 暂停
}
this.setState({
isStopNurse: !isStopNurse,
});
};
/**
* @name
@ -1235,265 +1068,11 @@ class IotCarePlanWE200 extends Component<any, any> {
}, 1000);
};
/**
* @name
* @description +1
*/
waterTestNext(index) {
let ActiveModeItem = this.state.ActiveModeItem;
if (index === 0 && ActiveModeItem.stepOneVideo) {
this.VideoSrcLoad(ActiveModeItem.stepOneVideo);
} else if (index === 1 && ActiveModeItem.stepTwoVideo) {
this.VideoSrcLoad(ActiveModeItem.stepTwoVideo);
} else if (index === 2 && ActiveModeItem.stepThreeVideo) {
this.VideoSrcLoad(ActiveModeItem.stepThreeVideo);
}
}
/**
* @name ,
* @description 1. 2./
* */
maskPenetrationNext() {
let {
MaskModeStepIndex,
MaskModeBuzzingIndex,
MaskModeVibrateIndex,
ActiveModeItem,
} = this.state;
// 模式多个步骤节点切换
// 已运行时间达到下一节点时,切换
let GearLength = ActiveModeItem.modeGear.length;
if (GearLength && MaskModeStepIndex < GearLength) {
let GearTime = minSecToS(ActiveModeItem.modeGear[MaskModeStepIndex].time);
if (this.elapsedTime > GearTime) {
// 已运行时间达到下一节点,且存在下一节点,步骤切换时更新
if (MaskModeStepIndex < GearLength) {
let index = MaskModeStepIndex + 1; // 提前步骤+1
this.setState({
MaskModeStepIndex: index,
});
this.FR200AutoChangeGear(index);
}
}
}
let BuzzingLength = ActiveModeItem.modeBuzzing.length;
if (BuzzingLength && MaskModeStepIndex < GearLength) {
let BuzzingTime = minSecToS(
ActiveModeItem.modeBuzzing[MaskModeStepIndex].time
);
if (this.elapsedTime > BuzzingTime) {
if (MaskModeBuzzingIndex < BuzzingLength) {
let index = MaskModeBuzzingIndex + 1; // 提前步骤+1
this.setState({
MaskModeBuzzingIndex: index,
});
this.FR200Buzzing();
}
}
}
let VibrateLength = ActiveModeItem.modeVibrate.length;
if (VibrateLength && MaskModeStepIndex < VibrateLength) {
let VibrateTime = minSecToS(
ActiveModeItem.modeVibrate[MaskModeStepIndex].time
);
if (this.elapsedTime > VibrateTime) {
if (MaskModeVibrateIndex < VibrateLength) {
let index = MaskModeVibrateIndex + 1; // 提前步骤+1
this.setState({
MaskModeVibrateIndex: index,
});
this.FR200Vibrate();
}
}
}
}
/** @name 精华促渗下一步,根据时间自动调用 */
essencePenetrationNext() {
let {
EssenceStepIndex,
EssenceBuzzingIndex,
EssenceVibrateIndex,
ActiveModeItem,
} = this.state;
// 模式多个步骤节点切换
// 已运行时间达到下一节点时,切换
let GearLength = ActiveModeItem.modeGear.length;
if (GearLength && EssenceBuzzingIndex < GearLength) {
let GearTime = minSecToS(
ActiveModeItem.modeGear[EssenceBuzzingIndex].time
);
if (this.elapsedTime > GearTime) {
// 已运行时间达到下一节点,且存在下一节点,步骤切换时更新
if (EssenceStepIndex < GearLength) {
let index = EssenceStepIndex + 1; // 提前步骤+1
this.setState({
EssenceStepIndex: index,
});
this.FR200AutoChangeGear(index);
}
}
}
let BuzzingLength = ActiveModeItem.modeBuzzing.length;
if (BuzzingLength && EssenceBuzzingIndex < BuzzingLength) {
let BuzzingTime = minSecToS(
ActiveModeItem.modeBuzzing[EssenceBuzzingIndex].time
);
if (this.elapsedTime > BuzzingTime) {
if (EssenceBuzzingIndex < BuzzingLength) {
let index = EssenceBuzzingIndex + 1; // 提前步骤+1
this.setState({
EssenceBuzzingIndex: index,
});
this.FR200Buzzing();
}
}
}
let VibrateLength = ActiveModeItem.modeVibrate.length;
if (VibrateLength && EssenceBuzzingIndex < VibrateLength) {
let VibrateTime = minSecToS(
ActiveModeItem.modeBuzzing[EssenceBuzzingIndex].time
);
if (this.elapsedTime > VibrateTime) {
if (EssenceVibrateIndex < VibrateLength) {
let index = EssenceVibrateIndex + 1; // 提前步骤+1
this.setState({
EssenceVibrateIndex: index,
});
this.FR200Vibrate();
}
}
}
}
/**切换挡位发起蜂鸣:可以切换到现在的挡位?*/
FR200Buzzing = () => {
console.log("FR200Buzzing 蜂鸣", this.elapsedTime);
const { ActiveModeItem, currentGear } = this.state;
let sendParams: any = {
...deviceCommandSamples.pause,
workMode: ActiveModeItem.modeType, // 使用模式
workStatus: "working",
gear: currentGear,
};
if (currentGear > 1) {
sendParams.gear = currentGear - 1;
let pauseArrayBuffer = deviceToolKitInstance.toBleCommand(
sendParams as any
);
sendCommand({
value: pauseArrayBuffer,
});
} else {
sendParams.gear = currentGear + 1;
let pauseArrayBuffer = deviceToolKitInstance.toBleCommand(
sendParams as any
);
sendCommand({
value: pauseArrayBuffer,
});
}
setTimeout(() => {
sendParams.gear = currentGear;
let pauseArrayBuffer = deviceToolKitInstance.toBleCommand(
sendParams as any
);
sendCommand({
value: pauseArrayBuffer,
});
}, 300);
};
/**
* @name FR200
* @description
*/
FR200AutoChangeGear = (index: number = 0) => {
console.log("FR200AutoChangeGear 切换挡位", this.elapsedTime);
const { ActiveModeItem, GearData } = this.state;
let gear = GearData[index].forehead;
// 同步挡位
this.setState({
currentGear: gear,
});
let sendParams: any = {
...deviceCommandSamples.pause,
workMode: ActiveModeItem.modeType, // 使用模式
workStatus: "working",
gear: gear,
};
const pauseArrayBuffer = deviceToolKitInstance.toBleCommand(
sendParams as any
);
sendCommand({
value: pauseArrayBuffer,
}).then(() => {
this.workStatus = "working";
this.resetTimer();
});
};
/**
* @name FR200
* @description
*/
FR200Vibrate = () => {
console.log("FR200Vibrate FR200震动", this.elapsedTime);
const { ActiveModeItem, currentGear } = this.state;
let sendParams: any = {
...deviceCommandSamples.pause,
workMode: ActiveModeItem.modeType, // 使用模式
workStatus: "working",
gear: currentGear,
};
const pauseArrayBuffer = deviceToolKitInstance.toBleCommand(
sendParams as any
);
sendCommand({
value: pauseArrayBuffer,
});
};
executePromises = async () => {
let waterStepList = this.state.waterStepList;
let waterStepIndex = this.state.waterStepIndex;
let that = this;
await new Promise<void>((resolve) => {
setTimeout(() => {
waterStepList[waterStepIndex].schedule = 100;
that.setState({
waterStepList,
});
resolve();
}, 3000);
}).then(() => {
return new Promise<void>((resolve) => {
setTimeout(() => {
waterStepList[waterStepIndex].finish = true;
that.setState({
waterStepList,
});
resolve();
}, 2000);
});
});
};
// 检测并控制工作状态
handleWorkStatus = async (isBtnClick: boolean, workStatus) => {
const { DeviceConnectStatus, ActiveModeItem } = this.state;
// 如果没有指定工作状态,则切换工作状态
let newWorkStatus =
workStatus ||
(this.workStatus == MODE_WORKING_ENUM.WORKING ? "pause" : "working");
@ -1504,33 +1083,8 @@ class IotCarePlanWE200 extends Component<any, any> {
workStatus: newWorkStatus,
};
// 水分测试需要特殊处理
// 水分测试准备 水分测试工作 水分测试启动
if (ActiveModeItem.modeType === "moistureTest") {
let that = this;
sendParams.testStatus = "standby"; // 切换为准备
// 3秒定时器逻辑3秒把进度条弄成100再加2秒获取最后结果
if (isBtnClick) {
that.setState({
isRuningTest: 2,
});
this.executePromises();
sendParams.testStatus = "start"; // 点击开始再开始
console.log("点击开始", isBtnClick);
}
}
// 面膜促渗和精华促渗
if (
ActiveModeItem.modeType === "maskPenetration" ||
ActiveModeItem.modeType === "essence"
) {
sendParams.gear = this.state.currentGear; // 点击开始再开始
}
console.log("准备发送自定义或工作指令", ActiveModeItem, sendParams);
const pauseArrayBuffer = deviceToolKitInstance.toBleCommand(
sendParams as any
);

@ -39,6 +39,7 @@ import Navbar from "@/components/navbar/navbar";
import ConnectionBluetoot from "@/components/bluetoot/connection";
import UpdateIotWL200 from "@/components/bluetoot/update-wl200/index";
import UpdateIotFR200 from "@/components/bluetoot/update-fr200/index";
/** 自定义组件 **/
import {
@ -856,7 +857,9 @@ class Index extends Component<any, any> {
// return;
if (platform === "devtools") {
setStorageSync("instrument_detail", item);
this.setState({ connectInstrument: item });
this.setState({
connectInstrument: item,
});
if (item.type === 1) {
//非IOT
setTimeout(() => {
@ -1027,6 +1030,26 @@ class Index extends Component<any, any> {
isShowVersionUpgradFinish: false,
});
};
UpgradeFinishFun = () => {
let { connectInstrument } = this.state;
console.log("connectInstrument", connectInstrument);
let content = connectInstrument.iotVersionUpgrade;
let nodes = decodeURIComponent(content || "");
nodes = nodes.replace(/\<img/gi, '<img style="width:100%;height:auto" ');
nodes = nodes.replace(
/\<table/gi,
'<table style="border-spacing: 0;border-collapse: collapse;border: 1px solid #000" '
);
nodes = nodes.replace(
/\<td/gi,
'<td style="border: 1px solid #000;text-align:center" '
);
this.setState({
isShowVersionUpgrading: false,
isShowVersionUpgradFinish: true, // 升级介绍
versionUpgradFinishNodes: nodes,
});
};
/** iot版本升级 END */
/**
@ -1306,11 +1329,23 @@ class Index extends Component<any, any> {
confirm={this.confirmUpdateVersionTip}
/>
{isShowVersionUpgrading && (
<UpdateIotWL200
isShow={isShowVersionUpgrading}
finishFun={this.wl200UpgradeFinishFun}
errorFun={this.wl200UpgradeErrorFun}
/>
<Block>
{connectInstrument.model === "WL200" && (
<UpdateIotWL200
isShow={isShowVersionUpgrading}
finishFun={this.wl200UpgradeFinishFun}
errorFun={this.wl200UpgradeErrorFun}
/>
)}
{connectInstrument.model === "FR200" && (
<UpdateIotFR200
isShow={isShowVersionUpgrading}
finishFun={this.UpgradeFinishFun}
errorFun={this.wl200UpgradeErrorFun}
/>
)}
</Block>
)}
<PopupAlert
isShow={isShowVersionUpgradFinish}

Loading…
Cancel
Save