本文转自: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.

  1. 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.

  1. 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.
  2. Create two integer variables, InitialGuess and RandomNumber. The first variable stores your guess, while the second stores the random number.
  3. 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.
  4. Double-click the activity. This State activity is displayed expanded in the Designer panel.
  5. In the Properties panel, in the DisplayName field, type Initializing Random Number. This enables you to easily tell states apart.
  6. In the Entry section, add an Assign activity.
  7. In the To field, add the RandomNumber variable.
  8. In the Value field, type new Random().Next(1,100). This expression generates a random number.
  9. Return to the main project view and add a new State activity.
  10. Connect it to the previously added activity.
  11. Double-click the last added State activity. This activity is displayed expanded in the Designer panel.
  12. In the Properties panel, in the DisplayName field, type Guess Number. This state is used to prompt the user to guess a number.
  13. In the Entry section, add an Input Dialog activity.
  14. 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.
  15. In the Result field, add the InitialGuess variable. This variable stores the user’s guess.
  16. Return to the main project view and create a transition that points from the Guess Number state to itself.
  17. Double-click the transition. The transition is displayed expanded in the Designer panel.
  18. 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.
  19. In the Condition section, type InitialGuess > RandomNumber. This verifies if the user’s guess is bigger than the random number.
  20. In the Action section, add a Message Box activity.
  21. 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.
  22. Return to the main project view and create a new transition that points from the Guess Number state to itself.
  23. Double-click the transition. The transition is displayed expanded in the Designer panel.
  24. 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.
  25. In the Condition section, type InitialGuess < RandomNumber. This verifies if the guess is smaller than the random number.
  26. In the Action section, add a Message Box activity.
  27. 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.
  28. Return to main project view and add a Final State activity to the Designer panel.
  29. Connect a transition from the Guess Number activity to the Final State.
  30. In the Properties panel, in the DisplayName field, type "Correct Guess".
  31. In the Condition field, type InitialGuess = RandomNumber. This is the condition on which this automation steps to the final state and end.
  32. Double-click the Final State activity. It is displayed expanded in the Designer panel.
  33. In the Entry section, add a Message Box activity.
  34. 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.

  1. Press F5. The automation is executed correctly.

Download example

另:

https://www.jianshu.com/p/8d77459c69d2?from=timeline&isappinstalled=0

【UiPath Studio 中文文档】10 项目类型 - 状态机 (State Machine)

[转]UiPath State Machines的更多相关文章

  1. 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 ...

  2. [翻译]:Artificial Intelligence for games 5.3 STATE MACHINES:状态机

    目录 Chapter 5 Decision Making 5.3 STATE MACHINES:状态机 Chapter 5 Decision Making 5.3 STATE MACHINES:状态机 ...

  3. UIPath RPA 自动化脚本 机器人从入门到精通

    本文链接:https://blog.csdn.net/qq_27256783/article/details/93619818 一.UiPath介绍 UiPath 是RPA(Robotic Proce ...

  4. State Machine.(状态机)

    What is a State Machine? Any device that changes its state from one to another due to some actions a ...

  5. reactjs入门到实战(四)---- state详解

    this.props 表示那些一旦定义,就不再改变的特性,而 this.state 是会随着用户互动而产生变化的特性. 组件免不了要与用户互动,React 的一大创新,就是将组件看成是一个状态机,一开 ...

  6. Qt: The State Machine Framework 学习

    State Machine,即为状态机,是Qt中一项非常好的框架.State Machine包括State以及State间的Transition,构成状态和状态转移.通过状态机,我们可以很方便地实现很 ...

  7. 【翻译】What is State Machine Diagram(什么是状态机图)?

    [翻译]What is State Machine Diagram(什么是状态机图)? 写在前面 在上一篇学习类图的时候将这个网站上的类图的一篇文章翻译了出来,感觉受益良多,今天来学习UML状态机图, ...

  8. React基础篇(2) -- state&props&refs

    内容简介 state props refs 行内样式及动态类名 state 基本介绍 React 把组件看成是一个状态机(State Machines).通过与用户的交互,实现不同状态,然后渲染 UI ...

  9. 创建组件的方法,组件的props属性、state属性的用法和特点,父子组件传值,兄弟组件传值

    1.创建组件的方法   函数组件   class组件 1.1 函数组 无状态函数式组件形式上表现为一个只带有一个 `render()` 方法的组件类,通过函数形式或者 `ES6` 箭头 `functi ...

随机推荐

  1. Ctrl + Shift + F7 ; F3、Shift + F3

    pycharm 查找并高亮参数 选中某一参数,Ctrl + Shift + F7  高亮所有该文件中所有该参数 接下来, 按 F3 在所有高亮选择中向下移动一个, Shift + F3 在所有高亮选择 ...

  2. git配置文件—— .editorconfig

    参考文档 editorconfig官方文档 github/editorconfig/wiki文档 一 概述 editorConfig不是什么软件,而是一个名称为.editorconfig的自定义文件. ...

  3. [TimLinux] HTTP cookie与session技术

    1. HTTP特点 基于TCP/IP协议实现,上层应用协议 版本:HTTP/1.0, HTTP/1.1 HTTP/1.0默认短连接,HTTP/1.1默认长连接 HTTP请求与响应的无状态性 无状态性与 ...

  4. ThreadLocal解决了什么问题

    小明所在的项目组(迭代组:一直在迭代的路上),经常会在已有接口的基础上开发一些小功能,并且前提是在保证现有用户的不受影响基础上迭代.功能迭代,在代码层面小明有1w种实现方法(吹牛的),一起来看看这次小 ...

  5. Jmeter介绍以及脚本制作与调试

    目录 Jmeter介绍 Jmeter安装 Jmeter主要测试组件 Jmeter元件作用域与执行顺序 Jmeter运行原理 Jmeter脚本制作 Jmeter脚本调试 Jmeter介绍 Jmeter ...

  6. 一元建站-基于函数计算 + wordpress 构建 serverless 网站

    前言 本文旨在通过 快速部署一个 wordpress 网站到阿里云函数计算平台 这个示例来展示 serverless web 新的开发模式, 包括 FUN 工具一键初始化 NAS, 同步网站到 NAS ...

  7. 分享一下HttpWatch pro 10.X 支持win10

    今天开始学Servlet,第一次安的是10的普通版,但发现功能太过简单不够学习使用,之后换了9的pro版本,发现单击"Record"按钮启动网络监听,会收到"ERROR_ ...

  8. yum换源,rpm包下载,源码包安装

    一.yum更换源 yum自带源地址一般斗是国外的,可能下载速度略慢,我们可以自己换成国内的源,比如163等.比如配置163的yum源:1.先删除默认源文件dvd.repo # rm -f /etc/y ...

  9. 区块链学习——HyperLedger-Fabric v1.0环境搭建详细教程

    相对与v0.6版本来说,1.0版本改变较大,此处不多说,只是将小白自己搭建1.0环境的过程分享给大家.希望对大家能有所帮助! 这一篇可能对前面的环境搭建会写的有些粗略,如有疑问,可阅读上一篇V0.6版 ...

  10. 《Java基础知识》Java 运算符

    计算机的最基本用途之一就是执行数学运算,作为一门计算机语言,Java也提供了一套丰富的运算符来操纵变量.我们可以把运算符分成以下几组: 算术运算符 关系运算符 位运算符 逻辑运算符 赋值运算符 其他运 ...