全球FlexSim系统仿真中文论坛

搜索
查看: 2377|回复: 0
打印 上一主题 下一主题

如何获取Activity的统计信息?

[复制链接]
跳转到指定楼层
1#
zorsite 发表于 2022-11-29 15:17:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 zorsite 于 2022-11-29 15:42 编辑 . p9 z7 A! M1 g) w' c
+ G- i, U( ^% Y, N& t/ {, p% h
如何获取Activity的统计信息?5 s0 g0 g: x+ ^* P! F* N
3D实体的属性面板中可以查看统计信息。, x/ C) K6 c. W6 t- Z! d
% n2 J0 E6 h+ A  w/ s6 B
同时可以通过Object.stats属性来获取相关信息。6 \- x) @) @7 _$ [6 f

0 `: M1 u% }5 x# p5 fActivity也有属性面板% a8 X  y4 `. I9 P
* |/ J' D0 A  L
但是Activity却没有stats属性,无法通过属性获取统计信息。
$ c8 o, m  a2 P8 z, m5 ]; r; B) O( C8 v5 k" Q1 ~' d( j1 m: L
原因在于当我们使用current关键字的时候,current被声明为Object对象,而activity被声明为treenode对象。8 R+ U# I( S$ V5 b' s
treenode作为Object的父类,其属性和方法不如其子类Object那样丰富。
9 d$ r" l: c$ e
# F* |5 E: H- c. F作为treenode的子类,Object对象除了有treenode的属性外,还具有以下属性:1 D8 n( G3 v/ S5 k1 r

% _2 [4 G0 i$ c' Y& n5 L. P其中就有stats属性,可以获取统计信息。! b# o# ?0 V% w9 R& g' e4 n
3 D' {2 ~: F, B: K! B1 [
那如何使用代码获取Activity的统计信息呢?
1 `5 o# M/ r. f$ u4 t( v0 q第1种方法,使用getstat命令。
0 i' I6 z, k& n' @& _' Mgetstat (node object, str name, int flag [, var p1, var p2, var p3]); v* t2 V% H! Y. u, ?
Returns the statistic value for the given objectDescription  }7 u; R  X6 L$ }
It is preferred to use Object.stats instead. Gets the specified statistic from the given object.
$ H+ P: b( P, G( f0 _$ n: QExample:
7 }, m+ _3 o) `( S  m0 S
  1. getstat(activity, "Content", STAT_CURRENT)
复制代码
  1. getstat(activity, "Input", STAT_CURRENT)
复制代码
  1. getstat(activity, "Staytime", STAT_AVERAGE)
复制代码
  1. double avgContent = getstat(3 ^, a, l4 N8 `* F% s  {
  2. // getstat requires between 4 and 6 parameters:8 \4 `1 w/ d: `' m5 V! [% b
  3. activity, // 1. the object (shared asset or activity) that has the statistic
    ! `# d0 z0 i/ [% a: h7 ?! \9 q
  4. "Content", // 2. the name of the statistic
    . ~6 T! `, E! J& I
  5. STAT_AVERAGE, // 3. the desired value from the statistic (could also be STAT_CURRENT, STAT_MIN, or STAT_MAX)
    2 Z3 c' d9 }& b; Y, k! `& K$ l  L
  6. // 4. an optional parameter the instance object (usually current)# L* }+ U9 p2 H% i2 s
  7. // 5. an additional parameter to help resolve which data to get
    % _8 ^. p; o- M0 U: d% u
  8. // 6. an additional parameter to help resolve which data to get
    : G- u# f+ E7 C; y- L9 V" c0 l0 Y
  9. );
复制代码
5 D2 ?, ~' {7 d4 f5 [; `0 l0 V
第2种方法,转换activity的类型。, X  B2 W) r  d; f' j+ B" ]) H
既然Object对象有stats属性,那把activity从treenode类型转换为Object类型不就可以了?
6 n7 M% s0 n8 T1 W转换的方式有2种:
7 A: y5 ?) {+ Z方法1,使用as关键字:
3 [# i7 y- h3 @5 ?& W. A0 B
  1. activity.as(Object).stats.input.value;. J  S8 F6 q& U% O! m) o0 m7 N
复制代码

7 {7 j% \. i4 f+ U& C( i方法2,将activity声明为Object类型的变量:
1 ]( P- N3 N0 {3 T. Y
  1. Object Obj_activity=activity;% ^1 i& J. K0 M; ]" C$ |
  2. return Obj_activity.stats.input.value;
复制代码
7 ^6 u! T; [5 [2 u
5 g, z' K8 t4 d& ]% x: y2 B0 v; z

" ~! i7 ]# J8 ~% Z" E" g, @6 D+ F+ b4 w6 H  }' i8 T1 ]

% Z) \. `; Z( p! T7 \
5 g" _7 h' M1 h# O6 T* w% ]3 P) ~5 y  V$ o7 V. F( ^
1 S2 w0 g, ^- _# m6 V: C

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|全球FlexSim系统仿真中文论坛 ( 京ICP备14043114号-2 )

GMT+8, 2025-10-25 01:21 , Processed in 0.077596 second(s), 14 queries .

Powered by Discuz! X3.3© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表