Sign in to follow this  
Guest andrewluck

Python and SendMessage function

Recommended Posts

Just started looking at Python to see what I can do with it. Checking the Scripting manual from TRI, p64, which describes the SendMessage function refers to Appendix B which should contain 'A complete list of system and data tags'. Unfortunately, this appendix is missing. Is this information available from anywhere else?ThanksAndrew Luck18 miles SW EGSH

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Andrew, try looking at Yackster's source code. Although written for FLyscripts, it might have some lines that provide some clues. Also,I remember vaguely that the SDK has similar functions. It may also provide some cluses. I've been studying ways to use python also, and find it very exciting. tony

Share this post


Link to post
Share on other sites

TonyThanks for the hints.I'm thinking that PMDG must have gathered a quantity of design notes and documentation from Rich in the process of building their projects. Maybe a note to them.Andrew Luck18 miles SW EGSH

Share this post


Link to post
Share on other sites

Lefteris is always around. I am sure he's got the answers.tony

Share this post


Link to post
Share on other sites

Thanks for that, Tony ;-).In fact, Chris Wallace had posted something to that effect (he was to publish a collection of all systems and datatags that he knew of).I am not sure if he did publish them or not - an email to him would actually be the best solution...Cheers,

Share this post


Link to post
Share on other sites

LefterisAhhh! as always, a man with the answers :-). Thanks for that.While I have your attention I'd like to thank you for the contribution that you've made to Fly! over the years. The 757 is awesome.Andrew Luck18 miles SW EGSH

Share this post


Link to post
Share on other sites

TonyDecided to start by looking at the Taking Chances scripts, figure out how they're supposed to work and then try to find what's stopping them from working correctly.At least Python now appears to compile Adventure scripts OK, not sure about global ones yet. Today has been a steep learning curve looking mainly at Taking Chances 2. At the moment I'm trying to debug why the OK buttons on the dialog boxes don't function. The event handler procedure is being called OK but nothing happens when the button is depressed.Hopefully I'll have some time during the week to take this further.Andrew Luck18 miles SW EGSH

Share this post


Link to post
Share on other sites

Careful, Andrew. Verify that you can convert py files into pyc when you place them in the global folder. Some people had difficulty getting FLY2 to do it( bug?). I don't remember if it makes a difference, once you have a pyc file. Anyway, make sure you can work with global, assuming that you will not be using the "scenario"--this is where a pyc file is placed for the "adventure" mode.tony

Share this post


Link to post
Share on other sites

TonyAt the moment I'm working with Adventure files and most of the time they convert to pyc files just fine. If they don't then you can just delete the pyc file and it'll recompile next time you enter the adventure. I haven't tried global scripts recently, haven't got a use for them at present.Taking Chances 2 is mostly working, I've got some problems with the UI. Also, half-way through all systems are supposed to be restored to working order, however, once I didn't get the electrical system back and another time didn't get the GPS. I'd be interested in your experiences with this one.Andrew Luck18 miles SW EGSH

Share this post


Link to post
Share on other sites

Andrew-you are certainly welcome! :-)Believe me, my contribution is peanuts compared to some other developers around here... I won't name names. They all know who they are...Even though I've switched to "the dark side", I'm still around for those who need my assistance...

Share this post


Link to post
Share on other sites

Andrew,Unfortunately, I did not work with taking chances at all, so I can't help you. when I decided to write Autoweather, I simply spent some time studying Python and the rest became easy. Perhaps, you want to state what you want to do, and some of us, especially the Python community can help you. Keep in mind that the Python community is very active and responds immediately to programming questions. I know I had to do it when I could not figure out some database editing issue. They quickly hit me with dozens of wonderful code samples that helped me complete the program quickly.tony

Share this post


Link to post
Share on other sites

TonyIs the code for AutoWeather available? I'd like to take a look.At the moment, the buttons on the UI don't work. Some work last night appears to indicate that the window ID fed to the event handler doesn't match that produced by ID('introwindow') so it's a Fly! interface problem rather than a Python one.Can you run the Taking Chances 2 adventure and let me know what it does on your system?Andrew Luck18 miles SW EGSH

Share this post


Link to post
Share on other sites

Andrew, I've just uploaded Autoweather 1.02, which has the source code as well. Any questions, let me know. I'll try Taking Chances2 and let you know.tony

Share this post


Link to post
Share on other sites

Work continues on the 3 Taking Chances scripts as and when I have the time.I've solved the problem with the UI buttons. The EventHandler function is passed the window ID that's contained within the window template file, not the ID that the window was created with via he OpenWindow function. Also, these scripts all use window id's that contain more than 4 letters. Understanding this has got the initial window OK button working in all three scripts.The third script has a timer window with the code commented out. Enabling this code causes Fly! to crash when loading the scenario. The problem here appears to be that you can't open two UI windows at once. Commenting out the other window means that you can use the timer window. I tried moving the timer window code to the event handler (after the first window closes) but this causes Fly! to lock solid when you try and close the first window. I'm still looking for a solution to this.Many people have commented that the first script doesn't do a lot. This is because the code to turn off the main fuel shutoff valve doesn't work. I've still to find the solution to this although I can kill the engine by turning the ignition switch off.This is an interesting learning experience as I haven't previously used Python. It is pretty intuitive. Any comments / solutions are welcome.Andrew Luck18 miles SW EGSH

Share this post


Link to post
Share on other sites

Does this mean that you got it to work in the global directory?tony

Share this post


Link to post
Share on other sites

Tony--I have a little idea I want to play around with. Could you please email me a copy of the Yakster source. I downloaded it once from Jeff Davis' website, but can't find it on my old computer...and the links are broken at his page to the Yakster stuff.Thanks.WilliamDbilldubiak@earthlink.net

Share this post


Link to post
Share on other sites

TonyNo, these are adventure scripts so they're designed to be attached to scenario's. However, if global scripts still aren't compiling you could always compile it as a scenario and then subsequently move the .pyc file to the global directory.Andrew Luck18 miles SW EGSH

Share this post


Link to post
Share on other sites

I have to admit to being stumped here. I cannot get a Python script to operate the fuel shutoff valve in the Cessna.Here's the device in flyhawk.gas - Fuel Shutoff Valve (used by Scripts) - fSub kill -- connects to Fuel Shutoff Valve -- shut 1 The script is trying to turn this on and off so I'm using the following fragments:# necessary global messagesfuelMessage = Message(MSG_SETDATA, ID('kill'), ID('st8t'))####################################### Turn on/off the fuel shutoff valve######################################def KillFuel(): global fuelMessage fuelMessage["intData"] = 0 fuelMessage["id"] = MSG_SETDATA SendMessage(fuelMessage)def RestoreFuel(): global fuelMessage fuelMessage["intData"] = 1 fuelMessage["id"] = MSG_SETDATA SendMessage(fuelMessage)######################################This code is identical to other functions that control other systems and appear to work OK so I just can't see where the fault lies here. This is about the last problem I have with the supplied Taking Chances scripts so once I get this cracked then I can release the new scripts. Trouble is, I've been looking at this on and off for a couple of weeks now and can't see the solution. Can anyone help?Andrew Luck18 miles SW EGSH

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this