| 1 |
<?xml version="1.0"?> |
| 2 |
|
| 3 |
<PropertyList> |
| 4 |
<name>timeofday</name> |
| 5 |
<layout>vbox</layout> |
| 6 |
<padding>20</padding> |
| 7 |
<modal>false</modal> |
| 8 |
|
| 9 |
<group> |
| 10 |
<layout>hbox</layout> |
| 11 |
|
| 12 |
<text> |
| 13 |
<label>Time Settings</label> |
| 14 |
</text> |
| 15 |
|
| 16 |
<empty><stretch>1</stretch></empty> |
| 17 |
|
| 18 |
<button> |
| 19 |
<legend>X</legend> |
| 20 |
<key>Esc</key> |
| 21 |
<pref-width>20</pref-width> |
| 22 |
<pref-height>20</pref-height> |
| 23 |
<binding> |
| 24 |
<command>dialog-close</command> |
| 25 |
</binding> |
| 26 |
</button> |
| 27 |
</group> |
| 28 |
|
| 29 |
<hrule/> |
| 30 |
|
| 31 |
<group> |
| 32 |
<layout>hbox</layout> |
| 33 |
|
| 34 |
<group> |
| 35 |
<layout>vbox</layout> |
| 36 |
|
| 37 |
<empty> |
| 38 |
<stretch>true</stretch> |
| 39 |
</empty> |
| 40 |
<group> |
| 41 |
<layout>table</layout> |
| 42 |
<name>date_group</name> |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
<text> |
| 47 |
<row>0</row> |
| 48 |
<col>0</col> |
| 49 |
<label>Year</label> |
| 50 |
</text> |
| 51 |
<input> |
| 52 |
<row>1</row> |
| 53 |
<col>0</col> |
| 54 |
<live>1</live> |
| 55 |
<name>demand-year</name> |
| 56 |
<property>/sim/time/demand-year</property> |
| 57 |
<binding> |
| 58 |
<command>dialog-apply</command> |
| 59 |
<object-name>demand-year</object-name> |
| 60 |
</binding> |
| 61 |
<binding> |
| 62 |
<command>nasal</command> |
| 63 |
<script> |
| 64 |
tod_setdate(); |
| 65 |
</script> |
| 66 |
</binding> |
| 67 |
</input> |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
<text> |
| 89 |
<row>0</row> |
| 90 |
<col>1</col> |
| 91 |
<label>Month</label> |
| 92 |
</text> |
| 93 |
<combo> |
| 94 |
<row>1</row> |
| 95 |
<col>1</col> |
| 96 |
<live>1</live> |
| 97 |
<name>month-combo</name> |
| 98 |
<property>/sim/time/demand-month</property> |
| 99 |
<editable>false</editable> |
| 100 |
<pref-width>130</pref-width> |
| 101 |
<halign>fill</halign> |
| 102 |
<binding> |
| 103 |
<command>dialog-apply</command> |
| 104 |
<object-name>month-combo</object-name> |
| 105 |
</binding> |
| 106 |
<binding> |
| 107 |
<command>nasal</command> |
| 108 |
<script> |
| 109 |
tod_setdate(); |
| 110 |
</script> |
| 111 |
</binding> |
| 112 |
</combo> |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
<text> |
| 136 |
<row>0</row> |
| 137 |
<col>2</col> |
| 138 |
<label>Day</label> |
| 139 |
</text> |
| 140 |
<input> |
| 141 |
<row>1</row> |
| 142 |
<col>2</col> |
| 143 |
<name>demand-day</name> |
| 144 |
<property>/sim/time/demand-day</property> |
| 145 |
<live>1</live> |
| 146 |
<binding> |
| 147 |
<command>dialog-apply</command> |
| 148 |
<object-name>demand-day</object-name> |
| 149 |
</binding> |
| 150 |
<binding> |
| 151 |
<command>nasal</command> |
| 152 |
<script> |
| 153 |
tod_setdate(); |
| 154 |
</script> |
| 155 |
</binding> |
| 156 |
</input> |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
</group> |
| 178 |
|
| 179 |
<empty> |
| 180 |
<stretch>true</stretch> |
| 181 |
</empty> |
| 182 |
<layout>vbox</layout> |
| 183 |
<group> |
| 184 |
<layout>table</layout> |
| 185 |
<halign>center</halign> |
| 186 |
|
| 187 |
<text> |
| 188 |
<row>0</row> |
| 189 |
<col>0</col> |
| 190 |
<halign>left</halign> |
| 191 |
<default-padding>0</default-padding> |
| 192 |
<label>UTC</label> |
| 193 |
</text> |
| 194 |
<text> |
| 195 |
<row>0</row> |
| 196 |
<col>1</col> |
| 197 |
<halign>left</halign> |
| 198 |
<default-padding>0</default-padding> |
| 199 |
<label>00:00:00</label> |
| 200 |
<live>true</live> |
| 201 |
<property>/sim/time/gmt-string</property> |
| 202 |
</text> |
| 203 |
<text> |
| 204 |
<row>0</row> |
| 205 |
<col>2</col> |
| 206 |
<halign>left</halign> |
| 207 |
<default-padding>0</default-padding> |
| 208 |
<label></label> |
| 209 |
</text> |
| 210 |
|
| 211 |
<text> |
| 212 |
<row>1</row> |
| 213 |
<col>0</col> |
| 214 |
<halign>left</halign> |
| 215 |
<default-padding>0</default-padding> |
| 216 |
<label>Local</label> |
| 217 |
</text> |
| 218 |
<text> |
| 219 |
<row>1</row> |
| 220 |
<col>1</col> |
| 221 |
<halign>left</halign> |
| 222 |
<default-padding>0</default-padding> |
| 223 |
<label>00:00:00</label> |
| 224 |
<live>true</live> |
| 225 |
<property>/sim/time/local-time-string</property> |
| 226 |
</text> |
| 227 |
<text> |
| 228 |
<row>1</row> |
| 229 |
<col>2</col> |
| 230 |
<halign>left</halign> |
| 231 |
<default-padding>0</default-padding> |
| 232 |
<label>UTC</label> |
| 233 |
<live>true</live> |
| 234 |
<property>/sim/time/local-timezone</property> |
| 235 |
</text> |
| 236 |
</group> |
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
<hrule/> |
| 259 |
|
| 260 |
<text> |
| 261 |
<label>Simulation Rate</label> |
| 262 |
</text> |
| 263 |
<text> |
| 264 |
<label></label> |
| 265 |
<live>true</live> |
| 266 |
<property>/sim/speed-up</property> |
| 267 |
</text> |
| 268 |
|
| 269 |
<group> |
| 270 |
<layout>hbox</layout> |
| 271 |
<default-padding>0</default-padding> |
| 272 |
<button> |
| 273 |
<legend>-</legend> |
| 274 |
<binding> |
| 275 |
<command>nasal</command> |
| 276 |
<script>controls.speedup(-1);</script> |
| 277 |
</binding> |
| 278 |
</button> |
| 279 |
<button> |
| 280 |
<legend>Reset</legend> |
| 281 |
<binding> |
| 282 |
<command>property-assign</command> |
| 283 |
<property>/sim/speed-up</property> |
| 284 |
<property>/sim/time/warp-delta</property> |
| 285 |
<value>1</value> |
| 286 |
</binding> |
| 287 |
</button> |
| 288 |
<button> |
| 289 |
<legend>+</legend> |
| 290 |
<binding> |
| 291 |
<command>nasal</command> |
| 292 |
<script>controls.speedup(1);</script> |
| 293 |
</binding> |
| 294 |
</button> |
| 295 |
</group> |
| 296 |
|
| 297 |
<empty> |
| 298 |
<pref-height>1</pref-height> |
| 299 |
</empty> |
| 300 |
<hrule/> |
| 301 |
|
| 302 |
<text> |
| 303 |
<label>Time Warp</label> |
| 304 |
</text> |
| 305 |
<text> |
| 306 |
<live>true</live> |
| 307 |
<property>/sim/time/warp-delta</property> |
| 308 |
</text> |
| 309 |
|
| 310 |
<group> |
| 311 |
<layout>hbox</layout> |
| 312 |
<default-padding>0</default-padding> |
| 313 |
<button> |
| 314 |
<legend>-</legend> |
| 315 |
<binding> |
| 316 |
<command>property-adjust</command> |
| 317 |
<property>/sim/time/warp-delta</property> |
| 318 |
<step type="int">-30</step> |
| 319 |
</binding> |
| 320 |
</button> |
| 321 |
<button> |
| 322 |
<legend>Reset</legend> |
| 323 |
<binding> |
| 324 |
<command>property-assign</command> |
| 325 |
<property>/sim/time/warp-delta</property> |
| 326 |
<value>0</value> |
| 327 |
</binding> |
| 328 |
</button> |
| 329 |
<button> |
| 330 |
<legend>+</legend> |
| 331 |
<binding> |
| 332 |
<command>property-adjust</command> |
| 333 |
<property>/sim/time/warp-delta</property> |
| 334 |
<step type="int">30</step> |
| 335 |
</binding> |
| 336 |
</button> |
| 337 |
</group> |
| 338 |
|
| 339 |
<empty> |
| 340 |
<stretch>true</stretch> |
| 341 |
</empty> |
| 342 |
|
| 343 |
</group> |
| 344 |
|
| 345 |
<empty> |
| 346 |
<pref-width>2</pref-width> |
| 347 |
</empty> |
| 348 |
|
| 349 |
<vrule/> |
| 350 |
<group> |
| 351 |
<padding>5</padding> |
| 352 |
<layout>vbox</layout> |
| 353 |
<default-padding>0</default-padding> |
| 354 |
<text> |
| 355 |
<halign>center</halign> |
| 356 |
<default-padding>0</default-padding> |
| 357 |
<label>Time Presets</label> |
| 358 |
</text> |
| 359 |
<hrule/> |
| 360 |
<button> |
| 361 |
<legend>Clock Time</legend> |
| 362 |
<equal>true</equal> |
| 363 |
<binding> |
| 364 |
<command>timeofday</command> |
| 365 |
<timeofday>real</timeofday> |
| 366 |
</binding> |
| 367 |
</button> |
| 368 |
|
| 369 |
<button> |
| 370 |
<legend>Dawn</legend> |
| 371 |
<equal>true</equal> |
| 372 |
<binding> |
| 373 |
<command>timeofday</command> |
| 374 |
<timeofday>dawn</timeofday> |
| 375 |
</binding> |
| 376 |
</button> |
| 377 |
|
| 378 |
<button> |
| 379 |
<legend>Morning</legend> |
| 380 |
<equal>true</equal> |
| 381 |
<binding> |
| 382 |
<command>timeofday</command> |
| 383 |
<timeofday>morning</timeofday> |
| 384 |
</binding> |
| 385 |
</button> |
| 386 |
|
| 387 |
<button> |
| 388 |
<legend>Noon</legend> |
| 389 |
<equal>true</equal> |
| 390 |
<binding> |
| 391 |
<command>timeofday</command> |
| 392 |
<timeofday>noon</timeofday> |
| 393 |
</binding> |
| 394 |
</button> |
| 395 |
|
| 396 |
<button> |
| 397 |
<legend>Afternoon</legend> |
| 398 |
<equal>true</equal> |
| 399 |
<binding> |
| 400 |
<command>timeofday</command> |
| 401 |
<timeofday>afternoon</timeofday> |
| 402 |
</binding> |
| 403 |
</button> |
| 404 |
|
| 405 |
<button> |
| 406 |
<legend>Dusk</legend> |
| 407 |
<equal>true</equal> |
| 408 |
<binding> |
| 409 |
<command>timeofday</command> |
| 410 |
<timeofday>dusk</timeofday> |
| 411 |
</binding> |
| 412 |
</button> |
| 413 |
|
| 414 |
<button> |
| 415 |
<legend>Evening</legend> |
| 416 |
<equal>true</equal> |
| 417 |
<binding> |
| 418 |
<command>timeofday</command> |
| 419 |
<timeofday>evening</timeofday> |
| 420 |
</binding> |
| 421 |
</button> |
| 422 |
|
| 423 |
<button> |
| 424 |
<legend>Night</legend> |
| 425 |
<equal>true</equal> |
| 426 |
<binding> |
| 427 |
<command>timeofday</command> |
| 428 |
<timeofday>midnight</timeofday> |
| 429 |
</binding> |
| 430 |
</button> |
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
</group> |
| 446 |
</group> |
| 447 |
|
| 448 |
<hrule/> |
| 449 |
|
| 450 |
<button> |
| 451 |
<legend>Close</legend> |
| 452 |
<default>true</default> |
| 453 |
<key>Esc</key> |
| 454 |
<binding> |
| 455 |
<command>dialog-close</command> |
| 456 |
</binding> |
| 457 |
</button> |
| 458 |
<nasal> |
| 459 |
<open> |
| 460 |
<![CDATA[ |
| 461 |
# Extract the year month day into properties |
| 462 |
var dlgRoot = cmdarg(); |
| 463 |
var cb_month = gui.findElementByName(dlgRoot, "month-combo"); |
| 464 |
var dtv = getprop("/sim/time/gmt"); |
| 465 |
var year = substr(dtv,0,4); |
| 466 |
var month = substr(dtv,5,2); |
| 467 |
var day = substr(dtv,8,2); |
| 468 |
#var daymax = gui.findElementByName(dlgRoot, "sl_day").getChild("max"); |
| 469 |
var months = ["January","February","March","April","May","June","July","August","September","October","November","December"]; |
| 470 |
var monthmax = [31,28,31,30,31,30,31,31,30,31,30,31]; |
| 471 |
|
| 472 |
# |
| 473 |
# populate the combo box with the months |
| 474 |
forindex(var idx; months) |
| 475 |
cb_month.getChild("value", idx, 1).setValue(months[idx]); |
| 476 |
|
| 477 |
setprop("/sim/time/demand-year",year); |
| 478 |
setprop("/sim/time/demand-month",months[month-1]); |
| 479 |
setprop("/sim/time/demand-month-idx",month-1); |
| 480 |
setprop("/sim/time/demand-day",day); |
| 481 |
|
| 482 |
# |
| 483 |
# method to set the time of day based on the dialog values |
| 484 |
tod_setdate = func{ |
| 485 |
forindex (var idx; months) { |
| 486 |
if (months[idx] == getprop("/sim/time/demand-month")) |
| 487 |
month=idx+1; |
| 488 |
} |
| 489 |
var year = getprop("/sim/time/demand-year"); |
| 490 |
if ( (math.fmod(year,4) == 0 and math.fmod(year,100) != 0) or (math.fmod(year,400) == 0)) |
| 491 |
monthmax[1]=29; |
| 492 |
else |
| 493 |
monthmax[1]=28; |
| 494 |
setprop("/sim/time/demand-month-idx",month-1); |
| 495 |
setprop("/sim/time/demand-month",months[month-1]); |
| 496 |
var hour = substr(dtv,11,2); |
| 497 |
var minute = substr(dtv,14,2); |
| 498 |
var second = substr(dtv,18,2); |
| 499 |
var new_dt=sprintf("%04d-%02d-%02dT%02d:%02d:%02d",getprop("/sim/time/demand-year"),month,getprop("/sim/time/demand-day"),hour,minute,second*1); |
| 500 |
setprop("/sim/time/gmt",new_dt); |
| 501 |
#daymax.setValue(monthmax[month-1]); |
| 502 |
if (getprop("/sim/time/demand-day") > monthmax[month-1]) |
| 503 |
setprop("/sim/time/demand-day",sprintf("%02d",monthmax[month-1])); |
| 504 |
} |
| 505 |
tod_setminuteofday = func(minute){ |
| 506 |
var hour = minute/60; |
| 507 |
var minute = math.fmod(minute,60); |
| 508 |
var second = 0; |
| 509 |
var new_dt=sprintf("%04d-%02d-%02dT%02d:%02d:%02d",getprop("/sim/time/demand-year"),month,getprop("/sim/time/demand-day"),hour,minute,second*1); |
| 510 |
setprop("/sim/time/gmt",new_dt); |
| 511 |
printf(new_dt); |
| 512 |
} |
| 513 |
]]> |
| 514 |
</open> |
| 515 |
</nasal> |
| 516 |
</PropertyList> |