本文转自: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. 图解leetcode —— 124. 二叉树中的最大路径和

    前言: 每道题附带动态示意图,提供java.python两种语言答案,力求提供leetcode最优解. 描述: 给定一个非空二叉树,返回其最大路径和. 本题中,路径被定义为一条从树中任意节点出发,达到 ...

  2. ubuntu部署.Net Core3.1(Nginx+pm2)

    前言 虽然.NetCore已经出来很久了,但是很多初学者还是不会在linux部署.所以写一篇初学者在ubuntu下部署Core的全过程,大佬请无视. 环境搭建 ubuntu18.04 NetCore3 ...

  3. CF1236B Alice and the List of Presents

    题意翻译 有nn种物品和mm个背包,每种物品有无限个,现将若干个物品放到这些背包中,满足: 1.每个背包里不能出现相同种类的物品(允许有空背包): 2.在所有的mm个背包中,每种物品都出现过. 求方案 ...

  4. HashMap踩坑实录——谁动了我的奶酪

    说到HashMap,hashCode 和 equals ,想必绝大多数人都不会陌生,然而你真的了解这它们的机制么?本文将通过一个简单的Demo还原我自己前不久在 HashMap 上导致的线上问题,看看 ...

  5. Creating your first iOS Framework

    转自:https://robots.thoughtbot.com/creating-your-first-ios-framework If you’ve ever tried to create yo ...

  6. Mybatis的模糊查询以及自动映射

    Mybatis的模糊查询 1.  参数中直接加入%% ? 1 2 3 4 5 6 7 8 9 param.setUsername("%CD%");       param.setP ...

  7. [TimLinux] django context_processor介绍

    1. context django里面 render 函数,HttpResponse,都有一个参数,context={},这个参数用于将视图层处理得到的数据传递到模板层. 2. context_pro ...

  8. cesium 结合 geoserver 实现地图属性查询(附源码下载)

    前言 cesium 官网的api文档介绍地址cesium官网api,里面详细的介绍 cesium 各个类的介绍,还有就是在线例子:cesium 官网在线例子,这个也是学习 cesium 的好素材. 内 ...

  9. CodeForces985F -- Isomorphic Strings

    F. Isomorphic Strings time limit per test 3 seconds memory limit per test 256 megabytes input standa ...

  10. ARTS-S mongo关闭与启动

    关闭 mongo admin --eval "db.shutdownServer()" 删除dbdata目录下的mongo.lock 启动 /usr/bin/mongod --db ...