lolowindev Posted September 24 Report Posted September 24 Bonjour, j'utilise fsuipcclient.dll avec WinDev 25 pour communiquer avec Prepar3D. J'essaie d'accéder aux informations sur les réservoirs de carburant de l'A320 en utilisant FsFuelTanksCollection, mais la collection semble être vide (Count retourne 0). Pouvez-vous me fournir un exemple de code WLangage montrant comment initialiser correctement la connexion FSUIPC, accéder à FsFuelTanksCollection, et obtenir les niveaux de carburant pour les réservoirs central, gauche et droit de l'A320 ? Merci." "Hello, I'm using fsuipcclient.dll with WinDev 25 to communicate with Prepar3D. I'm trying to access fuel tank information for the A320 using FsFuelTanksCollection, but the collection seems to be empty (Count returns 0). Could you provide a WLangage code example showing how to properly initialize the FSUIPC connection, access FsFuelTanksCollection, and obtain fuel levels for the center, left, and right tanks of the A320? Thank you." **********************************************WinDev *********************************************************************** oFuelTanks est un FsFuelTanksCollection oFuelTanks <- allouer un objet FsFuelTanksCollection SI oFuelTanks = Null ALORS Erreur("Impossible d'accéder aux données des réservoirs") RETOUR FIN // Vérification de la taille de la collection nTaille est un entier = oFuelTanks:Count SI nTaille = 0 ALORS Erreur("La collection de réservoirs est vide") RETOUR FIN nPourcentageCentral est un entier sur 4 octets nPourcentageGauche est un entier sur 4 octets nPourcentageDroit est un entier sur 4 octets nPourcentageCentral = oFuelTanks:get_Item(FSFuelTanks.Centre_Main):get_LevelPercentage() ****** bug **** nPourcentageGauche = oFuelTanks:Item[FSFuelTanks::Left_Main]:get_LevelPercentage() nPourcentageDroit = oFuelTanks:FsFuelTanksCollection.Item[FSFuelTanks::Right_Main]:get_LevelPercentage() Trace("Pourcentage de carburant dans le réservoir central : " + nPourcentageCentral + "%") Trace("Pourcentage de carburant dans le réservoir gauche : " + nPourcentageGauche + "%") Trace("Pourcentage de carburant dans le réservoir droit : " + nPourcentageDroit + "%")
Paul Henty Posted September 25 Report Posted September 25 Hi, I don't know WLanguage so I'm going to put the C# and my attempt at WLanguage. You are missing a few steps: First you must get a reference to the PayloadServices: C#: PayloadServices ps = FSUIPCConnection.PayloadServices; Wlanguage? ps is a PayloadServices ps = FSUIPCConnection.PayloadServices; Then you need to call RefreshData to load the current payload information from the Sim: ps:RefreshData() Then you need to get the fuel tanks collection: C#: FsFuelTanksCollection fuelTanks = ps.FuelTanks; WLanguage? oFuelTanks is a FsFuelTanksCollection oFuelTanks = ps:FuelTanks From here the rest of your code should work. Paul
lolowindev Posted September 25 Author Report Posted September 25 Thank you, Paul, Error: 'PayloadServices' is not public, creating an instance of 'PayloadServices' is forbidden. // Accès aux données des réservoirs ps est un PayloadServices // -Erreur :PayloadServices' n'est pas public, la création d'une instance de 'PayloadServices' est interdite. ps = FSUIPCConnection.PayloadServices //**************************** Mise à jour des données****************************** ps:RefreshData() oFuelTanks est un FsFuelTanksCollection oFuelTanks = ps:FuelTanks
Paul Henty Posted September 25 Report Posted September 25 34 minutes ago, lolowindev said: // Accès aux données des réservoirs ps est un PayloadServices // -Erreur :PayloadServices' n'est pas public, la création d'une instance de 'PayloadServices' est interdite. ps = FSUIPCConnection.PayloadServices The error is correct; you can't create a new instance of it. It's a static class. I don't know wlanguage so I'm not sure how to get a reference to a static class. Maybe this... ps <- FSUIPCConnection.PayloadServices Does that assign a reference of an existing class? Maybe it's not possible and you need to use the full name instead of 'ps': e.g. FSUIPCConnection.PayloadServices:RefreshData() oFuelTanks = FSUIPCConnection.PayloadServices:FuelTanks Try that. Or look at the WLanguage documentation to see how to deal with static classes in .NET. Paul
lolowindev Posted September 26 Author Report Posted September 26 Thank you again, Paul, I know nothing about programming and your help has really been a lifesaver. I've been at it for quite a long time, 3 or 4 weeks, and now it's working. Here is my code which works and is surely improvable, but it has the merit of functioning. // Accès aux données des réservoirs PayloadServices = FSUIPCConnection.PayloadServices //**************************** Mise à jour des données****************************** FSUIPCConnection.PayloadServices:RefreshData() oFuelTanks est un FsFuelTanksCollection oFuelTanks <- FSUIPCConnection.PayloadServices:FuelTanks SI oFuelTanks = Null ALORS Erreur("Impossible d'accéder aux données des réservoirs") RETOUR FIN //***************** Vérification de la taille de la collection***************** nTaille est un entier = oFuelTanks:Count SI nTaille = 0 ALORS Erreur("La collection de réservoirs est vide") //RETOUR FIN nPourcentageCentral est un entier sur 4 octets nPourcentageGauche est un entier sur 4 octets nPourcentageDroit est un entier sur 4 octets nPourcentageCentral = oFuelTanks:get_Item(FSFuelTanks::Centre_Main):get_LevelPercentage() nPourcentageGauche = oFuelTanks:get_Item(FSFuelTanks::Left_Main):get_LevelPercentage() nPourcentageDroit = oFuelTanks:get_Item(FSFuelTanks::Right_Main):get_LevelPercentage() Info("Pourcentage de carburant dans le réservoir central : " + nPourcentageCentral + "%") Info("Pourcentage de carburant dans le réservoir gauche : " + nPourcentageGauche + "%") Info("Pourcentage de carburant dans le réservoir droit : " + nPourcentageDroit + "%") 1
lolowindev Posted October 5 Author Report Posted October 5 bonjour paul, je cherche a écrire dans le reservoir central et il ne se passe rien, je n'ai pas d'erreure dans le code . j'ai oublié quelque chose? hello paul, i try to write in the central reservoir and nothing happens and i have no error in the code. did i forget something? oFuelTanks :get_Item(FSFuelTanks ::Centre_Main) :set_LevelPercentage(30) merci lolo
Paul Henty Posted October 5 Report Posted October 5 Hi Lolo, After you make changes to Payload Stations and Fuel Tanks you need to call WriteChanges() to send the changes to the Sim. I think in WinDev it will be something like: FSUIPCConnection.PayloadServices:WriteChanges() If you need to change many Fuel Tanks you just call this once at the end: oFuelTanks :get_Item(FSFuelTanks ::Centre_Main) :set_LevelPercentage(30) oFuelTanks :get_Item(FSFuelTanks ::Centre_Left) :set_LevelPercentage(50) oFuelTanks :get_Item(FSFuelTanks ::Centre_Right) :set_LevelPercentage(50) FSUIPCConnection.PayloadServices:WriteChanges() Paul
lolowindev Posted October 5 Author Report Posted October 5 Merci Paul, c'est exactement ça, ça marche, je suis heureux . ça fonctionne !!!! Thanks Paul, that's exactly it, it works, I'm happy. it works !!!! 1
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