rfresh Posted May 5, 2015 Report Posted May 5, 2015 Hi Paul I wanted to ask if you have done a .DLL wrapper for SimConnect? Thanks...
Paul Henty Posted May 5, 2015 Report Posted May 5, 2015 I haven't, no. I've never looked into SimConnect at all. Paul
rfresh Posted May 5, 2015 Author Report Posted May 5, 2015 OK...I just thought I'd ask. I'm writing a camera view app and SimConnect has a call that allows me to update the camera changes in real time as I make changes with an app, so I'm going to have to use SimConnect for this project. Your FSUIPC .DLL worked so well with my other project I was hoping you did one for SimConnect :smile: Thanks...
Pete Dowson Posted May 5, 2015 Report Posted May 5, 2015 I'm writing a camera view app and SimConnect has a call that allows me to update the camera changes in real time as I make changes with an app, so I'm going to have to use SimConnect for this project. Your FSUIPC .DLL worked so well with my other project I was hoping you did one for SimConnect :smile: It would be easy enough for me to add a facility to use the function SimConnect_CameraSetRelative6DOF via a set of offsets in FSUIPC. I'd only need to find the offset space for the 6 floats (24 bytes). I'm not sure this function does exactly what you want it to do. It looks like it controls a (defined?) user camera, it has no addressing capability for any of the defined cameras. Let me know -- best to send me an email -- and if you want, I'll add it to an interim test version for you to try before I make it firm. Email is petedowson@btconnect.com. Pete
rfresh Posted May 10, 2015 Author Report Posted May 10, 2015 Email sent...(My Win7 system crashed and I just now got it re-built thus the delay)...
rfresh Posted May 30, 2015 Author Report Posted May 30, 2015 Hi Paul, Pete provided me with the offsets to test moving the cockpit camera via the SimConnect function SimConnect_CameraSetRelative6DOF(). Pete built me a special beta version of FSUIPC for me to test with. The information he provided: Offsets 86A0, 86A4, 86A8, 86AC, 86B0 and 86B4 (ie 6 consecutive 32-bit values) should be written with the 6 float parameters for SimConnect_CameraSetRelative6DOF. The action is triggered by a write to 86A0, so either write that parameter last, or, better, write all 24 bytes as one structure, in one Write. Paul, can you give me an example of how the c# syntax should be written to make this call after loading the 6 values for the XYZ and PBH arguments? I'm going to load up some known values I took from inside an F-18 fighter and then I will set up the DOF() call via FSUIPC and make the call and observe if the camera position does indeed change (and report this back to Pete). Thanks...
Paul Henty Posted May 30, 2015 Report Posted May 30, 2015 Hi Ralph, Below is the code to do this. It uses the new structure feature to keep everything neat and allow you to declare a single offset for all 6 values. You'll need the latest version of the dll (attached). I've pasted the entire test form so you can see where everything goes. using FSUIPC; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace TestApp { public partial class CameraWriteStructure : Form { // declare the structure of 6 floats public class SimConnect6DOF : FSUIPCStruct { public FSUIPCStructField<float> fDeltaX = new FSUIPCStructField<float>(); public FSUIPCStructField<float> fDeltaY = new FSUIPCStructField<float>(); public FSUIPCStructField<float> fDeltaZ = new FSUIPCStructField<float>(); public FSUIPCStructField<float> fPitchDeg = new FSUIPCStructField<float>(); public FSUIPCStructField<float> fBankDeg = new FSUIPCStructField<float>(); public FSUIPCStructField<float> fHeadingDeg = new FSUIPCStructField<float>(); } // declare the offset, using the structure as the datatype. Offset starts at 86A0 private Offset<SimConnect6DOF> cameraSetRelative = new Offset<SimConnect6DOF>("camera", 0x86A0, true); private void button1_Click(object sender, EventArgs e) { // set the values to write SimConnect6DOF cameraData = new SimConnect6DOF(); cameraData.fDeltaX.Value = 12.34f; cameraData.fDeltaY.Value = 12.34f; cameraData.fDeltaZ.Value = 12.34f; cameraData.fPitchDeg.Value = 12.34f; cameraData.fBankDeg.Value = 12.34f; cameraData.fHeadingDeg.Value = 12.34f; // Assign the new structure to the offset value cameraSetRelative.Value = cameraData; // Process the group containing the 'cameraSetRelative' offset FSUIPCConnection.Process("camera"); } public CameraWriteStructure() { InitializeComponent(); } private void CameraWriteStructure_Load(object sender, EventArgs e) { FSUIPCConnection.Open(); } private void CameraWriteStructure_FormClosing(object sender, FormClosingEventArgs e) { FSUIPCConnection.Close(); } } } If you don't want to use the structure you can just declare 6 offset<float> in the normal way, each pointing to one of the offsets listed by Pete. You can put them in their own 'camera' group also. The important thing if you do it this way is that you must declare 86A0 last. The order you assign values before processing doesn't matter. I've tested the above code with the FSUIPC write logging and it's writing exactly what Pete has specified. Let me know if you need any more help. Regards, Paul
rfresh Posted June 3, 2015 Author Report Posted June 3, 2015 Wow, thanks for the code Paul...I'll give it a try...
Paul Henty Posted June 3, 2015 Report Posted June 3, 2015 Ralph, Please use the DLL attached. The previous one had a bug in it when using write-only offsets. Paul FSUIPCClient3.0_BETA.zip
rfresh Posted June 6, 2015 Author Report Posted June 6, 2015 Paul, After I unzip your DLL what folder do I put it in? I've been away from this for a while and don't recall what folder your DLL should be in? Thanks...
Paul Henty Posted June 6, 2015 Report Posted June 6, 2015 To find out the current folder for the DLL, go to the solution explorer tree in Visual Studio and look under the 'references' node. Find FSUIPCClient and right-click it, then select properties. In the properties windows look for the 'path' field and that will tell you where the current version of the DLL is on your disk. Just overwrite that with the new version and recompile your project. Paul
rfresh Posted June 6, 2015 Author Report Posted June 6, 2015 OK...its set to: C:\FSUIPCClient3.0_BETA\NET4 which I think is correct for your latest DLL. This line private Offset<SimConnect6DOF> cameraSetRelative = new Offset<SimConnect6DOF>("camera", 0x86A0, true); is giving me a compile error: A first chance exception of type 'System.NullReferenceException' occurred in FSUIPCClient.dll Additional information: Object reference not set to an instance of an object.
Paul Henty Posted June 6, 2015 Report Posted June 6, 2015 Are you running the test form I pasted above, or have you put this code in your own program?
rfresh Posted June 6, 2015 Author Report Posted June 6, 2015 I tried copying all of your code into a TestApp but had many errors so I put your code into my main app. Let me try the testApp again and check your DLL location.
rfresh Posted June 6, 2015 Author Report Posted June 6, 2015 I got the TestApp created with your code. I'm getting only one compile error: Error 2 'TestApp.Form1.Dispose(bool)': no suitable method found to override c:\users\fresh1011\documents\visual studio 2013\Projects\TestApp\TestApp\Form1.Designer.cs 14 33 TestApp on this method, the Dispose method name: protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); }
Paul Henty Posted June 6, 2015 Report Posted June 6, 2015 If you follow these steps you should be okay. 1. Create a new form 2. Add a button to the form and double click it to get to the code window. Remove the default 'click' event handler. 3. Add the 'using FSUIPC' to the top. 4. Copy and paste from my code to your new form code, everything between (not including): public partial class CameraWriteStructure : Form { (Note that in your code 'CameraWriteStructure' will be replaced by whatever you called the form. e.g. Form2.) and right at the bottom. } } Paul
rfresh Posted June 6, 2015 Author Report Posted June 6, 2015 I still get the same error: This line private Offset<SimConnect6DOF> cameraSetRelative = new Offset<SimConnect6DOF>("camera", 0x86A0, true); is giving me a compile error: A first chance exception of type 'System.NullReferenceException' occurred in FSUIPCClient.dll Additional information: Object reference not set to an instance of an object. Here is my code (following your instructions): using FSUIPC; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace TestApp { public partial class Form1 : Form { public Form1() { InitializeComponent(); } // declare the structure of 6 floats public class SimConnect6DOF : FSUIPCStruct { public FSUIPCStructField<float> fDeltaX = new FSUIPCStructField<float>(); public FSUIPCStructField<float> fDeltaY = new FSUIPCStructField<float>(); public FSUIPCStructField<float> fDeltaZ = new FSUIPCStructField<float>(); public FSUIPCStructField<float> fPitchDeg = new FSUIPCStructField<float>(); public FSUIPCStructField<float> fBankDeg = new FSUIPCStructField<float>(); public FSUIPCStructField<float> fHeadingDeg = new FSUIPCStructField<float>(); } // declare the offset, using the structure as the datatype. Offset starts at 86A0 private Offset<SimConnect6DOF> cameraSetRelative = new Offset<SimConnect6DOF>("camera", 0x86A0, true); private void button1_Click(object sender, EventArgs e) { // set the values to write SimConnect6DOF cameraData = new SimConnect6DOF(); cameraData.fDeltaX.Value = 12.34f; cameraData.fDeltaY.Value = 12.34f; cameraData.fDeltaZ.Value = 12.34f; cameraData.fPitchDeg.Value = 12.34f; cameraData.fBankDeg.Value = 12.34f; cameraData.fHeadingDeg.Value = 12.34f; // Assign the new structure to the offset value cameraSetRelative.Value = cameraData; // Process the group containing the 'cameraSetRelative' offset FSUIPCConnection.Process("camera"); } private void CameraWriteStructure_Load(object sender, EventArgs e) { FSUIPCConnection.Open(); } private void CameraWriteStructure_FormClosing(object sender, FormClosingEventArgs e) { FSUIPCConnection.Close(); } } }
Paul Henty Posted June 6, 2015 Report Posted June 6, 2015 The code looks fine. Most likely then is that you're still referencing an old version of the DLL. On your disk (C:\FSUIPCClient3.0_BETA\NET4), right click the DLL and go to properties. In the details tab check the version is 3.0.5632.8. If that's not correct, copy again from the Zip file above. If that's correct then go to the references node in Visual Studio, find FSUIPCClient, right click -> properties. Make sure that also has the same version number. (ignore the property 'Runtime Version', just check 'Version'). If that's not correct then delete this reference from the Solution Explorer (Rightclick -> remove). Then add it again by Rightclicking the References node -> Add Reference... In the dialog press the [browse] button at the bottom and find the DLL in C:\FSUIPCClient3.0_BETA\NET4 That should sort it out. I've rerun my test form with the DLL in the zip above (I downloaded it) and it worked. If all the versions look good at your end I'll have to have another think about it... Paul
rfresh Posted June 7, 2015 Author Report Posted June 7, 2015 That was it -- I had to get the updated DLL in there -- still had the old one for some reason. OK, so the test app runs now. I took these values cameraData.fDeltaX.Value = 0.50f; cameraData.fDeltaY.Value = -0.37f; cameraData.fDeltaZ.Value = -0.47f; cameraData.fPitchDeg.Value = 52.00f; cameraData.fBankDeg.Value = 0.00f; cameraData.fHeadingDeg.Value = 0.00f; from my Captain Sim 777 VC overhead panel view. From the captains seat position looking straight out the windshield, I clicked the button and expected to see the camera view change to show the over head but the camera only bumped up a very small amount from the captains view. So, I'm not sure why. I did get a small test app working extremely well using SimConnect last week, so I am familiar with the VC camera views. In my SimConnect app, once I set a view, I can move the camera around just by using the DOF() call so that's why I was thinking the FSUIPC call would respond in a like fashion. Let me think about this for a bit and see if I'm forgetting to setup something before making the camera call..thanks for your help... I'm attaching my main form file so you can see what I did. Form1.zip
Pete Dowson Posted June 7, 2015 Report Posted June 7, 2015 I did get a small test app working extremely well using SimConnect last week, so I am familiar with the VC camera views. In my SimConnect app, once I set a view, I can move the camera around just by using the DOF() call so that's why I was thinking the FSUIPC call would respond in a like fashion. I was waiting for a test result from you to make sure it worked. Since it evidently didn't, I've just re-checked -- and I had made a silly typo in the code. Apologies. It was a little rushed on the day before I went off to Romania I think. Please try version 4.939t FSUIPC4939t.zip Pete
rfresh Posted June 7, 2015 Author Report Posted June 7, 2015 Sorry Pete...I don't see any changes when I use your 't' version.
Pete Dowson Posted June 7, 2015 Report Posted June 7, 2015 Sorry Pete...I don't see any changes when I use your 't' version. Strange, because previously. It was using completely the wrong offsets! Best monitor the offsets (well the first 4 anyway) and show me the log. When I get a moment I'll try writing to them from FSinterrogate, or maybe a Lua plugin. The code in FSUIPC couldn't really be simpler. The typo just made it use the wrong set of offsets in the Simconnect call -- all parameters would have been zero I think. Pete
rfresh Posted June 7, 2015 Author Report Posted June 7, 2015 How do I enable the log and what folder is it in?
Pete Dowson Posted June 7, 2015 Report Posted June 7, 2015 How do I enable the log and what folder is it in? You've never used any of FSUIPC's logging facilities? They are the most important part of the tools provided for debugging. It's all covered in the documentation. Logging tab in FSUIPC options. Monitoring specific offsets is in the table on the right -- up to 4 offsets. Send to "normal log". Log files (along with absolutely everything concerned with FSUIPC) are in the FS Modules folder, of course. 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