Creating Mi-8 module for DCS-BIOS - ED Forums
 


Notices

Reply
 
Thread Tools Display Modes
Old 08-20-2017, 01:02 PM   #1
ArturDCS
Member
 
ArturDCS's Avatar
 
Join Date: Dec 2013
Location: Kaarina, Finland
Posts: 369
Reputation power: 4
ArturDCS will become famous soon enoughArturDCS will become famous soon enough
Default Creating Mi-8 module for DCS-BIOS

Doing my very first steps here and added Generator 1 & 2 Switch
If I toggle these in the cockpit the changes do show in DCS-BIOS Control Reference page. But not vice versa, cannot manipulate them in the ctrl-ref page and have the changes in the cockpit.

Looking at local cb_start_cmd which is used in already existing modules, is it just an unique number? Signature from Util.lua:defineToggleSwitch states it is "command"?


Mi8MT.lua :
Code:
BIOS.protocol.beginModule("Mi-8MT", 0x2600)
BIOS.protocol.setExportModuleAircrafts({"Mi-8MT"})

local documentation = moduleBeingDefined.documentation

local document = BIOS.util.document  

local parse_indication = BIOS.util.parse_indication

local defineFloat = BIOS.util.defineFloat
local defineIndicatorLight = BIOS.util.defineIndicatorLight
local definePushButton = BIOS.util.definePushButton
local definePotentiometer = BIOS.util.definePotentiometer
local defineRotary = BIOS.util.defineRotary
local defineSetCommandTumb = BIOS.util.defineSetCommandTumb
local defineTumb = BIOS.util.defineTumb
local defineToggleSwitch = BIOS.util.defineToggleSwitch
local defineToggleSwitchToggleOnly = BIOS.util.defineToggleSwitchToggleOnly
local defineFixedStepTumb = BIOS.util.defineFixedStepTumb
local defineFixedStepInput = BIOS.util.defineFixedStepInput
local defineVariableStepTumb = BIOS.util.defineVariableStepTumb
local defineString = BIOS.util.defineString
local defineRockerSwitch = BIOS.util.defineRockerSwitch
local defineMultipositionSwitch = BIOS.util.defineMultipositionSwitch

local cb_start_cmd = 3021

defineToggleSwitch("GEN1_SWITCH", 1, cb_start_cmd + 1, 538, "Circuit Breakers", "Generator 1 Switch, ON/OFF")
defineToggleSwitch("GEN2_SWITCH", 1, cb_start_cmd + 2, 539, "Circuit Breakers", "Generator 2 Switch, ON/OFF")
BIOS.protocol.endModule()
__________________
Co-developer of DCSFlightpanels together with pdmarsh.
Like the software? Please consider supporting it via PayPal.
ArturDCS is offline   Reply With Quote
Old 08-20-2017, 02:57 PM   #2
ArturDCS
Member
 
ArturDCS's Avatar
 
Join Date: Dec 2013
Location: Kaarina, Finland
Posts: 369
Reputation power: 4
ArturDCS will become famous soon enoughArturDCS will become famous soon enough
Default

OK so I started digging into the lua files for the Mi-8.

Code:
defineTumb("GEN1_SWITCH", 1, 3015, 538, 1, {0, 1}, nil, false, "Circuit Breakers", "Generator 1 Switch, ON/OFF")
Seems to do the trick. Tumb, what does that stand for?
__________________
Co-developer of DCSFlightpanels together with pdmarsh.
Like the software? Please consider supporting it via PayPal.
ArturDCS is offline   Reply With Quote
Old 08-20-2017, 03:10 PM   #3
ArturDCS
Member
 
ArturDCS's Avatar
 
Join Date: Dec 2013
Location: Kaarina, Finland
Posts: 369
Reputation power: 4
ArturDCS will become famous soon enoughArturDCS will become famous soon enough
Default

How do I reload the Lua engine(?) so I don't have to quit the mission and start again when I have added code to the Mi8MT.lua file?
__________________
Co-developer of DCSFlightpanels together with pdmarsh.
Like the software? Please consider supporting it via PayPal.
ArturDCS is offline   Reply With Quote
Old 08-20-2017, 03:36 PM   #4
ArturDCS
Member
 
ArturDCS's Avatar
 
Join Date: Dec 2013
Location: Kaarina, Finland
Posts: 369
Reputation power: 4
ArturDCS will become famous soon enoughArturDCS will become famous soon enough
Default

How do I figure out ranges, what are the end values?
From clickabledata.lua
Code:
elements["PTR-EEP-LVR-MODE"]        = multiposition_switch(_("AC Voltmeter Selector"), devices.ELEC_INTERFACE, device_commands.Button_17, 535, 11, 0.1)
It has 11 positions and after a few tries it seems like the range is 0 - 1.1. Is it possible to see those values somewhere? Some log?

So what seems to work is then in DCS-BIOS :
Code:
defineTumb("AC_VOLT_SEL", 1, cb_start_cmd + 17, 535, 0.1, {0, 1.1}, nil, false, "Circuit Breakers", "AC Voltmeter Selector")
__________________
Co-developer of DCSFlightpanels together with pdmarsh.
Like the software? Please consider supporting it via PayPal.
ArturDCS is offline   Reply With Quote
Old 08-20-2017, 04:47 PM   #5
[FSF]Ian
ED Testers Team
 
Join Date: Feb 2013
Location: Dortmund, Germany
Posts: 1,213
Reputation power: 12
[FSF]Ian is just really nice[FSF]Ian is just really nice[FSF]Ian is just really nice[FSF]Ian is just really nice[FSF]Ian is just really nice[FSF]Ian is just really nice[FSF]Ian is just really nice[FSF]Ian is just really nice[FSF]Ian is just really nice[FSF]Ian is just really nice[FSF]Ian is just really nice
Default

In general, argument values are somewhere in the range of -1.0 to 1.0 (inclusive). So far I haven't seen an argument value outside of this range.

If you have 11 possible values and they start at 0, the range would be {0, 1}:
0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0

If you are not sure what values are used by the sim, you can execute "return GetDevice(0):get_argument_value(n)" where n in the argument number. That will return the current value of that cockpit argument; you just have to manually set the switch to a few different positions and call that function again.

I don't know what "Tumb" stands for, it's just a term I adopted from ED's Lua files. Might be shorthand for something in Russian for all I know. It seems to refer to a control with several discrete positions.

To reload your Mi-8 Lua file, all you need to do is to execute the dofile(...) line that you added to BIOS.lua. That will work in most cases. You may still run into the occasional situation where you need to reload the sim, for example if you introduce an error in an inconvenient place and things only partially load, or if the state of the simulator gets confused because you tried to send commands to the simulator that it did not expect, but this is quite rare.

To execute Lua snippets in the sim, you can use the Lua console feature in DCS Witchcraft.
[FSF]Ian is offline   Reply With Quote
Old 08-20-2017, 05:50 PM   #6
ArturDCS
Member
 
ArturDCS's Avatar
 
Join Date: Dec 2013
Location: Kaarina, Finland
Posts: 369
Reputation power: 4
ArturDCS will become famous soon enoughArturDCS will become famous soon enough
Default

Thanks for the prompt reply.
I am installing Witchcraft. Received the following error. I am following your video & install guide.
Attached Thumbnails
Click image for larger version

Name:	error_witchcraft.jpg
Views:	23
Size:	77.9 KB
ID:	167826  
__________________
Co-developer of DCSFlightpanels together with pdmarsh.
Like the software? Please consider supporting it via PayPal.
ArturDCS is offline   Reply With Quote
Old 08-20-2017, 06:38 PM   #7
ArturDCS
Member
 
ArturDCS's Avatar
 
Join Date: Dec 2013
Location: Kaarina, Finland
Posts: 369
Reputation power: 4
ArturDCS will become famous soon enoughArturDCS will become famous soon enough
Default

Strange behavior from one of the controls.
If you have any idea it would be great, otherwise I'll leave it be.
Code:
defineTumb("BATT_HEAT_SWITCH", 1, cb_start_cmd + 75, 522, 1, {0, 1}, nil, false, "Electrical system", "Battery Heating Switch, ON/OFF")
Code:
--default_2_position_tumb(_("Battery Heating Switch, ON/OFF"), devices.ELEC_INTERFACE, cb_start_cmd + 75, 522)
This changes in the ctrl-ref page when switched in the cockpit but again, can't change it from the ctrl-ref page to make changes in the cockpit. Strange. Looks just like any other of the previous controls.

EDIT:
Problem found, it was the sequence cb_start_cmd + 75 that changed. I didn't notice it at first. Once I changed it to the correct number it works. That sequence and the former can be found in command_defs.lua for the Mi-8.
__________________
Co-developer of DCSFlightpanels together with pdmarsh.
Like the software? Please consider supporting it via PayPal.

Last edited by ArturDCS; 08-21-2017 at 04:42 AM. Reason: Found the problem.
ArturDCS is offline   Reply With Quote
Old 08-21-2017, 06:42 AM   #8
ArturDCS
Member
 
ArturDCS's Avatar
 
Join Date: Dec 2013
Location: Kaarina, Finland
Posts: 369
Reputation power: 4
ArturDCS will become famous soon enoughArturDCS will become famous soon enough
Default

DCS-BIOS bug?

Those controls that return to their off position once released, like reset toggle can't be manipulated from the DCS-BIOS ctrl-ref page. I compared to UH-1H, see screenshots.
I was trying to get the Group <n> On Buttons for the panels in the Mi-8 to work when I discovered this.

So it shows in the ctrl-ref page when I toggle them in the cockpit but vice versa does not work.
I can define them as defineToggleSwitch() for the Mi-8 but then they stay in the "unnatural" on position until toggled a 2nd time.
The UH-1H toggles are defined using defineRockerSwitch().
Attached Thumbnails
Click image for larger version

Name:	uh1h_returning_switch.jpg
Views:	25
Size:	115.1 KB
ID:	167845   Click image for larger version

Name:	mi-8_azs_grp_buttons.jpg
Views:	25
Size:	156.1 KB
ID:	167846  
__________________
Co-developer of DCSFlightpanels together with pdmarsh.
Like the software? Please consider supporting it via PayPal.
ArturDCS is offline   Reply With Quote
Old 08-21-2017, 11:42 AM   #9
[FSF]Ian
ED Testers Team
 
Join Date: Feb 2013
Location: Dortmund, Germany
Posts: 1,213
Reputation power: 12
[FSF]Ian is just really nice[FSF]Ian is just really nice[FSF]Ian is just really nice[FSF]Ian is just really nice[FSF]Ian is just really nice[FSF]Ian is just really nice[FSF]Ian is just really nice[FSF]Ian is just really nice[FSF]Ian is just really nice[FSF]Ian is just really nice[FSF]Ian is just really nice
Default

Assuming the switch starts in the OFF position, if you click the "toggle" button in the control reference once, it will toggle the state of the switch from OFF to ON. It will stay in that position until you send another command. There is nothing "unnatural" about this, the same thing happens if you click and hold the mouse button in the cockpit.

Once you send a second "toggle" command (or an "off" command), the switch returns to the OFF position. In the virtual cockpit, this happens as soon as you release the mouse button.
[FSF]Ian is offline   Reply With Quote
Old 08-21-2017, 11:46 AM   #10
ArturDCS
Member
 
ArturDCS's Avatar
 
Join Date: Dec 2013
Location: Kaarina, Finland
Posts: 369
Reputation power: 4
ArturDCS will become famous soon enoughArturDCS will become famous soon enough
Default

OK.
In the Mi-8 the group buttons get stuck behind the switches if you click a switch off while the group button (bar) is on. Looks awkward but if that is how it then no problemos. I'll just continue. Thanks!

Quote:
Originally Posted by [FSF]Ian View Post
Assuming the switch starts in the OFF position, if you click the "toggle" button in the control reference once, it will toggle the state of the switch from OFF to ON. It will stay in that position until you send another command. There is nothing "unnatural" about this, the same thing happens if you click and hold the mouse button in the cockpit.

Once you send a second "toggle" command (or an "off" command), the switch returns to the OFF position. In the virtual cockpit, this happens as soon as you release the mouse button.
__________________
Co-developer of DCSFlightpanels together with pdmarsh.
Like the software? Please consider supporting it via PayPal.
ArturDCS is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 08:30 AM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.