1
0
Fork 0

Merge commit '28c2fb' into next

This commit is contained in:
Stuart Buchanan 2016-02-10 21:07:48 +00:00
commit cdf9e5f12d

View file

@ -30,46 +30,218 @@
<hrule/>
<group>
<layout>hbox</layout>
<padding>4</padding>
<group>
<layout>hbox</layout>
<group>
<layout>vbox</layout>
<default-padding>0</default-padding>
<text>
<label>UTC</label>
</text>
<text>
<label>00:00:00</label>
<live>true</live>
<property>/sim/time/gmt-string</property>
</text>
<group>
<layout>vbox</layout>
<empty>
<pref-height>6</pref-height>
</empty>
<hrule/>
<empty>
<pref-height>6</pref-height>
</empty>
<empty>
<stretch>true</stretch>
</empty>
<group>
<layout>table</layout>
<name>date_group</name>
<!-- Date setting. Use the split out properties in the dialog load, this way these will remain constant when the dialog
is opened. Set these automatically when changed - however there appears to be a timezone/dst issue that subtracts an hour.
-->
<text>
<row>0</row>
<col>0</col>
<label>Year</label>
</text>
<input>
<row>1</row>
<col>0</col>
<live>1</live>
<name>demand-year</name>
<property>/sim/time/demand-year</property>
<binding>
<command>dialog-apply</command>
<object-name>demand-year</object-name>
</binding>
<binding>
<command>nasal</command>
<script>
tod_setdate();
</script>
</binding>
</input>
<!--<slider>
<row>2</row>
<col>0</col>
<name>sl_year</name>
<property>/sim/time/demand-year</property>
<live>1</live>
<min>1971</min>
<max>2037</max>
<step>1</step>
<binding>
<command>dialog-apply</command>
<object-name>sl_year</object-name>
</binding>
<binding>
<command>nasal</command>
<script>
tod_setdate();
</script>
</binding>
</slider>-->
<text>
<row>0</row>
<col>1</col>
<label>Month</label>
</text>
<combo>
<row>1</row>
<col>1</col>
<live>1</live>
<name>month-combo</name>
<property>/sim/time/demand-month</property>
<editable>false</editable>
<pref-width>130</pref-width>
<halign>fill</halign>
<binding>
<command>dialog-apply</command>
<object-name>month-combo</object-name>
</binding>
<binding>
<command>nasal</command>
<script>
tod_setdate();
</script>
</binding>
</combo>
<!--<slider>
<row>2</row>
<col>1</col>
<name>sl_month</name>
<property>/sim/time/demand-month-idx</property>
<live>1</live>
<min>0</min>
<max>11</max>
<step>1</step>
<binding>
<object-name>sl_month</object-name>
<command>dialog-apply</command>
</binding>
<binding>
<command>nasal</command>
<script>
setprop("/sim/time/demand-month",months[getprop("/sim/time/demand-month-idx")]);
tod_setdate();
</script>
</binding>
</slider>-->
<text>
<label>Local</label>
</text>
<text>
<label>00:00</label>
<live>true</live>
<property>/instrumentation/clock/local-short-string</property>
</text>
<text>
<row>0</row>
<col>2</col>
<label>Day</label>
</text>
<input>
<row>1</row>
<col>2</col>
<name>demand-day</name>
<property>/sim/time/demand-day</property>
<live>1</live>
<binding>
<command>dialog-apply</command>
<object-name>demand-day</object-name>
</binding>
<binding>
<command>nasal</command>
<script>
tod_setdate();
</script>
</binding>
</input>
<!--<slider>
<row>2</row>
<col>2</col>
<name>sl_day</name>
<property>/sim/time/demand-day</property>
<live>1</live>
<min>1</min>
<max>31</max>
<step>1</step>
<binding>
<command>dialog-apply</command>
<object-name>sl_day</object-name>
</binding>
<binding>
<command>nasal</command>
<script>
tod_setdate();
</script>
</binding>
</slider>-->
</group>
<!-- end of date setting -->
<empty>
<stretch>true</stretch>
</empty>
<layout>vbox</layout>
<group>
<layout>table</layout>
<halign>center</halign>
<empty>
<pref-height>6</pref-height>
</empty>
<hrule/>
<empty>
<pref-height>6</pref-height>
</empty>
<text>
<row>0</row>
<col>0</col>
<halign>left</halign>
<default-padding>0</default-padding>
<label>UTC</label>
</text>
<text>
<row>0</row>
<col>1</col>
<halign>left</halign>
<default-padding>0</default-padding>
<label>00:00:00</label>
<live>true</live>
<property>/sim/time/gmt-string</property>
</text>
<text>
<row>1</row>
<col>0</col>
<halign>left</halign>
<default-padding>0</default-padding>
<label>Local</label>
</text>
<text>
<row>1</row>
<col>1</col>
<halign>left</halign>
<default-padding>0</default-padding>
<label>00:00</label>
<live>true</live>
<property>/instrumentation/clock/local-short-string</property>
</text>
</group>
<!--<slider>
<row>2</row>
<col>0</col>
<name>sl_minute</name>
<property>/sim/time/demand-minute-of-day</property>
<live>1</live>
<min>0</min>
<max>1440</max>
<step>1</step>
<pref-width>250</pref-width>
<binding>
<command>dialog-apply</command>
<object-name>sl_minute</object-name>
</binding>
<binding>
<command>nasal</command>
<script>
tod_setminuteofday(getprop("/sim/time/demand-minute-of-day"));
</script>
</binding>
</slider>-->
<hrule/>
<text>
<label>Simulation Rate</label>
@ -109,12 +281,9 @@
</group>
<empty>
<pref-height>6</pref-height>
<pref-height>1</pref-height>
</empty>
<hrule/>
<empty>
<pref-height>6</pref-height>
</empty>
<text>
<label>Time Warp</label>
@ -163,10 +332,18 @@
<pref-width>2</pref-width>
</empty>
<group>
<layout>vbox</layout>
<vrule/>
<group>
<padding>5</padding>
<layout>vbox</layout>
<default-padding>0</default-padding>
<button>
<text>
<halign>center</halign>
<default-padding>0</default-padding>
<label>Time Presets</label>
</text>
<hrule/>
<button>
<legend>Clock Time</legend>
<equal>true</equal>
<binding>
@ -237,18 +414,89 @@
<timeofday>midnight</timeofday>
</binding>
</button>
</group>
<!--<group>
<layout>hbox</layout>
<checkbox>
<property>sim/time/warp-easing</property>
<live>true</live>
<binding>
<command>property-toggle</command>
<property>sim/time/warp-easing</property>
</binding>
</checkbox>
<text>
<label>Smooth transition</label>
</text>
</group>-->
</group>
</group>
<hrule/>
<hrule/>
<button>
<legend>Close</legend>
<default>true</default>
<key>Esc</key>
<binding>
<command>dialog-close</command>
</binding>
</button>
<button>
<legend>Close</legend>
<default>true</default>
<key>Esc</key>
<binding>
<command>dialog-close</command>
</binding>
</button>
<nasal>
<open>
<![CDATA[
# Extract the year month day into properties
var dlgRoot = cmdarg();
var cb_month = gui.findElementByName(dlgRoot, "month-combo");
var dtv = getprop("/sim/time/gmt");
var year = substr(dtv,0,4);
var month = substr(dtv,5,2);
var day = substr(dtv,8,2);
#var daymax = gui.findElementByName(dlgRoot, "sl_day").getChild("max");
var months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
var monthmax = [31,28,31,30,31,30,31,31,30,31,30,31];
</PropertyList>
#
# populate the combo box with the months
forindex(var idx; months)
cb_month.getChild("value", idx, 1).setValue(months[idx]);
setprop("/sim/time/demand-year",year);
setprop("/sim/time/demand-month",months[month-1]);
setprop("/sim/time/demand-month-idx",month-1);
setprop("/sim/time/demand-day",day);
#
# method to set the time of day based on the dialog values
tod_setdate = func{
forindex (var idx; months) {
if (months[idx] == getprop("/sim/time/demand-month"))
month=idx+1;
}
var year = getprop("/sim/time/demand-year");
if ( (math.fmod(year,4) == 0 and math.fmod(year,100) != 0) or (math.fmod(year,400) == 0))
monthmax[1]=29;
else
monthmax[1]=28;
setprop("/sim/time/demand-month-idx",month-1);
setprop("/sim/time/demand-month",months[month-1]);
var hour = substr(dtv,11,2);
var minute = substr(dtv,14,2);
var second = substr(dtv,18,2);
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);
setprop("/sim/time/gmt",new_dt);
#daymax.setValue(monthmax[month-1]);
if (getprop("/sim/time/demand-day") > monthmax[month-1])
setprop("/sim/time/demand-day",sprintf("%02d",monthmax[month-1]));
}
tod_setminuteofday = func(minute){
var hour = minute/60;
var minute = math.fmod(minute,60);
var second = 0;
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);
setprop("/sim/time/gmt",new_dt);
printf(new_dt);
}
]]>
</open>
</nasal>
</PropertyList>