[转]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,
InitialGuessandRandomNumber. 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
RandomNumbervariable. - 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
InitialGuessvariable. 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 ...
随机推荐
- python 协程与go协程的区别
进程.线程和协程 进程的定义: 进程,是计算机中已运行程序的实体.程序本身只是指令.数据及其组织形式的描述,进程才是程序的真正运行实例. 线程的定义: 操作系统能够进行运算调度的最小单位.它被包含在进 ...
- 在 Xcode9 中自定义文件头部注释和其他文本宏
在 Xcode9 中自定义文件头部注释和其他文本宏 . 参考链接 注意生成的plist文件的名称为IDETemplateMacros.plist 在plist文件里设置自己想要的模板 注意plist存 ...
- docker实践之docker-compose部署mysql
文章目录 docker实践之docker-compose部署mysql 1.安装部署docker 2.编写docker-compose文件 3.编写配置文件和初始化文件 4.启动数据库 5.检查初始化 ...
- pip-get.py安装问题
问题: 安装完成和配置环境之后:输入一个测试命令:pip help 出现下面这个问题. Fatal error in launcher: Unable to create process using ...
- PlantUML Viewer Chrome 插件 画时序图
PlantUML通过简单直观的语言来定义示意图 使用 Chrome+ PlantUML Viewer的插件画图 1,打开chrome网上应用店 2,搜索plantuml viewer 并添加 3,扩展 ...
- js原生实现链式动画效果
// 1. css样式 div { width: 100px; height: 100px; background: olivedrab; position: absolute; left: 0px; ...
- 最全的三剑客和linux正则符号讲解
第2章 linux符号系列与三剑客 194 2.1 特殊符号系列 194 2.1.1 普通符号系列 194 2.1.2 引号符号系列 196 2.1.3 定向符号 197 ...
- vs里 .sln和.suo 文件 Visual Studio里*.sln和*.suo文件的作用
Visual Studio里*.sln和*.suo文件的作用 VS项目采用两种文件类型(.sln 和 .suo)来存储特定于解决方案的设置.这些文件总称为解决方案文件,为解决方案资源 ...
- [从今天开始修炼数据结构]图的最小生成树 —— 最清楚易懂的Prim算法和kruskal算法讲解和实现
接上文,研究了一下算法之后,发现大话数据结构的代码风格更适合与前文中邻接矩阵的定义相关联,所以硬着头皮把大话中的最小生成树用自己的话整理了一下,希望大家能够看懂. 一.最小生成树 1,问题 最小生成树 ...
- hibernate mysql中文检出无效
在学习ssh框架是发现,检索条件是英文时,sql就能按照条件过滤出数据,当我换成中文是,检索出来的数据就是空,最后发现没有设置数据库连接url的编码格式 1.数据库编码 COLLATE='utf8_g ...