ワークフローを開始する
属性
- テンプレートワークフローを作成するテンプレートの名前。
- インクルードタスク:trueの場合、テンプレートとして 定義されたものはすべてタスクにもなる
出力
- ワークフローが抽出された指定されたテンプレートからワークフローが正常に抽出された
- ペイロード:
wf_uri
start_workflowアクションの "wf "識別子として使用できる。
- WORKFLOW_EXTRACTION_ERROR:指定されたテンプレートからワークフローを抽出できませんでした。
例
このアクションは次のように使うことができる:
<get_workflow_from_template id="get_workflow_from_template">
<param name="template">NameOfTemplate</param>
</get_workflow_from_template>
結果処理:
<rule id="extracted">
<expression><![CDATA[ #{event:command} == 'WORKFLOW_EXTRACTED']]></expression>
<actions>
<action id="start_workflow" type="start_workflow">
<param name="wf">#{event:payload.wf_uri}</param>
</action>
</actions>
</rule>
<rule id="extraction_error">
<expression><![CDATA[ #{event:command} == 'WORKFLOW_EXTRACTION_ERROR']]></expression>
<actions>
<finish_workflow id="finish_workflow">
<output>
<param name="wf_error" type="bool">true</param>
</output>
</finish_workflow>
</actions>
</rule>
セトバー
ワークフローまたはステップのパラメータを設定または更新する。
識別子:setvar
エレメント
- context_update: 設定または更新されるべきパラメータのリスト。
- context_of:更新するコンテキスト・スコープを定義する。デフォルトでは、現在アクティブなステップが更新されます。
- デフォルト値:ステップ
- 可能な値:
- ワークフロー:現在アクティブなステップが更新されます。
- ルート:ルートワークフローに戻り、どのワークフローでもアクセス可能な方法で値を保存します。
- Global:アプリケーションのどこからでもアクセスできるグローバル・コンテキスト値を作成します
(
直接参照では{global::my_value}、
Javascriptではappcontext.global.my_value
)。 - ユーザーセッション:global"(
#{user_session::my_value}で
アクセス)と似た働きをしますが、ユーザがサインアウトすると値は削除されます。
例
最小限
<setvar id="increase_step">
<context_update>
<param name="current_step">#{current_step}+1</param>
</context_update>
</setvar>
すべてのオプション
<setvar id="next_step">
<context_of>root</context_of>
<context_update>
<param name="current_step_index" type="long">#{current_step}+1</param>
<param name="step" type="object">?{context.steps[context.current_step_index]}?</param>
</context_update>
</setvar>
ダウンロード資産
1つまたは複数の指定されたアセットをダウンロードします。
識別子:download_assets
例
<download_assets id="test">
<asset_uris>xai:/assets/hops_02?version=1</asset_uris>
</download_assets>
<download_assets id="test">
<list name="asset_uris" listType="UNNAMED">
<elem>xai:/assets/hops_02?version=1</elem>
<elem>xai:/assets/hops_01?version=1</elem>
<elem>xai:/assets/hops_03?version=1</elem>
</list>
</download_assets>
タイマー
特定の遅延と期間を設定するオプションでタイマーを設定します。期間またはタイマーは、ステップが変更されたときに終了します。
識別子:タイマー
属性
- コマンドで送信される:タイムアウト時間終了後に送信される。
- delay:コマンドを送信するまでの時間。
- 期間:コマンドを再度送信するまでの時間間隔。
例
初回は5秒(5000ミリ秒)後、その後は2秒(2000ミリ秒)ごとにREFRESH
イベントをトリガーするタイマーをスタートさせるには、次のようにすればよい:
<timer id="trigger_refresh" command="REFRESH" delay="5000" period="2000"/>
休養リクエスト
このアクションは、REST API で JSON データを取得するために設計されています。POST と GET のデータタイプをサポートしています。
識別子:rest_request
属性
"https://myfcc.com/sampledata/enginedata"
- request_type:REST リクエストの型。
"GET"
- value_path:JSONデータ値へのパスを含む。
"$.rpm" //check Jayway JsonPath for more examples
- rest_params:REST サービスに渡すパラメータ。
\<list name="rest_params"
listType="NAMED">
\<param name="serial"
type="string">1337\</param>
\</list>
- repeat_every_ms:アクションが新しい値を要求する時間間隔をミリ秒単位で指定します。
5000
- payload_path:受信した値を格納するパスを任意で指定する。パスが指定されない場合、"sensor_value "が使用される。
"sensor_value"
例
次のようなJSON構造を持つJsonPathを考えてみよう:
[{
"color"="blue",
"id"=87427,
"name"="Blueforce87427",
"position"={
"datetime"="2017-07-20T13: 58: 47.947513+02: 00",
"positionX"=2722,
"positionY"=2,
"positionZ"=3980
}
}{
"color"="red",
"id"=11111,
"name"="Opfor11111",
"position"={
"datetime"="2017-07-20T13: 58: 47.947513+02: 00",
"positionX"=3222,
"positionY"=232,
"positionZ"=4000
}
}]
エンドポイントからデータを取得するには、以下のJsonPath
文字列を使用できます:
1.JsonPath:
$[0]['name']
1.返された文字列:
Blueforce87427
2.JsonPath:
$[0]['position']
2.返された文字列:
[{
"datetime"="2022-07-27T13:58:47.925260+02:00,
"positionX"=2722,
"positionY"= 2,
"positionZ"= 3980
}]
3.JsonPath:
$[*]
3.返された文字列:
Whole array with both objects
最小限
<rest_request id="my_rest_test0">
<param name="rest_url" type="string">https://alex.dev.ubimax.com/sampledata/enginedata</param>
<param name="request_type" type="string">POST</param>
<param name="value_path" type="string">$.rpm</param>
<list name="rest_params" listType="NAMED">
<param name="serial" type="string">1337</param>
</list>
</rest_request>
すべてのオプション
<rest_request id="my_rest_test0">
<param name="rest_url" type="string">https://alex.dev.ubimax.com/sampledata/enginedata</param>
<param name="request_type" type="string">POST</param>
<param name="value_path" type="string">$.rpm</param>
<param name="repeat_every_ms" type="string">5000</param>
<param name="payload_path" type="string">myPayload</param>
<list name="rest_params" listType="NAMED">
<param name="serial" type="string">1337</param>
</list>
</rest_request>
コミットメッセージの送信
カスタマイズ可能なプロパティを持つ汎用メッセージをFrontline コネクタに送信します。これらはDefaultInspectionRequestHandler.class
属性を介して処理されます。
識別子:send_commit_message
属性
- タイプ: Frontline コネクタで切り替えるイベント・タイプ。
- connection_timeout:タイムアウト時間を秒単位で指定する。
- 取り得る値:numeric_value
- 必須False
- デフォルト値:50
- save_response:レスポンスを保存するコンテキスト。
- 可能な値ステップ、ワークフロー
- 必須False
- デフォルト値ステップ
エレメント
- 識別子:統合サービスに使用されるID(タスクIDなど)を含む。
- プロパティを含む:統合サービスで使用できるパラメータのコレクションを含みます。
- 必須False
- デフォルト値:[] (空のコレクション)
注:プロパティは内部的にマップに変換され、その値は再帰的な変換の集まりになる。最終的なマップは、メッセージのペイロード文字列に JSON 文字列として格納され、文字列、数値、ブーリアンなどのプリミティブ値は、プロパティ・マップ・フィールド内に格納されます。これにより、統合サービスとの通信において、メッセージは非常に柔軟になります。
応答処理
コミット・メッセージを送信する際に考えられる結果は3つある:
タイムアウトは、指定された時間が経過しても応答がない場合に発生する。これは、メッセージがネットワークで失われたり、サーバーが結果を処理するのに時間がかかりすぎるために起こる。
この場合のエラーとは、一般に、ネットワークエラーやサーバーエラーによるメッセージ送信の失敗など、予期せぬ動作を意味する。期待されるエラー処理(例えば、プロセス中の無効な状態の処理)は、成功応答によって行われる。
すべての応答はsend_commit_message
モダリティで入力イベントを生成する。コマンドはRESPONSE_OK、RESPONSE_TIMEOUT
、RESPONSE_ERRORの
いずれかである。
メッセージは、レスポンス用の追加データを含むペイロードオブジェクトを
含む。エラーや
タイムアウトの
場合、ペイロードは、リクエストで使われたのと同じ値に設定された "type "と "identifier "フィールドを含む。これは、必要であれば、特定のリクエストのエラーを識別するために使用できる。
成功の場合、これらのフィールドは存在しないが、"status "フィールドには数値(統合サービス内のハンドラーによって定義される)が設定される。この値は、プロセスで想定されるエラーのケースを処理するために使用できます。すべての場合において、"response "フィールドには、統合サービスによって定義された文字列が格納されます。
ステータスとレスポンス値に加えて、統合サービスは、イベントと共に送り返される追加のプロパティを定義することができます。これらのプロパティは、イベント処理時にコンテキスト変数として使用できます。この例として、エラー処理のために顧客の WMS からエラーメッセージを送り返したり、成功したコミットを処理するための追加情報を送り返したりすることができます(この断片については以下を参照)。
例
<send_commit_message id="pre_task_request" type="PRE_TASK_REQUEST" connection_timeout="600">
<properties>
<param name="group" type="string">#{group}</param>
<param name="aisle" type="string">#{aisle}</param>
</properties>
</send_commit_message>
<send_commit_message id="complete_inspection" type="COMPLETE_INSPECTION" connection_timeout="1500">
<param name="identifier">#{cockpit_id}</param>
</send_commit_message>
識別子の値をタグ属性として設定することはできません。
<send_commit_message id="send_asset_info" type="PHOTO" connection_timeout="60">
<properties>
<param name="asset_uri" type="string">#{event:payload.media_file}</param>
<param name="order_id" type="string">?{pickOrder.name}?</param>
<param name="group_id" type="string">?{pickOrder.groups[activeGroup].label}?</param>
<param name="customer_reference">?{pickOrder.groups[activeGroup].picks[0].article.customerReference}?</param>
<param name="amount" type="string">?{pickOrder.groups[activeGroup].picks[0].amountOpen}?</param>
</properties>
</send_commit_message>
画像アセットのアップロードと、アップロードされたアセットの情報を含むコミットメッセージの送信
この例のステップでは、入力として画像アセットのURI(media_file)を受け取るだけです:
<step id="send_asset" uitemplate="WAIT" persist="false" screen_lock_enabled="false" debug_mode="false">
<actions>
<action id="upload_media" type="trigger_upload_asset">
<param name="asset_uri">#{media_file}</param>
<param name="delete_after_upload" type="bool">true</param>
<param name="upload_immediately" type="bool">true</param>
<param name="upload_immediately_delete_on_failure" type="bool">true</param>
</action>
<send_commit_message id="send_asset_info" type="PHOTO" connection_timeout="200">
<properties>
<param name="asset_uri" type="string">#{event:payload.asset_uri}</param>
<param name="asset_name" type="string">#{event:payload.asset_name}</param>
<param name="asset_version" type="string">#{event:payload.asset_version}</param>
</properties>
</send_commit_message>
<ui_notification id="show_nok" type="WARN">
<duration>SHORT</duration>
<message>Picture NOT OK</message>
</ui_notification>
<ui_notification id="show_upload_error" type="ERROR">
<duration>SHORT</duration>
<message>Media upload failed</message>
</ui_notification>
<ui_notification id="show_commit_error" type="ERROR">
<duration>SHORT</duration>
<message>Commit failed</message>
</ui_notification>
</actions>
<states>
<onresume>
<rule id="auto_exec">
<expression>1</expression>
<actions>
<action ref="upload_media"/>
</actions>
</rule>
</onresume>
<onevent>
<rule id="upload_ok">
<expression>
<![CDATA[#{event(trigger_upload_asset):command} == 'OK']]>
</expression>
<actions>
<action ref="send_asset_info"/>
</actions>
</rule>
<rule id="upload_error">
<expression>
<![CDATA[#{event(trigger_upload_asset):command} == 'ERROR' || #{event(trigger_upload_asset):command} == 'NETWORK_ERROR' || #{event(trigger_upload_asset):command} == 'INTERNAL_ERROR']]>
</expression>
<actions>
<action ref="show_upload_error"/>
<action ref="finish"/>
</actions>
</rule>
<rule id="commit_ok_ok">
<expression>
<![CDATA[#{event(send_commit_message):command} == 'RESPONSE_OK' && #{event(send_commit_message):payload.response} == 'OK']]>
</expression>
<actions>
<action ref="finish_workflow"/>
</actions>
</rule>
<rule id="commit_ok_nok">
<expression>
<![CDATA[#{event(send_commit_message):command} == 'RESPONSE_OK' && #{event(send_commit_message):payload.response} != 'OK']]>
</expression>
<actions>
<action ref="show_nok"/>
<action ref="goto_take_picture"/>
</actions>
</rule>
<rule id="commit_error_or_timeout">
<expression>
<![CDATA[#{event(send_commit_message):command} == 'RESPONSE_ERROR' || #{event(send_commit_message):command} == 'RESPONSE_TIMEOUT']]>
</expression>
<actions>
<action ref="show_commit_error"/>
<action ref="goto_take_picture"/>
</actions>
</rule>
</onevent>
</states>
</step>
カスタムエラー状態での処理
<actions>
<!-- dialog references variables set by the commit message response for error handling -->
<ui_dialog id="sap_error" type="Error" title="Error">
<message><![CDATA[#{sap_message}<br>Continue to '#{sap_material}/#{sap_position}'?]]></message>
<buttons>
<button>
<text>ANDRRES_fw</text>
<command>SAP_FIX</command>
<focused>true</focused>
</button>
<button>
<text>ANDRRES_bw</text>
<command>DO_NOT_TRY_AGAIN</command>
</button>
</buttons>
</ui_dialog>
<!-- more actions
[...]
-->
</actions>
<!-- more WF code
[...]
-->
<onevent>
<!-- Technical success but check for SAP response -->
<rule id="success">
<expression><![CDATA[#{event:command} == 'RESPONSE_OK' && #{event:payload.status} == 0 ]]></expression>
<actions>
<ui_notification id="show_done" type="INFO">
<duration>SHORT</duration>
<message>#{cockpit_id} completed...</message>
</ui_notification>
<action ref="close_ds_task"/>
<action ref="finish_workflow"/>
</actions>
</rule>
<rule id="sap_error_in_success">
<expression><![CDATA[#{event:command} == 'RESPONSE_OK' && #{event:payload.status} == 500 ]]></expression>
<actions>
<!-- variables are automatically set when the event is handled and can be used in the action -->
<action ref="sap_error"/>
</actions>
</rule>
<rule id="unknown_error_in_success">
<expression><![CDATA[#{event:command} == 'RESPONSE_OK' && #{event:payload.status} != 0 && #{event:payload.status} != 500 ]]></expression>
<actions>
<action ref="completion_error"/>
</actions>
</rule>
<rule id="request_error">
<expression><![CDATA[#{event:command} == 'RESPONSE_ERROR']]></expression>
<actions>
<action ref="completion_error"/>
</actions>
</rule>
<rule id="request_timeout">
<expression><![CDATA[#{event:command} == 'RESPONSE_TIMEOUT']]></expression>
<actions>
<action ref="completion_error"/>
</actions>
</rule>
</onevent>
MQTTの例
<send_commit_message id="send_mqtt" type="FRONTLINE_MQTT" connection_timeout="200">
<properties>
<param name="mqtt" type="string"><![CDATA[?{
var mqtt = {
topic: "MY/TOPIC",
content: "MY CONTENT"
};
var stringmqtt = JSON.stringify(mqtt);
stringmqtt;}?]]>
</param>
</properties>
</send_commit_message>
ハンドラ側
以下は、コネクター内の "Inspection "リクエスト・ハンドラ内でのハンドリング・コードの例である。
@Override
public CommitMessageResponse handleCommitMessage(CommitMessage aCommit) {
if("COMPLETE_INSPECTION".equals(aCommit.getType())) {
String evaluation = aCommit.getIdentifier();
// HANDLE EVENT
// [CODE]
if(isSuccess) {
log.info("Completion success!");
return new CommitMessageResponse(aCommit, 0, "Success!");
}
// HANDLE ERROR
CommitMessageResponse cmr = new CommitMessageResponse(aCommit, 500, "SAP Error!");
cmr.addProperties("sap_message", cr.getMessage()); // 'cr' is an object specific to the custom code
cmr.addProperties("sap_material", cr.getMaterial());
cmr.addProperties("sap_position", cr.getPosition());
return cmr;
}
// OTHER MESSAGES
エラーケースで追加されたプロパティは、イベントが処理されるときにワークフローで利用可能になる。
添付ファイルの追加
現在のステップのタスク結果に添付ファイルを追加する。
識別子:add_attachment
注:ワークフロータグでコンポーネントのレポートを有効にする必要があります。そうしないと、アクションは効果を発揮しない。<workflow [...] reporting="true"></workflow>の
例である。
エレメント
- タイプ:タスク結果に追加する添付ファイルのタイプを指定します。
- コンテンツ:タスク結果に追加したい内容を含む。
- をオーバーライドします:指定された型で既に保存されている値を置き換えます。
デフォルト・タイプ
- アセット
- バーコード・コンテンツ
- ドキュメント・コメント
- コメント
- question(完全な質問を保存するために "Questionnaire "コンポーネントによって使用されます)
- selected-answers(選択された回答を保存するために、"Questionnaire" コンポーネントで使用されます)
例
最小限
<add_attachment id="add_attachment">
<param name="type" type="string">documentation-comment</param>
<param name="content" type="string">#{current_comment}</param>
</add_attachment>
すべてのオプション
<add_attachment id="document_barcode">
<param name="type" type="string">barcode-content</param>
<param name="content" type="string">#{code}</param>
<param name="override" type="bool">false</param>
</add_attachment>
添付ファイルの内容を取得する
特定の添付データ型で最後に追加された添付ファイルを取得します。
識別子:get_attachment_content
エレメント
- タイプ:添付ファイルから取得したい添付ファイルのタイプを指定します。
- write_to:取得した添付ファイルの内容を格納する変数名を指定します。
- write_if_empty:受け取った値を保存する。与えられた変数に既存の値が存在する場合、データは上書きされる。
デフォルト・タイプ
- アセット
- バーコード・コンテンツ
- ドキュメント・コメント
- コメント
- question(完全な質問を保存するために "Questionnaire "コンポーネントによって使用されます)
- selected-answers(選択された回答を保存するために「アンケート」コンポーネントで使用されます。
注: 利用可能なタイプのリストにない場合は、独自の添付ファイルタイプを追加するオプションもあります。
例
最小限
<get_attachment_content id="get_attachment_content">
<param name="type" type="string">documentation-comment</param>
<param name="write_to" type="string">current_comment</param>
</get_attachment_content>
すべてのオプション
<get_attachment_content id="get_attachment_content">
<param name="type" type="string">documentation-comment</param>
<param name="write_to" type="string">current_comment</param>
<param name="write_if_empty" type="bool">true</param>
</get_attachment_content>
モジュール状態
モジュールの状態を変更するために使用します。例えば、音声入力認識を無効にするために使用します。
識別子:module_state
属性
- module_name:モジュール名
- 可能な値:
- de.ubimax.andriod.speechrecognition.SpeechRecognitionモジュール
- de.ubimax.andriod.client.output.SoundManager
- de.ubimax.andriod.core.gps.GeoModule
- de.ubimax.andriod.core.output.sound.TextToSpeechManager
- 必須False
- module_state:モジュールが入るはずの状態
例
<module_state id="resume_speech" module_name="de.ubimax.android.speechrecognition.SpeechRecognitionModule" change_state_to="resume"/>
<module_state id="pause_speech" module_name="de.ubimax.android.speechrecognition.SpeechRecognitionModule" change_state_to="pause"/>
ログオフ
クライアントをログオフします。
識別子:ログオフ
例
<logoff id="myaction"/>