Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently November 18th, 2024, 11:37 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Triggering Opus action on close of other app
PostPosted: February 8th, 2007, 9:05 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi

I'm working on a pub in Pro XE 5.5 that will use a small executable utility app summoned by using a button. I can hopefully run the executable on top of the runtime Opus page, but when the executable app is closed, I need for the main (Opus) pub to know that, and thereby trigger a page refresh action. (The other app changes some of the storage .txt files in My Documents, after which the Opus page needs to refresh to show these changes).

I can't think of any way to trigger the refresh action based on the closing/exiting of the other app.

Any ideas would be appreciated.

Kind Regards,

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: February 9th, 2007, 12:12 pm 
Offline

Joined: November 11th, 2004, 1:43 pm
Posts: 172
Location: Buckinghamshire, UK
Easiest: if that utility keeps some trace logs when it is running, you can point opus pub to look at the status of those logs (timestamps) or if they exists.

edit
For your case, the utility is writing to a file, hence action to keep an "eye" on the file being changed and do the refresh... Not at my Opus machine this morning.. will look at it when I get I have a chance, and if this ping hasn't been answered.


Slightly Harder: for situations where no trace files are maintained. Depending on platform, "psinfo" can be used to see what processes are running and the utility I believe should register as a process hence you will be able to see either active or not, and the publication to perform required tasks.
google psinfo for the utility.
Some scripting (files read/write) will be rqrd for this kind of checks..


For this message eomc40 has been thanked by : mackavi


Last edited by eomc40 on February 9th, 2007, 4:54 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: February 9th, 2007, 2:12 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi eomc40

Thank you for your reply.

Since I needed some actions to be done that I was unable to achieve in Opus, I'm in process of creating a small utility to add to a pub using REALBasic, which has a super-charged version of Basic programming. I'm too new at Basic programming to know about trace logs, etc. But, your suggestions are leads that I can look into.

The project is a Windows pub, so, whatever is finally utilized would need to work on Windows platforms.

So far, I can easily summon the utility executable as a launch file from within the Opus pub. The issue is that once the utility does its work, I need for the Opus page to refresh, thereby registering the changes achieved by running/closing the utility. I tried looking in OpusScript at "views" (get views, type, etc.) to check if Opus could note when the utility was closed, but with no success. Also, I'm trying to keep it as user-friendly as possible, so I haven't yet wanted to ask the user to refresh the page.

If you have further information, I would be grateful.

Kind Regards,

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: February 9th, 2007, 4:43 pm 
Offline

Joined: November 11th, 2004, 1:43 pm
Posts: 172
Location: Buckinghamshire, UK
Start by tryingg to use the following function
Two options
1). by trace logs I meant the application writing some files as it executes
(please see option two for exceptions considerations). If files are written, you can simply have a loop that checks for existence of xyz files which will mean certain "stage" of your application have executed. and on the app termination, its "sensor" will be seen and the opus will proceed to next task.


2). Refresh()

help file details its usage.
Once you have captured the exit status of the small application then the page can be refreshed, if you have variables within this page then it is more like reading in these once again...
Assume that you can program exceptions within the REALBasic so that your small application does close gracefully or if a failure occurs a tidy up process is in place else, opus will wait forever fo this to complete.


example

Opus calls RealApplication


RealApplication:

exit status 0 (end ok)
writes to file /tmp/finished_ok

exit status n (end with some error)
writes to file /tmp/finished_failure

Opus
"Listens" to the existense of /tmp/finished_ok or /tmp/finished_failed

When these files become available, then the calling Opus page

- saves all the populated variables
-refreshes itself
-read's in the variable
-proceed


For this message eomc40 has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: February 9th, 2007, 5:17 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi eomc40

Thank your for your reply.

I checked the REALBasic user guide for trace logs, and nothing even similar comes up. So, I'm not sure where to locate these.

The project I'm working on may be familiar to you. It's an upgrade of the pedigree tool I've worked on since last year, since I will be giving copies to a social work class I'm invited to do a guset lecture for next month.

For whatever reason, Opus won't successfully copy the 200 or so .txt files holding positions of symbols from one folder to another. (My limited skill at OpusScripting created these many files, whereas an expert scripter probably could have created all of them in one script object. But, I've got to work with what's available.) They copy, but some contents are blank and the files in the "copied" folder won't work to reset the symbols on the diagram. After every tweak I tried failed, I decided to try to learn REALBasic to create a small utility to copy and re-open these files. So, Opus no longer needs to do this job: rather the utility is summoned by a launch file action. The utility is coming along well: it's pretty simple, but does the job.

Probelm is that once the files are copied around, to get the diagram to reset using the new positions in the copied files, the Opus diagram page has to reset. Doesn't look professional to have the user refresh via button. Wanted to automate this by having Opus read that the utilty is closed (or the files now copied) and refresh the page. Detecting if the files simply exist doesn't work, since they already exist in the default save folder for Opus, and the copy destination folder is named by the user when they create the copies in runtime. I tried items "variable changed," and this didn't work.

So, while it seems the simplest of features to be able to save, copy re-open, I can't yet get it to work.

Absent this feature, the end-user is stuck with having the capability to work on only one pedigree diagram, rather than saving one, opening a new one, working on multiple ones, etc.

My best option is to try to figure out if I can locate any "footprint" that the utility's closing leaves, that Opus can then read, to trigger the diagram refresh.

Kind Regards,

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: February 9th, 2007, 5:53 pm 
Offline

Joined: November 11th, 2004, 1:43 pm
Posts: 172
Location: Buckinghamshire, UK
Program walk-through

Opus publication starts

User either
1). This is the very first time user has used the publication and will be creating a repository directory for his/her diagrams
i.e. c:\my_documents\eomc40

2). Has previously created some diagrams in folder
c:\my_documents\eomc40\project1
c:\my_documents\eomc40\project2
c:\my_documents\eomc40\project3
c:\my_documents\eomc40\project4



With these scenarios, when I look at option 1, all I will enter is my repository directory name "eomc40", the application will hence work clevery as follows.
As well as creating the directory eomc40, it will also create directory
c:\my_documents\eomc40\working_directory within which any of my current positional data will be retained. Once I am happy with my built data, it will ask me for a project name which I will enter as "ProjectX", at which point all the positional data files will be copied to this designated project. for the current runtime, my opus page will still display the diagrams as per working_directory files.
so far my directory is as follows


c:\my_documents\eomc40
c:\my_documents\eomc40\working_directory
c:\my_documents\eomc40\ProjectX

On exit, pub will ask me if I need to save what is on my display... either save or exit.

Second scenario

I fire up the publication, the pub realises I already have a directory tree build with one project. Which I can choose and load. If I choose to load my current pub, then, what will happen is that the contents of my ProjectX directory will be copied to the working_directory, and the page setup for me, again, can save (to new or exisiting) or not as the case may be.

Above will simplify the storage of your data.


Back to problem in hand.

At load time (publication load time), and the use selects project they are to work with, you can read in timestamp details of the files i.e. the creation time/modification time. This will hence be the markers for you next time you use the Realbasic application to copy files over.

If files are changed and are copied, then, it means the timestamp details will change hence the refresh operation can be called.

better still

"touch" a file to the repository directory, start up the RealBasic program which should at the end delete the "touched" file

opus checks (loop) for existence of the "touch" file. if exists, then we still running RealDasic, if not, we assume Realbasic has finished and deleted it, hence we can continue...

"touch"
Code:
var textObj = OpenFile("c:\my_documents\eomc40\working_directory \RealBasic_trace_log.txt")
textObj.Close()


a loop will use FileExists( Filename ) function

Code:
while ( FileExists( textObj ) {
  do this.. wait... if not will continue after last "}"
}


the status at this point means a refresh is required, again, save any variables, refresh page and read in variables again, re-dsiplaying the page...


P.S. Thinking on the hoof so, my choice of commands may need adjusting. One thing I know for sure, you might need to use
Code:
wait()
between creating file, starting RealBasic and checking for the file existence


For this message eomc40 has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: February 9th, 2007, 6:36 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi eomc40

Again, thank you for your help.

I'm going to need to "digest" what you've written, see if I can implement it.

Meanwhile, I did learn that REALBasic has a couple of event commands that may enable generation of a log file upon opening and closing. I'm trying to figure this side out, if needed.

Kind Regards,

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: February 10th, 2007, 2:19 am 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi

An update: some progress

The easiest way to do this, so far, is to have Opus write a text file to the Documents directory (SYSTEM_DOCUMENTS_DIR), the have the REALbasic utility delete this file upon closing. Opus can check if the file exists, which, once the utility closes, no longer exists. Then, if the file no longer exists, Opus can trigger a page refresh.

However, I've "backed myself into a corner." The only way this works is for for Opus to keep checking, using a ticker, and perpetually refreshing.

The good news is that I can code the RB utility to create or delete a file on opening or closing that Opus can check to see if it exists.

I need to do some more figuring on how to get it only to refresh the page once, after the utility is used, rather than endless checking and refreshing. So far, the logic has escaped me.

Any suggestions welcome.

Kind Regards,

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: February 10th, 2007, 4:57 pm 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 511
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
Can you get your Real basic application to write to the registry when it closes, then read the registry key in Opus?

_________________
Whoever designed this, never actually used it!


For this message sandyn has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: February 10th, 2007, 5:30 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi

Thank you for your reply.

Checking the REALbasic user's guide, it apperars that a registry item can be added, though I have yet to figure out the technique .

It would be easier to have simply used the copy files feature in Opus to allow the end-user in runtime to copy, using a wildcard, all the text files from the storage folder in My Documents to another storage folder.

However, when I do this, the files don't copy correctly. Strangely, data is missing. Files copy back and forth, but some are empty. Perhaps, the text files are not closing properly while the pub is viewing in runtime.

So, I've tried to create this work-a-round using a utility, created in REALbasic, to do mainly the same thing, but hopefully get faithful copies with all data. Problem is that the Opus page, to update by using the newly copied data files, needs to refresh. It needs to know when to refresh, for example after the utilty is used and closed.

So far, this necessitates constant checking, using a ticker, to see if the file (or registry key?) has been changed or deleted. I need to find a better trigger. It would be great if I could build a trigger into the utility, for example, that would, upon closing, pass a parameter to cause the Opus page to refresh. I can't guess how Opus would receive such a passed parameter or what shape it would take. However, that's probably not possible, or, if it is, will need to await my getting far more skilled at REALbasic coding.

Ugh!

Thanks again for your suggestion. I'll keep at it.

Kind Regards,

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: February 10th, 2007, 7:52 pm 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 511
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
I think your problem is almost identical to the problem I am currently having. I have an external EXE created in C#. It is launched by Opus and monitors the status of an interface card. When the interface card is triggered by a passive IR detector, the C# program sets a variable "Alarm Status". I want Opus to somehow detect this event. What I am currently investigating is using the clipboard to transfer the status and it works OK, but I have the same problem, how do I then get opus to monitor the clipboard without using the ticker. I think it's a fundamental problem since Opus is event driven, but the external program needs to generate an interrupt??

_________________
Whoever designed this, never actually used it!


For this message sandyn has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: February 10th, 2007, 8:31 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi

The good news is that if one of us comes up with a solution, it may benefit the other.

As of yet, I can't figure out a good way to have Opus "listen" and monitor a change either in the RB utility (for example, closes) or an added or deleted file or variable in the registry, without a constant ticker checking for these.

I'll keep trying to brainstorm it, and should any good ideas come about, post you.

Kind Regards,

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: February 11th, 2007, 12:12 am 
Offline

Joined: November 11th, 2004, 1:43 pm
Posts: 172
Location: Buckinghamshire, UK
Here's a sample of how you can achieve this

pub: REAL
Chapter 1
Page: PageCallingReal


For this I have created a starting point of page on-show to do the following
1). Create the touch file to be used by the RealBasic program at
the end of its execution.This file will be deleted by the RealBasic program
signalling a change in variable is_FileExist that results in the page being refreshed.

Code:
   textObj = OpenFile(SYSTEM_PUBLICATION_DIR + "\\" + "RealFile.log",false);
   textObj.Close()


This piece of code, can also be used at the point where you just about to call RealDasic program. In this case however, it simulates a file create each time the page is "shown"

2). Trigger: Variable changed
variable: is_FileExist
This will initially be set to 0, as a page variable, will be used by the script of the button.

3). Button: A Click: Denote file being deleted

This has two actions, changing the variable as of when a successful deletion of the file has been achieved.
code below

Code:
if(DeleteFile(SYSTEM_PUBLICATION_DIR + "\\" + "RealFile.log",false)) {
   Debug.trace("Success\n")
   is_FileExist = 1
} else {
    Debug.trace("Failed\n")
}



summary: The mentioned loop to check status of the file is handled here by the button being the action deleting the file.. but a while loop can still be used as follows

create a page level script object and have the following code

Code:
while ( FileExists( SYSTEM_PUBLICATION_DIR + "\\RealFile.log" )) {
  //sleep for a while
  wait (0.5)
  Debug.trace("File exist\n")
}
is_FileExist = 1



At this point after the "}", once the file has been deleted then that loop doesn't complete the test criteria of file exisiting hence the variable will be changed and the page will be "refreshed"
I have commented the scripts part in the pub, if you need it, remember the buttons action of changing the variable becomes redundant.
Hope you will be able to adopt this in your publications


You do not have the required permissions to view the files attached to this post.


For this message eomc40 has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: February 11th, 2007, 12:48 am 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi eomc40

Thank you for this brilliant solution! It will take me some time to figure it out thoroughly and implement it.

I'll keep you posted, and may need to ask a question or two as I go along.

Again, thanks very much.

Kind Regards,

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: February 11th, 2007, 6:20 am 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi eomc40

I've almost got everything working OK. The scripting you provided works perfectly, and I've adapted and got it to work in the pub.

There seems to be a problem with the refresh itself.

All the files that the REALbasic utility needs to copy are copied, except the one text file which contains all of the line rotation positions and angles (you will probably be familiar with this line rotation since you had helped with the script for it).

This .txt file is in the same folder as all the other files. The .txt file itself is copied, but it's empty, no data in it.

If I experiment by adding a button to test only the refresh feature (not summon or use the REALbasic utility or even make copies), it produces the same issue--this one .txt file after refresh is empty of contents. The contents don't seem to survive a refresh. If you navigate away from and then return to the page (normal page use) or close and re-open the page, it works fine, just not when refreshed.

This is a great mystery! I can't figure it out. I'm not sure how to get the refresh feature to work properly (the other files are fine).

Any suggestions about getting this file's contents to survive refresh would be appreciated.

Again, thank you for this brilliant solution.

Kind Regards,

_________________
Stephen


For this message Stephen has been thanked by : mackavi


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group