Goksel Sunar Posted October 13, 2015 Report Posted October 13, 2015 Hi I create one lua file and assign to F6 key in the "FSUIPC Options and Settings" windows and , if I hit F6 key in the simulation , this is working good now. Lua Code : function Pitot_HEAT() testVar = ipc.readUD(0x66C0) if logic.And(testVar,1) == 1 then ipc.control(65858,1) else ipc.control(65858,0) endendevent.offset(0x66C0, 'UD', 'Pitot_HEAT') I am writing c# windows forms application and , I want to access this offset and change value . I wrote this code but did not get results. c# Code: private Offset<int> Pitot_HEAT = new Offset<int>(0x66C0) //ON Pitot_HEAT.Value=1; //OFF Pitot_HEAT.Value=0; thank you for your interest. Goksel
Paul Henty Posted October 13, 2015 Report Posted October 13, 2015 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
Goksel Sunar Posted October 13, 2015 Author Report Posted October 13, 2015 I have a timer in the form and " FSUIPCConnection.Process();" in the procedure. I did as you said, but did not change the results. Maybe you have other suggestions? best regards. Goksel
Paul Henty Posted October 13, 2015 Report Posted October 13, 2015 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
Goksel Sunar Posted October 14, 2015 Author Report Posted October 14, 2015 Hi, I was able to write a working example code. But ,I am not sure is this the right way . I create a while loop in the Lua code . Because ,I could not find a way to continuous control of the offset value. II think when the offset value is changed , automatically trigger control for it self. am i wrong ? Because , as the first example , I do what you say , and open the log screen and I saw the offset value changing from csharp code but nothing happened in simulation. If can you review code and write a comment , I would be hapy :) Lua Code : function PFuelCutOffSwitch(param) n = ipc.readLvar('L:Eng1_FuelCutOffSwitch') if param == 1 and n==0 then ipc.writeLvar('L:Eng1_FuelCutOffSwitch',1) end if param == 0 and n==1 then ipc.writeLvar('L:Eng1_FuelCutOffSwitch',0) end end event.offset('0x66C0','UD', 'PFuelCutOffSwitch')while 1 dotestVar = ipc.readUD(0x66C0)if logic.And(testVar,1) == 1 thenPFuelCutOffSwitch(1)endif logic.And(testVar,1) == 0 thenPFuelCutOffSwitch(0)endend csharp code private Offset<int> Pitot_HEAT = new Offset<int>(0x66C0); //ON FSUIPCConnection.Process(); Pitot_HEAT.Value=1; //OFF FSUIPCConnection.Process(); Pitot_HEAT.Value=0;
Paul Henty Posted October 14, 2015 Report Posted October 14, 2015 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
Goksel Sunar Posted October 14, 2015 Author Report Posted October 14, 2015 Dear paul , now work :) function PFuelCutOffSwitch() testVar = ipc.readUD(0x66C0)n = ipc.readLvar('L:Eng1_FuelCutOffSwitch') if logic.And(testVar,1) == 1 then if n==0 then ipc.writeLvar('L:Eng1_FuelCutOffSwitch',1) end endif logic.And(testVar,1) == 0 then if n==1 then ipc.writeLvar('L:Eng1_FuelCutOffSwitch',0) end end end event.offset('66C0','UD', 'PFuelCutOffSwitch') Thank you a thousand times, how many times I have read pdf files, but I've missed. I have one final question with your permission. how can I define this offsets in .net . I did like the lights example but did not again :) lua code event.offsetmask(0x66C0, 8,'UD', 'Fuel_Pump')event.offsetmask(0x66C0, 256,'UD', 'Beacon_Light')event.offsetmask(0x66C0, 1024,'UD', 'Strobe_Light') c# code private Offset<BitArray> Lights = new Offset<BitArray>(0x66C0,2); // on FSUIPCConnection.Process(); lights.Value[1] =true ; // I was [0]...[8] I tried it a one to eight. //off FSUIPCConnection.Process(); lights.Value[1] =false ; // I was [0]...[8] I tried it a one to eight.
Paul Henty Posted October 14, 2015 Report Posted October 14, 2015 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
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