我正在编写一个程序,开关按钮打开电动机并关闭电动机。
我想在引发标志时关闭电动机。(标志是@IOTest :: IO :: ClutchDetector == 0 || 1)我设置了一个带有3个选项的组合框作为测试,所以离合器检测器= 0 ==脱离,1 ==订婚,2 =在运输..
如果(@IOTest :: IO :: ClutchDetector == 2)In Transit
允许马达继续运行当我运行下面的程序时...使用while循环..允许电机接通(@IOTest :: IO :: ClutchDetector == 2)并且当我更改@IOTest :: IO :: ClutchDetector == 0 || 1)
然而,当我将clutchDetector组合框更改为== 0或1时,系统崩溃,我必须终止进程才能将其恢复。请帮忙..有关如何更改此代码的建议..
on sysvar CCU::ClutchPowerOnOff
{
int clutchMotorOff = 1;
cancelTimer(clutchMotorTimer);
;
////////// from here if clutch Power Off is selected
if (@this == this::ClutchPowerOff)
{
write("Clutch Power Off");
sysSetVariableInt(sysvar::IO::IOPiggy1::MotorPowerClutchOnOff, 0 );
sysSetVariableInt(sysvar::CCU::ClutchPowerOnOff, 0);
}
else if(@this == this::ClutchPowerOn)
clutchMotorTimer.set(CLUTCH_POWER_ON_TIME_MS);
while (@IOTest::IO::ClutchDetector == 2)
{
if (clutchMotorOff == 1)
{
write("!!!!Clutch Motor ON because Clutch wasn't engaged!!!!");
sysSetVariableInt(sysvar::IO::IOPiggy1::MotorPowerClutchOnOff, 1 );
sysSetVariableInt(sysvar::CCU::ClutchPowerOnOff, 1);
write("!!!!Timer on!!!!");
//flag set to prevent restarting the timer
clutchMotorOff == 0;
}
}
//sysSetVariableInt(sysvar::IO::IOPiggy1::MotorPowerClutchOnOff, 0 );
//sysSetVariableInt(sysvar::CCU::ClutchPowerOnOff, 0);
sysSetVariableInt(sysvar::IO::IOPiggy1::MotorPowerClutchOnOff, 0 );
sysSetVariableInt(sysvar::CCU::ClutchPowerOnOff, 0);
//set flag to indicate Motor switched off
clutchMotorOff == 1;
write("!!Detector Clutch Dis Engaged / Engaged - Motor Not Allowed!!");
cancelTimer(clutchMotorTimer);
}
答案 0 :(得分:2)
//flag set to prevent restarting the timer
clutchMotorOff == 0;
您没有设置标志,此声明无效。使用=
代替==
。
同样的:
clutchMotorOff == 1;