Goal:
"Application A" is running, but the user wants to start "application B". The transition should be seamless by involving as few button presses as possible. So a single press of a button should:
1. close the currently active application
2. change button layout
3. start new application
Eventghost tree design:
My design of the eventghost three basically consists of 3 different folders:
1. "Preset folder". Used to exclusively enable a folder which contains remote key buttons mapped to a unique application.
2. "Context folder". In this folder there are many different folders, one for each application that I want to control. Only one can be enabled at the same time. Each application has macros which functions like an API to the application in question.
3. Global macros. These are functions that does not have buttons mapped. Instead macros in this folder can be called directly by any of the macros in the "Context folder" or "preset folder".
Preferred solution:
In the context folder there are two application: applicationA and applicationB. Each of these applications have macros that correspond to the functions that I need to access using my remote.
ApplicationA implements a macro which is triggered by the event: CloseApplication (used to close the application in question, surprise!). A macro like that also exists in the context folder of ApplicationB. So when the event CloseApplication is trigged, even though it is implemented in each application´s folder located in the "context folder", it practise it will only result in that one macro gets triggeres since only once application folder can be enabled at a certain time in the context folder.
So to enable seamless switching from ApplicationA to ApplicationB the event called CloseApplication is triggered each time a new preset is set. The design of a preset folder may look like this:
- Code: Select all
1. MyRemote.Button.X (event)
2. Trigger event: CloseApplication (implemented in the context folder belonging to ApplicationA)
3. Set exclusive folder to ApplicationB
4. Trigger event: ApplicationB.Start
The problem (I think) is that the CloseApplication event (step 2) does not reach the correct target (ApplicationA). The reason is that the macro which holds the CloseApplication event gets disabled by the "set exclusive folder" action (step 3) before the completion of the triggering of CloseApplication (step2).
The result is that the CloseApplication event actually triggers the CloseApplication implemented in ApplicationB, and in this case we want to start ApplicationB and not close it
Also, I think events are triggered at the end of a execution of macro event though they may be defined to be triggered early in a macro (haven´t checked the EG implementation for that, just my rather random observations). So what I need is a synchronious event, but I don´t think that is available. The closest I get is the "jump to macro action" which are synchroious but can only be used by specifying the exact macro that should be triggered, hence not loosly coupled. I´ve come up with a couple of workarounds:
Workaround 1:
Save the current preset´s macro that is used to exit the application in shared memory, and then execute it when a new preset is launched. Is that even possible?
Workaround 2:
Make all application macros globally available. Have the context folder which contain macros that map a remote button with an application function, and dynamically construct the event string that is used to close the current application. Example:
- Code: Select all
Preset folder:
ApplicationA
close current application by constructing & triggering an event: TriggerEvent(CloseApplication + 'eg.globals.currentApplication')
set global variable: eg.globals.currentApplication = ApplicationA
start applicationA
ApplicationA
close current application by constructing & triggering an event: TriggerEvent(CloseApplication + 'eg.globals.currentApplication')
set global variable: eg.globals.currentApplication = ApplicationB
start applicationB
Context folder:
ApplicationA
myRemoteButton
triggerEvent(ApplicationA.doSomething)
ApplicationB
myRemoteButton2
triggerEvent(ApplicationB.doSomethingElse)
Global macros:
ApplicationA
ApplicationA.Close (event)
ApplicationA.doSomething (event)
...
ApplicationB
ApplicationB.Close (event)
ApplicationB.doSomethingElse
...
Workaround 3:
Store the current preset´s "close application macro" in a variable. Is it even possible?
- Code: Select all
Preset folder:
ApplicationB
execute stored macro (ApplicationA)
change preset to ApplicationB
store ApplicationB´s "close application macro" in variable.
start applicationB
..
