Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi,

I am making a software to integrate FSX via FSUIPC. Evertyhing goes well, Thanks To Pete and Paul.

...but now I have a problem which I could not find a solution. Maybe someone can have an idea.

I made a temporary code to test the result. The objective here is to toggle the master battery as you see.

My problem is the master battery keeps its state. When I debug the values I see that my toggle button is working and writing the value as I want but when it goes back to reading the value the master battery value stays in its previous state. For example assume that the battery is on and value is 1, when I turn it of it gets 0. But as soon as it reads the value it goes back to one. My button is working but I cant find why or what makes the value switch back to its previous state. Can you help me?

My code is in C# and it is as fallows.

...

public partial class Form1 : Form

{

private Offset<int> _masterBattery = new Offset<int>(0x281C);

...

public void ConnectFSUIPC()

{

try

{

FSUIPCConnection.Open();

timer1.Enabled = true;

}

catch (Exception)

{

FSUIPCConnection.Close();

}

}

public void getSIMData()

{

FSUIPCConnection.Process();

switch (_masterBattery.Value)

{

case 0: button1.BackColor = Color.Empty; break;

case 1: button1.BackColor = Color.LightGreen; break;

}

}

private void Form1_Load(object sender, EventArgs e)

{

ConnectFSUIPC();

}

private void timer1_Tick(object sender, EventArgs e)

{

getSIMData();

}

private void button1_Click(object sender, EventArgs e)

{

switch (_masterBattery.Value)

{

case 0: _masterBattery.Value = 1; FSUIPCConnection.Process(); break;

case 1: _masterBattery.Value = 0; FSUIPCConnection.Process(); break;

}

}

}

}

Posted

My problem is the master battery keeps its state. When I debug the values I see that my toggle button is working and writing the value as I want but when it goes back to reading the value the master battery value stays in its previous state. For example assume that the battery is on and value is 1, when I turn it of it gets 0. But as soon as it reads the value it goes back to one. My button is working but I cant find why or what makes the value switch back to its previous state. Can you help me?

I don't know C# so I'm not commenting on the code. You say "when I turn it of it gets 0. But as soon as it reads the value it goes back to one", but do you really mean that? i.e. Do you mean it stays off for as long as you don't read it? And are you talking about the actual switch (as seen in a gauge, for instance), or only about the offset value? Do they always correspond?

Have you tried using FSUIPC's logging facilities? Use the Monitoring option to monitor the offset. Maybe you have something else running which is setting the switch as well. Have you tested on a default aircraft to make sure it isn't related to the specific model?

Regards

Pete

Posted (edited)

Hi Pete,

Thanks for your answer. I am using FSUIPC logger and I watch the value on the FS title Bar. I am using default planes and I tried on different planes. I can manage the mastery battery inside the cockpit or in game gauges. They perfectly work well.

In my software I am using a button to toggle it. When it is "ON" the button also turns to green when it is "OFF" the button is colorless. There are my other buttons like fuel pump, alternator, avionics... and they work perfectly well but this particular "master battery". I use exactly the same code with other toggle buttons. But I cant toggle the battery with my button. I debug my code step by step. I see that my button is able to toggle the value but as soon as it exist that block the value goes back to previous state. Looks like something else is switching it back.

Edited by Ahmet Mehmetbeyoğlu
Posted

Looks like something else is switching it back.

Yes, so please monitor it to the Log so we can see what happens. If you also lg Events" (on checkbox on the left side of Logging) it will show if extra commands are doing it.

The whole point of the FSUIPC logging is to help track things down. Merely seeing it on the title bar is no good to me (I am not there), and it doesn't show any other details.

Regards

Pete

Posted

10530 Monitor IPC:281C (U32) = 0

13931 SimRead: 281C="ELECTRICAL MASTER BATTERY"

INT32: 0 (0x00000000)

14009 System time = 07/12/2012 14:59:42, Simulator time = 14:59:38 (12:59Z)

14118 Aircraft="Beech Baron 58 Paint1"

121853 READ0 3304, 4 bytes: 01 00 00 46 ...F

121853 READ0 3308, 4 bytes: 08 00 DE FA ....

123974 READ0 281C, 4 bytes: 00 00 00 00 ....

125815 WRITE0 281C, 4 bytes: 01 00 00 00 ....

125987 READ0 281C, 4 bytes: 00 00 00 00 ....

128046 READ0 281C, 4 bytes: 00 00 00 00 ....

130011 READ0 281C, 4 bytes: 00 00 00 00 ....

132024 READ0 281C, 4 bytes: 00 00 00 00 ....

134036 READ0 281C, 4 bytes: 00 00 00 00 ....

136064 READ0 281C, 4 bytes: 00 00 00 00 ....

138061 READ0 281C, 4 bytes: 00 00 00 00 ....

138560 LUA: beginning "B:\FSX\Modules\ipcReady.lua"

140073 READ0 281C, 4 bytes: 00 00 00 00 ....

142086 READ0 281C, 4 bytes: 00 00 00 00 ....

142148 Advanced Weather Interface Enabled

144098 READ0 281C, 4 bytes: 00 00 00 00 ....

146111 READ0 281C, 4 bytes: 00 00 00 00 ....

148123 READ0 281C, 4 bytes: 00 00 00 00 ....

150136 READ0 281C, 4 bytes: 00 00 00 00 ....

152148 READ0 281C, 4 bytes: 00 00 00 00 ....

154160 READ0 281C, 4 bytes: 00 00 00 00 ....

156173 READ0 281C, 4 bytes: 00 00 00 00 ....

158185 READ0 281C, 4 bytes: 00 00 00 00 ....

160198 READ0 281C, 4 bytes: 00 00 00 00 ....

162210 READ0 281C, 4 bytes: 00 00 00 00 ....

164222 READ0 281C, 4 bytes: 00 00 00 00 ....

166235 READ0 281C, 4 bytes: 00 00 00 00 ....

168247 READ0 281C, 4 bytes: 00 00 00 00 ....

170260 READ0 281C, 4 bytes: 00 00 00 00 ....

172272 READ0 281C, 4 bytes: 00 00 00 00 ....

174300 READ0 281C, 4 bytes: 00 00 00 00 ....

176312 READ0 281C, 4 bytes: 00 00 00 00 ....

178138 WRITE repeated 6 times

178138 WRITE0 281C, 4 bytes: 00 00 00 00 ....

178309 READ0 281C, 4 bytes: 00 00 00 00 ....

180337 READ0 281C, 4 bytes: 00 00 00 00 ....

182334 READ0 281C, 4 bytes: 00 00 00 00 ....

183036 WRITE0 281C, 4 bytes: 01 00 00 00 ....

184347 READ0 281C, 4 bytes: 00 00 00 00 ....

186375 READ0 281C, 4 bytes: 00 00 00 00 ....

188371 READ0 281C, 4 bytes: 00 00 00 00 ....

190384 READ0 281C, 4 bytes: 00 00 00 00 ....

192396 READ0 281C, 4 bytes: 00 00 00 00 ....

194424 READ0 281C, 4 bytes: 00 00 00 00 ....

....

Posted
....

183036 WRITE0 281C, 4 bytes: 01 00 00 00 ....

184347 READ0 281C, 4 bytes: 00 00 00 00

You enabled IPC read and write logging, but not Events, as I asked. That might show what happens in that 311 mSecs which stops it being changed.

Pete

Posted

My bad, sorry. So you mean "Events (non-axis controls)" I thought this is something different.

Well, it's different from things writing to FSUIPC offsets, of course. it logs FS non-axis controls ("events") being sent to FS's simulation engine. Maybe it may show a battery master control? If so the next step is to find out where it's coming from. That's not so easy.

Pete

Posted

I enables "events (non axis controls)" and logged it. It seems there is no sign of anything still.

9688 SimConnect_Open succeeded: waiting to check version okay

11591 READ0 3304, 4 bytes: 01 00 00 46 ...F

11591 READ0 3308, 4 bytes: 08 00 DE FA ....

11591 WRITE0 8001, 13 bytes: 36 50 45 54 45 58 50 44 52 56 57 33 00 6PETEXPDRVW3.

11622 Running in "Microsoft Flight Simulator X", Version: 10.0.61637.0 (SimConnect: 10.0.61259.0)

11622 Initialising SimConnect data requests now

11622 FSUIPC Menu entry added

11638 \\BDT-KAY-BT-01W\B$\FSX\FLIGHTS\OTHER\FLTSIM.FLT

11638 \\BDT-KAY-BT-01W\B$\FSX\SimObjects\Airplanes\beech_baron_58\Beech_Baron_58.AIR

11919 Monitor IPC:281C (U32) = 0

11919 Monitor IPC:2E80 (U32) = 0

16599 READ0 337E, 2 bytes: 13 00 ..

21607 READ0 337E, 2 bytes: 27 00 '.

26645 READ0 337E, 2 bytes: 3B 00 ;.

28190 *** EVENT: Cntrl= 66514 (0x000103d2), Param= 0 (0x00000000) ATC_MENU_CLOSE

29828 SimRead: 281C="ELECTRICAL MASTER BATTERY"

INT32: 0 (0x00000000)

29828 SimRead: 2E80="AVIONICS MASTER SWITCH"

INT32: 0 (0x00000000)

31684 READ0 337E, 2 bytes: 5F 00 _.

36692 READ0 337E, 2 bytes: 73 00 s.

41699 READ0 337E, 2 bytes: 87 00 ..

46707 READ0 337E, 2 bytes: 9A 00 ..

51730 READ0 337E, 2 bytes: AE 00 ..

56754 READ0 337E, 2 bytes: C2 00 ..

61761 READ0 337E, 2 bytes: D6 00 ..

66597 System time = 07/12/2012 17:51:10, Simulator time = 17:50:15 (15:50Z)

66691 Aircraft="Beech Baron 58 Paint1"

66878 READ0 337E, 2 bytes: EC 00 ..

66909 LUA: beginning "B:\FSX\Modules\ipcReady.lua"

70372 Advanced Weather Interface Enabled

71886 READ0 337E, 2 bytes: B9 01 ..

76893 READ0 337E, 2 bytes: A9 02 ..

81916 READ0 337E, 2 bytes: AB 03 ..

86924 READ0 337E, 2 bytes: A3 04 ..

91947 READ0 337E, 2 bytes: AA 05 ..

96955 READ0 337E, 2 bytes: AC 06 ..

101978 READ0 337E, 2 bytes: B1 07 ..

107001 READ0 337E, 2 bytes: B4 08 ..

112009 READ0 337E, 2 bytes: B3 09 ..

113335 READ0 3304, 4 bytes: 01 00 00 46 ...F

113335 READ0 3308, 4 bytes: 08 00 DE FA ....

116596 READ0 281C, 4 bytes: 00 00 00 00 ....

117017 READ0 337E, 2 bytes: 94 0A ..

119201 READ0 281C, 4 bytes: 00 00 00 00 ....

121010 READ0 281C, 4 bytes: 00 00 00 00 ....

122040 READ0 337E, 2 bytes: 9C 0B ..

122399 WRITE0 281C, 4 bytes: 01 00 00 00 ....

127110 READ0 337E, 2 bytes: 9C 0C ..

127172 READ0 281C, 4 bytes: 00 00 00 00 ....

132180 READ0 337E, 2 bytes: 6A 0D j.

137250 READ0 337E, 2 bytes: 40 0E @.

142273 READ0 337E, 2 bytes: 15 0F ..

147281 READ0 337E, 2 bytes: D8 0F ..

152289 READ0 337E, 2 bytes: D8 10 ..

156001 Sim stopped: average frame rate for last 89 secs = 48.4 fps

157343 READ0 337E, 2 bytes: 96 11 ..

162351 READ0 337E, 2 bytes: AA 11 ..

166219 LogOptions changed, now 00000000 00000001

Posted

I enables "events (non axis controls)" and logged it. It seems there is no sign of anything still.

Hmm. I've done exactly the same here and I get this:


********* FSUIPC4, Version 4.859k by Pete Dowson *********
...
168372 System time = 07/12/2012 16:07:06, Simulator time = 16:04:32 (16:04Z)
171461 Aircraft="Beech Baron 58 Paint1"
...
207029 Monitor IPC:281C (U32) = 0
282564 WRITE0 281C, 4 bytes: 01 00 00 00 ....
282580 Monitor IPC:281C (U32) = 1
282580 SimRead: 281C="ELECTRICAL MASTER BATTERY"
INT32: 1 (0x00000001)
283064 READ0 281C, 4 bytes: 01 00 00 00 ....

[/CODE]

The master battery switch is one of the SimConnect variables which can be written to (many things can only be changed by sending controls or events). As you see, when I write 1 to 281C, Smconnect actions it and I read back 1.

Evidently in your case something is stopping SimConnect from switching. Just to make sure we are noth using the same software, try updating to FSUIPC 4.859k.

I'm not sure what to suggest next. It'll be a process of elimination. You say you can switch it on from the gauge? What does the log show then? Do you have any add-ons which might be interfering?

What if you switch it on in FS and try switching it off from your program. Does that work?

What about getting a SimConnect log? That'd show other programs doing things, maybe? See the FAQ subforum for instructions.

It is such a simple little thing. I dont know how it could be so mystifyingly wrong.

Posted

Thank you Pete. I will dig more as you suggest. I believe it is something else interfering. I use some add-ons like F1 Battery X an add-on which recharges battery voltage. Maybe one of them could be the reason. I also use saitek panels. I can use master battery from saitek panels very well. If I find a clue I will inform you then.

Best Regards,

Ahmet,

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.