DeviceSimulator

DeviceSimulator是模拟器开发的基类,目前有两个派生类SerialPortSimulator,NativeLibSimulator。

DeviceSimulator

构造函数

constructor(config, state)
  • config: 配置参数
  • state: 初始状态

DeviceSimulator.getInfo

给模拟器提供信息的函数。目前支持的信息包括:README.md和协议。

需要在具体设备模拟器的派生类重写。

返回结果 {readme, doc}

举例:
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

当在控制台使用不带参数的emit命令时,会调用此函数发送默认数据给驱动。

需要在具体设备模拟器的派生类重写。

results matching ""

    No results matching ""