TG-PlatformPlus/qml/debug/motor/Speed.qml

73 lines
1.7 KiB
QML
Raw Normal View History

2026-03-02 14:29:58 +08:00
import QtQuick
SpeedForm {
id: self
property var min : 1
function executeInstruction(param)
{
var attr = {
"deviceId": planDeviceId,
"param": JSON.stringify(param),
"interfaceIndex": planInterfaceIndex
}
console.info("executeInstruction:", attr)
taskActuatorManager.startInstruction(planInstructionId, attr)
}
Connections{
target: self
function onStopClick()
{
_slider.value = 0
var param = {
"speed": "0",
"direction": "1"
}
executeInstruction(param)
}
function onLockClick()
{
locked = true
remainingTime = 0
}
function onUnLockClick()
{
locked = false
remainingTime = 60000 * min
}
function onSendPlanCmd()
{
if(Math.abs(_slider.value) < 10)
_slider.value = 0
var param = {
"direction" : _slider.value > 0 ? "1" : "0",
"speed" : Math.abs(_slider.value)
}
executeInstruction(param)
}
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');
}
}