修改剩料收集,获取圈舍成功后开始连接蓝牙。配置页面增加弹框提示。装料页面增加定时3秒上传数据,增加班次初始化成功以后才开始扫描蓝牙设备。修改装料卸料文字区分。增加db sqlLite模块

This commit is contained in:
liuwu 2023-12-20 14:40:11 +08:00
parent 8717e992a6
commit e186cc353e
4 changed files with 454 additions and 206 deletions

View File

@ -212,6 +212,7 @@
htmlc+='<button class="btnCowshed mui-btn-info btnCowshed" type="button" onclick="selectCowshed(this,' + '\'' + c.cowshed_name +'\''+ ',' + '\'' + c.id + '\')">'+c.cowshed_name+'</button>' htmlc+='<button class="btnCowshed mui-btn-info btnCowshed" type="button" onclick="selectCowshed(this,' + '\'' + c.cowshed_name +'\''+ ',' + '\'' + c.id + '\')">'+c.cowshed_name+'</button>'
}) })
document.getElementById('htmlc').innerHTML = htmlc document.getElementById('htmlc').innerHTML = htmlc
startCollect()
} else { } else {
mui.alert(err.msg); mui.alert(err.msg);
} }
@ -365,7 +366,6 @@
} }
}) })
} }
startCollect()
getTmrCowshed() getTmrCowshed()
} }

View File

@ -172,53 +172,8 @@
weiData.push({value: "70", text: "70"}) weiData.push({value: "70", text: "70"})
weiData.push({value: "80", text: "80"}) weiData.push({value: "80", text: "80"})
function init() {
}
var apiready = function apiready() { var apiready = function apiready() {
initSbList() initSbList()
init()
muiInitPage()
muiInitFix()
muiInitWeightSize()
var indexPage = api.getPrefs({
sync: true,
key: 'initpage'
});
if (indexPage) {
pageData.forEach(p => {
if (indexPage === p.value) {
document.getElementById('initpage').innerHTML = p.text
}
})
}
var requireFix = api.getPrefs({
sync: true,
key: 'fixbeforeload'
});
if (requireFix) {
fixData.forEach(p => {
if (requireFix == p.value) {
document.getElementById('fixbeforeload').innerHTML = p.text
}
})
}
var weightSize = api.getPrefs({
sync: true,
key: 'weightSize'
});
if (weightSize) {
weiData.forEach(p => {
if (weightSize == p.value) {
console.log(requireFix === p.value)
document.getElementById('weightSize').innerHTML = p.text
}
})
}
} }
function downloadApp(){ function downloadApp(){
@ -272,6 +227,10 @@
timeout: 5 timeout: 5
}, function (ret, err) { }, function (ret, err) {
if (ret) { if (ret) {
api.showProgress({
title: '初始化中...',
modal: true
});
var initsb = api.getPrefs({ var initsb = api.getPrefs({
sync: true, sync: true,
key: 'initsb' key: 'initsb'
@ -290,6 +249,50 @@
}); });
document.getElementById('initsb').innerHTML = pickData[0].text; document.getElementById('initsb').innerHTML = pickData[0].text;
muiInit(); muiInit();
muiInitPage()
muiInitFix()
muiInitWeightSize()
var indexPage = api.getPrefs({
sync: true,
key: 'initpage'
});
if (indexPage) {
pageData.forEach(p => {
if (indexPage === p.value) {
document.getElementById('initpage').innerHTML = p.text
}
})
}
var requireFix = api.getPrefs({
sync: true,
key: 'fixbeforeload'
});
if (requireFix) {
fixData.forEach(p => {
if (requireFix == p.value) {
document.getElementById('fixbeforeload').innerHTML = p.text
}
})
}
var weightSize = api.getPrefs({
sync: true,
key: 'weightSize'
});
if (weightSize) {
weiData.forEach(p => {
if (weightSize == p.value) {
console.log(requireFix === p.value)
document.getElementById('weightSize').innerHTML = p.text
}
})
}
setTimeout(function () {
api.hideProgress();
}, 1000);
} else { } else {
mui.alert("sbList:" + err.msg); mui.alert("sbList:" + err.msg);
} }

View File

@ -97,10 +97,11 @@
} }
.mui-toast-message { .mui-toast-message {
background: url(/app/themes/default/images/toast.png) no-repeat center 10px #407ae6; /* background: url(/app/themes/default/images/toast.png) no-repeat center 10px #407ae6;
opacity: 1; opacity: 1; */
font-size: xx-large; font-size: x-large;
color: #fff; /* color: #fff;
*/
width: 100%; width: 100%;
padding: 20px 10px 20px 10px; padding: 20px 10px 20px 10px;
} }
@ -253,10 +254,22 @@
30: "㉚" 30: "㉚"
} }
var ble; var ble;
var db;
var weightSize = 40; var weightSize = 40;
var apiready = function apiready() { var apiready = function apiready() {
// 获取db连接
db = api.require('db');
db.openDatabase({
name: 'test',
path: 'fs://Database/cqjiouzai.db'
}, function(ret, err) {
console.log(JSON.stringify(ret) + JSON.stringify(err))
if (ret.status) {
initFeedResult();
}
});
var size = api.getPrefs({sync: true,key: 'weightSize'}) var size = api.getPrefs({sync: true,key: 'weightSize'})
if (size && !isNaN(size)){ if (size && !isNaN(size)){
weightSize = Number(size) weightSize = Number(size)
@ -287,7 +300,7 @@
// }, 2000); // }, 2000);
// }); // });
initPage(); initPage();
initService()
// api.addEventListener({ // api.addEventListener({
// name: 'keyback' // name: 'keyback'
// }, function (ret, err) { // }, function (ret, err) {
@ -301,8 +314,56 @@
// } // }
// }); // });
// }); // });
resultInterval = setInterval(function () {
var feedListCache = []
var cacheList = api.getPrefs({ sync: true, key: 'feedListCache' })
// 存在
if (cacheList && cacheList!=='' && cacheList!=='[]') {
feedListCache = JSON.parse(cacheList)
api.ajax({
url: 'https://tmr.nxcyx.com/api/app/tmr/resultUpload',
headers: {
'Content-Type': 'application/json;charset=utf-8' //建议key使用首字母大写的形式如 User-Agent
},
method: 'post',
data: {
body: feedListCache[0]
}
}, function (ret, err) {
if (ret.code === 200) {
feedListCache.splice(0,1);
api.setPrefs({
key: 'feedListCache',
value: feedListCache
});
}else {
addNotice(4,'red','submitData,' + err.msg);
}
});
}else{
}
}, 3000);
}; };
//创建用户表
function initFeedResult() {
select(db, 'SELECT * FROM result', function(ret, err) {
if (ret.status == false || err.status == false) {
// execute(db, 'CREATE TABLE result(Id int, Name varchar(255), psd varchar(255),jumpadd varchar(255),alias varchar(255))', function(ret, err) {
// if (ret.status == true) {
// console.log('创建用户表成功');
// execute(db, "INSERT INTO User (Id,Name,psd,jumpadd,alias) VALUES ('1','user1','user1','frame0.html','黑山变屏位图');", function(ret, err) {})
// }
// });
console.log('用户表不存在');
} else {
console.log('用户表已存在');
}
});
}
function rescan(){ function rescan(){
if(!connetcedStatus){ if(!connetcedStatus){
if(bleData.length>0){ if(bleData.length>0){
@ -552,6 +613,7 @@
sourceCow: api.getPrefs({ sync: true, key: 'sourceCow' }), sourceCow: api.getPrefs({ sync: true, key: 'sourceCow' }),
dateOf: getDateStr(new Date()) dateOf: getDateStr(new Date())
}; };
initService()
initTrain(param); initTrain(param);
} else { } else {
document.getElementById('text').innerHTML = '<font style="color:red">班次加载失败</font>'; document.getElementById('text').innerHTML = '<font style="color:red">班次加载失败</font>';
@ -666,7 +728,11 @@
// 误差小于100必须校准才能自动跳转 // 误差小于100必须校准才能自动跳转
allowAuto = false; allowAuto = false;
document.getElementById('isfix').innerHTML = '<font style="color:red;font-size: x-large;">未校准</font>' document.getElementById('isfix').innerHTML = '<font style="color:red;font-size: x-large;">未校准</font>'
document.getElementById('feedNum').innerHTML = '<font style="color:blue">:' + _planSum + '</font>/<font style="color:green">已装:' + _feedNum + '</font>'; if (load) {
document.getElementById('feedNum').innerHTML = '<font style="color:blue">:' + _planSum + '</font>/<font style="color:green">已装:' + _feedNum + '</font>';
}else{
document.getElementById('feedNum').innerHTML = '<font style="color:blue">:' + _planSum + '</font>/<font style="color:green">已卸:' + _feedNum + '</font>';
}
text = feedName + _planSum; text = feedName + _planSum;
batchName = e.className + e.trainNumber; batchName = e.className + e.trainNumber;
templateName = e.templetName; templateName = e.templetName;

View File

@ -10,7 +10,7 @@ function weightFix() {
return false; return false;
} }
var btnArray1 = [feedName + '已完成', feedName + '未开始']; var btnArray1 = [feedName + '已完成', feedName + '未开始'];
mui.confirm('<b style="color:red">如果装料完成需要先上传</b>', '<b style="font-weight:900">校准前' + feedName + '状态</b>', btnArray1, function (e) { mui.confirm('<b style="color:red">如果完成需要先上传</b>', '<b style="font-weight:900">校准前' + feedName + '状态</b>', btnArray1, function (e) {
if (e.index == 0) { if (e.index == 0) {
mui.toast('<b style="color:red">校准失败,已完成请先上传</b>'); mui.toast('<b style="color:red">校准失败,已完成请先上传</b>');
} else { } else {
@ -63,152 +63,323 @@ function submitData() {
end: dateTime, end: dateTime,
time: dateTime time: dateTime
}; };
api.ajax({ // api.showProgress({
url: 'https://tmr.nxcyx.com/api/app/tmr/resultUpload', // title: '数据上传中...',
headers: { // modal: true
'Content-Type': 'application/json;charset=utf-8' //建议key使用首字母大写的形式如 User-Agent // });
}, var feedListCache = []
method: 'post', var cacheList = api.getPrefs({ sync: true, key: 'feedListCache' })
data: { // 存在
body: param if (cacheList && cacheList!=='' && cacheList!=='[]') {
} feedListCache = JSON.parse(cacheList)
}, function (ret, err) { feedListCache.push(param)
if (ret && ret.code == 200) { api.setPrefs({
mui.toast(param.name + " 已上传 " + param.feedWeight,{duration:3500,type:'div'}); key: 'feedListCache',
remark = '手动上传' value: feedListCache
beforeWeight = nowWeight; });
// document.getElementById('beforeWeight').innerHTML = '称实时/装料前:' + nowWeight + '/' + beforeWeight; }else{
feedIndex = feedIndex + 1; feedListCache.push(param)
// 没有下一个饲料,车次加一 api.setPrefs({
if (feedIndex > feedList.length - 1) { key: 'feedListCache',
trainIndex = trainIndex + 1; value: feedListCache
// 没有下一个车次,饲喂完成 });
if (trainIndex > trainArr.length - 1) { }
// mui.alert("本班次饲喂完成"); // api.hideProgress();
feedStatus = false mui.toast(param.name + " 已上传 " + param.feedWeight,{duration:1500,type:'div'});
_feedNum = batchName+'次饲喂完成' remark = '手动上传'
renderUnload(); beforeWeight = nowWeight;
renderLoad(); // document.getElementById('beforeWeight').innerHTML = '称实时/装料前:' + nowWeight + '/' + beforeWeight;
feedMyChart.setOption({ feedIndex = feedIndex + 1;
dataset: { // 没有下一个饲料,车次加一
source: [[1, _feedNum]] if (feedIndex > feedList.length - 1) {
} trainIndex = trainIndex + 1;
}); // 没有下一个车次,饲喂完成
weightMyChart.setOption({ if (trainIndex > trainArr.length - 1) {
dataset: { // mui.alert("本班次饲喂完成");
source: [[1, nowWeight]] feedStatus = false
} _feedNum = batchName+'次饲喂完成'
});
var param1 = {
SF: "AA A5 ",
LEN: '1A 00 ',
DES: 'FF FF ',
SRC: '12 34 ',
TID: 'B0 A1 ',
CMD1: '38 02 ',
X: '00 00 ',
Y: '00 00 ',
WIDTH: '40 00 ',
HEIGHT: '20 00 ',
FORMAT: '00 00 01 00 ',
CNT: '04 00 ',
CRC: '00 00 ',
EF: '5A 55 ',
msg: ''
};
// param1.msg = batchName+'饲喂完成'
var newmsg = batchName+'次';
var msglen = newmsg.getByteLen();
var ttr = '';
if (Number(_planSum - _feedNum) >= 0) {
ttr = '少';
echartsType = '少';
} else {
ttr = '多';
echartsType = '多';
}
if (msglen < 8) {
for (var i = 0; i < 8 - msglen; i++) {
newmsg = newmsg + ' ';
}
newmsg = newmsg + ttr;
} else {
newmsg = feedName + ttr;
}
param1.msg = newmsg + '饲喂完成';
// console.log(param1.msg)
zfk.getMsg(param1, function (ret, err) {
var str = ret.sendMsg;
str = str.replace(/\s+/g, "");
var num = str.length / 2;
param.value = "FF0500" + num.toString(16) + str;
msgList.push(param.value);
})
document.getElementById('submitData').setAttribute("class", 'btnc mui-btn-success dis');
document.getElementById('feedNum').innerHTML = param1.msg;
setTimeout(function(){
console.log("停止蜂鸣");
control("00", "00");
},500)
return false;
}
// 自动点击下一车,并定位,同时刷新下一个开始装料时间
document.getElementById('classeCode_' + classCode + 'train_' + trainIndex).click();
document.querySelector('#' + 'classeCode_' + classCode + 'train_' + trainIndex).scrollIntoView(true);
api.setGlobalData({key: 'startTime', value: currTimeFn(new Date())});
return false;
} else {
// 判断是否是圈舍
if (feedList[feedIndex].batchRation) {
load = false;
} else {
load = true;
}
// 设置下一个饲料选中状态
var doms = document.getElementsByClassName('mui-badge');
if (doms.length > 0) {
for (var i = 0; i < doms.length; i++) {
doms[i].setAttribute("class", 'mui-badge');
}
}
document.getElementById('feed_' + feedIndex).setAttribute("class", 'mui-badge mui-badge-purple');
}
// 刷新已装装料为0显示下一个饲料名称定位到下一个饲料位置刷新允许误差刷新计划重量刷新显示班次信息
_feedNum = 0;
feedName = feedList[feedIndex].name;
// document.getElementById("upload").innerHTML = '上传'+json[0].name
document.getElementById('submitData').innerHTML = '上传' + feedName;
// document.getElementById('fix').innerHTML = '装料前校准' + feedName;
document.getElementById('fix').innerHTML = '装料前校准';
document.querySelector('#feed_' + feedIndex).scrollIntoView(true);
allow = feedList[feedIndex].allow;
_planSum = feedList[feedIndex].weight.toFixed(0);
renderUnload(); renderUnload();
renderLoad();
feedMyChart.setOption({ feedMyChart.setOption({
dataset: { dataset: {
source: [[1, _feedNum]] source: [[1, _feedNum]]
} }
}); });
// 误差小于100必须校准才能自动跳转 weightMyChart.setOption({
allowAuto = false; dataset: {
document.getElementById('isfix').innerHTML = '<font style="color:red;font-size: x-large;">未校准</font>' source: [[1, nowWeight]]
text = feedName + _planSum; }
document.getElementById('nowFeed').innerHTML = '<font style="color:blue;margin-left:10px;">' + batchName + ',' + feedName + '</font>'; });
document.getElementById('feedNum').innerHTML = '<font style="color:blue">:' + _planSum + '</font>/<font style="color:green">已装:' + _feedNum + '</font>'; var param1 = {
ledStatus = false; SF: "AA A5 ",
// setTimeout(() => { LEN: '1A 00 ',
console.log("停止蜂鸣"); DES: 'FF FF ',
control("00", "00"); SRC: '12 34 ',
setTimeout(function () { TID: 'B0 A1 ',
ledStatus = true; CMD1: '38 02 ',
statusEle = false; X: '00 00 ',
}, 500); Y: '00 00 ',
// },500) WIDTH: '40 00 ',
} else if (err) { HEIGHT: '20 00 ',
addNotice(4,'red','submitData,' + err.msg); FORMAT: '00 00 01 00 ',
mui.alert( err.msg); CNT: '04 00 ',
CRC: '00 00 ',
EF: '5A 55 ',
msg: ''
};
// param1.msg = batchName+'饲喂完成'
var newmsg = batchName+'次';
var msglen = newmsg.getByteLen();
var ttr = '';
if (Number(_planSum - _feedNum) >= 0) {
ttr = '少';
echartsType = '少';
} else {
ttr = '多';
echartsType = '多';
}
if (msglen < 8) {
for (var i = 0; i < 8 - msglen; i++) {
newmsg = newmsg + ' ';
}
newmsg = newmsg + ttr;
} else {
newmsg = feedName + ttr;
}
param1.msg = newmsg + '饲喂完成';
// console.log(param1.msg)
zfk.getMsg(param1, function (ret, err) {
var str = ret.sendMsg;
str = str.replace(/\s+/g, "");
var num = str.length / 2;
param.value = "FF0500" + num.toString(16) + str;
msgList.push(param.value);
})
document.getElementById('submitData').setAttribute("class", 'btnc mui-btn-success dis');
document.getElementById('feedNum').innerHTML = param1.msg;
setTimeout(function(){
console.log("停止蜂鸣");
control("00", "00");
},500)
return false;
}
// 自动点击下一车,并定位,同时刷新下一个开始装料时间
document.getElementById('classeCode_' + classCode + 'train_' + trainIndex).click();
document.querySelector('#' + 'classeCode_' + classCode + 'train_' + trainIndex).scrollIntoView(true);
api.setGlobalData({key: 'startTime', value: currTimeFn(new Date())});
return false;
} else {
// 判断是否是圈舍
if (feedList[feedIndex].batchRation) {
load = false;
} else {
load = true;
}
// 设置下一个饲料选中状态
var doms = document.getElementsByClassName('mui-badge');
if (doms.length > 0) {
for (var i = 0; i < doms.length; i++) {
doms[i].setAttribute("class", 'mui-badge');
}
}
document.getElementById('feed_' + feedIndex).setAttribute("class", 'mui-badge mui-badge-purple');
}
// 刷新已装装料为0显示下一个饲料名称定位到下一个饲料位置刷新允许误差刷新计划重量刷新显示班次信息
_feedNum = 0;
feedName = feedList[feedIndex].name;
// document.getElementById("upload").innerHTML = '上传'+json[0].name
document.getElementById('submitData').innerHTML = '上传' + feedName;
// document.getElementById('fix').innerHTML = '装料前校准' + feedName;
if (load) {
document.getElementById('fix').innerHTML = '装料前校准';
} else {
document.getElementById('fix').innerHTML = '卸料前校准';
}
document.querySelector('#feed_' + feedIndex).scrollIntoView(true);
allow = feedList[feedIndex].allow;
_planSum = feedList[feedIndex].weight.toFixed(0);
renderUnload();
feedMyChart.setOption({
dataset: {
source: [[1, _feedNum]]
} }
}); });
// 误差小于100必须校准才能自动跳转
allowAuto = false;
document.getElementById('isfix').innerHTML = '<font style="color:red;font-size: x-large;">未校准</font>'
text = feedName + _planSum;
document.getElementById('nowFeed').innerHTML = '<font style="color:blue;margin-left:10px;">' + batchName + ',' + feedName + '</font>';
if (load) {
document.getElementById('feedNum').innerHTML = '<font style="color:blue">:' + _planSum + '</font>/<font style="color:green">已装:' + _feedNum + '</font>';
} else {
document.getElementById('feedNum').innerHTML = '<font style="color:blue">:' + _planSum + '</font>/<font style="color:green">已卸:' + _feedNum + '</font>';
}
ledStatus = false;
// setTimeout(() => {
console.log("停止蜂鸣");
control("00", "00");
setTimeout(function () {
ledStatus = true;
statusEle = false;
}, 500);
// api.ajax({
// url: 'https://tmr.nxcyx.com/api/app/tmr/resultUpload',
// headers: {
// 'Content-Type': 'application/json;charset=utf-8' //建议key使用首字母大写的形式如 User-Agent
// },
// method: 'post',
// data: {
// body: param
// }
// }, function (ret, err) {
// if (ret && ret.code == 200) {
// api.hideProgress();
// mui.toast(param.name + " 已上传 " + param.feedWeight,{duration:1500,type:'div'});
// remark = '手动上传'
// beforeWeight = nowWeight;
// // document.getElementById('beforeWeight').innerHTML = '称实时/装料前:' + nowWeight + '/' + beforeWeight;
// feedIndex = feedIndex + 1;
// // 没有下一个饲料,车次加一
// if (feedIndex > feedList.length - 1) {
// trainIndex = trainIndex + 1;
// // 没有下一个车次,饲喂完成
// if (trainIndex > trainArr.length - 1) {
// // mui.alert("本班次饲喂完成");
// feedStatus = false
// _feedNum = batchName+'次饲喂完成'
// renderUnload();
// renderLoad();
// feedMyChart.setOption({
// dataset: {
// source: [[1, _feedNum]]
// }
// });
// weightMyChart.setOption({
// dataset: {
// source: [[1, nowWeight]]
// }
// });
// var param1 = {
// SF: "AA A5 ",
// LEN: '1A 00 ',
// DES: 'FF FF ',
// SRC: '12 34 ',
// TID: 'B0 A1 ',
// CMD1: '38 02 ',
// X: '00 00 ',
// Y: '00 00 ',
// WIDTH: '40 00 ',
// HEIGHT: '20 00 ',
// FORMAT: '00 00 01 00 ',
// CNT: '04 00 ',
// CRC: '00 00 ',
// EF: '5A 55 ',
// msg: ''
// };
// // param1.msg = batchName+'饲喂完成'
// var newmsg = batchName+'次';
// var msglen = newmsg.getByteLen();
// var ttr = '';
// if (Number(_planSum - _feedNum) >= 0) {
// ttr = '少';
// echartsType = '少';
// } else {
// ttr = '多';
// echartsType = '多';
// }
// if (msglen < 8) {
// for (var i = 0; i < 8 - msglen; i++) {
// newmsg = newmsg + ' ';
// }
// newmsg = newmsg + ttr;
// } else {
// newmsg = feedName + ttr;
// }
// param1.msg = newmsg + '饲喂完成';
// // console.log(param1.msg)
// zfk.getMsg(param1, function (ret, err) {
// var str = ret.sendMsg;
// str = str.replace(/\s+/g, "");
// var num = str.length / 2;
// param.value = "FF0500" + num.toString(16) + str;
// msgList.push(param.value);
// })
// document.getElementById('submitData').setAttribute("class", 'btnc mui-btn-success dis');
// document.getElementById('feedNum').innerHTML = param1.msg;
// setTimeout(function(){
// console.log("停止蜂鸣");
// control("00", "00");
// },500)
// return false;
// }
// // 自动点击下一车,并定位,同时刷新下一个开始装料时间
// document.getElementById('classeCode_' + classCode + 'train_' + trainIndex).click();
// document.querySelector('#' + 'classeCode_' + classCode + 'train_' + trainIndex).scrollIntoView(true);
// api.setGlobalData({key: 'startTime', value: currTimeFn(new Date())});
// return false;
// } else {
// // 判断是否是圈舍
// if (feedList[feedIndex].batchRation) {
// load = false;
// } else {
// load = true;
// }
// // 设置下一个饲料选中状态
// var doms = document.getElementsByClassName('mui-badge');
// if (doms.length > 0) {
// for (var i = 0; i < doms.length; i++) {
// doms[i].setAttribute("class", 'mui-badge');
// }
// }
// document.getElementById('feed_' + feedIndex).setAttribute("class", 'mui-badge mui-badge-purple');
// }
// // 刷新已装装料为0显示下一个饲料名称定位到下一个饲料位置刷新允许误差刷新计划重量刷新显示班次信息
// _feedNum = 0;
// feedName = feedList[feedIndex].name;
// // document.getElementById("upload").innerHTML = '上传'+json[0].name
// document.getElementById('submitData').innerHTML = '上传' + feedName;
// // document.getElementById('fix').innerHTML = '装料前校准' + feedName;
// if (load) {
// document.getElementById('fix').innerHTML = '装料前校准';
// } else {
// document.getElementById('fix').innerHTML = '卸料前校准';
// }
// document.querySelector('#feed_' + feedIndex).scrollIntoView(true);
// allow = feedList[feedIndex].allow;
// _planSum = feedList[feedIndex].weight.toFixed(0);
// renderUnload();
// feedMyChart.setOption({
// dataset: {
// source: [[1, _feedNum]]
// }
// });
// // 误差小于100必须校准才能自动跳转
// allowAuto = false;
// document.getElementById('isfix').innerHTML = '<font style="color:red;font-size: x-large;">未校准</font>'
// text = feedName + _planSum;
// document.getElementById('nowFeed').innerHTML = '<font style="color:blue;margin-left:10px;">' + batchName + ',' + feedName + '</font>';
// if (load) {
// document.getElementById('feedNum').innerHTML = '<font style="color:blue">:' + _planSum + '</font>/<font style="color:green">已装:' + _feedNum + '</font>';
// } else {
// document.getElementById('feedNum').innerHTML = '<font style="color:blue">:' + _planSum + '</font>/<font style="color:green">已卸:' + _feedNum + '</font>';
// }
// ledStatus = false;
// // setTimeout(() => {
// console.log("停止蜂鸣");
// control("00", "00");
// setTimeout(function () {
// ledStatus = true;
// statusEle = false;
// }, 500);
// // },500)
// } else if (err) {
// api.hideProgress();
// addNotice(4,'red','submitData,' + err.msg);
// mui.alert( err.msg);
// }
// });
} }
var weightDataFilter; var weightDataFilter;
@ -221,21 +392,7 @@ var characteristicUUID = '';
var lastTime = ""; var lastTime = "";
var time = ""; var time = "";
var feedStatus = false; var feedStatus = false;
var connetcedStatus = false; var connetcedStatus = false;
// setInterval(function () {
// console.log(connetcedStatus)
// if (connetcedStatus && uuid) {
// connetcedStatus = false
// connect({peripheralUUID: uuid}, function (ret3) {
// console.log(JSON.stringify(ret3))
// })
// }
// }, 1000)
// 初始化所有服务
// 获取当前时间字符串 // 获取当前时间字符串
function currTimeFn(_date) { function currTimeFn(_date) {
@ -651,6 +808,28 @@ function closeApp() {
}); });
} }
function execute(db, sql, callback) {
db.executeSql({
name: 'test',
sql: sql
}, function(ret, err) {
// console.log(JSON.stringify(ret)+'['+sql+']');
// console.log(JSON.stringify(err)+'['+sql+']');
callback(ret, err);
});
}
function select(db, selsql, callback) {
db.selectSql({
name: 'test',
sql: selsql
}, function(ret, err) {
// console.log(JSON.stringify(ret)+'['+selsql+']');
// console.log(JSON.stringify(err)+'['+selsql+']');
callback(ret, err);
});
}
// 以下是一个基于JavaScript的称重异常过滤程序示例该程序使用滑动窗口算法来过滤异常值 // 以下是一个基于JavaScript的称重异常过滤程序示例该程序使用滑动窗口算法来过滤异常值
// 该程序使用一个dataBuffer数组来保存最近的一组测量值并返回这组值的平均值。程序在filter方法中将新的测量值加入到dataBuffer中并调用getAverageValue方法获取平均值。如果该平均值与上一个有效值的偏差小于maxDeviation则将该测量值视为有效值并返回该平均值否则将该测量值视为异常值并返回上一个有效值。 // 该程序使用一个dataBuffer数组来保存最近的一组测量值并返回这组值的平均值。程序在filter方法中将新的测量值加入到dataBuffer中并调用getAverageValue方法获取平均值。如果该平均值与上一个有效值的偏差小于maxDeviation则将该测量值视为有效值并返回该平均值否则将该测量值视为异常值并返回上一个有效值。
// 使用时可以创建一个WeightDataFilter实例并调用filter方法来传入新的测量值如下所示 // 使用时可以创建一个WeightDataFilter实例并调用filter方法来传入新的测量值如下所示