import {
validateNumber
} from '../core/validate';
import {
composer,
fiterWithBinaryStr
} from '../core/utils';
import Electronic from './electronic';
import protocolAssembler from '../protocol/cmd';
import Control from '../core/control';
import {
SUPPORTLIST
} from '../settings';
/**
* Temperature sensor module
* @extends Electronic
*/
class Temperature extends Electronic {
constructor(port, slot) {
super();
this.args = {
port: validateNumber(port),
slot: validateNumber(slot)
};
}
/**
* getter of protocol
*/
get protocol() {
return composer(protocolAssembler.readTemperature, [this.args.port, this.args.slot]);
}
/**
* Get data of Temperature sensor
* @return {Promise}
*/
async getData() {
return await Control.read(this.protocol);
}
static get SUPPORT() {
return fiterWithBinaryStr(SUPPORTLIST, '1111');
}
}
export default Temperature;