| 203 | | % TODO: Have an additional loop in here for the nodes |
| 204 | | for n=1:Nnode |
| 205 | | |
| 206 | | % Calculate the appropriate min and target |
| 207 | | % energy for start of NEXT day interval |
| 208 | | % as we set parameters for current interval to be |
| 209 | | % bound by this. |
| 210 | | sys.Emin(k+1) = sys.Emin(k) - Ec_min; |
| 211 | | sys.Etarget(k+1) = sys.Etarget(k) - (sys.Etarget(k) / (user.L - k + 1)); |
| 212 | | |
| 213 | | % Calculate the various system variables |
| 214 | | % 1. Interval when to send back latest batch of high-res data |
| 215 | | sys = BestDataSendInterval(user, sys, env); |
| 216 | | % 2. Get Tsamp |
| 217 | | sys = Eoptimize(user, sys, env); |
| 218 | | |
| 219 | | % Update the number of buffered samples given the newly |
| 220 | | % calculated sample rate for this interval (includes the |
| 221 | | % samples for this interval) |
| 222 | | sys = getNumBufferedSamples(sys, user, k); |
| 223 | | |
| 224 | | % Now calculate the consumed energy for the various parameters |
| 225 | | % determined by the optmization for this interval |
| 226 | | % (In the real deployment case iCount could be used here) |
| 227 | | Ec = Econsump(user, sys); |
| 228 | | |
| 229 | | % Now get the actual energy that will remain at start of next interval |
| 230 | | sys.Ea(k+1) = sys.Ea(k) - Ec + Eharvest; |
| 231 | | |
| 232 | | end |
| | 223 | |
| | 224 | % Calculate the appropriate min and target |
| | 225 | % energy for start of NEXT day interval |
| | 226 | % as we set parameters for current interval to be |
| | 227 | % bound by this. |
| | 228 | sys.Emin(k+1) = sys.Emin(k) - Ec_min; |
| | 229 | sys.Etarget(k+1) = sys.Etarget(k) - (sys.Etarget(k) / (user.L - k + 1)); |
| | 230 | |
| | 231 | % Calculate the various system variables |
| | 232 | % 1. Interval when to send back latest batch of high-res data |
| | 233 | sys = BestDataSendInterval(user, sys, env); |
| | 234 | % 2. Get Tsamp |
| | 235 | sys = Eoptimize(user, sys, env); |
| | 236 | |
| | 237 | % Update the number of buffered samples given the newly |
| | 238 | % calculated sample rate for this interval (includes the |
| | 239 | % samples for this interval) |
| | 240 | sys = getNumBufferedSamples(sys, user, k); |
| | 241 | |
| | 242 | % Now calculate the consumed energy for the various parameters |
| | 243 | % determined by the optmization for this interval |
| | 244 | % (In the real deployment case iCount could be used here) |
| | 245 | Ec = Econsump(user, sys); |
| | 246 | |
| | 247 | % Now get the actual energy that will remain at start of next interval |
| | 248 | sys.Ea(k+1) = sys.Ea(k) - Ec + Eharvest; |