[转]UiPath State Machines
本文转自:https://docs.uipath.com/studio/docs/state-machines
A state machine is a type of automation that uses a finite number of states in its execution. It can go into a state when it is triggered by an activity, and it exits that state when another activity is triggered.
Another important aspect of state machines are transitions, as they also enable you to add conditions based on which to jump from one state to another. These are represented by arrows or branches between states.
There are two activities that are specific to state machines, namely State and Final State, found under Workflow > State Machine.
Note:
You can only create one initial state, yet it is possible to have more than one Final State.
The State activity contains three sections, Entry, Exit and Transition(s), while the Final State only contains one section, Entry. Both of these activities can be expanded by double-clicking them, to view more information and edit them.
The Entry and Exit sections enable you to add entry and exit triggers for the selected state, while the Transition(s) section displays all the transitions linked to the selected state.
Transitions are expanded when you double-click them, just like the State activity. They contain three sections, Trigger, Condition and Action, that enable you to add a trigger for the next state, or add a condition under which an activity or sequence is to be executed.
Example of How to Use a State Machine
To exemplify how to use a state machine, we are going to build the guessing game we did in the previous chapter, the only difference being that we will try to guess a number between 1 and 100.
- Create a blank process and, on the Design tab, in the File group, select New > State Machine. The New State Machine window is displayed.
Note:
You can also add a State Machine activity to the Designer panel to create a new state machine automation.
- In the Name field type a name for the automation, such as "First State Machine", and leave the default project location or add a subfolder. Click Create. The Designer panel is updated accordingly.
- Create two integer variables,
InitialGuess
andRandomNumber
. The first variable stores your guess, while the second stores the random number. - Add a State activity to the Designer panel and connect it to the Start node. This is the initial state, and it is used to generate a random number.
- Double-click the activity. This State activity is displayed expanded in the Designer panel.
- In the Properties panel, in the DisplayName field, type Initializing Random Number. This enables you to easily tell states apart.
- In the Entry section, add an Assign activity.
- In the To field, add the
RandomNumber
variable. - In the Value field, type
new Random().Next(1,100)
. This expression generates a random number. - Return to the main project view and add a new State activity.
- Connect it to the previously added activity.
- Double-click the last added State activity. This activity is displayed expanded in the Designer panel.
- In the Properties panel, in the DisplayName field, type Guess Number. This state is used to prompt the user to guess a number.
- In the Entry section, add an Input Dialog activity.
- Select the Input Dialog, and in the Properties panel, add an appropriate Label and Title to prompt the user to guess a number between 1 and 100.
- In the Result field, add the
InitialGuess
variable. This variable stores the user’s guess. - Return to the main project view and create a transition that points from the Guess Number state to itself.
- Double-click the transition. The transition is displayed expanded in the Designer panel.
- In the Properties panel, in the DisplayName field, type Try Smaller. This message is displayed on the arrow, enabling you to run through your automation easier.
- In the Condition section, type
InitialGuess
>RandomNumber
. This verifies if the user’s guess is bigger than the random number. - In the Action section, add a Message Box activity.
- In the Text field, type something similar to "Your guess is too big. Try a smaller number." This message is displayed when the user’s guess is bigger than the random number.
- Return to the main project view and create a new transition that points from the Guess Number state to itself.
- Double-click the transition. The transition is displayed expanded in the Designer panel.
- In the Properties panel, in the DisplayName field, type "Try Bigger". This message is displayed on the arrow, enabling you to run through your automation easier.
- In the Condition section, type
InitialGuess
<RandomNumber
. This verifies if the guess is smaller than the random number. - In the Action section, add a Message Box activity.
- In the Text field, type something similar to "Your guess is too small. Try a bigger number." This message is displayed when the users guess is smaller than the random number.
- Return to main project view and add a Final State activity to the Designer panel.
- Connect a transition from the Guess Number activity to the Final State.
- In the Properties panel, in the DisplayName field, type "Correct Guess".
- In the Condition field, type
InitialGuess
=RandomNumber
. This is the condition on which this automation steps to the final state and end. - Double-click the Final State activity. It is displayed expanded in the Designer panel.
- In the Entry section, add a Message Box activity.
- In the Text field, type something similar to "Congratulations. You guessed correctly! The number was " +
RandomNumber.ToString
+ "." This is the final message that is to be displayed, when the user correctly guesses the number.
The final project should look as in the following screenshot.
- Press F5. The automation is executed correctly.
另:
https://www.jianshu.com/p/8d77459c69d2?from=timeline&isappinstalled=0
【UiPath Studio 中文文档】10 项目类型 - 状态机 (State Machine)
[转]UiPath State Machines的更多相关文章
- Important Programming Concepts (Even on Embedded Systems) Part V: State Machines
Earlier articles in this series: Part I: Idempotence Part II: Immutability Part III: Volatility Part ...
- [翻译]:Artificial Intelligence for games 5.3 STATE MACHINES:状态机
目录 Chapter 5 Decision Making 5.3 STATE MACHINES:状态机 Chapter 5 Decision Making 5.3 STATE MACHINES:状态机 ...
- UIPath RPA 自动化脚本 机器人从入门到精通
本文链接:https://blog.csdn.net/qq_27256783/article/details/93619818 一.UiPath介绍 UiPath 是RPA(Robotic Proce ...
- State Machine.(状态机)
What is a State Machine? Any device that changes its state from one to another due to some actions a ...
- reactjs入门到实战(四)---- state详解
this.props 表示那些一旦定义,就不再改变的特性,而 this.state 是会随着用户互动而产生变化的特性. 组件免不了要与用户互动,React 的一大创新,就是将组件看成是一个状态机,一开 ...
- Qt: The State Machine Framework 学习
State Machine,即为状态机,是Qt中一项非常好的框架.State Machine包括State以及State间的Transition,构成状态和状态转移.通过状态机,我们可以很方便地实现很 ...
- 【翻译】What is State Machine Diagram(什么是状态机图)?
[翻译]What is State Machine Diagram(什么是状态机图)? 写在前面 在上一篇学习类图的时候将这个网站上的类图的一篇文章翻译了出来,感觉受益良多,今天来学习UML状态机图, ...
- React基础篇(2) -- state&props&refs
内容简介 state props refs 行内样式及动态类名 state 基本介绍 React 把组件看成是一个状态机(State Machines).通过与用户的交互,实现不同状态,然后渲染 UI ...
- 创建组件的方法,组件的props属性、state属性的用法和特点,父子组件传值,兄弟组件传值
1.创建组件的方法 函数组件 class组件 1.1 函数组 无状态函数式组件形式上表现为一个只带有一个 `render()` 方法的组件类,通过函数形式或者 `ES6` 箭头 `functi ...
随机推荐
- luogu P2863 [USACO06JAN]牛的舞会The Cow Prom |Tarjan
题目描述 The N (2 <= N <= 10,000) cows are so excited: it's prom night! They are dressed in their ...
- iOS RSA加解密签名和验证
转自:http://www.jianshu.com/p/81b0b54436b8 Pre:在公司负责了一个项目,需要用到iOS RSA验证签名的功能.后台给我的仅仅是一个公钥的字符串.经过起初的一段时 ...
- Java修炼——基于TCP协议的Socket编程_双向通信_实现模拟用户登录
首先我们需要客户端和服务器端. 服务器端需要:1.创建ServerSocket对象.2.监听客户端的请求数据.3.获取输入流(对象流)即用户在客户端所发过来的信息. ...
- 胸部CT提取分割肺部
1. 肺部分割提取简介 在处理胸部CT时,我们常常需要获取肺部的一个mask,也就是将肺部结构从数据中提取出来.二维图像还好说,但是三维图像就会变得复杂复杂一点.肺部的分割常常做后续操作的预处理,所以 ...
- 2017 CCPC秦皇岛 H题 Prime set
Given an array of integers , we say a set is a prime set of the given array, if and is prime. Ba ...
- 一款简单的C++猜数字游戏(新手必学)
前言本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理.作者:1只小弛 废话不多说,直接上代码! #include<bits/s ...
- 一元建站-基于函数计算 + wordpress 构建 serverless 网站
前言 本文旨在通过 快速部署一个 wordpress 网站到阿里云函数计算平台 这个示例来展示 serverless web 新的开发模式, 包括 FUN 工具一键初始化 NAS, 同步网站到 NAS ...
- Linux 内存映射函数 mmap()函数详解
mmap将一个文件或者其它对象映射进内存.文件被映射到多个页上,如果文件的大小不是所有页的大小之和,最后一个页不被使用的空间将会清零.mmap在用户空间映射调用系统中作用很大.头文件 <sys/ ...
- hdu 1667 The Rotation Game ( IDA* )
题目大意: 给你一个“井”子状的board,对称的由24个方块组成,每个方块上有123三个数字中的一个.给你初始状态,共有八种变换方式,求字典序最小的最短的的变换路径使得,board中间的八个方块上数 ...
- CSS | 圣杯布局、双飞翼布局 | 自适应三栏布局
圣杯布局和双飞翼布局是前端工程师需要日常掌握的重要布局方式.两者的功能相同,都是为了实现一个两侧宽度固定,中间宽度自适应的三栏布局 虽然两者的实现方法略有差异,不过都遵循了以下要点: 1.两侧宽度固定 ...