@@ -16,6 +16,7 @@ import { spi0, spi1, SpiAdcBus, SpiAdcChannel } from '../spi-adc/SpiAdcBus';
16
16
import { SpiAdcChips } from '../spi-adc/SpiAdcChips' ;
17
17
import { webApp } from '../web/Server' ;
18
18
import { utils , valueMap , vMaps } from './Constants' ;
19
+ import { config } from "../config/Config" ;
19
20
20
21
interface IConfigItemCollection {
21
22
set ( data ) ;
@@ -378,9 +379,10 @@ export class Controller extends ConfigItem {
378
379
return this . _spiAdcChips ;
379
380
}
380
381
public get analogDevices ( ) {
381
- //if (typeof this._analogDevices === 'undefined') {
382
- this . _analogDevices = AnalogDevices . loadDefintions ( ) ;
383
- //}
382
+ if ( config . development || typeof this . _analogDevices === 'undefined' || ! this . _analogDevices ) {
383
+ console . log ( 'Loading devices' ) ;
384
+ this . _analogDevices = AnalogDevices . loadDefintions ( ) ;
385
+ }
384
386
return this . _analogDevices ;
385
387
}
386
388
/**************************************************
@@ -832,7 +834,6 @@ export class Controller extends ConfigItem {
832
834
this . oneWire . removeInternalReferences ( binding ) ;
833
835
}
834
836
}
835
-
836
837
export class DeviceFeedCollection extends ConfigItemCollection < DeviceFeed > {
837
838
constructor ( data : any , name ?: string ) { super ( data , name || 'feeds' ) ; }
838
839
public createItem ( data : any ) : DeviceFeed { return new DeviceFeed ( data ) ; }
@@ -965,7 +966,7 @@ export class Feed {
965
966
options : this . feed . options
966
967
} ) ;
967
968
this . lastSent = v ;
968
- logger . verbose ( `Feed sending ${ this . feed . property } : ${ JSON . stringify ( v ) } ` ) ;
969
+ logger . verbose ( `Feed sending ${ this . feed . property } : ${ JSON . stringify ( v ) } to ${ this . feed . deviceBinding } ` ) ;
969
970
}
970
971
}
971
972
catch ( err ) { logger . error ( `Error sending device feed: ${ err . message } ` ) ; }
@@ -1977,7 +1978,6 @@ export class I2cController extends ConfigItem {
1977
1978
public get detected ( ) : any [ ] { return this . data . detected ; }
1978
1979
public set detected ( val : any [ ] ) { this . data . detected = val ; }
1979
1980
public get buses ( ) : I2cBusCollection { return new I2cBusCollection ( this . data , 'buses' ) ; }
1980
-
1981
1981
public getExtended ( ) {
1982
1982
let c = this . get ( true ) ;
1983
1983
c . buses = this . buses . toExtendedArray ( ) ;
@@ -1988,7 +1988,6 @@ export class I2cController extends ConfigItem {
1988
1988
for ( let i = 0 ; i < this . buses . length ; i ++ ) await this . buses . getItemByIndex ( i ) . deleteConnectionAsync ( id ) ;
1989
1989
} catch ( err ) { return Promise . reject ( new Error ( `Error removing connection from i2c controller` ) ) ; }
1990
1990
}
1991
-
1992
1991
public async setDeviceState ( binding : string | DeviceBinding , data : any ) : Promise < any > {
1993
1992
try {
1994
1993
let bind = typeof binding === 'string' ? new DeviceBinding ( binding ) : binding ;
@@ -2013,7 +2012,6 @@ export class I2cController extends ConfigItem {
2013
2012
}
2014
2013
catch ( err ) { return Promise . reject ( err ) ; }
2015
2014
}
2016
-
2017
2015
public async getDevice ( binding : string | DeviceBinding ) : Promise < any > {
2018
2016
try {
2019
2017
let bind = typeof binding === 'string' ? new DeviceBinding ( binding ) : binding ;
@@ -2092,7 +2090,6 @@ export class I2cController extends ConfigItem {
2092
2090
}
2093
2091
catch ( err ) { return Promise . reject ( err ) ; }
2094
2092
}
2095
-
2096
2093
public async setDevice ( dev ) : Promise < I2cDevice > {
2097
2094
try {
2098
2095
let busId = ( typeof dev . busId !== 'undefined' ) ? parseInt ( dev . busId , 10 ) : undefined ;
@@ -2298,7 +2295,6 @@ export class I2cController extends ConfigItem {
2298
2295
bus . removeInternalReferences ( binding ) ;
2299
2296
}
2300
2297
}
2301
-
2302
2298
}
2303
2299
export class I2cBusCollection extends ConfigItemCollection < I2cBus > {
2304
2300
constructor ( data : any , name ?: string ) { super ( data , name ) }
@@ -2837,6 +2833,8 @@ export class I2cDevice extends ConfigItem {
2837
2833
let feed : DeviceFeed ;
2838
2834
let connectionId ;
2839
2835
let connection ;
2836
+
2837
+
2840
2838
// search for existing feed; also acts as to not allow duplicate feeds
2841
2839
feed = this . getDeviceFeed ( data ) ; // try to find feed with matching data; useful if data is sent from njsPC
2842
2840
if ( typeof feed !== 'undefined' ) {
0 commit comments