Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Goを使ったセンサーデータ収集基盤の事例のお話 / golang.tokyo 26 LT

Goを使ったセンサーデータ収集基盤の事例のお話 / golang.tokyo 26 LT

Takeshi Shinoda

September 25, 2019
Tweet

More Decks by Takeshi Shinoda

Other Decks in Programming

Transcript

  1. ࣗݾ঺հ • ࣰా ݈ (͠ͷͩ ͚ͨ͠) • @takeshinoda • MODE,

    Inc ۈ຿ • ීஈ͸Rubyist • ன͸GoͱTypeScriptॻ͍ͯ·͢ • Go΋݁ߏ޷͖
  2. ϓϩμΫγϣϯ΁ͷ͓ख఻͍ MODE Ϋϥ΢υ ࣌ܥྻ DB WebHook Πϕϯτج൫ OTA (Over-the-Air) ϩάऩू

    σόΠε؅ཧ ೝূ Users / Devices / API access MODE ήʔτ΢ΣΠ MODE αʔϏε Ϗδωεɾۀ຿αʔϏε ݱ࣮σʔλ ηϯαʔ/֤छػثσʔλ ͜͜ͷϨΠϠʔʹରͯ͠ PoCϨϕϧ͔Β ϓϩμΫγϣϯϨϕϧ·Ͱͷ ٕज़Λఏڙ͢Δ
  3. MODE Ϋϥ΢υ MODE ήʔτ΢ΣΠ MODE αʔϏε Ϣʔβʔɾఏܞاۀ ݱ࣮ੈք Sensor Cloud

    Mobility Cloud Factory Cloud ࣌ܥྻ DB ࣌ܥྻ DB/SDS ࣌ܥྻ DB
  4. MODE Gateway PLC Bluetooth MODbus GPS OBD-II ControllerPC RS-485 Bluetooth

    LE MODbus/RTU NMEA 0183 CANbus / ISO9141-2 Smb protocol MODE Platform Application TSDB Event Dispatcher Manage Devices OTA Update Authentica tion Application MQTT REST API REST API
  5. MODE Gateway PLC Bluetooth MODbus GPS OBD-II ControllerPC RS-485 Bluetooth

    LE MODbus/RTU NMEA 0183 CANbus / ISO9141-2 Smb protocol MODE Platform Application TSDB Event Dispatcher Manage Devices OTA Update Authentica tion Application MQTT REST API REST API Go: Gateway, Server side TypeScript: Frontend, Gateway
  6. Gateway OS: Ubuntu 16.04, 18.04, Yocto… Gateway main process Node

    process WiFi / 3G OTA Updater Log collector
  7. Πϕϯτൃੜॲཧ TS for await (const sensorData of sensorModule.dataIterator()) { try

    { await timeout(dataSender.sendData(sensorData), timeout); } catch (error) { logger.error(`Failed: ${error}`); } } async* dataIterator(): AsyncIterable<SensorData[]> { while (true) { let sensorData: SensorData[]; try { sensorData = await this.next(); } catch (error) { throw error; // break loop } yield sensorData; } }
  8. Πϕϯτൃੜॲཧ Go select { case l := <- serial.Rx: return

    string(l), nil case <-time.After(timeout): return "", errors.New(“readtimeout”) } for { buf := make([]bytes, 1024) if _, err := s.Read(buf); err != nil { … } serial.Rx <- buf }