User Tools

Site Tools


specifications:uri

====== Differences ====== This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
specifications:uri [2016/03/20 03:29]
Guvalif removed
specifications:uri [2016/07/25 09:21]
Guvalif created
Line 1: Line 1:
 +FIXME **This page is not fully translated, yet. Please help completing the translation.**\\ //(remove this paragraph once the translation is finished)//
 +
 <markdown> <markdown>
 URI Definition URI Definition
-==============+=============================================================================== 
 + 
 +基本仕様 
 +------------------------------------------------------------------------------- 
 + 
 +コントロールサーバーのホストは通常**"localhost (127.0.0.1)"**であり、 
 +ポートは**config.json**内の`port`プロパティに従って決定されます。(規定値は17264です。) 
 + 
 +コントロールサーバーはREST APIを提供し、ユーザーは以下の書式により、 
 +各種リソースやコマンドを使用することができます。 
 + 
 +``` 
 +http://<HOST>:<PORT>/<VERSION>/<INSTANCE>/...(/<METHOD>
 +``` 
 + 
 +`<VERSION>`はAPIのバージョンを表す文字列であり、アプリケーション自体のメジャーバージョンに追随します。 
 +(例: **ControlServer_Win_v2.0.1**であれば、**v2**となります。) 
 + 
 +### リソース取得時に返却されるJSONのフォーマット 
 + 
 +GETリクエストを実行した際、以下のようなJSONが返却されます。 
 + 
 +```json 
 +
 +    "resource": <RESOURCE_NAME:string>, 
 +    "data": <DATA:json> 
 +
 +``` 
 + 
 +### コマンド実行時に返却されるJSONのフォーマット 
 + 
 +GET以外のHTTPリクエスト,および各種コマンドを実行した際、以下のようなJSONが返却されます。 
 + 
 +```json 
 +
 +    "resource": <RESOURCE_NAME:string>, 
 +    "data":
 +        "command": <COMMAND_NAME:string>, 
 +        "result": <RESULT:boolean> 
 +    } 
 +
 +``` 
 + 
 + 
 +リソース一覧 
 +------------------------------------------------------------------------------- 
 + 
 +### コマンドラインストリーム (cmdstream) 
 + 
 +WebSocketを用いてPLENを操作するストリームリソースを提供します。 
 + 
 +コマンド名と各引数を**/ (スラッシュ)**で区切って送信することで、 
 +Pythonで実装されているコマンドを直接呼び出すことが可能です。 
 +([参考](https://github.com/plenprojectcompany/plen-ControlServer/blob/master/control_server/drivers/abstract.py)) 
 + 
 +```javascript 
 +var socket = new WebSocket('ws://localhost:17264/v2/cmdstream'); 
 + 
 +socket.send('<METHOD_NAME>/<PARAM_0>/<PARAM_1>/...'); 
 +``` 
 + 
 +戻り値は、Python上での各コマンドの戻り値を文字列化したものです。 
 + 
 +### モーション (motions) 
 + 
 +PLENの動作を定義するモーションリソースを提供します。 
 +`<SLOT:integer>`にはアクセスしたいモーションリソースのスロット番号を指定します。 
 + 
 +``` 
 +http://localhost:17264/v2/motions/<SLOT:integer> 
 +``` 
 + 
 +|HTTPリクエスト|動作                                                            | 
 +|:-------------|:---------------------------------------------------------------| 
 +|**GET**       |モーションリソースを取得します。                                | 
 +|**DELETE**    |モーションリソースを削除します。(空のモーションを書き込みます。)| 
 +|**PUT**       |モーションリソースを上書きします。                              | 
 + 
 +``` 
 +http://localhost:17264/v2/motions/<SLOT:integer>/play 
 +http://localhost:17264/v2/motions/stop 
 +``` 
 + 
 +|コマンド|動作                    | 
 +|:-------|:-----------------------| 
 +|**play**|モーションを再生します。| 
 +|**stop**|モーションを停止します。| 
 + 
 +### バージョン情報 (version) 
 + 
 +PLEN本体のバージョン情報に関するリソースを提供します。 
 + 
 +``` 
 +http://localhost:17264/v2/version 
 +``` 
 + 
 +|HTTPリクエスト|動作                                | 
 +|:-------------|:-----------------------------------| 
 +|**GET**       |バージョン情報リソースを取得します。| 
 + 
 +### サーバー構成情報 (metadata) 
 + 
 +以下のようなサーバー構成情報に関するリソースを提供します。 
 + 
 +- APIのバージョン 
 +- 要求するPLENのファームウェアバージョン 
 + 
 +``` 
 +http://localhost:17264/v2/metadata 
 +``` 
 + 
 +|HTTPリクエスト|動作                                  | 
 +|:-------------|:-------------------------------------| 
 +|**GET**       |サーバー構成情報リソースを取得します。| 
 + 
 + 
 +単独実行可能コマンド一覧 
 +------------------------------------------------------------------------------- 
 + 
 +### PLENへの接続 (connect) 
 + 
 +``` 
 +http://localhost:17264/v2/connect 
 +``` 
 + 
 +### PLENからの切断 (disconnect)
  
-Edit me.+``` 
 +http://localhost:17264/v2/disconnect 
 +```
 </markdown> </markdown>
specifications/uri.txt · Last modified: 2021/04/01 13:51 (external edit)