File tree 6 files changed +74
-6
lines changed
6 files changed +74
-6
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ const update = require('./globalUpdates');
24
24
const appUpdater = require ( './appUpdater' ) ;
25
25
const CliAutoComplete = require ( './CliAutoComplete' ) ;
26
26
const { SITLProcess } = require ( './sitl' ) ;
27
+ const settingsCache = require ( './settingsCache' ) ;
27
28
28
29
process . on ( 'uncaughtException' , function ( error ) {
29
30
if ( process . env . NODE_ENV !== 'development' ) {
@@ -385,6 +386,9 @@ $(function() {
385
386
$ ( '#demoModeReset' ) . on ( 'click' , function ( ) {
386
387
SITLProcess . deleteEepromFile ( 'demo.bin' ) ;
387
388
} ) ;
389
+ $ ( '#maintenanceFlushSettingsCache' ) . on ( 'click' , function ( ) {
390
+ settingsCache . flush ( ) ;
391
+ } ) ;
388
392
function close_and_cleanup ( e ) {
389
393
if ( e . type == 'click' && ! $ . contains ( $ ( 'div#options-window' ) [ 0 ] , e . target ) || e . type == 'keyup' && e . keyCode == 27 ) {
390
394
$ ( document ) . unbind ( 'click keyup' , close_and_cleanup ) ;
Original file line number Diff line number Diff line change @@ -78,7 +78,6 @@ var FC = {
78
78
MIXER_CONFIG : null ,
79
79
BATTERY_CONFIG : null ,
80
80
OUTPUT_MAPPING : null ,
81
- SETTINGS : null ,
82
81
BRAKING_CONFIG : null ,
83
82
SAFEHOMES : null ,
84
83
BOARD_ALIGNMENT : null ,
@@ -570,8 +569,6 @@ var FC = {
570
569
571
570
this . OUTPUT_MAPPING = new OutputMappingCollection ( ) ;
572
571
573
- this . SETTINGS = { } ;
574
-
575
572
this . SAFEHOMES = new SafehomeCollection ( ) ;
576
573
577
574
this . RATE_DYNAMICS = {
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ const { FwApproach } = require('./../fwApproach');
20
20
const Waypoint = require ( './../waypoint' ) ;
21
21
const mspDeduplicationQueue = require ( './mspDeduplicationQueue' ) ;
22
22
const mspStatistics = require ( './mspStatistics' ) ;
23
+ const settingsCache = require ( './../settingsCache' ) ;
23
24
24
25
var mspHelper = ( function ( ) {
25
26
var self = { } ;
@@ -3060,9 +3061,12 @@ var mspHelper = (function () {
3060
3061
} ;
3061
3062
3062
3063
self . _getSetting = function ( name ) {
3063
- if ( FC . SETTINGS [ name ] ) {
3064
- return Promise . resolve ( FC . SETTINGS [ name ] ) ;
3064
+
3065
+ const storedSetting = settingsCache . get ( name ) ;
3066
+ if ( typeof storedSetting !== 'undefined' ) {
3067
+ return Promise . resolve ( storedSetting ) ;
3065
3068
}
3069
+
3066
3070
var data = [ ] ;
3067
3071
self . _encodeSettingReference ( name , null , data ) ;
3068
3072
return MSP . promise ( MSPCodes . MSP2_COMMON_SETTING_INFO , data ) . then ( function ( result ) {
@@ -3109,7 +3113,7 @@ var mspHelper = (function () {
3109
3113
}
3110
3114
setting . table = { values : values } ;
3111
3115
}
3112
- FC . SETTINGS [ name ] = setting ;
3116
+ settingsCache . set ( name , setting ) ;
3113
3117
return setting ;
3114
3118
} ) ;
3115
3119
}
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const Store = require ( 'electron-store' ) ;
4
+ const store = new Store ( ) ;
5
+ const FC = require ( './fc' ) ;
6
+
7
+ var settingsCache = ( function ( ) {
8
+
9
+ let publicScope = { } ;
10
+ let privateScope = { } ;
11
+
12
+ const SETTINGS_KEY = 'settings' ;
13
+
14
+ privateScope . getSetingKey = function ( settingName ) {
15
+ return FC . CONFIG . target + '_' + FC . CONFIG . flightControllerVersion + '_' + settingName ;
16
+ }
17
+
18
+ publicScope . flush = function ( ) {
19
+ store . delete ( SETTINGS_KEY ) ;
20
+ console . log ( 'Settings cache flushed' ) ;
21
+ } ;
22
+
23
+ publicScope . get = function ( settingName ) {
24
+ let settings = store . get ( SETTINGS_KEY , null ) ;
25
+
26
+ if ( settings === null ) {
27
+ return undefined ;
28
+ }
29
+ let setting = settings [ privateScope . getSetingKey ( settingName ) ] ;
30
+ return setting ;
31
+ } ;
32
+
33
+ publicScope . set = function ( settingName , value ) {
34
+ let settings = store . get ( SETTINGS_KEY , null ) ;
35
+
36
+ if ( settings === null ) {
37
+ settings = { } ;
38
+ }
39
+
40
+ settings [ privateScope . getSetingKey ( settingName ) ] = value ;
41
+ store . set ( SETTINGS_KEY , settings ) ;
42
+ } ;
43
+
44
+ return publicScope ;
45
+ } ( ) ) ;
46
+
47
+ module . exports = settingsCache ;
Original file line number Diff line number Diff line change 5812
5812
},
5813
5813
"gsTelemetrySpeed" : {
5814
5814
"message" : " Speed"
5815
+ },
5816
+ "maintenance" : {
5817
+ "message" : " Maintenance"
5818
+ },
5819
+ "maintenanceFlushSettingsCache" : {
5820
+ "message" : " Flush settings cache"
5815
5821
}
5816
5822
}
Original file line number Diff line number Diff line change 87
87
</ div >
88
88
</ div >
89
89
</ div >
90
+ < div class ="options-section gui_box grey ">
91
+ < div class ="gui_box_titlebar ">
92
+ < div class ="spacer_box_title " data-i18n ="maintenance "> </ div >
93
+ </ div >
94
+ < div class ="spacer_box settings ">
95
+ < div class ="default_btn " style ="float: none; width: 200px; ">
96
+ < a id ="maintenanceFlushSettingsCache " href ="# " i18n ="maintenanceFlushSettingsCache "> </ a >
97
+ </ div >
98
+ </ div >
99
+ </ div >
90
100
</ div >
91
101
</ div >
You can’t perform that action at this time.
0 commit comments