MachAlrm_Progn_res MachAlrm_Progn combine MachAlrm_Progn_singl e_res p

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
MachAlrm_Progn_res MachAlrm_Progn::combine(MachAlrm_Progn_single_res prgs[], size_t n, FILE *dbg_out)
{
MachAlrm_Progn_res res = {};
ETCTIME etm_min = -1, etm_min_trusted = -1;
for(size_t i = 0; i < n; i++)
{
if((etm_min == -1) || ((prgs[i].Talrm != -1) && (prgs[i].Talrm < etm_min)))
etm_min = prgs[i].Talrm;
if(prgs[i].Talarm_trusted && ((etm_min_trusted == -1) || ((prgs[i].Talrm != -1) && (prgs[i].Talrm < etm_min_trusted))))
etm_min_trusted = prgs[i].Talrm;
}
res.alrm_near = etm_min;
res.alrm_far = etm_min_trusted;
if((etm_min == -1) || (etm_min != etm_min_trusted))
for(size_t i = progn_nperiods; i > 0;)
{
i--;
if((etm_min == -1) || (((ETCTIME)(progn_periods[i]/ETCTIME2SECOND_ratio*m_cfg.Talrm_trust_interval))*ETCTIME2SECOND_ratio < etm_min))
{
res.alrm_near = ((ETCTIME)(progn_periods[i]/ETCTIME2SECOND_ratio*m_cfg.Talrm_trust_interval))*ETCTIME2SECOND_ratio;
break;
}
}
LTRACE(("combine result: %I64u, %I64u", etm_min, etm_min_trusted));
if(dbg_out)
fprintf(dbg_out, "combine result: %I64u, %I64u\n", etm_min, etm_min_trusted);
return(res);
}