Explicit start/stop buttons for winds-aloft updater

This commit is contained in:
Tobias Dammers 2021-09-24 20:11:19 +02:00
parent 9b315100ff
commit e914d6afb8
3 changed files with 39 additions and 2 deletions

View File

@ -16,6 +16,7 @@
</options>
<downloading type="bool">0</downloading>
<text-status type="string"></text-status>
<aloft-updater-status type="string">stopped</aloft-updater-status>
</simbrief>
</sim>
<!--

View File

@ -40,7 +40,7 @@ var download = func (username, onSuccess, onFailure=nil) {
var errs = [];
call(onSuccess, [filename], nil, {}, errs);
if (size(errs) > 0) {
setprop('/sim/simbrief/text-status', 'parser errors, see log for details');
setprop('/sim/simbrief/text-status', 'errors, see log for details');
debug.printerror(errs);
}
else {
@ -471,6 +471,14 @@ var startAloftUpdater = func () {
}
if (aloftTimer.isRunning) return;
aloftTimer.start();
setprop('/sim/simbrief/aloft-updater-status', 'running');
};
var stopAloftUpdater = func () {
if (aloftTimer != nil) {
aloftTimer.stop();
setprop('/sim/simbrief/aloft-updater-status', 'stopped');
}
};
var importWindsAloft = func (ofp) {
@ -604,7 +612,9 @@ var main = func(addon) {
else {
print("Loading SimBrief importer");
globals['simbrief'] = {
'loadFP': loadFP
'loadFP': loadFP,
'startAloftUpdater': startAloftUpdater,
'stopAloftUpdater': stopAloftUpdater,
};
var myMenuNode = findMenuNode(1);
myMenuNode.setValues({

View File

@ -168,6 +168,7 @@
</group>
<group>
<layout>hbox</layout>
<halign>left</halign>
<checkbox>
<property>/sim/simbrief/options/import-winds-aloft</property>
<label>Winds Aloft</label>
@ -177,6 +178,31 @@
<halign>left</halign>
<pref-width>100</pref-width>
</checkbox>
<text>
<label>Updater: unknown</label>
<format>Updater: %s</format>
<property>/sim/simbrief/aloft-updater-status</property>
<live type="bool">true</live>
<halign>left</halign>
</text>
<button>
<legend>Start</legend>
<binding>
<command>nasal</command>
<script>simbrief.startAloftUpdater();</script>
</binding>
<halign>left</halign>
</button>
<button>
<legend>Stop</legend>
<binding>
<command>nasal</command>
<script>simbrief.stopAloftUpdater();</script>
</binding>
<halign>left</halign>
</button>
<empty>
</empty>
</group>
<hrule/>
<group>