QStateMachine with dynamic transitions - qt

I have an application where the UI is driven by a QStateMachine and some of the states can be described as "non interruptible" : once they are entered, the user has to interact with the UI and when it's done then the state can be exited but the transition might depends on external events.
Here is how i would illustrate the problem:
A : initial state
B : "non interruptible" state
C, D, .. : other states
and then some transitions :
event1 -> transition A_to_B
event2 -> transition B_to_C
event3 -> transition B_to_D
Now the application starts the state machine and enters A :
1 - the user click the UI which triggers a QSignalTransition (event1).
2 - while in B, a remote server send something to the app and this should define if we'll enter C (event2) or D (event3) but only after B is exited properly.
The problem is that if we define transition statically (before the state machine is started) then when event2 or event3 are sent, the transition might cause B to be interrupted (let's say the user has not finish to select something for example)
Is it possible to dynamically change a transition between 2 states as soon as we know which one we need ?
Hope the description is clear.
Thank you.

Related

My mod can't toggle mouse buttons while alt+f4. What's causing this and how can I fix this?

MC version: 1.8.9
public static void EnableAutoFarm(){
KeyBinding.setKeyBindState(mc.gameSettings.keyBindAttack.getKeyCode(), true); // statement a
KeyBinding.setKeyBindState(mc.gameSettings.keyBindRight.getKeyCode(), true); // statement b
}
So I have been coding a afk mod that can auto farm crops. The server I made it for restarts every 12 hours. To counter this I made a system that will activate auto farm after server restart and reconnecting. This will all happen while mc window is alt+f4'ed. Normally when I manually activate the auto farm while in focus with mc window statement a and statement b works perfectly fine even after alt+f4. But when I alt+f4 and it gets disconnected because of server restart it auto reconnects and then auto warps back to the farm and then it runs EnableAutoFarm() method. In that situation auto farm method's statement a won't work even tho the state is set to true but the statement b works perfectly fine tho. What could be causing this?
Extra info:
F3 + P is enabled so it doesn't loose focus while alt+f4'ed
Statement a and b automatically sets to false when it disconnects because of the method I made.
alt+f4 will exit the game completely by default on your computer. So you would need to find a different key combination to do what you are trying to do.

WatchOS Background URLSession handle(_:) not called when app is not closed (lowered wrist)

I'm trying to create a Watch-App where I download data (around 30 MB).
Therefore I create a URLSession with a background configuration like so:
let config = URLSessionConfiguration.background(withIdentifier: "<some-id>")
self.session = URLSession(configuration: config, delegate: self, delegateQueue: .main)
and then start the download:
let request = URLRequest(url: "<some-url>", method: .GET)
self.task = session.downloadTask(with: request)
self.task.resume()
Since the user is not gonna stare at the watch for 5 minutes, I want to notify him with some haptic feedback when the download finished.
Therefore I wanted to use the handle(_:) function of the ExtensionDelegate. According to the documentation, this should be called with a WKURLSessionRefreshBackgroundTask when the download finished:
The system creates a background URLSession task when any of the following events occur:
Authentication is required to complete a background transfer.
All background transfers associated with a session identifier have completed (either successfully or unsuccessfully). https://developer.apple.com/documentation/watchkit/wkurlsessionrefreshbackgroundtask
This handle(_:) method is only called if I close my app though (pressing the crown), not when i lower my wrist to lock the screen.
I also noticed, that if I look at the watch again, the callbacks for urlSession(.. didWriteData ..) are not working anymore.
Am I missing something or is this even expected behaviour? I'm testing on a real Apple-Watch Series 4 with WatchOS 5 installed.

Meteor mizzaou user-status package

I am not able to find more detailed docs than these. I am having issues in using status.idle. It is always false for online users even if the user is doing nothing( has been idle for more than 10mins).
I am not sure how is it diff from status.online then.
[![enter image description here][2]][2]
Here, idle is always false when user is online. I need it to be based upon the user activity.
Heres the server side code :
Meteor.publish('usersIdle', function(id){
if(this.userId){
let users = DTU.find({dTId : id}).fetch();
let dUId = _.pluck(users, 'userId');
console.log(UserStatus.connections.find({userId : {$in : doubtUsersId}, idle : false}).fetch())
return UserStatus.connections.find({userId : {$in : doubtUsersId}});
}
});
But here the 'idle' field is defined in the object.
Once you add the package, you have UserStatus object that is made available on the client side (and the server, but as an example, lets look at the client side object).
A typical scenario would be:
Once the user logs in successfully, call UserStatus.startMonitor() which will listen to key presses, mouse clicks.
Once the user logs out, call UserStatus.stopMonitor() to stop monitoring.
You then have an UserStatus.isIdle() reactive var that tells you whether that particular user is idle or not. You may use this status - for example, to log out the user. The same is also available on the server side. I'm not sure if you should explicitly write the status to Meteor.users.status.idle though.
You can check out the demo application here. It's source code is here

Game Maker - Turn On/Off Sound

What I have
I have two rooms: rm_home and rm_options. I have a sound: snd_Bgm. And, I have three objects: obj_bgm, obj_BtnOnClicked, and obj_BtnOffClicked.
What I want is very simple
Player can turn on/off the snd_Bgm.
What I have done
In obj_bgm, I have these events:
Create Event: set var global.sound to 1
Room Start: stop sound snd_Bgm; if global.sound == 1 then play sound snd_Bgm
In obj_BtnOnClicked, I have these events:
Left-Pressed Event: play sound snd_Bgm; set var global.sound to 1
In obj_BtnOffClicked, I have these events:
Left-Pressed Event: stop sound snd_Bgm; set var global.sound to 0
I put obj_BtnOnClicked, and obj_BtnOffClicked in rm_options, which can be accessed from rm_home. Then, I put obj_bgm in rm_home.
This is the problem
When game start, it will show rm_home and plays the snd_bgm. I go to rm_options, then click the obj_BtnOffClicked to turn off the sound, so the sound is off. But, when I go back to rm_home, the sound is on again.
What I think
I shouldn't put Create Event: set var global.sound to 1 in obj_bgm, because when rm_home start, it takes the value of var global.sound from Create Event. But, if I put Create Event in obj_BtnOnClicked or obj_BtnOffClicked, it shows a Get Error.
What should I do? Please explain your answer. Thanks.
Are your rooms and your variables persistent ?
If rm_home is not persistent, it will restart every time you leave it. So every object placed in that room will be reset, including obj_bgm, which sets your sound variable to 1. I think this is the reason the sound restarts when you come back to rm_home.
If you still want to reset the room but not this particular object, you can make it persistent. You can do it either by ticking the box in the object or through code.
If you put the create event in a button object, it will not be read until you go to the options room. So when the obj_bgm tries to set it to 1, it does not exist yet. I believe it causes the error.
I make these remarks on assumptions, but I would need to see your code or your error message to help you further.

How to achieve Delay in State Machine Workflow

Windows Workflow State Machine
has a state (AwaitingFeedbackState) with two transitions.
Transition 1) awaiting receive message from client within "Trigger" body, email activity within "Action"
Transition 2) CheckReminderEnabledActivity within "Trigger" body, delay and email reminder activity within "Action"
when CheckReminderEnabledActivity is true, the behaviour works fine, the work flow goes into delay but if it is
set to false, the workflow infinity loops in AwaitingFeedbackState, keeps hitting CheckReminderEnabledActivity.
Is there a way to disable this transition if CheckReminderEnabledActivity is set to false when process enters CheckReminderEnabledActivity for
the first time ?
I have fixed this by bringing in the delay and send reminder activity within the trigger body and have now also added if else as well. In the else body I have added a custom bookmark as per example here
https://code.msdn.microsoft.com/Windows-Workflow-50c3fba5

Resources