Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Asobo CJ4 or the Working Title mod?
Have you tried logging events (with console window open) to see what events are used when you start the engine manually via the UI?
Have you looked at available lvars (and maybe hvars) to see if any seem relevant, and the values they hold when you start via the UI?

Let me know which version of the CJ4 you are using and I can take a look later - or probably tomorrow, as I have an urgent issue I need to look into today.

John

  • 7 months later...
Posted

You are probably better of installing the WT mod for the CJ4 and using the MobiFlight presets for this (see https://hubhop.mobiflight.com/). You could try the presets with the vanilla CJ4 - they may work or not...
If you want to use the vanilla CJ4 and the MF presets (for the WT mod) don't work, try monitoring offsets 0x0892 and 0x092A (which hold the General Eng Starter simvar for engines 1 and 2 respectively) and see how they change when you run/stop the engines in the UI. If they change values accordingly, you can try assigning your buttons to set the values in those offsets using the Offset Word Set control with the appropriate parameter.
You could maybe also try the Toggle Starter 1/2 controls.

John

Posted
34 minutes ago, John Dowson said:

, try monitoring offsets 0x0892 and 0x092A (which hold the General Eng Starter simvar for engines 1 and 2 respectively) and see how they change when you run/stop the engines in the UI.

I've checked this and they don't change.

34 minutes ago, John Dowson said:

You could maybe also try the Toggle Starter 1/2 controls.

This changes the run/stop from off to Stop, but I can't get it to Run using this. I've also tried Starter 1 Set control and this achieves the same thing.
However, overloading assignments and sending the following 3 controls toggles between run/stop:
    MIXTURE1_RICH
    TOGGLE_FUEL_VALVE_ENG1
    TURBINE_IGNITION_SWITCH_SET1
and Run switch to OFF:
    MIXTURE1_LEAN
    TOGGLE_FUEL_VALVE_ENG1

To overload your assignments, to need to manually edit the ini. Assign to the first control and save, then, with the FSUIPC button assignments window open, open your FSUIPC7.ini file in an editor. Locate the line for the assignment just added, then place a ; after the '=' on that assignment line and save. In FSUIPC, reload your assignments. You can then assign to the second control. Repeat to assign to the third control. Once all assignments are done, remove the ; you added, then reload your assifnments one more time.
This is how my ini looks for button assignment to run/stop toggle:

70=P174,7,C65983,0 	-{MIXTURE1_RICH}-
71=P174,7,C66494,0 	-{TOGGLE_FUEL_VALVE_ENG1}-
72=P174,7,C67017,0 	-{TURBINE_IGNITION_SWITCH_SET1}-

There are also other control combinations that work. See https://forums.flightsimulator.com/t/map-engine-run-stop-to-device-button-citation-cj4.

John

Posted

You could also add your own preset to do this, which maybe easier. For example, for the run/stop toggle, create a file called myevents.txt in your FSUIPC7 installation folder, and add the following line:

CRJ Engine1 Run-StopToggle# 0 (>K:MIXTURE1_RICH) 0 (>K:TOGGLE_FUEL_VALVE_ENG1) 0 (>K:TURBINE_IGNITION_SWITCH_SET1)

You can then assign to 'Preset: CRJ Engine1 Run'. You can add similar presets for engine 2 and also for off.

Note that presets are only loaded when FSUIPC starts, so if you make any changes, restart FSUIPC7 to take affect.

John

  • 4 weeks later...
Posted
7 hours ago, ElNochen said:
is there any way to use these mobiflight presets on the websocket server from fsuipc?

You can use presets by writing to offset to the generic control offset at 0x3110, but you need to determine the control number if the preset. You can also use offset 0x7C50 where you can write the preset name directly (preceded by 'P:') - see the offset status document for details)

I presume you can write to any offset using the websocket server, and I am not sure if there is a higher level API available, but@Paul Henty should be able to confirm.

John

Posted
1 hour ago, John Dowson said:

I presume you can write to any offset using the websocket server, and I am not sure if there is a higher level API available, but@Paul Henty should be able to confirm.

Yes, any offset can be used from the websocket server. There is no higher level APi for writing controls though, so you need to use the offset directly.

To send the control, declare two offsets of type int with size 4. The first one should be the parameter value at 0x3114. The second should be the control number at 0x3110. The order is important. 0x3114 should be declared before 0x3110.

0x7C50 probably just needs to be declared as a string offset with the appropriate length. I can't find it in the docs I have here. Must be new.

Paul

Posted
6 hours ago, Paul Henty said:

0x7C50 probably just needs to be declared as a string offset with the appropriate length. I can't find it in the docs I have here. Must be new.

This was added in v7.3.0 and is included in the latest offset documentation:

Quote
Area for setting lvars, activating hvars, calling presets and executing calculator code.
To set and lvar value, first write the value to offset 0x0780 as a string, up to 8 characters in length (including the string terminator, so max 7 characters).
Then write the lvar name, preceded by 'L:', to offset
0x7C50, maximum of 64 characters (including string
terminator character).
To call a preset, first write the preset parameter (if needed) to offset 0x7C80 as a 32-bit integer value, then write the preset name, preceded by 'P:' to offset 0x7C50.
To activate a hvar, write the hvar name preceded by 'H:' to offset 0x7C50. Mo parameter is needed or used. Lvars, hvars and presets must be known to FSUIPC when using this facility. If it is not known, you can still use this offset but use the calculator code version.
Any string found not starting with 'L:', 'H:' or 'P:' is taken to be calculator code and will be executed as such.

John

Posted (edited)
 

I'm still a beginner, I couldn't get a complete understanding of this, could you give me a simple example of how I would run a preset on the websocket,
it can be a simple example, that once I understand how it works I can adapt it to my needs.

Edited by ElNochen
Posted
11 hours ago, ElNochen said:

I'm still a beginner, I couldn't get a complete understanding of this, could you give me a simple example of how I would run a preset on the websocket,
it can be a simple example, that once I understand how it works I can adapt it to my needs.

I cannot help you with the WebSocket server as I have never used this - @Paul Henty may be able to assist. However, I assume it is just a matter of writing the correct data to an offset with the facilities provided - you just need to write the preset name (preceded by 'P:') to offset 0x7C50.

John

Posted
13 hours ago, ElNochen said:

could you give me a simple example of how I would run a preset on the websocket

The main example for writing offsets is here:

http://fsuipcwebsockets.paulhenty.com/#cmdoffsetswrite

The full code is available via the button at the bottom of the page.

You'll just need to plug in your own offset declarations and write the appropriate values. I've never used these facilities but from looking at the documentation, this is probably what you need:

Offset Declaration Request:

        var request = {
            command: 'offsets.declare',
            name: 'runpreset',
            offsets: [
                { name: 'presetParameter', address: 0x7C80, type: 'int', size: 4 },
                { name: 'presetName', address: 0x7C50, type: 'string', size: 48 },
            ]
        }

 

Write Request:

       var presetName = 'MyPreset'; 
       var presetParameter = 0;
       var request = {
            command: 'offsets.write',
            name: 'runpreset',
            offsets: [
                { name: 'presetParameter', value: presetParameter },
                { name: 'presetName', value: 'P:' + presetString }
            ]
        }

Paul

Posted
18 minutes ago, Paul Henty said:

Offset Declaration Request:

        var request = {
            command: 'offsets.declare',
            name: 'runpreset',
            offsets: [
                { name: 'presetParameter', address: 0x7C80, type: 'int', size: 4 },
                { name: 'presetName', address: 0x7C50, type: 'string', size: 48 },
            ]
        }

 

Looking at this I have realised that I have made a mistake in the position of the parameter - as the total length of offset 0x7C50 is 72 bytes, I should have but the preset parameter at offset 0x7C94, allowing for 68 bytes for the offset name. Or, probably better, allowing 8 bytes for the parameter so putting the parameter at offset 0x7C90 and allowing 64 bytes for the name.

I will leave this for now, but may have to update if preset names get larger than 48 bytes.

John

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.