magicgerd Posted December 10, 2011 Report Posted December 10, 2011 Hi Programmers, I hope, anyone of you can help me. I want to use the newweather interface for FS9 within VB6. But I have no idea, how to do. The newweather.h is for C-language. How can I get access to it ? ( I only need ro read all wind layers for now) I hope, someone can help me. Greetings Gerd
Pete Dowson Posted December 10, 2011 Report Posted December 10, 2011 The newweather.h is for C-language. How can I get access to it ? ( I only need ro read all wind layers for now) The NewWeather.h merely describes the structure of the data. Yes, it is in C/C++ terms and can be used directly in a C/C++ program, but surely you can define a similar structure, or at least use it to pull a read memory block apart to get what you want? If there are any terms, like WORD, DWORD and so on you don't know (these are Microsoft defines rather than C or C++) then let me know and I'll explain.. Otherwise it should be pretty clear. Regards Pete
magicgerd Posted December 10, 2011 Author Report Posted December 10, 2011 Hi Pete, thx for the rapid reply. I tried to define the structure I need (I' just interested in turbulences at AC). But what is the read syntx now exactly. I tried the following: ####################################################### Dim dwResult As Long, x As AdvWind If FSUIPC_Read(AW_GETWAT, 16, VarPtr(x), dwResult) Then FSUIPC_Process (dwResult) ####################################################### But the result I expected is not what I get. Althoug there are no turbulences ist shows a value of "2". Here's my definition in VB: ----------------------------------------------------------------------------------------- Public Const AW_GETWAT = &H400000 '// Read set Wind at Type AdvWind Len As Integer '; // Length of this structure in bytes (16) nAfter As Integer '; // Number of layers above this one UpperAlt As Integer '; // Metres Speed As Integer '; // Knots Gust As Integer '; // Max gust speed, knots Direction As Integer '; // usual 65536 = 360 units Turbulence As Integer '; // 0-4 Shear As Integer '; // 0-3 End Type ---------------------------------------------------------------------------------------- What am I doing wrong ??? Thanks in advance Gerd
Pete Dowson Posted December 10, 2011 Report Posted December 10, 2011 I tried the following: ####################################################### Dim dwResult As Long, x As AdvWind If FSUIPC_Read(AW_GETWAT, 16, VarPtr(x), dwResult) Then FSUIPC_Process (dwResult) ####################################################### You are using the older Advanced Weather Interface? Why did you ask about the NewWeather header file, then? If you plan on doing more than one FSUIPC_Read you should do them all in a batch then call FSUIPC_Process, as the latter switches processes every time. Here's my definition in VB:----------------------------------------------------------------------------------------- Public Const AW_GETWAT = &H400000 '// Read set Wind at Type AdvWind Len As Integer '; // Length of this structure in bytes (16) nAfter As Integer '; // Number of layers above this one UpperAlt As Integer '; // Metres Speed As Integer '; // Knots Gust As Integer '; // Max gust speed, knots Direction As Integer '; // usual 65536 = 360 units Turbulence As Integer '; // 0-4 Shear As Integer '; // 0-3 End Type ---------------------------------------------------------------------------------------- What am I doing wrong ??? I don't know VB at all, but are you sure "Integer" is the same as "short" (i.e. 16-bits)? Check that. Otherwise, please do try using the FSUIPC logging facilities to see what data is actually being sent. There are options for logging both reads and writes. For the AWI interface you probably need to log weather too. I can't remember much about that -- it was originally written for FS2000 or FS2002. The NWI is more usually used nowadays. Regards Pete
magicgerd Posted December 17, 2011 Author Report Posted December 17, 2011 (edited) Hello Pete, here's still a problem. I changed my code and now use the NWI. I'm intersted in the turbulences at AC. I read 384 Bytes from &HC0FC using a data structure to get the 24 wind-layers. That works perfect. But my problem is the following: When I set global weather in FS, the turbulences are shown correct : 0 for none, 1 for few, 2 for medium, 3 for heavy and 4 for x-treme. To check it out, I set five wind-layers in FS, setting each to a different value. When I now slew through the layers everything is perfect. But when I set local weather for a special weather-station, the values are incorrect. Example: I place my AC to Frankfurt-Hahn airport and set the 5 layers as described above, setting it to the Hahn weather station. Now the strange thing is: No turb returns 0 ~ light turb returns 0 ~ medium turb returns 1 ~ heavy turb returns 2 ~ x-treme turb returns 3 As you see, all values are minus 1. The other values like wind speed a.s.o are OK. But only using local weather. Using global weather, everything is correct. Now my question: am I doing something wrong or can it be possible, that there is a bug in FSUIPC (I really cant believe that :smile:) ??? Please give me a help. Regards Gerd Edited December 17, 2011 by magicgerd
Pete Dowson Posted December 17, 2011 Report Posted December 17, 2011 Example: I place my AC to Frankfurt-Hahn airport and set the 5 layers as described above, setting it to the Hahn weather station. Now the strange thing is: No turb returns 0 ~ light turb returns 0 ~ medium turb returns 1 ~ heavy turb returns 2 ~ x-treme turb returns 3 As you see, all values are minus 1. The other values like wind speed a.s.o are OK. But only using local weather. Using global weather, everything is correct. The encoding in FSUIPC is identical for GLOB or a real ICAO. It knows no difference, they are just ICAO codes to FSUIPC and are treated the same. So I suspect it is FSX. Have you checked the logging? Compare the wind blocks in the METAR being sent, see if there are differences between the GLOB one and the local one for EDFH. Regards Pete
magicgerd Posted December 17, 2011 Author Report Posted December 17, 2011 So I suspect it is FSX. I'm not using FSX but FS9. So it can't be FSX. Gerd
Pete Dowson Posted December 17, 2011 Report Posted December 17, 2011 I'm not using FSX but FS9. So it can't be FSX. Ah. FS9. You should say. And which version of FSUIPC? That code is 8 years old. I've no idea. I can delve into it but I'm reluctant to change anything that folks have been using and depending on for all that time. Nevertheless the logging is still important. Please do the log and show me what it says it is setting. Pete
magicgerd Posted December 17, 2011 Author Report Posted December 17, 2011 Ah. FS9. You should say. And which version of FSUIPC? That code is 8 years old. I've no idea. I can delve into it but I'm reluctant to change anything that folks have been using and depending on for all that time. Nevertheless the logging is still important. Please do the log and show me what it says it is setting. Pete What do you exactly mean with "logging" ?? I'm usin V 3.99
Pete Dowson Posted December 17, 2011 Report Posted December 17, 2011 What do you exactly mean with "logging" ?? FSUIPC options (in the Modules menu -- take a look one day), Logging tab, log weather. Have you never seen the FSUIPC options? The logging facilities are normally an essential part of developing FSUIPC applications, especially the logging of IPC reads and writes to check that your program is reading / writing the right things. I'm amazed you've never heard of them. There is a Chapter in the user guide about the facilities too. I'm usin V 3.99 Please update to the latest 3.998 version so you are using the same as I. 3.998n is available in the Download Links subforum. Pete
magicgerd Posted December 17, 2011 Author Report Posted December 17, 2011 FSUIPC options (in the Modules menu -- take a look one day), Logging tab, log weather. Have you never seen the FSUIPC options? The logging facilities are normally an essential part of developing FSUIPC applications, especially the logging of IPC reads and writes to check that your program is reading / writing the right things. I'm amazed you've never heard of them. There is a Chapter in the user guide about the facilities too. Please update to the latest 3.998 version so you are using the same as I. 3.998n is available in the Download Links subforum. Pete OK, I will use the log-option and send you the log. Maybe tomorrow, 'cause today I will have not enough time to do so. Gerd
Pete Dowson Posted December 17, 2011 Report Posted December 17, 2011 OK, I will use the log-option and send you the log. Maybe tomorrow, 'cause today I will have not enough time to do so. Don't send anything -- a weather log will be huge and I'm not ploughing through it all. Just find the entries showing the weather you are setting and reading for Global and that you are setting and reading for the specific weather station you are at. Then paste both extracts into a message here. I think you should also compare what you get when trying to set the same things via the FS weather dialogues. That is how I derived all this stuff in the first place. Pete
magicgerd Posted December 17, 2011 Author Report Posted December 17, 2011 Hi Pete, I did the following: I set 5 Windlayers in FS using global weather. 1. TOP: 2000 ft ~ Windspeed: 10 kts ~ No TURB 2. TOP: 5000 ft ~ Windspeed: 20 kts ~ TURB light(1) 3. TOP: 6000 ft ~ Windspeed: 30 kts ~ TURB: medium(2) 4. TOP: 7000 ft ~ Windspeed: 40 kts ~ TURB: heavy(3) 5. TOP: 8000 ft ~ Windspeed: 50 kts ~ TURB: x-treme(4) Then i did the same, using Hahn weather station. Here is the log for Global settings: 8679703 Clear All Weather requested: external weather discarded 8680047 >Change: surface wind: to alt=2000ft AGL, dir=0T, vel=10.0, gust=0.0, turb=0, shear=0, var=0.0, Flags=0, AMSL=3560ft 8680047 >Change: wind layer 0: to alt=5000ft AMSL, dir=1T, vel=20.0, gust=0.0, turb=1, shear=0, var=0.0 8680047 >Change: wind layer 1: to alt=6000ft AMSL, dir=0T, vel=30.0, gust=0.0, turb=1, shear=0, var=0.0 8680047 >Change: wind layer 2: to alt=7000ft AMSL, dir=0T, vel=40.0, gust=0.0, turb=2, shear=0, var=0.0 8680047 >Change: wind layer 3: to alt=8000ft AMSL, dir=0T, vel=50.0, gust=0.0, turb=3, shear=0, var=0.0 8680047 >Change: Visibility[0]: range=70.0sm (112654m), from=0ft, to=15000ft 8680047 Results: Visibility[0]: range=70.0sm (112654m), from=0ft, to=15000ft 8680047 Results: FS98 Wind0: ground (1247ft) to 2316ft AGL, dir 1M, vel 10, gust 0, turb 0 8680047 Results: FS98 Wind1: 3560ft to 5000ft AMSL, dir=0T, vel 20, gust 0, turb 64 8680047 Results: FS98 Wind2: 5000ft to 6000ft AMSL, dir=0T, vel 30, gust 0, turb 64 8680047 Results: FS98 Wind3: 6000ft to 7000ft AMSL, dir=0T, vel 40, gust 0, turb 128 And here the same setting for Hahn weather station: 8858843 Clearing All Weather 8858875 Weather cleared by user action 8858875 External weather discarded 8858875 >Change: surface wind: to alt=2000ft AGL, dir=0T, vel=0.0, gust=0.0, turb=0, shear=0, var=0.0, Flags=0, AMSL=3546ft 8858875 >Change: No upper wind layers 8858875 >Change: Visibility[0]: range=70.0sm (112654m), from=-4920ft, to=15000ft 8858875 Results: Visibility[0]: range=70.0sm (112654m), from=-4920ft, to=15000ft 8858875 Results: FS98 Wind0: ground (1227ft) to 2320ft AGL, dir 0M, vel 0, gust 0, turb 0 8858875 Results: FS98 Wind1: 3550ft to 215010ft AMSL, dir=0T, vel 0, gust 0, turb 0 8858875 Results: FS98 Wind2: 0ft to 0ft AMSL, dir=0T, vel 0, gust 0, turb 0 8858875 Results: FS98 Wind3: 0ft to 0ft AMSL, dir=0T, vel 0, gust 0, turb 0 8916640 Results: FS98 AmbientWind at PlaneAlt=8507: dir 0T, vel 40 8916640 >Change: surface wind: to alt=1146ft AGL, dir=0T, vel=5.2, gust=0.0, turb=0, shear=0, var=0.0, Flags=0, AMSL=2690ft 8916640 >Change: wind layer 0: to alt=5000ft AMSL, dir=0T, vel=10.4, gust=0.0, turb=0, shear=0, var=0.0 8916640 >Change: wind layer 1: to alt=6000ft AMSL, dir=0T, vel=15.6, gust=0.0, turb=0, shear=0, var=0.0 8916640 >Change: wind layer 2: to alt=7000ft AMSL, dir=0T, vel=20.9, gust=0.0, turb=1, shear=0, var=0.0 8916640 >Change: wind layer 3: to alt=8000ft AMSL, dir=0T, vel=26.1, gust=0.0, turb=1, shear=0, var=0.0 8916640 >Change: Visibility[0]: range=70.0sm (112654m), from=1640ft, to=15000ft 8916640 Results: Visibility[0]: range=70.0sm (112654m), from=1640ft, to=15000ft 8916640 Results: FS98 Wind0: ground (1227ft) to 1460ft AGL, dir 1M, vel 5, gust 0, turb 0 8916640 Results: FS98 Wind1: 2690ft to 5000ft AMSL, dir=0T, vel 10, gust 0, turb 0 8916640 Results: FS98 Wind2: 5000ft to 6000ft AMSL, dir=0T, vel 16, gust 0, turb 0 8916640 Results: FS98 Wind3: 6000ft to 7000ft AMSL, dir=0T, vel 21, gust 0, turb 64 Regards Gerd
Pete Dowson Posted December 17, 2011 Report Posted December 17, 2011 Here is the log for Global settings: 8680047 >Change: surface wind: to alt=2000ft AGL, dir=0T, vel=10.0, gust=0.0, turb=0, shear=0, var=0.0, Flags=0, AMSL=3560ft 8680047 >Change: wind layer 0: to alt=5000ft AMSL, dir=1T, vel=20.0, gust=0.0, turb=1, shear=0, var=0.0 8680047 >Change: wind layer 1: to alt=6000ft AMSL, dir=0T, vel=30.0, gust=0.0, turb=1, shear=0, var=0.0 8680047 >Change: wind layer 2: to alt=7000ft AMSL, dir=0T, vel=40.0, gust=0.0, turb=2, shear=0, var=0.0 8680047 >Change: wind layer 3: to alt=8000ft AMSL, dir=0T, vel=50.0, gust=0.0, turb=3, shear=0, var=0.0 And here the same setting for Hahn weather station: 8916640 >Change: surface wind: to alt=1146ft AGL, dir=0T, vel=5.2, gust=0.0, turb=0, shear=0, var=0.0, Flags=0, AMSL=2690ft 8916640 >Change: wind layer 0: to alt=5000ft AMSL, dir=0T, vel=10.4, gust=0.0, turb=0, shear=0, var=0.0 8916640 >Change: wind layer 1: to alt=6000ft AMSL, dir=0T, vel=15.6, gust=0.0, turb=0, shear=0, var=0.0 8916640 >Change: wind layer 2: to alt=7000ft AMSL, dir=0T, vel=20.9, gust=0.0, turb=1, shear=0, var=0.0 8916640 >Change: wind layer 3: to alt=8000ft AMSL, dir=0T, vel=26.1, gust=0.0, turb=1, shear=0, var=0.0 I thought you said the only thing different was the turbulence? Seems that the wind speed is also different. I think I need to see exactly what you are writing. Could you also enable IPC write logging, and cut out the sections where you write those wind layers each timer, please? Meanwhile you should note that localised weather is almost impossible to control exactly. There are all sorts of terrible bugs in the FS9 and FSX weather system. This is why the better weather programs like Active Sky provide a global mode facility (and in fact default to that mode in latest releases). Regards Pete
magicgerd Posted December 17, 2011 Author Report Posted December 17, 2011 Hi Pete, I do not write anything, I just read the weather. I made the settings via FS weather settings only. regards Gerd
Pete Dowson Posted December 17, 2011 Report Posted December 17, 2011 Hi Pete, I do not write anything, I just read the weather. I made the settings via FS weather settings only. Ah. Two things there: First, the dialogues for weather settings do not do what you think they do -- as you can see in fact, from the wind speeds and altitudes you get. Second, the weather changes as soon as you exit the dialogues. You can't do much about that. Global weather is more predictable because it isn't influenced by other weather stations. However, unlike FSX, FS9 has no global weather mode, and the weather soon localises in any case. In any case, if you are simply reading the details from FSUIPC then you are reading what FSUIPC gets from the FS internal structures which are created by FS, not by FSUIPC. You wouldn't want FSUIPC to lie to you would you? For actually using the NWI, as a test, I've just made two small Lua plug-ins which use the NWI to set 5 wind layers only, one for "GLOB" and the other for, in my case, EGCC. Just change EGCC to wherever you are -- make sure it is a weather station, though, AND that you are positioned actually AT the station. Often the weather station is off the airport a mile or more. Try these plug-ins yourself. Just put them into the Modules folder and assign two keypresses or buttons to them. You'll see they are identical, an attempt to set 5 layers with increasing speeds, directions and turbulence. All get set fine excepting turbulence which is adjusted differently in the two cases: Global 0,1,2,3,4 becomes 0,0,1,2,4 Local 0,1,2,3,4 becomes 0,0,0,1,3 Interesting, true. But I'm afraid there's nothing I can do about it. Especially not after 8 years when it is used by so many applications. WthrGLOB.lua NW_SETEXACT = 2 -- Set weather bypassing user filtersNW_CLEAR = 3 -- Clear all weather, but leave dynamic setting aloneNW_DYNAMICS = 4 -- Set weather dynamics (from uDynamics value)-- Set dynamics to zero, then clear all weatheripc.writeUW(0xC80C, 0)ipc.writeUW(0xC800, NW_DYNAMICS)ipc.sleep(1000)ipc.writeUW(0xC800, NW_CLEAR)ipc.sleep(1000)offs = 0xc8fcturb = 0alt = 3000spd = 10dir = 30while turb < 5 do ipc.writeStruct(offs, "4UW", alt / 3.28084, spd, 0, dir * 65536 / 360, "2UB", turb, 0, "3UW", 0, 0, 0) offs = offs + 16 alt = alt + 3000 spd = spd + 10 dir = dir + 10 turb = turb + 1endipc.writeUD(0xc8f8, 5) -- 5 layersipc.writeStruct(0xc800, "2UW", NW_SETEXACT, 0, "1UD", 0, "4STR", "GLOB")[/CODE][u][b]WthrEGCC.lua[/b][/u][CODE]NW_SETEXACT = 2 -- Set weather bypassing user filtersNW_CLEAR = 3 -- Clear all weather, but leave dynamic setting aloneNW_DYNAMICS = 4 -- Set weather dynamics (from uDynamics value)-- Set dynamics to zero, then clear all weatheripc.writeUW(0xC80C, 0)ipc.writeUW(0xC800, NW_DYNAMICS)ipc.sleep(1000)ipc.writeUW(0xC800, NW_CLEAR)ipc.sleep(1000)offs = 0xc8fcturb = 0alt = 3000spd = 10dir = 30while turb < 5 do ipc.writeStruct(offs, "4UW", alt / 3.28084, spd, 0, dir * 65536 / 360, "2UB", turb, 0, "3UW", 0, 0, 0) offs = offs + 16 alt = alt + 3000 spd = spd + 10 dir = dir + 10 turb = turb + 1endipc.writeUD(0xc8f8, 5) -- 5 layersipc.writeStruct(0xc800, "2UW", NW_SETEXACT, 0, "1UD", 0, "4STR", "EGCC")[/CODE]Have fun!Pete
magicgerd Posted December 18, 2011 Author Report Posted December 18, 2011 Hi Pete, I've been thinking about the problem for a while. Now I noticed something. When I open the FS weather-dialogue and set 5 wind-layers with 0,1,2,3,4 turbulences and confirm with "OK", FS stores these values somewhere in memory. I think you will agree until here. Now I try to read these values with FSUIPC and I get wrong values, like 0,0,1,2,4 That means, FS stored false values in memory, because FSUIPC reads the values stored by FS. Am I right until now ?? But now the strange thing: When I reopen the FS weather-dialogue FS will show the correct values exactly like I entered before. How can Fs know about these correct values when FS stored them incorrect previously ?? The correct values must be stored at another location. What do you think about my theorie ?? Greetings Gerd
Pete Dowson Posted December 18, 2011 Report Posted December 18, 2011 How can Fs know about these correct values when FS stored them incorrect previously ?? The correct values must be stored at another location. What do you think about my theorie ?? Quite honestly, I've no idea. I don't think the dialogues are trustworthy -- you need to find some way of actually checking the weather which is truly implemented in the simulation, not what the dialogues tell you. Digging into the internals of the WEATHER.DLL is very difficult, and a real mess is facing you if you want to try it. Things were much cleaner and straightforward in FS2002 and before. The things wrong with the FS9 version were also, unfortunately, carried forward into FSX. But by then I gave up trying to figure it out and used SimConnect instead, which is even more mystifying when it comes to trying to read and write weather. Crafting a good weather control program for FS9 or FSX is more of an art form than a science, and folks like HiFi Simulation should be congratulated on doing as well as they do with Active Sky. Incidentally, in the example I quoted earlier, with the two Lua plug-ins, the difference between the results of writing Global and Local weather disappear if you first write Global and then, without clearing all the weather again, write the local weather the same. You then get identical results. What is happening is that because, after clearing the weather, there are no wind layers at all at all the surrounding stations, when a lone one is set the weather there is immediately 'tempered' by the influence of all around. Naturally multiple layers of wind cannot be sustained in isolation at one point on the globe. By setting all of the as-yet-unset stations to something similar to what you want locally, when you do set the local weather it looks more correctly what you ask for. This is actually how it is written up in the little Read Me document on the NWI. You just cannot get away with writing local weather only. The best way is to write the global default first, then stations at say 40 miles away and getting closer to local is a sequence. An alternative which works well is to set them all 'Pending', and then Activate them when done. That method was added specifically for the weather control programs. Regards Pete
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now