English

SINETStreamHelper ユーザガイド(センサー制御部)

目次

1. モジュール構成
2. API概要
3. インタフェース SensorListener
3.1 メソッド概要
3.2 メソッド詳細
3.2.1 onSensorTypesReceived
3.2.2 onSensorEngaged
3.2.3 onSensorDisengaged
3.2.4 onSensorDataReceived
3.2.5 onError
4. クラスSensorController
4.1 コンストラクタ概要
4.2 メソッド概要
4.3 コンストラクタ詳細
4.4 メソッド詳細
4.4.1 bindSensorService
4.4.2 unbindSensorService
4.4.3 getAvailableSensorTypes
4.4.4 enableSensors
4.4.5 disableSensors
4.4.6 setIntervalTimer
4.4.7 setLocation
4.4.8 resetLocation
4.4.9 setUserData

付録
A.1 ライフサイクル

1. モジュール構成

SINETStreamHelperライブラリにおける「センサー読み取り値の収集」機能のモジュール構成を以下に示す。

        #---------------------------------------+
        | User Application                      |
        +---------------------------------------+
             |                      A
    =========|======================|=============== API functions
             |                      |
      +------|----------------------|-------------+
      |      V                      | [JSON]      |
      | +------------------+   +----------------+ |
      | | SensorController |-->| SensorListener | |
      | +------------------+   +----------------+ |
      |      |      A                             |
      |      V      |                             |
      | +------------------+                      |
      | |  SensorService   |                      |
      | +------------------+    SINETStreamHelper |
      +------|------A-----------------------------+
             |      |
    =========|======|==================================== Android System
             |      |
             V      | [SensorEvent]
        +------------------+
        |  SensorManager   |
        +------------------+
               |  A
    ===========|==|============================================= Devices
               V  | [Raw Data]
            +--------+
            | Sensor |+
            | Device ||+
            +--------+||
              +-------+|
               +-------+

〈凡例〉

2. API概要

3. インタフェース SensorListener

3.1 メソッド概要

3.2 メソッド詳細

3.2.1 onSensorTypesReceived

void onSensorTypesReceived(@NonNull
                           java.util.ArrayList<java.lang.Integer> sensorTypes,
                           @NonNull
                           java.util.ArrayList<java.lang.String> sensorTypeNames)
    for (int i = 0; i < sensorTypes.size(i); i++) {
        int sensorType = sensorTypes.get(i);
        String sensorTypeName = sensorTypeNames.get(i);
        ...
    }

3.2.2 onSensorEngaged

void onSensorEngaged(@NonNull
                     java.lang.String info)

3.2.3 onSensorDisengaged

void onSensorDisengaged(@NonNull
                        java.lang.String info)

3.2.4 onSensorDataReceived

void onSensorDataReceived(@NonNull
                          java.lang.String jsonData)
     {
         "device":{
             "sysinfo":{
                 "android":"8.0.0",
                 "manufacturer":"Google",
                 "model":"Android SDK built for x86"
             },
             "userinfo":{},
             "location":{}
         },
         "sensors":[
             {
                 "type":"light",
                 "name":"Goldfish Light sensor",
                 "timestamp":"20210224T184244.120+0900",
                 "value":9894.7001953125
             }
         ]
     }

3.2.5 onError

void onError(@NonNull
             java.lang.String errmsg)

4. クラスSensorController

4.1 コンストラクタ概要

4.2 メソッド概要

4.3 コンストラクタ詳細

public SensorController(@NonNull
                        android.content.Context context,
                        int clientId)

4.4 メソッド詳細

4.4.1 bindSensorService

public void bindSensorService()

4.4.2 unbindSensorService

public void unbindSensorService()

4.4.3 getAvailableSensorTypes

public void getAvailableSensorTypes()

4.4.4 enableSensors

public void enableSensors(@NonNull
                          java.util.ArrayList<java.lang.Integer> sensorTypes)

4.4.5 disableSensors

public void disableSensors(@NonNull
                           java.util.ArrayList<java.lang.Integer> sensorTypes)

4.4.6 setIntervalTimer

public void setIntervalTimer(long seconds)

4.4.7 setLocation

public void setLocation(double latitude, double longitude)

4.4.8 resetLocation

public void resetLocation()

4.4.9 setUserData

public void setUserData(@Nullable
                        java.lang.String publisher,
                        @Nullable
                        java.lang.String note)

付録

A.1 ライフサイクル

           ( constructor )
                  |
                  | <---- setIntervalTimer()
                  | <---- setLocation()
                  | <---- setUserData()
    +-----------> |
    |             V
    |        bindSensorService()
    |             |
    |             |-----> onSensorEngaged()
    |             V
    |        getAvailableSensorTypes()
    |             |
    |             |-----> onSensorTypesReceived()
    |             |
    |    +------> |
    |    |        V
    |    |   enableSensors()
    |    |        |
    |    |        |-----> onSensorDataReceived()
    //   //       //           :
    |    |        |-----> onSensorDataReceived()
    |    |        V
    |    |   disableSensors()
    |    |        |
    |    +--------<>
    |             |
    |             V
    |        unbindSensorService()
    |             |
    |             |-----> onSensorDisengaged()
    |             |
    +-------------<>
                  |
                  V