int 형의 변수를 선언하는 for 루프가 있는데 실제로 int를 입력하는 것과는 반대로 사용되는 이유는 모르겠습니다. 나는 두 가지의 차이점을 이해하지만 int32_t가 필요한지 모르겠다.루프 변수 선언에 대한 int32_t 유형
class Alarm_Parameter_List
{
public :
Alarm_Parameters alarm_Parameter[50];
int Count;
Alarm_Parameter_List(){ Count = 0;}
};
}
난 그냥 int32_t 대신 INT의 사용 이유를 이해 해달라고 :
void AlarmProcess::AlarmProcess_alarm_Timer_1Sec()
{
//Timer function called every 50ms
static AlarmParams alarm_Params;
//Update LED and buzzer
//Buzzer is on for 1 second and off for 10 seconds then repeats.
//Why define index as int32_t?
for(int32_t i32_Index = 0;i32_Index < AlarmProcess_getInstance()->alarm_Parameter_List.Count; i32_Index++)
{
//Check for non latching mode
if(AlarmProcess_getInstance()->alarm_Parameter_List.alarm_Parameter[i32_Index].Latching == false)
{
//Get channel number
int32_t i32_Channel_Num = AlarmProcess_getInstance()->alarm_Parameter_List.alarm_Parameter[i32_Index].Channel_Number;
//Get alarm detection type
int32_t i32_Detection = AlarmProcess_getInstance()->alarm_Parameter_List.alarm_Parameter[i32_Index].Detection;
//Check detection type and channel number mapping
if((i32_Detection == HIGH && AlarmProcess_getInstance()->m_mapHighAlarmRaised[i32_Channel_Num] == true) ||
(i32_Detection == LOW && AlarmProcess_getInstance()->m_mapLowAlarmRaised[i32_Channel_Num] == true) ||
(i32_Detection == WINDOW_IN && AlarmProcess_getInstance()->m_mapWindowInAlarmRaised[i32_Channel_Num] == true) ||
(i32_Detection == WINDOW_OUT && AlarmProcess_getInstance()->m_mapWindowOutAlarmRaised[i32_Channel_Num] == true))
{
// check for buzzer on or off
if(s_bIsActivate == true)
{
//Check for one second elapse
if((s_i32alarmTimerCount[i32_Channel_Num]) >= ONE_SECOND)
{
RETAILMSG(DEBUG_ALARM_PROCESS,(_T("Buzzer off:%d\r\n"),s_i32alarmTimerCount));
//Update counter variable
s_i32alarmTimerCount[i32_Channel_Num] = 0;
//Get alarm settings
AlarmProcess_getInstance()->b_AlarmProcess_GetAlarmsettingDetails(i32_Index,alarm_Params);
// Turn off the the buzzer
b_AlarmProcess_control_Buzzer(false,ZERO);
// update the flag
s_bIsActivate = false;
}
//Increment timer count variable
s_i32alarmTimerCount[i32_Channel_Num] += GPT_TIMER_RESOLUTION;
}
else
{
//Check for 10 second elapse
if((s_i32alarmTimerCount[i32_Channel_Num]) >= TEN_SECOND)
{
// Reinitialize the counter variable
s_i32alarmTimerCount[i32_Channel_Num] = 0;
RETAILMSG(DEBUG_ALARM_PROCESS,(_T("Buzzer ON:%d\r\n"),s_i32alarmTimerCount));
//Check if buzzer need to be enabled
if(s_bIsBuzzer == true)
{
//Enable buzzer
b_AlarmProcess_control_Buzzer(true,i32_Detection);
}
// update the flag
s_bIsActivate = true;
}
//increment timer count variable
s_i32alarmTimerCount[i32_Channel_Num] += GPT_TIMER_RESOLUTION;
}
}
}
}
그리고 Alarm_Parameter_List 클래스는 다음과 같다.
이 질문에 대한 대답은 모두 "원래의 코더의 마음을 읽을 수 없습니다"범주에 속합니다. – cdhowie
'AlarmProcess_getInstance() -> alarm_Parameter_List.Count' 타입이'int'이므로,'int'를 직접 사용했을 것입니다. –
@RSahu :하지만'int32_t'는 _signed_ 정수형입니다. – TonyK