Closed bsilverajan closed 1 year ago
I rewrote this part of the draft, and plan to instead move the following pseudocode into an Appendix:
// struct Resource {
//
// bool band;
// int pmin;
// int pmax;
// int epmin;
// int epmax;
// int st;
//
// time_t last_sampled_time;
// time_t last_rep_time;
// int curr_state;
// int prev_state;
//
// ...
//
// };
boolean is_notifiable( Resource * r ) {
#define BAND_EXISTS ( r->band )
#define LT_EXISTS ( r->lt )
#define GT_EXISTS ( r->gt )
#define EPMIN_TRUE ( curr_time - r->last_sampled_time >= r->epmin )
#define EPMAX_TRUE ( curr_time - r->last_sampled_time > r->epmax )
#define PMIN_TRUE ( curr_time - r->last_reported_time >= r->pmin )
#define PMAX_TRUE ( curr_time - r->last_reported_time > r->pmax )
#define LT_TRUE ( r->curr_state < r->lt ^ r->prev_state < r->lt )
#define GT_TRUE ( r->curr_state > r->gt ^ r->prev_state > r->gt )
#define ST_TRUE ( abs( r->curr_state - r->prev_state ) >= r->st )
#define IN-BAND_TRUE ( r->gt < r->lt && r->gt <= r->curr_state && r->curr_state <= r->lt )
#define OUT-OF-BAND_TRUE ( r->lt < r-gt && r->gt < r->curr_state && r->curr_state < r->lt )
#define BAND-MIN_TRUE ( r->lt <= r->curr_state)
#define BAND-MAX_TRUE (r->curr_state <= r->gt)
if PMAX_TRUE {
return true;
}
if PMIN_TRUE {
if !BAND_EXISTS {
if LT_TRUE || GT_TRUE || ST_TRUE {
return true;
}
}
else {
if ( ( BAND-MIN_TRUE && !GT_EXISTS) || (BAND-MAX_TRUE && !LT_EXISTS) || IN-BAND_TRUE || OUT-OF-BAND_TRUE ) {
return true;
}
}
}
return false;
}
Explanation:
@marco-tiloca-sics @dnav please review
In the definition of the Resource
structure:
Add also lt
and gt
, before st
Rename last_rep_time
to last_reported_time
In is_notifiable()
:
Even though the name of curr_time
is intuitive, it can be separately defined upfront right at the beginning of is_notifiable()
, making it clear that its value is the current time. For instance, curr_time
can take what is returned by a function get_current_time()
, not to be detailed in the example.
#define LT_TRUE ( r->curr_state < r->lt ^ r->prev_state < r->lt )
Shouldn't this be like this instead?
#define LT_TRUE ( ( r->curr_state < r->lt && r->prev_state > r->lt ) ^ ( r->curr_state > r->lt && r->prev_state < r->lt ) )
#define GT_TRUE ( r->curr_state > r->gt ^ r->prev_state > r->gt )
Shouldn't this be like this instead?
#define GT_TRUE ( (r->curr_state > r->gt && r->prev_state < r->gt ) ^ (r->curr_state < r->gt && r->prev_state > r->gt ) )
#define IN-BAND_TRUE ( r->gt < r->lt && r->gt <= r->curr_state && r->curr_state <= r->lt )
Shouldn't this be like this instead?
#define IN-BAND_TRUE ( LT_EXISTS && GT_EXISTS && r->gt < r->lt && r->gt <= r->curr_state && r->curr_state <= r->lt )
#define OUT-OF-BAND_TRUE ( r->lt < r-gt && r->gt < r->curr_state && r->curr_state < r->lt )
Shouldn't this be like this instead?
#define OUT-OF-BAND_TRUE ( LT_EXISTS && GT_EXISTS && r->lt < r-gt && ( r->gt < r->curr_state ^ r->curr_state < r->lt ) )
#define BAND-MIN_TRUE ( r->lt <= r->curr_state)
Shouldn't this be like this instead?
#define BAND-MIN_TRUE ( LT_EXISTS && r->lt <= r->curr_state)
#define BAND-MAX_TRUE (r->curr_state <= r->gt)
Shouldn't this be like this instead?
#define BAND-MAX_TRUE (GT_EXISTS && r->curr_state <= r->gt)
In the definition of the
Resource
structure:
- Add also
lt
andgt
, beforest
- Rename
last_rep_time
tolast_reported_time
In
is_notifiable()
:
- Even though the name of
curr_time
is intuitive, it can be separately defined upfront right at the beginning ofis_notifiable()
, making it clear that its value is the current time. For instance,curr_time
can take what is returned by a functionget_current_time()
, not to be detailed in the example.
Would it be alright just to cut corner a little and add just a single line, such as:
time_t curr_time = get_current_time();
#define LT_TRUE ( r->curr_state < r->lt ^ r->prev_state < r->lt )
Shouldn't this be like this instead?#define LT_TRUE ( ( r->curr_state < r->lt && r->prev_state > r->lt ) ^ ( r->curr_state > r->lt && r->prev_state < r->lt ) )
#define GT_TRUE ( r->curr_state > r->gt ^ r->prev_state > r->gt )
Shouldn't this be like this instead?#define GT_TRUE ( (r->curr_state > r->gt && r->prev_state < r->gt ) ^ (r->curr_state < r->gt && r->prev_state > r->gt ) )
I would prefer to keep the macros I proposed, based on Michael's code for 2 reasons:
#define IN-BAND_TRUE ( r->gt < r->lt && r->gt <= r->curr_state && r->curr_state <= r->lt )
Shouldn't this be like this instead?#define IN-BAND_TRUE ( LT_EXISTS && GT_EXISTS && r->gt < r->lt && r->gt <= r->curr_state && r->curr_state <= r->lt )
#define OUT-OF-BAND_TRUE ( r->lt < r-gt && r->gt < r->curr_state && r->curr_state < r->lt )
Shouldn't this be like this instead?#define OUT-OF-BAND_TRUE ( LT_EXISTS && GT_EXISTS && r->lt < r-gt && ( r->gt < r->curr_state ^ r->curr_state < r->lt ) )
#define BAND-MIN_TRUE ( r->lt <= r->curr_state)
Shouldn't this be like this instead?#define BAND-MIN_TRUE ( LT_EXISTS && r->lt <= r->curr_state)
#define BAND-MAX_TRUE (r->curr_state <= r->gt)
Shouldn't this be like this instead?#define BAND-MAX_TRUE (GT_EXISTS && r->curr_state <= r->gt)
I can add the LT_EXISTS and GT_EXISTS macros to these.
Pseudocode is now rectified and added as an appendix to draft -06
From https://mailarchive.ietf.org/arch/msg/core/WOe7F8-y3TNbrqnLkYQshZB1flk/
[Section 3.3]
"and time to prepare for the next notification"
I think you mean "and the time when to prepare the next notification".
As to these two lines in the reference code:
Based on the definitions of pmin and pmax, shouldn't these lines rather be like the following?
Based on the definitions of lt and gt, shouldn't these lines rather be like the following?