From: Burak K. <bbu...@gm...> - 2022-06-12 19:31:33
|
Hi Jomi, When I pause the agent execution on the container, everything stops, but another thread which created using a session does not stop. I would like to capture the "Pause" of the agents runtime to pause the other thread. But i think your idea is also applicable. Thank you. Best regards. 12 Haz 2022 Paz 17:47 tarihinde Jomi Hubner <jom...@gm...> şunu yazdı: > Hi Burak, > > I am not sure what do you mean for “pausing” an artifact. If it is related > to some “wait” operation of cartago, I do not know a way to get that state. > You likely have to handle that state by yourself and send that information > to your other thread. > > HTH, > > Jomi > > > On 10 Jun 2022, at 09:09, Burak Karaduman <bbu...@gm...> > wrote: > > > > Hi all, > > > > Is it possible to detect the "Pause" operation of the Jason & Cartago > container, because I would like to stop my extra thread-controlled timer > when the container is paused? Is there any operation for this? > > > > > > Thank you for your help. > > > > Best regards. > > > > Burak Karaduman <bbu...@gm...>, 7 Haz 2022 Sal, 20:43 > tarihinde şunu yazdı: > > Hi Jomi, > > > > My supervisor also suggested the same approach, but I think you should > bring this feature in your next update. > > > > Thank you. > > > > Best regards. > > > > Jomi Hubner <jom...@gm...>, 7 Haz 2022 Sal, 20:10 tarihinde şunu > yazdı: > > Hi Burak, > > > > I’d suggest you to take a look at Cartago examples, the Clock example… > > > > Otherwise, you may create a thread in your artifact that runs forever, > sleeps a bit, creates the “security block” of Cartago, where you change the > artifact state… > > > > HTH, > > > > Jomi > > > > > On 6 Jun 2022, at 11:36, Burak Karaduman <bbu...@gm...> > wrote: > > > > > > Hi Jomi, > > > > > > I had solved my problem as you suggested. Thank you so much for your > help. I share the solution I hope it can help others in the future. > > > > > > this.beginExternalSession(); > > > commit(); > > > this.endExternalSession(false); > > > > > > However, I have another question, I have a function which is > encapsulated inside an artefact namely getUDPMessage(). However, this > should be continuously checked in case of data is sent anytime. Is it > possible to attach a feature for continuously listening a function of an > artifact? > > > > > > Best regards. > > > > > > Jomi Hubner <jom...@gm...>, 6 Haz 2022 Pzt, 14:08 tarihinde > şunu yazdı: > > > Hi Burak, > > > > > > I guess that instructions that change the state of the artifact (obs > props/signals) have to be executed in a special way in cartago to avoid > breaking its atomicity/transactional features. > > > > > > if a thread of yours is changing the artifact, the change should be > executed inside a block beginExternalSession/endExternalSession. In your > code, the thread is created inside this block, but the signal is not > running inside such a block. Maybe you can move the begin/end… to inside > the “run()” method. > > > > > > HTH > > > > > > Jomi > > > > > > > On 5 Jun 2022, at 19:18, Burak Karaduman <bbu...@gm...> > wrote: > > > > > > > > Dear all, > > > > > > > > I am trying to create a timer that counts based on seconds. However, > I am getting this error; > > > > > > > > java.lang.IllegalMonitorStateException > > > > at > java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.signalAll(AbstractQueuedSynchronizer.java:1487) > > > > at cartago.Artifact.commitObsStateChangesAndSignal(Artifact.java:573) > > > > at cartago.Artifact.signal(Artifact.java:637) > > > > at example_JaCaMo.MyTimer.access$000(MyTimer.java:11) > > > > at example_JaCaMo.MyTimer$1.run(MyTimer.java:29) > > > > at java.base/java.util.TimerThread.mainLoop(Timer.java:556) > > > > at java.base/java.util.TimerThread.run(Timer.java:506) > > > > > > > > My code is simply like this: > > > > > > > > public class MyTimer extends Artifact { > > > > > > > > void init() { > > > > defineObsProperty("mytimer", 0); > > > > timer_creation(); > > > > } > > > > > > > > void timer_creation() { > > > > this.beginExternalSession(); > > > > > > > > Timer timer = new Timer(); > > > > > > > > TimerTask task = new TimerTask(){ > > > > private int i = 0; > > > > public void run(){ > > > > if (i <= 30) { > > > > signal("timerEnd"); > > > > System.out.println(i); > > > > > > > > } > > > > } > > > > }; > > > > > > > > > > > > timer.scheduleAtFixedRate(task, 0, 1000); //1000ms = 1sec > > > > this.endExternalSession(true); > > > > } > > > > } > > > > > > > > How can I tackle this problem? > > > > > > > > Thank you. > > > > > > > > Best regards. > > > > > > > > > > > > > > > > -- > > > > Burak KARADUMAN, > > > > Ph.D. Student at the University of Antwerp & Flanders Make, > > > > Modeling Intelligent Complex Software & Systems (MICSS-Lab), > > > > G236, Department of Computer Science, Faculty of Science, Campus > Middelheim, > > > > Middelheimlaan 1, 2020 Antwerp, Belgium > > > > > > > > _______________________________________________ > > > > Jason-users mailing list > > > > Jas...@li... > > > > https://lists.sourceforge.net/lists/listinfo/jason-users > > > > > > > > > > > > -- > > > Burak KARADUMAN, > > > Ph.D. Student at the University of Antwerp & Flanders Make, > > > Modeling Intelligent Complex Software & Systems (MICSS-Lab), > > > G236, Department of Computer Science, Faculty of Science, Campus > Middelheim, > > > Middelheimlaan 1, 2020 Antwerp, Belgium > > > > > > > > > > > -- > > Burak KARADUMAN, > > Ph.D. Student at the University of Antwerp & Flanders Make, > > Modeling Intelligent Complex Software & Systems (MICSS-Lab), > > G236, Department of Computer Science, Faculty of Science, Campus > Middelheim, > > Middelheimlaan 1, 2020 Antwerp, Belgium > > > > > > > > -- > > Burak KARADUMAN, > > Ph.D. Student at the University of Antwerp & Flanders Make, > > Modeling Intelligent Complex Software & Systems (MICSS-Lab), > > G236, Department of Computer Science, Faculty of Science, Campus > Middelheim, > > Middelheimlaan 1, 2020 Antwerp, Belgium > > > > |