loading
 
importing variables into roborealm
nav jan from India  [9 posts]
8 year
i have generated an executable file of a python code.then i called that .exe file from roborealm using EXECUTE_PROGRAM. i need to access the result from .exe file into ROBOREALM.
My issue is how to use variable value (generated in .exe file ) into roborealm.
Please give suggestions.
Steven Gentner from United States  [1446 posts] 8 year
If you read the docs at

http://www.roborealm.com/help/Execute_Program.php

you will read about the 'Receive sequence'. Entering something like

[program_response]<cr><lf>

would enter your programs output that it prints to stdout into the 'program_response' variable. Note I just made that variable up ... you can call it anything you want.

Or do you need to transfer binary data?

STeven.
nav jan from India  [9 posts] 8 year
i just want to update a roborealm variable with integer value like either 1 or 2...
one more confusion..please clarify..
whatever i print in exe file , get stored in "program_response " variable in roborealm?
Thankss alot for  your reply and help
Steven Gentner from United States  [1446 posts] 8 year
Yes, you can use 'print 1' or 'print 2' in your app to output text that then gets stored in the variable ... give it a try!

STeven.
Steven Gentner from United States  [1446 posts] 8 year
Make that

print '1\r\n'

based on the receive sequence (forgot the newline).

STeven.
nav jan from India  [9 posts] 8 year
thanks alot for your help.i got it working.now, i m able to receive values into roborealm variable..but i encountered another issue that the value comes into roborealm when that exe. file is called next time..means 1st time exe. is called , it runs but it does not update the roborealm variables,..when again ,as that exe file is called it updates the roborealm variable with last result of exe..please provide the solution to this problem
Steven Gentner from United States  [1446 posts] 8 year
The order of the modules is relevant ... I can't tell if that is your issue unless you post your robofile. Its also possible something else is going on but I can't tell since I'm not sure what you are doing. Can you post your robofile? I don't need the file you are executing though as I can simulate those results.

STeven.
nav jan from India  [9 posts] 8 year
in the file, pop4.exe(created from pop4.py file,attached here) is called upon motion detection.if user selects YES ,1is returned in RR variable res. if user selects NO ,2 is returned in variable res. next res value is checked using if condition...if user selects YES ,another exe file(a7) is called which again gives output either 1or 2 similar to pop4 code. a7 return is taken into res1 variable. next if res1 is 1 COG is calculated and has to be transmitted using serial module, else notjhing to be done. here, various variables like decision has been used just to check the results(no use in main algo)
nav jan from India  [9 posts] 8 year
in the file, pop4.exe(created from pop4.py file,attached here) is called upon motion detection.if user selects YES ,1is returned in RR variable res. if user selects NO ,2 is returned in variable res. next res value is checked using if condition...if user selects YES ,another exe file(a7) is called which again gives output either 1or 2 similar to pop4 code. a7 return is taken into res1 variable. next if res1 is 1 COG is calculated and has to be transmitted using serial module, else notjhing to be done. here, various variables like decision has been used just to check the results(no use in main algo)

code for pop4.exe is(exe generated from python code as below)
from Tkinter import *
from tkMessageBox import *
def close_after_2s():
    root.destroy()
if askyesno('MOTION DETECTED!', 'Do You Like To Trigger'):
        print '1\r\n'
else:
        print '2\r\n'
program.robo
Steven Gentner from United States  [1446 posts] 8 year
Can you check quickly what happens when you select the "wait for program exit" on the second execute? You have it on the first but not on the second.

Also, select the "latch" condition for the first If statement otherwise even while movement is happening the scripts will be run. Using the latch forces the movement to stop and then start again before those python files are executed.

See if that  helps ...

STeven.
nav jan from India  [9 posts] 8 year
yes sir!
i m informing u after testing your suggestions
thanks for your support
nav jan from India  [9 posts] 8 year
hello sir!
i m unable to get the output of pop4.exe on execute program console on my laptop...i m unable to understand the problem. can u please check the attached program on your end and see if correct results coming.
i m very grateful to u for your help.
do roborealm get corrupt sometimes??
code for pop4 is here(python file)..u may simulate with ur .exe
from Tkinter import *
from tkMessageBox import *
def close_after_2s():
    root.destroy()
if askyesno('MOTION DETECTED!', 'Do You Like To Trigger'):
        print '1\r\n'
else:
        print '2\r\n'
        

program.robo
nav jan from India  [9 posts] 8 year
hi!
i am not getting return value into rr variable from execute program on none systems of mine.
please help me out
please provide me with example code or please  check my above program
nav jan from India  [9 posts] 8 year
hello
i am now getting the stdout data of exe file into roborealm variable..but the problem exists.the execute program loads the data into rr variable next time it reaches to execute exe file rather than at instant.
when   ''wait for program end " is selected, the stdout data is not coming(neither times showing on execute  program console)
please help me out with the issue.
i have provided the codes
Steven Gentner from United States  [1446 posts] 8 year
The Execute module wasn't written to accept input not immediately available (such as a person typing in a response). We've re-ordered the module and confirmed that it now works with your python script. Can you download the latest version and give things a try again?

Note, the popup request will stop the pipeline processing which will make the entire app appear frozen until someone provides input.

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index