曝光台 注意防骗
网曝天猫店富美金盛家居专营店坑蒙拐骗欺诈消费者
//for their personal use.
// This is the code to send the Falcon 4's shared memory data to EPIC via
//pigeonholes
#include <windows.h>
#include <stdio.h>
#include <iostream.h>
#include "EPICIO.hpp"
#include "flightdata.h"
//The following defines the handle to access the Falcon4 shared memory
HANDLE gSharedMemHandle = NULL;//Falcon4 shared memory handle
void* gSharedMemPtr = NULL;
int main (void) //starting point for C++ code
{
//First lets initialize some variables
int handle = -1, JAMCount=0;
int bit = 0;
CHAR JAMCheck = 'y';
int tempLight=0; //tempLight is used for manually setting lights during testing
int PHnum = 1;//Pigeon Holes used with Falcon4SP3 will be 1, 2, 3 and 4
//The Falcon4 landing gears are not light bits so extra code is needed
int I =0, GearStatusLgt = 0;
int NoseGearTemp=0,LeftGearTemp=0,RightGearTemp=0,GearTrans=0;
//Next lets open the EPIC device
handle = _OpenDevice(1); // 0= EPICISA, 1=EPICUSB0, etc
if (handle <0) //This would mean an error
{
cout<<"Error opening EPIC device";
}
//We should either get a handle or an error code
//The following extracts the Falcon4 data from shared memory
FlightData* flightData;
gSharedMemHandle = OpenFileMapping(FILE_MAP_ALL_ACCESS, TRUE, "FalconSharedMemoryArea");
if (gSharedMemHandle)
22
{
gSharedMemPtr = MapViewOfFile(gSharedMemHandle, FILE_MAP_WRITE, 0, 0, 0);
}
else
{
printf ("Unable to open file. Is Falcon Running?\n"); //Falcon4 must be running
exit (0);//Pops open a Dos Window with this message
}
//The following code allows the manual checking of lights on an Output Module
teststart:
cout<<"Do you want to test lights? ";cin>>JAMCheck;
if (JAMCheck=='n') goto testend;
cout<<"What Output Module? ";cin>>PHnum;
cout<<"What Bit do you want to turn on/off? ";cin>>bit;
tempLight=1;
if (bit==1) goto special;
bit=bit-1;
do
{
tempLight = tempLight*2;
bit=bit - 1;
}while(bit>0);
//The following is the EPIC Pigeonhole send command
_SendPH(handle,PHnum,(UCHAR)(tempLight&0xFF),(UCHAR)((tempLight&0xFF00)>>8),(UCHAR)((tempLight&0xFF0000)>>16),(UCHAR)((
tempLight&0xFF000000)>>24));
_GetData(handle); //Temporary fix of a bug in EPIC
if (JAMCheck == 'y') goto teststart;
else goto testend;
special: //Required to handle the special case of testing bit “1”
{
tempLight=1;
_SendPH(handle,PHnum,(UCHAR)(tempLight&0xFF),(UCHAR)((tempLight&0xFF00)>>8),(UCHAR)((tempLight&0xFF0000)>>16),(UCHA
R)((tempLight&0xFF000000)>>24));
_GetData(handle);
if (JAMCheck == 'y') goto teststart;
}
testend:
//------------------------------Now lets talk to Falcon4 shared memory--------------------------------------
23
cout<<"/nDo you want to interface to Falcon4SP3? ";cin>>JAMCheck;
if (JAMCheck=='n') goto finish;
JAMCount = 1;
do
{
flightData = (FlightData*)gSharedMemPtr; //Get a copy of the Falcon4 shared memory
NoseGearTemp = flightData->NoseGearPos; // Get the nose gear state
LeftGearTemp = flightData->LeftGearPos; // Get the left gear state
RightGearTemp = flightData->RightGearPos; // Get the right gear state
if (NoseGearTemp ==1) {GearTrans=1;} //Build a word with the gear information
if (LeftGearTemp ==1) {GearTrans=GearTrans+2;}
if (RightGearTemp ==1) {GearTrans=GearTrans+4;}
//------------------Now lets send all the Falcon4 data in 5 Pigeonholes--------------------------
//------------------------------Pigeonhole 1 has the lightBits data------------------------------------------
// Look in the flightData.h file to find the data definitions
_SendPH(handle,1,(UCHAR)(flightData->lightBits&0xFF),(UCHAR)((flightData->lightBits&0xFF00)>>8),(UCHAR)((flightData-
>lightBits&0xFF0000)>>16),(UCHAR)((flightData->lightBits&0xFF000000)>>24));
//------------------------------Pigeonhole 2 has the lightBits2 data------------------------------------------
_SendPH(handle,2,(UCHAR)(flightData->lightBits2&0xFF),(UCHAR)((flightData->lightBits2&0xFF00)>>8),(UCHAR)((flightData-
>lightBits2&0xFF0000)>>16),(UCHAR)((flightData->lightBits2&0xFF000000)>>24));
//------------------------------Pigeonhole 3 has the lightBits3 data------------------------------------------
_SendPH(handle,3,(UCHAR)(flightData->lightBits3&0xFF),(UCHAR)((flightData->lightBits3&0xFF00)>>8),(UCHAR)((flightData-
中国航空网 www.aero.cn
航空翻译 www.aviation.cn
本文链接地址:
航空资料18(17)