XP Interfacer une carte EFDE sans SIOC avec OCUSBMapper ?

Je suis tombé dessus ... c'est un modèle vide avec les déclarations et les fonctions d'initialisations.

Une base de départ pour créer ses scripts LUA perso ...
Pour l'instant, je n'ai pas trouvé les déclarations dans les fichiers existants vers les IO pour les changer ...

J'ai bien une déclaration vers le tabl'eau leds[ ] mais aucune trace du lien entre un numéro d'IO et sa fonction dans le cockpit ....

J'ai abandonné pour l'instant mes recherches ... si vous trouvez quelque chose, dites le moi ....

Objectif : Prendre une LED, comme la LED AT et la brancher sur une sortie choisie par nous ...
 
Dernière édition:
J'ai un peu regardé la chose.

J'ai regardé DatarefTool en scrutant : pikitanga/ocusbmapper/usb1/input/digital
Quand j'actionne un interrupteur je vois par exemple :
[0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

le 6ème nombre est 1. Du coup, j'ai essayé :

Code:
--[[
*****************************************************************************************
* Program Script Name    :    RJ85.EFDE_OVH
*
* Author Name            :    Emmanuel v1.00
*
*   Revisions:
*   -- DATE --    --- REV NO ---        --- DESCRIPTION ---
*      31/01/2020   1.0.0                Création
*
*
*
*
*****************************************************************************************
--]]



--*************************************************************************************--
--**                                   XLUA GLOBALS                                   **--
--*************************************************************************************--

--[[

SIM_PERIOD - this cont'ains the duration of the current frame in seconds (so it is alway a
fraction).  Use this to normalize rates,  e.g. to add 3 units of fuel per second in a
per-frame callback you’d do fuel = fuel + 3 * SIM_PERIOD.

IN_REPLAY - evaluates to 0 if replay is off, 1 if replay mode is on

--]]


--*************************************************************************************--
--**                                    CONSTANTS                                     **--
--*************************************************************************************--

USB_DEVICE = 1

--*************************************************************************************--
--**                                 GLOBAL VARIABLES                                 **--
--*************************************************************************************--



--*************************************************************************************--
--**                                 LOCAL VARIABLES                                  **--
--*************************************************************************************--
local simDR_battery = -1
local ovhDR_button_YD_on = -1
local seatBelts = -1
local ovhDRavionics = -1


--*************************************************************************************--
--**                              FIND X-PLANE DATAREFS                                 **--
--*************************************************************************************--

simDR_battery                = find_dataref("sim/cockpit/electrical/battery_on")

-- switch

ovhDR_button_batt_on        = find_dataref("sim/cockpit/engine/APU_running")
ovhDR_button_YD_on            = find_dataref("sim/s'ystems/yaw_damper_on")
seatBelts                    = find_dataref("sim/cockpit/switches/fasten_seat_belts")
ovhDRseatBelts                = find_dataref("sim/s'ystems/seatbelt_sign_toggle")
ovhDRavionics                = find_dataref("sim/cockpit/electrical/avionics_on")



--*************************************************************************************--
--**                                FIND X-PLANE COMMANDS                                **--
--*************************************************************************************--



--*************************************************************************************--
--**                               FIND CUSTOM DATAREFS                                  **--
--*************************************************************************************--


usbDR_input_digital          = find_dataref("pikitanga/ocusbmapper/usb" .. USB_DEVICE .. "/input/digital")
--[[
usbDR_input_analog           = find_dataref("pikitanga/ocusbmapper/usb" .. USB_DEVICE .. "/input/analog")
usbDR_input_analog_notshow   = find_dataref("pikitanga/ocusbmapper/usb" .. USB_DEVICE .. "/output/analog/notshow")
usbDR_output_allon           = find_dataref("pikitanga/ocusbmapper/usb" .. USB_DEVICE .. "/output/allon")
usbDR_output_dspl            = find_dataref("pikitanga/ocusbmapper/usb" .. USB_DEVICE .. "/output/dspl")
usbDR_output_dspl_brightness = find_dataref("pikitanga/ocusbmapper/usb" .. USB_DEVICE .. "/output/dspl/brightness")
usbDR_output_leds            = find_dataref("pikitanga/ocusbmapper/usb" .. USB_DEVICE .. "/output/leds")
--]]

--*************************************************************************************--
--**                               FIND CUSTOM COMMANDS                               **--
--*************************************************************************************--



--*************************************************************************************--
--**                         CREATE READ-ONLY CUSTOM DATAREFS                            **--
--*************************************************************************************--



--*************************************************************************************--
--**                        READ-WRITE CUSTOM DATAREF HANDLERS                          **--
--*************************************************************************************--



--*************************************************************************************--
--**                        CREATE READ-WRITE CUSTOM DATAREFS                         **--
--*************************************************************************************--



--*************************************************************************************--
--**                              CUSTOM COMMAND HANDLERS                             **--
--*************************************************************************************--



--*************************************************************************************--
--**                               CREATE CUSTOM COMMANDS                               **--
--*************************************************************************************--



--*************************************************************************************--
--**                              X-PLANE COMMAND HANDLERS                            **--
--*************************************************************************************--



--*************************************************************************************--
--**                              REPLACE X-PLANE COMMANDS                               **--
--*************************************************************************************--



--*************************************************************************************--
--**                               WRAP X-PLANE COMMANDS                               **--
--*************************************************************************************--



--*************************************************************************************--
--**                                OBJECT CONSTRUCTORS                                  **--
--*************************************************************************************--



--*************************************************************************************--
--**                                   CREATE OBJECTS                                    **--
--*************************************************************************************--



--*************************************************************************************--
--**                                  SYSTEM FUNCTIONS                                **--
--*************************************************************************************--

function process_switches()

    if usbDR_input_digital[5] and simDR_battery == 0 then
        simDR_battery[1] = 0
    end
    if usbDR_input_digital[4] == 1 then
        seatBelts = 2
    end
    if usbDR_input_digital[4] == 0 then
        seatBelts = 0
    end

end

function process_buttons()
end

function process_dials()

end

function process_leds()

end

function process_displays()

    --[[
   
    0 - 9     = corresponding digit
    10        = blank
    11        = -
    12 - 15 = varies depending on the hardware device eg MCP 13 is an "A"
   
    --]]

end

function process_encoders()

end


--*************************************************************************************--
--**                                XLUA EVENT CALLBACKS                                **--
--*************************************************************************************--

--function aircraft_load() end

--function aircraft_unload() end

--function flight_start() end

--function flight_crash() end

function before_physics()

    process_switches()
    process_buttons()
    process_dials()
    process_leds()
    process_displays()
    process_encoders()

end

--function after_physics() end

--function after_replay() end

--*************************************************************************************--
--**                                SUB-MODULE PROCESSING                                **--
--*************************************************************************************--

-- dofile("")

Ça marche pas.
 
Dernière édition:
le chiffre qui est à 1 sur ton tabl'eau est le sixième ... entrée 6 de la carte traduit en informatique , c'est l'entrée 5 parce que l'entrée 1 commence à zéro !
D'autres t'expliqueront ça mieux que moi
en base 2 tu comptes 0 et 1 , en hexa de 0 à F ...
C'est comme ça sur les pokeys , le nombfre de fois ou j'ai tapé le mauvais numéro ... il me semble que Pikitanga le mentionne dans l'un des scripts ...
 
Dernière édition:
entree digitale = -1
Je pense également qu'il faut finir le script comme Pikitanga ... voir template ou les scripts ...
 
Oui, c'était un extrait, je finis par

Code:
function before_physics()

    mcpv3_leds()
    mcpv3_switches()
    mcpv3_buttons()
    mcpv3_displays()
    mcpv3_encoders()

end

Que veux-tu dire par : entree digitale = -1 ?
 
A digital input has an initial value of -1.
They live in groups of nine inputs eg 0 - 8
As soon as one of these inputs changes state, all nine inputs are updated to their true state.
Therefore always write your script avoiding the "else" statement for digital inputs.
 
*************************************************************************************--
--** LOCAL VARIABLES **--
--*************************************************************************************--

local flt_alt_value_prev = -1
local flt_alt_acceleration = -1

local land_alt_value_prev = -1
local land_alt_acceleration = -1

--local do_once = 1
 
@Avro
merci , je viens de voir ...
tu as essayé de désactiver temporairement xpuipc par le menu plugin / administation / xpuipc checkbox ?
 
Il faudrait prendre une dataref facilement identifiable et contrôlable pour commencer, en utilisant un annonciateur du MCP par exemple ...
AT, ou speed ou ALT ...
 
Battery est un exemple simple. En SIOC :

15 sim/cockpit/electrical/battery_on

Code:
Var 0501, name ETATBATTERY, Link IOCP, Offset 15
Var 0502, name BATT_SW, Link IOCARD_SW, Input 4
{

    &ETATBATTERY = &BATT_SW

}

En LUA :

Code:
local simDR_battery = -1
simDR_battery = find_dataref("sim/cockpit/electrical/battery_on")
usbDR_input_digital = find_dataref("pikitanga/ocusbmapper/usb" .. USB_DEVICE .. "/input/digital")

function process_switches()

    if usbDR_input_digital[5] ==1 and simDR_battery == 0 then
        simDR_battery = 1
    end
    if usbDR_input_digital[5] ==0 and simDR_battery == 1 then
        simDR_battery = 0
    end

end[

function before_physics()

    process_switches()
    process_buttons()
    process_dials()
    process_leds()
    process_displays()
    process_encoders()

end
/CODE]
 
Oui, très bien ça, et ça donne quoi avec l'un et avec l'autre ?

(Vu comme cela SIOC est plus simple (y))
 
En SIOC : OK et en LUA : KO

En apparence SIOC est plus simple mais à déboguer lua est probablement plus cool. Cela devrait marcher mais non !

J'ai une idée, je vais creuser.
 
Pourtant, c'est pas mal comme code ...

Ce qui me gène en LUA, c'est qu'il n'y a pas d'outils de débogage ... genre une une console pour afficher des variables, ou alors je n'ai pas creusé ...

En SIOC, tu as le SIOC monitor et tu sais si une variable bouge comme tu le souhaites, même FSUIPC a une un log pour afficher les valeurs des offset.

Avec LUA tu ne sais même pas si ton code travaille ?
 
Fab , je taquine , mais tu n'es pas assez observateur ... et lua et beaucoup plus moderne que sioc ! :p


sc
FAE42B6C-E65D-46DB-BCE4-9D1DFE9A9DE0.jpeg
 
Oui, c'est l'idée ...

il n'y a pas moyen denvoyer quelque chose vers une console ou une fenêtre das XP ?
 
https://forums.x-plane.org/index.ph...lua-scripting/&do=findComment&comment=1460039

regarde sur le lien , je n'ai mis que le début , il y d'autres paragraphes ...
pour xlua , il faut démarrer xp par la console windows , tu auras le log xlua ....

Script packaging and basic structure

XLua scripts are organized into "modules". Each module is a fully independent script that runs inside your aircraft.

  • Modules are completely independent of each other and do not share data. They are designed for isolation.
  • You do not need to use more than one module. Multiple modules are provided to let work be copied as a whole from one aircraft to each other.
  • Each module can use one .lua script file or more than one .lua script file, depending on author’s preferences.
So, here are two methods you can use for this:

  1. As you described, place each script in its own directory (module) with the script name matching the folder name. See the default 747 for examples.
  2. You can also place multiple scripts in one directory (module). The "main" script file is loaded and run automatically. The other scripts in a directory will load and run based on naming convention used. If the script names include the directory name, they will load and run automatically (see the default C90 for examples), otherwise you will need to use dofile(script_name) to load and run the other scripts.
Subfolders in the scripts folder are not allowed. All modules must be within "scripts".

The file init.lua is part of the XLua plugin itself and should not be edited or removed.

How a module script runs

When your aircraft is loaded (before the .acf and art files are loaded) the XLua plugin is loaded, and it loads and runs each of your module scripts.

When your module’s script is run, all Lua code that is outside of any function is run immediately. Your script should use this immediate execution only to:

  • Create new datarefs and commands specific to your module and
  • Find built-in datarefs and commands from the sim. All other work should be deferred until you receive additional callbacks.
Once the aircraft itself has been loaded, your script will receive a number of major callbacks. These callbacks run a function in your script if a function with the matching name is found. You do not have to implement a function for every major callback, but you will almost certainly want to implement at least some of them.

Besides major callbacks, one other type of function in your script will run: when you create or modify commands and when you create writeable datarefs, you provide a Lua function that is called when the command is run by the user or when the dataref is written (e.g. by the panel or a manipulator).
 
Number "types" in Lua are dynamic. Prior to Lua 5.3 all numbers were floats. Integers in 5.3 (and after) are now "truly" integers. However, this is all internal to Lua. You cannot assign "integer" or "float" in Lua, it is done internally based on the value. In Lua you can determine what a number is at any point by using math.type(x), which will return "integer" for an integer, "float" for a float, or nil if it is not a number.
If you're having a problem writing to number DataRefs in FlyWithLua (that you are sure are designated as "number" and are writeable) , I would file a bug report with Laminar.
 
J'ai essayé avec la console Windows avec des print() un peu partout ... j'vois rien ...

Je continue les tests ....
 
CA Y EST !
Il faut lancer XP à partir de la console MAIS ... rediriger (avec >) les sorties vers un fichier en faisant
X-plane.exe> monfichierlog.txt

Donc pas de sortie directement sur la console mais un fichier avec les erreurs et le print() !

On avance !
 
J'ai dû rater une marche, le fichier monfichierlog.txt reste à 0 octet.

Il y a un fichier Log.txt qui se crée mais je n'ai pas vu de problème particulier. Il charge mon script.

Code:
DataRefTool: Plane loaded #: 0
DataRefTool: Found 44 unique possible datarefs in file "C:\X-Plane 11/Aircraft/AvroRJ85 XP11 8.09\plugins\sasl\64\win.xpl"
DataRefTool: Found 6 unique possible datarefs in file "C:\X-Plane 11/Aircraft/AvroRJ85 XP11 8.09\plugins\xlua\64\win.xpl"
DataRefTool: Found 125 unique possible datarefs in file "C:\X-Plane 11/Aircraft/AvroRJ85 XP11 8.09\plugins/xlua/scripts\RJ85.opencockpits_mcp\RJ85.opencockpits_mcp.lua"
DataRefTool: Found 5 unique possible datarefs in file "C:\X-Plane 11/Aircraft/AvroRJ85 XP11 8.09\plugins/xlua/scripts\RJ85.EFDE_OVH\RJ85.EFDE_OVH.lua"
…
 
Retour
Haut