简体   繁体   English

代理状态图出现问题

[英]Trouble with agent state chart

I'm trying to create an agent statechart where a transition should happen every day at 4 pm (except weekends). 我正在尝试创建一个代理状态图,应该在每天的下午4点(周末除外)进行转换。

I have already tried: 1. a conditional transition (condition: getHourOfDay() == 16) 2: A timeout transition that will "reinsert" my agent into the chart every 1 s and check if time = 16. 我已经尝试过:1.有条件的转换(条件:getHourOfDay()== 16)2:超时转换,每隔1 s将代理“重新插入”到图表中,并检查time = 16。

My code is still not running, does anyone have any idea how to solve it? 我的代码仍未运行,是否有人知道如何解决?

在此处输入图片说明

This is my statechart view. 这是我的状态图视图。 Customer is a single resource that is supposed to "get" the products out of my stock everyday at 4pm. 客户是一种资源,应该每天下午4点从我的库存中“取出”产品。 It is supposed to happen in the "Active" state. 它应该在“活动”状态下发生。

在此处输入图片说明

I have set a timeout transition (from Active-Active) that runs every 1s. 我设置了一个从1秒运行的超时过渡(从Active-Active)。

在此处输入图片说明

Inside my "Active" state in the "entrance action" i wrote my code to check if it is 4 pm and run my action if so. 在“进入动作”的“活动”状态下,我编写了代码以检查是否为下午4点,如果是,请运行我的动作。

I thought since i set a timeout transition it would check my condition every 1s, but apparently it is not working. 我以为,自从我设置了一个超时转换后,它将每隔1秒检查一次我的状况,但显然它不起作用。

Don't use condition-based transitions, for performance reasons. 出于性能原因,请勿使用基于条件的转换。 In your case, it also never triggers because it is only evaluated when something happens in the model. 在您的情况下,它也永远不会触发,因为仅在模型中发生某些事情时才对其进行评估。 Incidentally, that is not the case at 4pm. 顺便说一下,下午4点不是这种情况。

re your timeout approach: Why would you "reinsert" your agent into its own statechart? 重新使用超时方法:为什么要将代理“重新插入”到自己的状态图中? Not sure I understand... 不确定我了解...

Why not set up a schedule or event with your recurrence requirement and make it send a message to the statechart: stateChart.fireEvent("trigger!"); 为什么不根据您的重复要求设置计划或事件,并使其发送消息到状态图: stateChart.fireEvent("trigger!"); . In your statechart, add a message-based transition that waits for this message. 在状态图中,添加一个等待该消息的基于消息的过渡。 This will work. 这将起作用。

Be careful to understand the difference between the Statechart.fireEvent() and the Statechart.receiveMessage() functions, though. 但是,请小心了解Statechart.fireEvent()Statechart.receiveMessage()函数之间的区别。

PS: and agree with Felipe: please start using SOF the way it is meant, ie also mark replies as solved. PS:并同意Felipe的观点:请按照其含义使用SOF,即也将答复标记为已解决。 It helps us but also future users to quickly find solutions :-) cheers 它不仅可以帮助我们,也可以帮助未来的用户快速找到解决方案:-)欢呼

Your agent does not enter the Active state via an internal transition. 您的代理不会通过内部转换进入“活动”状态。

Redraw the transition to actually go out of the Active state and then enter it again as below: 重绘过渡以使其实际退出“活动”状态,然后再次输入,如下所示: 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM