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> </options>
<downloading type="bool">0</downloading> <downloading type="bool">0</downloading>
<text-status type="string"></text-status> <text-status type="string"></text-status>
<aloft-updater-status type="string">stopped</aloft-updater-status>
</simbrief> </simbrief>
</sim> </sim>
<!-- <!--

View File

@ -40,7 +40,7 @@ var download = func (username, onSuccess, onFailure=nil) {
var errs = []; var errs = [];
call(onSuccess, [filename], nil, {}, errs); call(onSuccess, [filename], nil, {}, errs);
if (size(errs) > 0) { 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); debug.printerror(errs);
} }
else { else {
@ -471,6 +471,14 @@ var startAloftUpdater = func () {
} }
if (aloftTimer.isRunning) return; if (aloftTimer.isRunning) return;
aloftTimer.start(); 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) { var importWindsAloft = func (ofp) {
@ -604,7 +612,9 @@ var main = func(addon) {
else { else {
print("Loading SimBrief importer"); print("Loading SimBrief importer");
globals['simbrief'] = { globals['simbrief'] = {
'loadFP': loadFP 'loadFP': loadFP,
'startAloftUpdater': startAloftUpdater,
'stopAloftUpdater': stopAloftUpdater,
}; };
var myMenuNode = findMenuNode(1); var myMenuNode = findMenuNode(1);
myMenuNode.setValues({ myMenuNode.setValues({

View File

@ -168,6 +168,7 @@
</group> </group>
<group> <group>
<layout>hbox</layout> <layout>hbox</layout>
<halign>left</halign>
<checkbox> <checkbox>
<property>/sim/simbrief/options/import-winds-aloft</property> <property>/sim/simbrief/options/import-winds-aloft</property>
<label>Winds Aloft</label> <label>Winds Aloft</label>
@ -177,6 +178,31 @@
<halign>left</halign> <halign>left</halign>
<pref-width>100</pref-width> <pref-width>100</pref-width>
</checkbox> </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> </group>
<hrule/> <hrule/>
<group> <group>