Exemplo n.º 1
0
void registerCallbacks()
{
	XPLMDebugString("Registering callbacks\n");
	XPLMRegisterFlightLoopCallback(
							sendRequestedDataCallback,
							situation_update_period,
							NULL);
							
	
	XPLMRegisterFlightLoopCallback(
							receiveCallback,
							recv_delay,
							NULL);							
}
Exemplo n.º 2
0
PLUGIN_API int XPluginEnable(void)
{
	recv_enabled = 1;
	plugin_enabled = 1;
	XPLMDebugString("XPUDPNG: enabled\n");

	/* Register Flight Loop Callbacks */
	XPLMRegisterFlightLoopCallback(ReceiveClientTalkCallback, XPUDPNG_RECV_FREQ_CALL, NULL);

	return ensure_socket_bound();
}
Exemplo n.º 3
0
PLUGIN_API int XPluginStart(
        char * outName,
        char * outSig,
        char *outDesc) {
    XPLMRegisterFlightLoopCallback(MyFlightLoopCallback, 0.01f, NULL);
    Q_ASSERT(!globalPlugin);
    globalPlugin = new XPlanePlugin();
    if(globalPlugin) {
        return globalPlugin->pluginStart(outName, outSig, outDesc);
    } else {
        INFO << "Unable to create plugin";
        return 0;
    }
}
int	createGNSWindow()
{
    int res = 0;

    XPLMCreateWindow_t win;
    win.structSize = sizeof(XPLMCreateWindow_t);
    win.left = g_pos_x;
    win.top = g_pos_y + (int)(gpGNSIntf->bezel_height*g_zoom);
    win.right = g_pos_x+(int)(gpGNSIntf->bezel_width*g_zoom);
    win.bottom = g_pos_y;
    win.visible = true;
    win.drawWindowFunc = myDrawWindowCallback;
    win.handleMouseClickFunc = myHandleMouseClickCallback;
    win.handleKeyFunc = myHandleKeyCallback;
    win.handleCursorFunc = myHandleCursorCallback;
    win.handleMouseWheelFunc = myHandleMouseWheelFunc;
    win.refcon = NULL;



    //Register the Draw Window
    // Create a windows for displaying the projection info
    gWindow = XPLMCreateWindowEx(&win);

    logMessageEx("--- GNS Window created");

    initTextures();
    logMessageEx("--- Textures created");

    /// Register so that our gauge is drawing during the Xplane gauge phase
    XPLMRegisterDrawCallback(myDrawGNSCallback, xplm_Phase_Window, 1, NULL); // before window draw
    logMessageEx("--- DrawCallback registered");

    //Register the callback for gUpdateInterval.  Positive intervals
    //are in seconds, negative are the negative of sim frames.  Zero
    //registers but does not schedule a callback for time.
    XPLMRegisterFlightLoopCallback(myFlightLoopCallback, gUpdateInterval, NULL);
    logMessageEx("--- FlightLoopCallback registered");

    //Set the initial values of the COM and NAV
    gGNSx30Proxy.setCOMActiveFrequency(XPLMGetDatai(g_com1_active_ref)*10);
    gGNSx30Proxy.setCOMStandbyFrequency(XPLMGetDatai(g_com1_standby_ref)*10);
    gGNSx30Proxy.setNAVActiveFrequency(XPLMGetDatai(g_nav1_active_ref)*10);
    gGNSx30Proxy.setNAVStandbyFrequency(XPLMGetDatai(g_nav1_standby_ref)*10);


    gnsOpened = true;

    return res;
}
Exemplo n.º 5
0
PLUGIN_API int XPluginStart(
						char *		outName,
						char *		outSig,
						char *		outDesc)
{
	char	outputPath[255];
	strcpy(outName, "TTSL");
	strcpy(outSig, "TTSL.EES.IOS");
	strcpy(outDesc, "Plugin to control environmental elements for EES project");

	// Register move plane
	XPLMRegisterFlightLoopCallback(		
			flight_callback,	/* Callback */
			1.0,					/* Interval */
			NULL);					/* refcon not used. */

	// Register weather
	XPLMRegisterFlightLoopCallback(		
			weather_callback,	/* Callback */
			1.0,					/* Interval */
			NULL);					/* refcon not used. */

	return 1;
}
Exemplo n.º 6
0
/*
 * XPluginStart
 * 
 * Our start routine registers our window and does any other initialization we 
 * must do.
 * 
 */
PLUGIN_API int XPluginStart(
						char *		outName,
						char *		outSig,
						char *		outDesc)
{
	/* First we must fill in the passed in buffers to describe our
	 * plugin to the plugin-system. */

	strcpy(outName, "DisPlugin");
	strcpy(outSig, "edu.nps.moves.xplane");
	strcpy(outDesc, "A plugin that sends DIS to reflect aircraft position");

	

	/* Now we create a window.  We pass in a rectangle in left, top,
	 * right, bottom screen coordinates.  We pass in three callbacks. */

	gWindow = XPLMCreateWindow(
					50, 600, 300, 200,			/* Area of the window. */
					1,							/* Start visible. */
					MyDrawWindowCallback,		/* Callbacks */
					MyHandleKeyCallback,
					MyHandleMouseClickCallback,
					NULL);						/* Refcon - not used. */

	// Register a callback that will be executed every N seconds

	//gPlaneLat = XPLMFindDataRef("sim/flightmodel/position/latitude");
	//gPlaneLon = XPLMFindDataRef("sim/flightmodel/position/longitude");
	//gPlaneEl = XPLMFindDataRef("sim/flightmodel/position/elevation");

	XPLMRegisterFlightLoopCallback(
		MyFlightLoopCallback, // Function to call
		0.1,                  // Time interval
		NULL);                // refcon not used



	// Call C++ capable functions
	return wrap_startPlugin();

	/* We must return 1 to indicate successful initialization, otherwise we
	 * will not be called back again. */
	 
	//return 1;
}
Exemplo n.º 7
0
PLUGIN_API int XPluginEnable(void)
{
	// Open sockets
	sock = new XPC::UDPSocket(RECVPORT);
	XPC::MessageHandlers::SetSocket(sock);

	XPC::Log::WriteLine(LOG_INFO, "EXEC", "Plugin Enabled, sockets opened");
	if (benchmarkingSwitch > 0)
	{
		XPC::Log::FormatLine(LOG_INFO, "EXEC", "Benchmarking Enabled (Verbosity: %i)", benchmarkingSwitch);
	}
	XPC::Log::FormatLine(LOG_INFO, "EXEC", "Debug Logging Enabled (Verbosity: %i)", LOG_LEVEL);
	
	float interval = -1; // Call every frame
	void* refcon = NULL; // Don't pass anything to the callback directly
	XPLMRegisterFlightLoopCallback(XPCFlightLoopCallback, interval, refcon);

	return 1;
}
Exemplo n.º 8
0
PLUGIN_API int XPluginStart(
                        char *		outName,
                        char *		outSig,
                        char *		outDesc)
{
    strcpy(outName, "SDK210Tests");
    strcpy(outSig, "sandybarbour.projects.SDK210Tests");
    strcpy(outDesc, "A plug-in to test the new SDK210 API's.");

    // Register the callback for errors
    XPLMSetErrorCallback(SDK210TestsErrorCB);

    // Datarefs to get the aicraft position
    SDK210Tests_refx = XPLMFindDataRef("sim/flightmodel/position/local_x");
    SDK210Tests_refy = XPLMFindDataRef("sim/flightmodel/position/local_y");
    SDK210Tests_refz = XPLMFindDataRef("sim/flightmodel/position/local_z");

    XPLMRegisterFlightLoopCallback(SDK210TestsMainLoopCB, 1.0, NULL);

    return 1;
}
Exemplo n.º 9
0
PLUGIN_API int XPluginStart(
						char *		outName,
						char *		outSig,
						char *		outDesc)
{
	char	outputPath[255];
		
	strcpy(outName, "TimedProcessing");
	strcpy(outSig, "xplanesdk.examples.timedprocessing");
	strcpy(outDesc, "A plugin that records sim data.");

	vis_amount = 5000;

	/* Open a file to write to.  We locate the X-System directory 
	 * and then concatenate our file name.  This makes us save in
	 * the X-System directory.  Open the file. */
	XPLMGetSystemPath(outputPath);
	strcat(outputPath, "TimedProcessing.txt");

	
	gOutputFile = fopen(outputPath, "w");

	/* Find the data refs we want to record. */
	gPlaneLat = XPLMFindDataRef("sim/flightmodel/position/latitude");
	gPlaneLon = XPLMFindDataRef("sim/flightmodel/position/longitude");
	gPlaneEl = XPLMFindDataRef("sim/flightmodel/position/elevation");
	gPlaneVis = XPLMFindDataRef("sim/weather/visibility_reported_m");

	/* Register our callback for once a second.  Positive intervals
	 * are in seconds, negative are the negative of sim frames.  Zero
	 * registers but does not schedule a callback for time. */
	XPLMRegisterFlightLoopCallback(		
			MyFlightLoopCallback,	/* Callback */
			1.0,					/* Interval */
			NULL);					/* refcon not used. */
			
	return 1;
}
Exemplo n.º 10
0
PLUGIN_API int XPluginStart(
                        char *        outName,
                        char *        outSig,
                        char *        outDesc)
{
    strcpy(outName, "UDB HILSIM");
    strcpy(outSig, "UDB.HardwareInLoop");
    strcpy(outDesc, "UDB Hardware-In-Loop Simulator");
          
    drP = XPLMFindDataRef("sim/flightmodel/position/P");
	drQ = XPLMFindDataRef("sim/flightmodel/position/Q");
	drR = XPLMFindDataRef("sim/flightmodel/position/R");
    drLat = XPLMFindDataRef("sim/flightmodel/position/latitude");
	drLon = XPLMFindDataRef("sim/flightmodel/position/longitude");
	drElev = XPLMFindDataRef("sim/flightmodel/position/elevation");
	drLocal_ax = XPLMFindDataRef("sim/flightmodel/position/local_ax");
	drLocal_ay = XPLMFindDataRef("sim/flightmodel/position/local_ay"); 
	drLocal_az = XPLMFindDataRef("sim/flightmodel/position/local_az");
	drLocal_vx = XPLMFindDataRef("sim/flightmodel/position/local_vx");
	drLocal_vy = XPLMFindDataRef("sim/flightmodel/position/local_vy"); 
	drLocal_vz = XPLMFindDataRef("sim/flightmodel/position/local_vz");
	drLocalDays = XPLMFindDataRef("sim/time/local_date_days");
	drLocalSecs = XPLMFindDataRef("sim/time/local_time_sec");
	drGroundSpeed = XPLMFindDataRef("sim/flightmodel/position/groundspeed");
	drAirSpeedTrue = XPLMFindDataRef("sim/flightmodel/position/true_airspeed");
	drHeading = XPLMFindDataRef("sim/flightmodel/position/psi");
	drLocal_x = XPLMFindDataRef("sim/flightmodel/position/local_x");
	drLocal_y = XPLMFindDataRef("sim/flightmodel/position/local_y");
	drLocal_z = XPLMFindDataRef("sim/flightmodel/position/local_z");
	drPhi = XPLMFindDataRef("sim/flightmodel/position/phi");
	drTheta = XPLMFindDataRef("sim/flightmodel/position/theta");
    drPsi = XPLMFindDataRef("sim/flightmodel/position/psi");
	drAlpha = XPLMFindDataRef("sim/flightmodel/position/alpha");
	drBeta = XPLMFindDataRef("sim/flightmodel/position/beta");
	drThrOverRide = XPLMFindDataRef("sim/operation/override/override_throttles");
	drPitchAxis = XPLMFindDataRef("sim/joystick/FC_ptch");
	drRollAxis = XPLMFindDataRef("sim/joystick/FC_roll");
	drYawAxis = XPLMFindDataRef("sim/joystick/FC_hdng");
	drThro = XPLMFindDataRef("sim/flightmodel/engine/ENGN_thro_use");

	fTextColour[0] = 1.0;
	fTextColour[1] = 1.0;
	fTextColour[2] = 1.0;

	XPLMRegisterFlightLoopCallback(GetBodyRates, 1.0, NULL);
	XPLMRegisterDrawCallback(
					DrawStrings,
					xplm_Phase_Window, 	/* Draw when sim is doing objects */
					0,						/* After objects */
					NULL);					/* No refcon needed */
	
//	XPLMSetDatai(drOverRide, 1);		// Now overide surfaces, not yaw,roll,pitch

	/* Register our hot key for the new view. */
	gHotKey = XPLMRegisterHotKey(XPLM_VK_F8, xplm_DownFlag, 
				"Circling External View",
				MyHotKeyCallback,
				NULL);

	XPLMRegisterDrawCallback(
				MyDrawCallback,	
				xplm_Phase_Objects, 	/* Draw when sim is doing objects */
				0,						/* After objects */
				NULL);					/* No refcon needed */

	memset(&CamPath, 0, sizeof(float) * 3 * CamPathLength);

	return 1;
}
Exemplo n.º 11
0
void create_ui()
{
    create_dialog();
    create_menu();
    XPLMRegisterFlightLoopCallback(hide_dialog_flcb, 0, NULL);
}
Exemplo n.º 12
0
PLUGIN_API int XPluginStart(char *outName, char *outSig, char *outDesc) {

    /* First set up our plugin info. */
    strcpy(outName, "SmoothSailing 0.1");
    strcpy(outSig, "Smooth Sailing by Colin Lieberman");
    strcpy(outDesc, "Simple weather and visibility controls for convenience");

    initConfig();

    /* datarefs used for the transponder setting & checks to determine if i want to set it */
    ref_xpndr_mode      = XPLMFindDataRef("sim/cockpit/radios/transponder_mode");
    ref_xpndr_setting   = XPLMFindDataRef("sim/cockpit/radios/transponder_code");
    ref_alt_agl         = XPLMFindDataRef("sim/flightmodel/position/y_agl");
    ref_grnd_spd        = XPLMFindDataRef("sim/flightmodel/position/groundspeed");

    /* dataref for visibility */
    ref_visibility      = XPLMFindDataRef("sim/weather/visibility_reported_m");

    /* datarefs for cloud base */
    ref_cloud_base0     = XPLMFindDataRef("sim/weather/cloud_base_msl_m[0]");
    ref_cloud_base1     = XPLMFindDataRef("sim/weather/cloud_base_msl_m[1]");
    ref_cloud_base2     = XPLMFindDataRef("sim/weather/cloud_base_msl_m[2]");

    ref_cloud_tops0     = XPLMFindDataRef("sim/weather/cloud_tops_msl_m[0]");
    ref_cloud_tops1     = XPLMFindDataRef("sim/weather/cloud_tops_msl_m[1]");
    ref_cloud_tops2     = XPLMFindDataRef("sim/weather/cloud_tops_msl_m[2]");

    ref_alt_msl         = XPLMFindDataRef("sim/flightmodel/position/elevation");

    /* datarefs for setting time */
    ref_use_sys_time    = XPLMFindDataRef("sim/time/use_system_time");
    
    ref_local_time      = XPLMFindDataRef("sim/time/local_time_sec");
    ref_zulu_time       = XPLMFindDataRef("sim/time/zulu_time_sec");

    /* datarefs for wind */
    ref_heading         = XPLMFindDataRef("sim/flightmodel/position/psi");
    ref_wind_speed0     = XPLMFindDataRef("sim/weather/wind_speed_kt[0]");
    ref_wind_speed1     = XPLMFindDataRef("sim/weather/wind_speed_kt[1]");
    ref_wind_speed2     = XPLMFindDataRef("sim/weather/wind_speed_kt[2]");
    ref_wind_direction0 = XPLMFindDataRef("sim/weather/wind_direction_degt[0]");
    ref_wind_direction1 = XPLMFindDataRef("sim/weather/wind_direction_degt[1]");
    ref_wind_direction2 = XPLMFindDataRef("sim/weather/wind_direction_degt[2]");
    ref_wind_altitude   = XPLMFindDataRef("sim/weather/wind_altitude_msl_m[0]");
    ref_wind_turb0      = XPLMFindDataRef("sim/weather/turbulence[0]");

	if( DEBUG ) {
        debug_window = XPLMCreateWindow(
                        50, 600, 400, 200,			/* Area of the window. */
                        1,							/* Start visible. */
                        MyDrawWindowCallback,		/* Callbacks */
                        MyHandleKeyCallback,
                        MyHandleMouseClickCallback,
                        NULL);						/* Refcon - not used. */
    }
        
    // * Register our callback for every loop. Positive intervals
    // * are in seconds, negative are the negative of sim frames.  Zero
    // * registers but does not schedule a callback for time.
    XPLMRegisterFlightLoopCallback(
            SmoothSailingCallback,	// * Callback *
            CALLBACK_INTERVAL,          // * Interval -1 every loop*
            NULL);				        // * refcon not used. *

    return 1;
}
XPCProcess::XPCProcess() :
	mInCallback(false),
	mCallbackTime(0)
{
	XPLMRegisterFlightLoopCallback(FlightLoopCB, 0, reinterpret_cast<void *>(this));
}
Exemplo n.º 14
0
PLUGIN_API int XPluginStart(char* outName,
                            char* outSig,
                            char* outDesc)
{
	szString[0] = '\0';
	strcpy(outName, "UDB HILSIM");
	strcpy(outSig, "UDB.HardwareInLoop");
	strcpy(outDesc, "UDB Hardware-In-Loop Simulator");

	// P, Q, and R are roll, pitch, and yaw rates, degrees per second,
	// in the NED coordinate system, in "flight" (not body) frame of reference
	drP = XPLMFindDataRef("sim/flightmodel/position/P");
	drQ = XPLMFindDataRef("sim/flightmodel/position/Q");
	drR = XPLMFindDataRef("sim/flightmodel/position/R");

	// standard GPS lat, long, and elevation
	drLat  = XPLMFindDataRef("sim/flightmodel/position/latitude");
	drLon  = XPLMFindDataRef("sim/flightmodel/position/longitude");
	drElev = XPLMFindDataRef("sim/flightmodel/position/elevation");

	// acceleration, meters/sec/sec, in OGL frame of reference
	// note: this is NOT the same as what the accelerometers read
	drLocal_ax = XPLMFindDataRef("sim/flightmodel/position/local_ax");
	drLocal_ay = XPLMFindDataRef("sim/flightmodel/position/local_ay"); 
	drLocal_az = XPLMFindDataRef("sim/flightmodel/position/local_az");

	// velocity, meters/sec, in OGL frame of reference
	drLocal_vx = XPLMFindDataRef("sim/flightmodel/position/local_vx");
	drLocal_vy = XPLMFindDataRef("sim/flightmodel/position/local_vy"); 
	drLocal_vz = XPLMFindDataRef("sim/flightmodel/position/local_vz");

	drLocalDays = XPLMFindDataRef("sim/time/local_date_days");
	drLocalSecs = XPLMFindDataRef("sim/time/local_time_sec");

	// 3D true airspeed, meters/second
	drAirSpeedTrue = XPLMFindDataRef("sim/flightmodel/position/true_airspeed");

	// location in OGL frame
	drLocal_x = XPLMFindDataRef("sim/flightmodel/position/local_x");
	drLocal_y = XPLMFindDataRef("sim/flightmodel/position/local_y");
	drLocal_z = XPLMFindDataRef("sim/flightmodel/position/local_z");

	// Euler roll, pitch, and yaw angles, degrees, using NED
	// + phi is roll to the right (CCW around NED_x)
	// + theta is pitch up (CCW around NED_y)
	// + psi is yaw to the right (CCW around NED_z)
	drPhi   = XPLMFindDataRef("sim/flightmodel/position/phi");
	drTheta = XPLMFindDataRef("sim/flightmodel/position/theta");
	drPsi   = XPLMFindDataRef("sim/flightmodel/position/psi");

	// Euler angles of attack and sideslip, degrees, using NED
	// These are angles of body frame with respect to fight path
	// + alpha is pitch up (CCW around NED_y)
	// + beta is yaw right (CCW around NED_z)
	drAlpha = XPLMFindDataRef("sim/flightmodel/position/alpha");
	drBeta  = XPLMFindDataRef("sim/flightmodel/position/beta");

	drThrOverRide = XPLMFindDataRef("sim/operation/override/override_throttles");
	drPitchAxis   = XPLMFindDataRef("sim/joystick/FC_ptch");
	drRollAxis    = XPLMFindDataRef("sim/joystick/FC_roll");
	drYawAxis     = XPLMFindDataRef("sim/joystick/FC_hdng");
	drThro        = XPLMFindDataRef("sim/flightmodel/engine/ENGN_thro_use");

// sim/operation/override/override_gearbrake	int	y	boolean	Override gear and brake staus
// sim/flightmodel/controls/parkbrake	float	y	???	Parking Brake

	drBrakeOverRide = XPLMFindDataRef("sim/operation/override/override_gearbrake");
	drBrake         = XPLMFindDataRef("sim/flightmodel/controls/parkbrake");

	// These are the values that the accelerometers read, in multiples of gravity
	// g_nrml is UDB_z
	// g_axil is UDB_y
	// g_side is UDB_x
	drg_nrml = XPLMFindDataRef("sim/flightmodel/forces/g_nrml");
	drg_axil = XPLMFindDataRef("sim/flightmodel/forces/g_axil");
	drg_side = XPLMFindDataRef("sim/flightmodel/forces/g_side");

	fTextColour[0] = 1.0;
	fTextColour[1] = 1.0;
	fTextColour[2] = 1.0;

	XPLMRegisterFlightLoopCallback(GetBodyRates, 1.0, NULL);
	XPLMRegisterDrawCallback(
	    DrawStrings,
	    xplm_Phase_Window,      // Draw when sim is doing objects
	    0,                      // After objects
	    NULL);                  // No refcon needed

//	XPLMSetDatai(drOverRide, 1);// Now overide surfaces, not yaw, roll, pitch

	// Register our hot key for the new view
	gHotKey = XPLMRegisterHotKey(
	    XPLM_VK_F8,
	    xplm_DownFlag, 
	    "Circling External View",
	    MyHotKeyCallback,
	    NULL);

	XPLMRegisterDrawCallback(
	    MyDrawCallback,
	    xplm_Phase_Objects,     // Draw when sim is doing objects
	    0,                      // After objects
	    NULL);                  // No refcon needed

	XPLMRegisterKeySniffer(
		MyKeySniffer,           // Our callback
		1,                      // Receive input before plugin windows
		0);                     // Refcon - not used

	memset(&CamPath, 0, sizeof(float) * 3 * CamPathLength);
	return 1;
}