89 lines
2.6 KiB
QML
89 lines
2.6 KiB
QML
import QtQuick
|
|
|
|
SpeedForm {
|
|
id: self
|
|
property var min : 1
|
|
Connections{
|
|
target: self
|
|
|
|
function onStopClick()
|
|
{
|
|
_slider.value = 0
|
|
sendPlanCmd()
|
|
}
|
|
|
|
function onLockClick()
|
|
{
|
|
locked = true
|
|
remainingTime = 0
|
|
|
|
}
|
|
function onUnLockClick()
|
|
{
|
|
locked = false
|
|
remainingTime = 60000 * min
|
|
|
|
}
|
|
|
|
function onSendPlanCmd()
|
|
{
|
|
if(g_curPro.id === "")
|
|
{
|
|
alert.show("请打开工程")
|
|
return
|
|
}
|
|
if(Math.abs(_slider.value) < 10)
|
|
_slider.value = 0
|
|
var cmdPlans = ""
|
|
var result = ""
|
|
if (_slider.value == 0) {
|
|
cmdPlans = {"id": planCmdId, "start" : false}
|
|
result = backend_proxy.send_cmd_set(planCmdId, g_curPro.id, g_session.id, JSON.stringify(cmdPlans))
|
|
if(result.code !== 200)
|
|
{
|
|
alert.show(result.msg)
|
|
}
|
|
} else {
|
|
cmdPlans = {"id": planCmdId, "dir" : _slider.value > 0 ? 1 : 0}
|
|
result = backend_proxy.send_cmd_set(planCmdId, g_curPro.id, g_session.id, JSON.stringify(cmdPlans))
|
|
|
|
if(result.code !== 200)
|
|
{
|
|
alert.show(result.msg)
|
|
}
|
|
|
|
cmdPlans = {"id": planCmdId, "speed" : Math.abs(_slider.value)}
|
|
result = backend_proxy.send_cmd_set(planCmdId, g_curPro.id, g_session.id, JSON.stringify(cmdPlans))
|
|
if(result.code !== 200)
|
|
{
|
|
alert.show(result.msg)
|
|
}
|
|
|
|
cmdPlans = {"id": planCmdId, "start" : true}
|
|
result = backend_proxy.send_cmd_set(planCmdId, g_curPro.id, g_session.id, JSON.stringify(cmdPlans))
|
|
if(result.code !== 200)
|
|
{
|
|
alert.show(result.msg)
|
|
}
|
|
}
|
|
}
|
|
|
|
function onDestime()
|
|
{
|
|
if(remainingTime >0)
|
|
remainingTime -= 1000
|
|
else if( remainingTime == 0 )
|
|
{
|
|
remainingTime -= 1000
|
|
lockClick()
|
|
}
|
|
}
|
|
}
|
|
|
|
function formatTime(milliseconds) {
|
|
var seconds = Math.floor((milliseconds / 1000) % 60);
|
|
var minutes = Math.floor((milliseconds / (1000 * 60)) % 60);
|
|
return minutes.toString().padStart(2, '0') + ':' + seconds.toString().padStart(2, '0');
|
|
}
|
|
}
|