finish assigned altitude in metric

This commit is contained in:
Zichao Lin 2022-05-07 23:50:50 +08:00
parent ccd82a4cc4
commit 303134c4a2
6 changed files with 86 additions and 26 deletions

@ -3,16 +3,13 @@
TinyEurocat *pMyPlugIn = NULL; TinyEurocat *pMyPlugIn = NULL;
void __declspec ( dllexport ) void __declspec ( dllexport ) EuroScopePlugInInit ( EuroScopePlugIn :: CPlugIn **ppPlugInInstance )
EuroScopePlugInInit ( EuroScopePlugIn :: CPlugIn ** ppPlugInInstance )
{ {
// allocate // allocate
* ppPlugInInstance = pMyPlugIn = * ppPlugInInstance = pMyPlugIn = new TinyEurocat ;
new TinyEurocat ;
} }
void __declspec ( dllexport ) void __declspec ( dllexport ) EuroScopePlugInExit ( void )
EuroScopePlugInExit ( void )
{ {
delete pMyPlugIn ; delete pMyPlugIn ;
} }

@ -1,16 +1,60 @@
#include "StdAfx.h" #include "StdAfx.h"
#include "TinyEurocat.h" #include "TinyEurocat.h"
#include <cstring>
#include "stdlib.h"
#include <cstdio>
TinyEurocat::TinyEurocat(void) : CPlugIn ( COMPATIBILITY_CODE,
TinyEurocat::TinyEurocat(void) : CPlugIn ( EuroScopePlugIn::COMPATIBILITY_CODE, "TinyEurocat",
"TinyEurocat", "1.0.0",
"1.0.0", "Future Sim",
"Future Sim", "Open-source" )
"Open-source" )
{ {
RegisterTagItemType("Metric / Current Altitude", TAG_ITEM_MET_CURR_ALT);
RegisterTagItemType("Metric / Cleared Altitude", TAG_ITEM_MET_ASS_ALT);
RegisterTagItemType("Metric / Current Speed", TAG_ITEM_MET_CURR_SPD);
} }
void TinyEurocat::OnGetTagItem( CFlightPlan FlightPlan,
CRadarTarget RadarTarget,
int ItemCode,
int TagData,
char sItemString [ 16 ],
int *pColorCode,
COLORREF *pRGB,
double *pFontSize )
{
int maalt, mcalt, mcspd;
switch (ItemCode)
{
case TAG_ITEM_MET_ASS_ALT:
maalt = FlightPlan.GetClearedAltitude() * 0.3048;
if(maalt != 0)
{
maalt /= 100;
if(maalt % 3 == 1)
maalt -= 1;
else if(maalt % 3 == 2)
maalt += 1;
char tmpstr[15];
itoa(maalt * 10, tmpstr, 10);
sprintf(sItemString, "%04s", tmpstr);
}
else
{
strcpy(sItemString, " ");
}
break;
case TAG_ITEM_MET_CURR_ALT:
mcalt = 1;
itoa(mcalt, sItemString, 10);
break;
case TAG_ITEM_MET_CURR_SPD:
mcspd = RadarTarget.GetGS() * 1.852;
itoa(mcspd, sItemString, 10);
break;
}
}
TinyEurocat::~TinyEurocat(void) TinyEurocat::~TinyEurocat(void)
{ {

@ -1,10 +1,25 @@
#pragma once #pragma once
#include "..\lib\EuroScopePlugIn.h" #include "..\lib\EuroScopePlugIn.h"
class TinyEurocat : public EuroScopePlugIn::CPlugIn using namespace EuroScopePlugIn;
const int TAG_ITEM_MET_CURR_ALT = 1;
const int TAG_ITEM_MET_ASS_ALT = 2;
const int TAG_ITEM_MET_CURR_SPD = 3;
class TinyEurocat : public CPlugIn
{ {
public: public:
TinyEurocat(void); TinyEurocat(void);
~TinyEurocat(void); ~TinyEurocat(void);
void OnGetTagItem( CFlightPlan FlightPlan,
CRadarTarget RadarTarget,
int ItemCode,
int TagData,
char sItemString [ 16 ],
int *pColorCode,
COLORREF *pRGB,
double *pFontSize );
}; };

@ -108,6 +108,7 @@
<ClCompile Include="TinyEurocat.cpp" /> <ClCompile Include="TinyEurocat.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\lib\EuroScopePlugIn.h" />
<ClInclude Include="stdafx.h" /> <ClInclude Include="stdafx.h" />
<ClInclude Include="TinyEurocat.h" /> <ClInclude Include="TinyEurocat.h" />
</ItemGroup> </ItemGroup>

@ -35,5 +35,8 @@
<ClInclude Include="TinyEurocat.h"> <ClInclude Include="TinyEurocat.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\lib\EuroScopePlugIn.h">
<Filter>资源文件</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -5,7 +5,7 @@
#pragma once #pragma once
#ifndef VC_EXTRALEAN #ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料 #define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料
#endif #endif
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的 #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的
@ -14,24 +14,24 @@
#include <afxext.h> // MFC 扩展 #include <afxext.h> // MFC 扩展
#ifndef _AFX_NO_OLE_SUPPORT #ifndef _AFX_NO_OLE_SUPPORT
#include <afxole.h> // MFC OLE 类 #include <afxole.h> // MFC OLE 类
#include <afxodlgs.h> // MFC OLE 对话框类 #include <afxodlgs.h> // MFC OLE 对话框类
#include <afxdisp.h> // MFC 自动化类 #include <afxdisp.h> // MFC 自动化类
#endif // _AFX_NO_OLE_SUPPORT #endif // _AFX_NO_OLE_SUPPORT
#ifndef _AFX_NO_DB_SUPPORT #ifndef _AFX_NO_DB_SUPPORT
#include <afxdb.h> // MFC ODBC 数据库类 #include <afxdb.h> // MFC ODBC 数据库类
#endif // _AFX_NO_DB_SUPPORT #endif // _AFX_NO_DB_SUPPORT
#ifndef _AFX_NO_DAO_SUPPORT #ifndef _AFX_NO_DAO_SUPPORT
#include <afxdao.h> // MFC DAO 数据库类 #include <afxdao.h> // MFC DAO 数据库类
#endif // _AFX_NO_DAO_SUPPORT #endif // _AFX_NO_DAO_SUPPORT
#ifndef _AFX_NO_OLE_SUPPORT #ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // MFC 对 Internet Explorer 4 公共控件的支持 #include <afxdtctl.h> // MFC 对 Internet Explorer 4 公共控件的支持
#endif #endif
#ifndef _AFX_NO_AFXCMN_SUPPORT #ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC 对 Windows 公共控件的支持 #include <afxcmn.h> // MFC 对 Windows 公共控件的支持
#endif // _AFX_NO_AFXCMN_SUPPORT #endif // _AFX_NO_AFXCMN_SUPPORT