StevenK Posted March 20, 2014 Report Posted March 20, 2014 Hi everyone. I need a little help. I am trying to get the current date and time from FSX through FSUIPC into a c# program im making. So far i have managed to get the following working. Hours Minuets Year I need help on the "seconds" "day" "month" If someone can help me work out the number I need to devide it by i would be very greatful Here is my code so far I have entered XXXXX for the parts I need help with Many Thanks //Sim Time Hour:Minuet:Seconds double sim_timehour = (double)sim_timeh.Value / 16777217; double sim_timemin = (double)sim_timem.Value / 16777217; double sim_timesec = (double)sim_times.Value XXXXX; this.fsxSimTime.Text = sim_timehour.ToString("F0") + ":" + sim_timemin.ToString("f0") + ":" + sim_timesec.ToString("f0"); //Sim Date Day/Month/Year double sim_dayday = (double)sim_dayd.Value XXXXX; double sim_daymonth = (double)sim_daym.Value XXXXX; double sim_dayyear = (double)sim_dayy.Value; this.fsxSimDate.Text = sim_daymonth.ToString("F0") + "/" + sim_daymonth.ToString("f0") + "/" + sim_dayyear.ToString("f0");
Pete Dowson Posted March 21, 2014 Report Posted March 21, 2014 I am trying to get the current date and time from FSX through FSUIPC into a c# program im making. I'm afraid I've no idea what interface you are using into FS. I don't see anything there referring to any actual FSUIPC offsets. I can help you interpret offsets, but I've no idea what you are reading nor how, nor what that odd value "16777217" has to do with anything. The sim date and time offsets I would always use are the simple ones -- those from 0238 to 024A. If you need to see offsets correctly iterpreted, so that you can choose the right ones, please use FSInterrogate2, as supplied in the FSUIPC SDK. Pete
StevenK Posted March 21, 2014 Author Report Posted March 21, 2014 I have been using FSInterrogate2 to get the offsetsThe offsets are Time:Hours: 0238Minuets: 0239Seconds: 023A Date:Day: 0245Month: 0244Year: 024A Here is the first part of the code that goes into C# private Offset<int> sim_timeh = new Offset<int>(0x0238); //TimeHours private Offset<int> sim_timem = new Offset<int>(0x0239); //TimeMinuets private Offset<int> sim_times = new Offset<int>(0x023A); //TimeSeconds private Offset<int> sim_dayd = new Offset<int>(0x0245); //DateDay private Offset<int> sim_daym = new Offset<int>(0x0244); //DateMonth private Offset<int> sim_dayy = new Offset<int>(0x024A); //DateYear These are then shown in a text label //Sim Time Hour:Minuet:Seconds double sim_timehour = (double)sim_timeh.Value / 16777217; //TimeHours double sim_timemin = (double)sim_timem.Value / 16777217; //TimeMinuets double sim_timesec = (double)sim_times.Value; //TimeSeconds this.fsxSimTime.Text = sim_timehour.ToString("F0") + ":" + sim_timemin.ToString("f0") + ":" + sim_timesec.ToString("f0"); //Sim Date Day/Month/Year double sim_dayday = (double)sim_dayd.Value; //DateDay double sim_daymonth = (double)sim_daym.Value; //DateMonth double sim_dayyear = (double)sim_dayy.Value; //DateYear this.fsxSimDate.Text = sim_daymonth.ToString("F0") + "/" + sim_daymonth.ToString("f0") + "/" + sim_dayyear.ToString("f0"); The Hour and Minuets and Year display perfect as they should.The Seconds, Day and Month just show random numbers. I used the offests found in the FSInterrogate2, and so far all my other requests from FSX using other offsets are giving the correct data.
Pete Dowson Posted March 21, 2014 Report Posted March 21, 2014 I have been using FSInterrogate2 to get the offsets That is a useful utility to experiment and see the values, but your sole reference should be the Offsets document. I suspect that is where you are going wrong! Here is the first part of the code that goes into C# private Offset<int> sim_timeh = new Offset<int>(0x0238); //TimeHoursprivate Offset<int> sim_timem = new Offset<int>(0x0239); //TimeMinuets private Offset<int> sim_times = new Offset<int>(0x023A); //TimeSeconds private Offset<int> sim_dayd = new Offset<int>(0x0245); //DateDay private Offset<int> sim_daym = new Offset<int>(0x0244); //DateMonth private Offset<int> sim_dayy = new Offset<int>(0x024A); //DateYear What interface are you using? Is it Paul Henty's DLL? If so you probably need help using it -- he supports it in the SubForum here so entitled. In C# is <int> an 8-bit unsigned BYTE value? Because if not there's the start of a lot of problems in the first place. Apart from 024A all those offsets are 8-bit unsigned values. And 024A is a 16-bit unsigned value (occupying 2 bytes). An "int" is usually a 32-bit signed value! (occupying 4 bytes). Where does the value 16777217 come from? What's the point of that? Byte values can't be larger than 255 in any case! Pete
Paul Henty Posted March 21, 2014 Report Posted March 21, 2014 Hi Steven, Pete is correct, you're not declaring the offsets correctly. Not everything is an int. Please review my UserGuide.pdf, especially page 7 which explains which .net types you need depending on the offset size. You do need to be getting this information from Pete's documents though (FSUIPC4 Offset Status.pdf). If you need any more help please post in my sub forum. Paul
StevenK Posted March 21, 2014 Author Report Posted March 21, 2014 That is a useful utility to experiment and see the values, but your sole reference should be the Offsets document. I suspect that is where you are going wrong! What interface are you using? Is it Paul Henty's DLL? If so you probably need help using it -- he supports it in the SubForum here so entitled. In C# is <int> an 8-bit unsigned BYTE value? Because if not there's the start of a lot of problems in the first place. Apart from 024A all those offsets are 8-bit unsigned values. And 024A is a 16-bit unsigned value (occupying 2 bytes). An "int" is usually a 32-bit signed value! (occupying 4 bytes). Where does the value 16777217 come from? What's the point of that? Byte values can't be larger than 255 in any case! Pete The 16777217 is dividing the value it fetches by 16777217 so XXXX divided by 16777217 will give me the correct time for the Hours and Minuets And it is Paul Henty's yes. Would i be better using a different DLL? My basic idea is to create a custom ACARS system that will fetch data from FSX and send it to PHPVMS So far things are going good. Im able to connect to FSX and fetch all the data i need appart from FSX Date and Time and a few other small (none important) bits of info but I can live without them I just need to get the date and time from FSX
StevenK Posted March 21, 2014 Author Report Posted March 21, 2014 Hi Steven, Pete is correct, you're not declaring the offsets correctly. Not everything is an int. Please review my UserGuide.pdf, especially page 7 which explains which .net types you need depending on the offset size. You do need to be getting this information from Pete's documents though (FSUIPC4 Offset Status.pdf). If you need any more help please post in my sub forum. Paul Thanks Paul for the reply. Any chance you could post a link to the PDF's? I will place my project on hold for now and read the manuals
Paul Henty Posted March 21, 2014 Report Posted March 21, 2014 Thanks Paul for the reply. Any chance you could post a link to the PDF's? I will place my project on hold for now and read the manuals My user guide is in the docs folder of the zip file that contained my DLL. You can get the latest from my sub forum: http://forum.simflight.com/topic/74848-fsuipc-client-dll-for-net-version-24/ The offset list is in the "Modules\FSUIPC Documents" folder under your main FSX folder. Paul
StevenK Posted March 21, 2014 Author Report Posted March 21, 2014 Great stuff Many thanks and i will post a topic in your forum if i need any help. Again thanks :)
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