DGIV Simpit

meson800

Addon Developer
Addon Developer
Donator
Joined
Aug 6, 2011
Messages
405
Reaction score
2
Points
18
I have created a working DGIV simpit, ableit not completed, that uses pushbuttons and toggle switches to simulate the buttons (such as airlock, thruster doors, apu power, etc).

Due to time limitations, it isn't finished but here are some pictures of what I have done so far.

Image of front MFD panel with fuel display


Overall simulator without side panels


Wiring of MFD panel

The MFD's are run using ExternalMFD and AutoHotKey. The script creates two externalMFD's and simulates keypresses on them.
The fuel display is also done using AutoHotKey.

To simulate all of the DGIV buttons, I use the following basic function.
Code:
OBJHANDLE hsimVessel = oapiGetVesselByName(shipName);
((VESSEL2 *)oapiGetVesselInterface(hsimVessel))->clbkPanelMouseEvent(id,event,mx,my)
In my code, I replaced shipName with "DGIV_SIM"; to control a dgiv, I just rename it DGIV_SIM in the scenerio.
To simulate a "mouse event" on the panel, I had to find out the id,event,mx, and my values for all of the DGIV switches. To do this, I did the following.


Code:
DLLCLBK void opcFocusChanged (OBJHANDLE hGainsFocus, OBJHANDLE hLosesFocus)
{
	OBJHANDLE hVessel = oapiGetVesselByName("DGIV_SIM");
	if (hGainsFocus == hVessel && oapiIsVessel(hVessel))
	{
		InstallVesselHook((VESSEL2 *)oapiGetVesselInterface(hGainsFocus));
		SetEventsEnabled(true);

	}
	if (hLosesFocus == hVessel && oapiIsVessel(hVessel))
	{
		RemoveVesselHook((VESSEL2 *)oapiGetVesselInterface(hGainsFocus));
		SetEventsEnabled(false);
	}
}

This uses Face's VesselHook and HookMethods, to which I edited the line 299, the print line inside HookMethods::clbkPanelMouseEvent from
Code:
fprintf(l, "%d[%s]M(%d) %d: %d %d\n", GetTickCount(), this->GetName(), ev, id, mx, my);
to
Code:
fprintf(l,"%d,%d,%d,%d\n",ev,id,mx,my);

This meant that any mouse click on the DGIV' panel would be outputted to the log file at Your_Orbiter_Folder\Modules\Plugin\Events.log in a simple line format.
Code:
(Vessel hooking system initiated)
(Class table was empty)
(Vessel table was empty)
Vessel hooked
Class hooked
1,233,10,8
1,233,13,30
Sample Events.log

From this, I could extract the event,id,mx,and my value for every switch on the DGIV.

Here is a quick spreadsheet I made with the event,id,mx,and my values for every switch on the DGIV.
https://dl.dropbox.com/u/4618573/DGIV%20Sim%20Switches.xlsx

To wire the switches, I used an Arduino and two mulitplexers (https://www.sparkfun.com/products/299), wired a push button or toggle switch to the multiplexers, and programmed the Arduino to output when a switch's state changes to the computer, which is intercepted by my Orbiter module. If anyone wants to see my Arduino code, I'll post it.

My Orbiter module (I will post it as soon as I finish it) takes a updated switch state from the Arduino, finds which DGIV switch it corresponds to using a config file, and sends the DGIV the correct panelMouseEvent code.

After I finish wiring all of the panels, I plan on adding LED's to change with different states of the DGIV.

Hopefully this is helpful for other simpit builders, as we can now simulate any panel switch in our simpits.

Also, thanks Face for the vessel hooking code! I couldn't have done it without your help :tiphat:
 

sitha241

Member
Joined
Feb 22, 2010
Messages
278
Reaction score
0
Points
16
Location
Zagreb
Thank you a lot sir!! :tiphat:
I wanted DIVG but I did not have idea how to do it with DGIV virtual buttons!
:thumbup:
:cheers:
 

Donamy

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Oct 16, 2007
Messages
6,907
Reaction score
205
Points
138
Location
Cape
Very cool !! gonna be watch'n this take shape.
 

Phil Smith

Donator
Donator
Joined
Jun 5, 2011
Messages
273
Reaction score
101
Points
58
Location
UK
a hell of the job!
really impressive!! I like wiring looks awesome.
I hope one of my friend can help me with cutting metal with CNC for my pit.
Can we get more pics of displays? (for MFDs and for fuel indication)
Btw, what kind of buttons for MFDs will you use? How will they look?
 
Last edited:

meson800

Addon Developer
Addon Developer
Donator
Joined
Aug 6, 2011
Messages
405
Reaction score
2
Points
18
So, the simulator is finished...at least kind of.
All of panels, electronics, labeling, and programming is done, but due to an issue where three switches can "bypass" a forth, the panels don't actually work. Whoops :facepalm:
Luckily, adding diodes to the switches will solve the problem, so I will be able to get it running in two weeks when the diodes arrive! As no more physical work is to be done, here's some pictures of the completed simpit.
picture.php

picture.php

picture.php


Although it pales in comparison to some of the other simpits here :)cheers: ao7g), it was fairly low-budget as I am still in high-school. But the next simpit...

Thanks for the inpsiration that helped me complete this! :tiphat:

Phase two of the project will be adding status LED's and more eyecandy, but I'll play with my new simpit first before tackling that ;)

To Phil Smith:
I'm using these buttons https://www.sparkfun.com/products/9190
they send commands through the arduino to an ahk script which simulates mouseclicks on the External MFD's.
 

sitha241

Member
Joined
Feb 22, 2010
Messages
278
Reaction score
0
Points
16
Location
Zagreb
Wow :)
Just do not flee from forum cause Il need your help..I am now in process of getting funds from university to build simpit but I planned to do motion platform too..
Il need your help with doing virtual buttons to phyisical switches on DGIV..
Nice work man :)
 

meson800

Addon Developer
Addon Developer
Donator
Joined
Aug 6, 2011
Messages
405
Reaction score
2
Points
18
I would never flee from OF :)
I'll be glad to help you, just PM me.
My Orbiter module uses config files to define which virtual buttons correspond to which physical buttons, so one could make a simpit for any of the great vessels here, not just the DGIV. (I'd really like to see a simpit for NASSP)
 
Top