Jump to content
The simFlight Network Forums

Paul Henty

Members
  • Posts

    1,724
  • Joined

  • Days Won

    77

Everything posted by Paul Henty

  1. I think the problem is that you've setup the event to read a double word ('UD') which is 4 bytes, but in the C# you're only writing 2 Bytes. If you only need 2 bytes then the Lua should probably be: event.offsetmask(0x66C0, 8,'UW', 'Fuel_Pump')event.offsetmask(0x66C0, 256,'UW', 'Beacon_Light')event.offsetmask(0x66C0, 1024,'UW', 'Strobe_Light') 'UW' is an unsigned word (2 bytes). Paul
  2. From what you've written the C# part of your program is working. I don't know Lua, (it would be better to ask Pete) but according to the documentation, this line is wrong: event.offset('0x66C0','UD', 'PFuelCutOffSwitch') The two correct ways are: event.offset(0x66C0,'UD', 'PFuelCutOffSwitch') or event.offset('66C0','UD', 'PFuelCutOffSwitch') Paul
  3. You can check if the C# part is working by using the logging tab of FSUIPC. Use the panel on the right ("Specific Value Checks") to log 0x66C0 to the FS window. You will be able to see if that offset is actually getting changed by your C# code. If it is then the problem is elsewhere, maybe your Lua code. You can check the FSUIPC4.Log file for any Lua errors. Paul
  4. Hi Goksel, After you change the value you must call FSUIPCConnection.Process() in order to send the new values to FSUIPC. Also, if you are only writing to offset 0x66C0 in your C# code then it's best to declare it as Write Only: private Offset<int> Pitot_HEAT = new Offset<int>(0x66C0, true); If you want to read and write in the C# code then you must make at least one read (call FSUIPCConnection.Process()) before setting a new value. Paul
  5. Hi Matthias, I've tried your code here (the switch statement and readonly variables) and it works fine for all ATC options in FSX. You must have something else causing a problem that you haven't posted. It might be worth posting the declarations for the relevant offsets, and the code in fsuipc_process(). I don't have any version of p3d so I can't comment on that. Try asking Pete in the main support forum, but make sure you update to the latest FSUIPC4 version in the downloads subforum first. Paul
  6. Hi Dan, FSUIPC doesn't allow you to open FSX because FSUIPC is loaded by FSX. So FSX needs to be running for FSUIPC to be running. You can however use normal Visual Basic to open any program on the computer. This example shows opening FSX using a hard-coded path. In your application you would get the path using one of two methods which I will explain below: You need to add the following line to the top of the file: Imports System.IO This is the code that will launch FSX: Dim fsxFilePath As String = "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\FSX.exe" Dim processInfo As ProcessStartInfo = New ProcessStartInfo() processInfo.FileName = fsxFilePath processInfo.WorkingDirectory = Path.GetDirectoryName(fsxFilePath) Dim fsx As Process = Process.Start(processInfo) If you don't want to hard-code the path (e.g. because your program will be used by other people), the easiest way is to ask the user to enter the path (or find it using an OpenFileDialog control that you add to the form). There are many resources on the internet and YouTube showing how to use this dialog control. It's beyond the scope of the support I can offer on this forum. You could also get the path from the registry but there seems to be many places you need to look as each version of Flight Sim seems to use a different registry key. There is a discussion about it here: http://www.fsdeveloper.com/forum/threads/registry-keys-fsx-fsx-se-p3dv1-p3dv2.432633/ If you want to go this route, you'll need to lookup how to access the registry from Visual Basic.NET. Again there are lot of resources out there. No, this is not something FSUIPC was designed to do. You can edit files using plain Visual Basic; there are lots of resources on how to do this. However, the .CFG file is formatted like an .INI file. There are .NET libraries available that make editing .INI files easier (it's quite a lot of code to write yourself otherwise). Here is one I found that has examples (and source code I think) in VB.NET, but there may be better ones out there. http://www.codeproject.com/Articles/21896/INI-Reader-Writer-Class-for-C-VB-NET-and-VBScript If you have any more questions just ask. I can't teach VB.NET or do general programming support here, but I will point you in the right direction as I've done here. I do however give detailed help and code examples regarding the use of my DLL. If you have general FSUIPC questions (not .NET related) then it's best to post those up in the main support forum for Pete to answer. Paul
  7. I can't see any other posts from you. If Mario didn't answer your question, please post it again here. Regards, Paul
  8. There are standard FSX/P3D controls to set the view to cameras 0 to 9. They are listed in the 'List of FSX and P3D Controls.pdf" document: You can send these controls via offset 3110. Declare as an 'int' and write-only: private Offset<int> sendControl = new Offset<int>("SendControl", 0x3110, true); Then when you want to switch the view assign the new number and process the "SendControl" group: (This example is for camera 5) sendControl.Value = 66855; FSUIPCConnection.Process("SendControl"); Paul
  9. Hi Brian, I've had a look at it and it's not possible without a lot of work. The main stumbling block is that the Offset(Of Type) class uses .NET generics to specify the type of the offset. COM/ActiveX has no such concept so it can't be mapped directly. This means the automatic COM visibility option I was planning on using will just ignore the Offset class It's probably possible to manually add a separate set of interfaces/methods that could be called via COM, but it would be a big job to work it all out and test it. If you want to pursue the idea of an ActiveX or (more likely) a COM DLL then try asking up in the main support forum. It's more of a C/C++ programmers job. Paul
  10. If you mean you want to use it as an in-process COM object then it's possible for me to add a COM wrapper. However, it the DLL would still be managed code and would still required the .NET runtime to be installed. I can't guarantee it would work but you're welcome to try. If you mean an invisible activex user interface control, that could be a bit more difficult but I'm happy to look into it. If you're looking for a non-managed, COM version of this DLL then it doesn't exist. There may be other COM interfaces to FSUIPC written in other (more appropriate) languages like C++ but you'd need to ask up in the main support forum. Alternatively, if you want to give a bit more information about how exactly you want to access the DLL (e.g. languages, development and runtime environments etc), I might be able to suggest a better solution than COM interop to managed code. Paul
  11. Maybe. He's back on Monday. I suggest asking in the main support forum as more people will see it and may be able to help. Paul
  12. Sorry, I've just looked a bit closer and you've got the offsets a bit wrong. They should be this: (ID should be 2900 - it just needs to be declared after the others). private Offset<int> ctrl = new Offset<int>(0x2904); private Offset<int> val = new Offset<int>(0x2908); private Offset<int> id = new Offset<int>(0x2900); id.value = 637; // FSX ID od my Simobject ctrl.value = 66054; // STOBES_SET for example val.value = 1; // Set to 1 for true FSUIPCConnection.Process(); Paul
  13. It seems fine, except that it might not work with the Simobject ID. The ID needs to be from the FSUIPC TCAS table (the AI aircraft tables). You can get this through the DLL using the AITrafficServices. Pete might have used the Simobject ID to generate the TCAS IDs in FSUIPC, but I don't know. You'll have to look and find out. Paul
  14. Hi Motus, As far as I know, it's only possible to send controls to the user's aircraft (0x3110) and an AI traffic aircraft (0x2900). See the documentation for details on 0x2900.If you want to try it, declare 3 offset<int> (2904, 2908, 2900), You must declare 2900 after the others for it to work. For other types of object you'll need to use SimConnect. Paul
  15. I can't see any way of clearing the flight plan. I don't think there is anyway to do it, even using the FSX User interface. Paul
  16. Yes, you can write the full path to offset 0x0130. Example: Declare the offset at form (class) level. (Here I have put it in it's own group and made it write only to make things simpler...) private Offset<string> flightPlan = new Offset<string>("LoadFlightPlan", 0x0130, 256, true); To load the flightplan... string flightPlanPath = @"C:\Users\phent_000\Documents\Flight Simulator X Files\VFR Jersey to Bristol.PLN"; this.flightPlan.Value = flightPlanPath;FSUIPCConnection.Process("LoadFlightPlan"); Paul
  17. Edited previous post as I mistakenly thought the 'Select' should come before the Toggle_exit. Paul
  18. Hi Mattias, You need to call Process() after you've set the value of the offset, not before. So your first two lines need to be reversed. The way you have it now, the Toggle_Exit control is never sent as the process has already been done. I think you need to change your code to this: void Process_FS_Doors(int iDoorNumber) { // 1. Toggle the selected exit sendControl.Value = TOGGLE_AIRCRAFT_EXIT; Fsuipc_Process(); // 2. Wait a bit Thread.Sleep(50); // 3. Select the exit to control if(iDoorNumber == 0) sendControl.Value = SELECT_1; if(iDoorNumber == 1) sendControl.Value = SELECT_2; if(iDoorNumber == 2) sendControl.Value = SELECT_3; if(iDoorNumber == 3) sendControl.Value = SELECT_4; Fsuipc_Process(); } Paul
  19. Hi Ben, The FSUIPC offsets for PDMG are read-only so writing to them will have no effect. In order to make the aircraft do something you need to send controls. If your switch is programmed like a joystick button then you can do this directly in FSUIPC (Buttons + Switches tab). The PMDG controls do not appear in the dropdown but you can use the first entry <custom Control> to enter the control number manually and then set the parameter in the normal way. If you're using your own program to talk to FSUIPC via the IPC API, or you're using 3rd-party software which can only set FSUIPC offsets, then you can use the 'send control' offset at 0x3110. The control numbers (also called Events) for PMDG aircraft can be found in their SDK. I forget the name of the exact file but it's a c header file with the .h extension. For example, the Captain's Main Display DU selector switch is called EVT_DSP_CPT_MAIN_DU_SELECTOR in the .h file and has the decimal value of 69967. My understanding is that the parameter values for the controls match those documented for the offsets (albeit that controls always accept 2 bytes as a parameter value, so byte values need to be passed as 2 byte integers). So, sending control 69967 with a parameter value of 4 should set the switch to the MFD position. I don't have any PMDG aircraft so I can't test this for you. Paul
  20. No, I wrote that dll and provide support for it it here. Pete kindly offered me this sub-forum as it's for interfacing with FSUIPC. Pete does read posts here as well. I'm not an expert on FSUIPC in general so I'm not the best person to ask about your current question. Pete will help more when he's back. Paul
  21. This is one for Pete rather than me, maybe a moderator can move this to the main support forum? If not I'm sure Pete will see it here on his return. Incidentally, I think you've made a typo as the offset is 0x3367 not 0x3362 as you've written. Also, have you tried sending the control rather than writing to the offset? It's TOGGLE_AIRCRAFT_EXIT 66389 I guess the parameter would be the same one byte bit field as per the offset. (If you've not sent controls before see offset 0x3110) Paul
  22. Your ini file [Auto] section looks wrong which means the sndloop lua is never loaded (as confirmed in your latest log) You have: 1.Lua=Sndloop It should be: 1=Lua Sndloop Paul
  23. Here is how I would approach this: 1. Create a class to hold score items. These are going to be all the things you want to check for that calculate the overall score. I suggest you put this at the form/class level (at the same level as the offsets declarations). However, if you prefer you can put this in it's own class file and make it public. private class scoreItem { public string description; public int scoreValue; public bool failed = false; public scoreItem(string Description, int ScoreValue) { this.description = Description; this.scoreValue = ScoreValue; } } 2. Declare the offsets you need for the scoring. For this example you'll need these offsets: (To use the BitArray you may need to add 'using using System.Collections;' at the top of the form. private Offset<ushort> onGround = new Offset<ushort>(0x0366); private Offset<int> ias = new Offset<int>(0x02BC); private Offset<BitArray> lights = new Offset<BitArray>(0x0D0C, 2); private Offset<ushort> pause = new Offset<ushort>(0x0264); 3. Create a dictionary to hold all the scores. (Under the offsets). private Dictionary<string, scoreItem> scores; 4. Create a method to populate all the score items. For this example I only have two items: One is to lose points if you pause. The other is to lose points if you don't have the landing light on before take off. You can use the score value to 'weight' the items. So here pausing (10) is twice as bad as forgetting the landing lights (5). private void createScoreItems() { this.scores = new Dictionary<string, scoreItem>(); // Added two possible penalties for demonstration // 1. Pausing the sim scoreItem pausing = new scoreItem("Fly the route without pausing the flight sim.", 10); this.scores.Add("pausing", pausing); // 2. Forgetting landing lights on takeoff scoreItem noLightsTakeOff = new scoreItem("Turn on the landing lights for take-off.", 5); this.scores.Add("noLightsTakeoff", noLightsTakeOff); // Add more here } 5. Create a method to work out the score: (I've done it here as a percentage) private double calculatePercentageScore() { int totalPossible = this.scores.Sum(s => s.Value.scoreValue); int notFailed = this.scores.Sum(s => s.Value.failed ? 0 : s.Value.scoreValue); return (double)notFailed / (double)totalPossible * 100d; } 6. Create a method to show the score: Here I print the percentage score in a text box, and put all the score items in to two lists. One is items passed so far, the other is items failed so far: private void showScore() { // display the actual score this.txtScore.Text = calculatePercentageScore().ToString("F0") + "%"; // show the passed and failed scores in the list this.lstFailed.Items.Clear(); this.lstFailed.ForeColor = Color.Red; this.lstPassed.Items.Clear(); foreach (scoreItem si in this.scores.Values) { if (si.failed) { this.lstFailed.Items.Add(si.description); } else { this.lstPassed.Items.Add(si.description); } } } 7. After you open the connection (or somewhere at the start of your application) call the methods to initialise the scores and show the starting scores: try { // Attempt to open a connection to FSUIPC (running on any version of Flight Sim) FSUIPCConnection.Open(); // Opened OK FSUIPCConnection.Process(); createScoreItems(); showScore(); // start the timer timer1.Interval = 250; timer1.Start(); } catch (Exception ex) { // Badness occurred - show the error message MessageBox.Show(ex.Message, AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } 8. In the timer tick, check the conditions for each score. If they have failed, mark the relevant score item as failed and show the new score. FSUIPCConnection.Process(); // Check the pause score item if (pause.Value == 1) { // sim paused - fail the pause item this.scores["pausing"].failed = true; showScore(); } // check the noLandingLightsTakeoff score item // If we're still on the ground and the IAS is over 60 and the lights are off then fail double iasKnots = (double)ias.Value / 128d; if (onGround.Value == 1 && iasKnots > 60 && !lights.Value[2]) { this.scores["noLightsTakeoff"].failed = true; showScore(); } All of that will give you a working scoring system in real-time with the two example score items. These conditions are fairly simple, you'll likely need more complicated checks involving keeping track of the flight phase (e.g. Before Taxi, Taxi, After take off, Top of climb, decent, approach etc). Paul
  24. Which part of this specifically are you having a problem with? Your description above seems to describe exactly how to do this. Paul
  25. To log events when offsets change you need to keep a copy of the previous values. Then test against the current values. If they are different you can write the new value to the log. After every 'tick' you must update the last values with the current values. Below is some code that shows logging 'pause/un-pause' and when the gear is put up and down. 1. Create variables to store the last values. These can be the same type as the raw 'value' of the offset (that's what I've used), or they could be the real-world values after conversion. These are at the form/class level, the same as the offsets. private Offset<ushort> pause = new Offset<ushort>(0x0264); private Offset<int> gearPositionNose = new Offset<int>(0x0BEC); private ushort lastPause; private int lastGearPositionNose; 2. Create a method to set these values from the current values of the offsets: private void setLastValues() { this.lastGearPositionNose = this.gearPositionNose.Value; this.lastPause = this.pause.Value; } 3. Call this method after open to set the initial values: try { // Attempt to open a connection to FSUIPC (running on any version of Flight Sim) FSUIPCConnection.Open(); // Opened OK FSUIPCConnection.Process(); setLastValues(); // start the timer timer1.Interval = 250; timer1.Start(); } catch (Exception ex) { // Badness occurred - show the error message MessageBox.Show(ex.Message, AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } 4. In the TIck, test the current values of the relevant offsets and log if they are changed. Finally call the method to update the last values with the current ones (ready for the next tick). private void timer1_Tick(object sender, EventArgs e) { // Pause // If pause changed write it to the log FSUIPCConnection.Process(); if (this.pause.Value != this.lastPause) { log("Sim was " + (pause.Value == 1 ? "PAUSED" : "UN-PAUSED")); } // Gear if (gearPositionNose.Value == 0) { this.textBox4.Text = "Gear Up"; if (this.lastGearPositionNose != 0) { log("Gear UP"); } } else if (gearPositionNose.Value == 16383) { this.textBox4.Text = "Gear Down"; if (this.lastGearPositionNose != 16383) { log("Gear DOWN"); } } else { this.textBox4.Text = "Gear In Transit"; } setLastValues(); } 5. For this demonstration, my 'log' method just adds an item to a ListBox on the form. private void log(string message) { string logLine = DateTime.Now.ToString() + ": " + message; this.listBox1.Items.Add(logLine); } Paul
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.