【发布时间】:2013-03-17 18:02:06
【问题描述】:
首先这会被触发:
if ((temperatureChannel[channelID].currentTemperature > temperatureChannel[channelID].highLimit) | (temperatureChannel[channelID].currentTemperature < temperatureChannel[channelID].lowLimit))
activateAlarm(channelID);
激活警报被触发,然后从那里:
void activateAlarm(int channelID);
{ while (temperatureChannel[channelID].currentTemperature > temperatureChannel[channelID].highLimit || temperatureChannel[channelID].currentTemperature < temperatureChannel[channelID].lowLimit)
{
logSubsystem(temperatureChannel[channelID].currentTemperature);
}
}
然后在以下情况下触发警报屏幕:
int logSubsystem(int currentTemperature)
case 'F': //if user input is 'F'
case 'f': //if user input is 'f'
currentTemperature--;
printf("your current exceeded temp is %i\n \n", currentTemperature);
if (currentTemperature <= 100 || currentTemperature >= 50);
compareLimit();
break; //exits loop
如何设置此功能,以便如果用户使用 F 递减并使当前温度低于限制(50),那么它将返回到 compareLimit 功能和要求上限/下限触发状态为FALSE,程序恢复到原来的预警状态?
【问题讨论】:
-
上下文不足。根据您的问题,您可能需要:1.
while循环,2.longjmp(),3. ??? -
我还能给你看什么?我只是不想用不必要的代码给你增加负担
-
这也很好。特别是,我很想知道
activateAlarm()函数的作用。 -
它用于创建一个while循环条件,以便如果温度处于高/低限制区域,那么它会初始化logSubSystem,这是一组允许用户打印的case语句小消息。但是,我想弄清楚的是,他们在进入 logSubSystem 后如何回到 main
-
顺便说一句,您的第一个代码中有错误。您使用了按位或而不是逻辑或。