DeviceSimulator
DeviceSimulator is the base class for simulator development. Currently, there are two derived classes: SerialPortSimulator and NativeLibSimulator.
DeviceSimulator
Constructor
constructor(config, state)
- config: configuration parameters
- state: initial state
DeviceSimulator.getInfo
Function that provides information to the simulator. Currently supported information includes: README.md and protocol.
Need to be rewritten in the derived class of the specific device simulator.
Return result {readme, doc}
Example:
getInfo()
{
let readme = fs.readFileSync(path.join(__dirname, 'README.md'), 'utf-8');
let doc = fs.readFileSync(path.join(__dirname, 'doc.pdf'), 'base64');
return {readme, doc}
}
DeviceSimulator.onEmitEmptyCommand
When the emit command without parameters is used in the console, this function will be called to send default data to the driver.
Need to be overridden in the derived class of the specific device simulator.