LoginSignup
1
1

More than 3 years have passed since last update.

Raspberry Pi をThingWorx につなげる(後編その2)

Posted at

後編その2: ThingWorx でIoT アプリを開発します

前編はこちら
中編はこちら
後編その1はこちら
引き続きThingWorx にアップされたデータを可視化するIoT アプリを作成します。

手順

  1. LED 操作パネル作成
  2. 時系列データを表示
  3. 完成:マッシュアップを実行

1. LED操作パネル作成

ウィジット追加

  1. Radio Button ウィジットを配置します
    image.png

  2. ButtonStates を”LED_state”に設定します
    image.png

サービス追加

  1. Things_raspPiThing_1 の右側の”+” をクリック
    image.png

  2. SetProperties を選択し"→" をクリック

  3. Mashup Loaded?にチェックが入っていないことを確認して“Done”をクリック
    image.png

サービスとウィジットの紐付け

  1. Radio Button ウィジットの左上にカーソルをあててSelectedValueをドラッグしたまま
    SetPropertiesのProp_LED_number でドロップ
  2. 同じくウィジットからSelectionChangedをドラッグしたままSetProperties でドロップ
    image.png

  3. SetProperties をクリックすると右図のようになります
    image.png

マッシュアップ画面の実行

  1. “Save” をクリック
  2. “View Mashup”で画面を実行
  3. ボタンの操作でLEDが点灯・消灯することを確認しましょう image.png

2. 時系列データを表示

時系列データ保存のためValue Stream を作成

  1. フォルダアイコンをクリック
    DATA STORAGE のValue Streams 右にある”+” をクリック
    image.png

  2. ValueStream を選択してOK をクリック
    image.png

  3. 名前に”raspPi_VS” を設定

  4. “Save” をクリック
    image.png

Value Stream にThing のデータを保存する設定

  1. Resent リストからraspPiThing_1 を選択
  2. “General Information”の画面を開く
  3. Value Stream の項目にraspPi_VS を設定
  4. ”Save”をクリック
    image.png

  5. “Properties and Alerts” に切り替え

  6. Prop_Humidity を選択

  7. 右側の”Logged”をチェック

  8. 画面右端のチェックマークをクリック(隣はキャンセル)

  9. 同様にProp_Temperature もLogged をチェックし保存

  10. “Save”をクリック
    image.png

  • 設定作業が正しければ、以下の表示になります image.png

マッシュアップ画面への時系列データの表示追加

  1. raspPi_Mashup を選択し編集画面を開く
  2. Time Series Chart ウィジットを下段に配置 image.png

3. Things_raspPiThing_1 の右側の"+" をクリック
4. QueryPropertyHistory の"→" をクリック
5. Mashup Loaded? にチェックをいれて“Done” をクリック
image.png

  1. QueryPropertyHistory のReturned Date 下の“All Data” アイテムをドラッグしたまま
    Time Series Chart ウィジットでドロップ
  2. バインド先は”Data” を選択 image.png

ウィジットの設定

  1. 配置したTime Series Chart ウィジットを選択
  2. 左下のPropertyリストにて以下の項目を設定
    NumberOfSeries: 2
    XAxisField: timestamp
    DataField1: Prop_Temperature
    DataField2: Prop_Humidity
    image.png

  3. Auto Refresh ウィジットのRefresh イベントを
    QueryPropertyHistory にドラッグ&ドロップで紐付ける
    image.png

  4. “Save”をクリック

3. 完成です

お疲れ様でした。マッシュアップを実行しましょう。
image.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1