启动工作流程
属性
- 模板:工作流程模板名称
- include_tasks:如果为 "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
设置或更新工作流程或步骤的参数。
标识符:setvar
要素
- context_update: 应设置或更新的参数列表。
- context_of:定义应更新的上下文范围。默认情况下,将更新当前活动的步骤。
- 默认值:步骤
- 可能的值:
- 工作流程:将更新当前活动步骤。
- 根:以任何工作流程都可访问的方式保存值,并返回到根工作流程。
- 全局:创建一个全局上下文值,可从应用程序中的任何位置访问
(
直接引用中的{global::my_value}
或 Javascript 中的appcontext.global.my_
value
)。 - 用户会话:工作原理类似于 "全局"(使用
#{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>
下载资产
下载一个或多个指定资产。
标识符:下载资产
示例
<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>
计时器
设置计时器,可选择设置特定的延迟和周期。当步骤发生变化时,周期或计时器结束。
标识符:定时器
属性
- 命令:超时结束后发送。
- 延迟:包含发送命令的时间。
- 周期:包含再次发送命令的时间间隔。
示例
要启动一个定时器,第一次在 5 秒(5000 毫秒)后触发REFRESH
事件,之后每 2 秒(2000 毫秒)触发一次,可以使用下面的方法:
<timer id="trigger_refresh" command="REFRESH" delay="5000" period="2000"/>
休息要求
此操作旨在通过 REST API 检索 JSON 数据。它支持 POST 和 GET 数据请求类型。
标识符:rest_request
属性
- rest_url:包含 REST API URL。
"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:包含超时时间,单位为秒。
- save_response(保存响应):包含保存响应的上下文。
要素
- 标识符:包含集成服务使用的 ID(如任务 ID)。
- 属性:包含集成服务可使用的参数集合。
- 必须填写:假
- 默认值:[](空集合)
注:属性在内部转换为映射,其值可以是递归转换的集合。最终映射以 JSON 字符串的形式存储在报文的有效负载字符串中,而字符串、数字和布尔值等原始值则存储在属性映射字段中。这使得信息在与集成服务通信时非常灵活。
响应处理
发送提交信息有三种可能的结果:
如果在指定时间后仍未收到响应,就会发生超时。发生这种情况的原因是信息在网络中丢失或服务器处理结果需要太多时间。
在这种情况下,错误一般指意外行为,如由于网络错误或服务器错误导致信息发送失败。预期的错误处理(如处理进程中的无效状态)是通过成功响应来完成的。
所有响应都会生成一个具有send_commit_message
模式的输入事件。命令为RESPONSE_OK、RESPONSE_TIMEOUT
或RESPONSE
_ERROR
。
信息包含一个有效载荷
对象,该对象包含响应的附加数据。在出错
和超时的
情况下,有效载荷中的 "类型 "和 "标识符 "字段将设置为与请求中相同的值。如有需要,这可用于识别特定请求的错误。
在成功的情况下,这些字段不会出现,但 "状态 "字段会被设置为一个数值(由集成服务中的处理程序定义)。该值可用于处理流程中预计会出现的错误。在所有情况下,"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>
处理方
下面是连接器中 "检查 "请求处理程序内的处理代码示例。
@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>
要素
- 类型:包含要添加到任务结果中的附件类型。
- 内容:包含要添加到任务结果中的内容。
- 覆盖:包含已用给定类型保存的值被替换的内容。
默认类型
- 资产
- 条码内容
- 文档评论
- 评论
- 问题("问卷 "组件用于保存完整的问题)
- selected-answers("问卷 "组件用于保存选定的答案)
示例
最低限度
<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:保存接收到的值。如果给定变量中已有数值,数据将被覆盖。
默认类型
- 资产
- 条码内容
- 文档评论
- 评论
- 问题("问卷 "组件用于保存完整的问题)
- 选定的答案("问卷 "组件用于保存选定的答案
注意: 如果可用类型列表中还没有您自己的附件类型,您也可以选择添加该类型。
实例
最低限度
<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.SpeechRecognitionModule
- de.ubimax.andriod.client.output.SoundManager
- de.ubimax.andriod.core.gps.GeoModule
- de.ubimax.andriod.core.output.sound.TextToSpeechManager
- 必须填写:假
- 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"/>