Files
Cluster/clusterApp/main.c

139 lines
3.0 KiB
C
Raw Normal View History

2026-04-17 18:22:45 +08:00
#include <stdio.h>
#include <stdlib.h>
#include <BaseTypes.h>
#include <InsTask/MainBoardCommunication.h>
#include <InsTask/ResourceLoader.h>
#include <InsTask/DisplayRender.h>
#include <InsTask/CduCommunication.h>
#include <InsRender.h>
Bool globAppQuit = INS_FALSE;
Bool globIpv6_NetworkInstalled = INS_FALSE;
Bool globI2c_PeepBuffer = INS_FALSE;
Bool globReboot = INS_FALSE;
volatile UInt32 CduComSrvPnt = 0;
#ifdef COMPILE_IN_WINDOWS
#include <windows.h>
#ifndef SLEEP
#define SLEEP(msec) Sleep((msec))
#endif // SLEEP
HINSTANCE globHInstance;
#else
#include <unistd.h>
#ifndef SLEEP
#define SLEEP(msec) usleep((msec)*1000)
#endif // SLEEP
#include <signal.h>
static void sighandle(int sig)
{
switch(sig)
{
case 10:
globI2c_PeepBuffer = (globI2c_PeepBuffer == INS_FALSE ? INS_TRUE : INS_FALSE);
break;
case 16:
printf("CduComSrvPnt:0x%x\n", CduComSrvPnt);
break;
case 17:
printf("Ipv6_NetworkInstalled\n");
globIpv6_NetworkInstalled = INS_TRUE;
break;
case SIGINT:
case SIGTERM:
globAppQuit = INS_TRUE;
break;
default:
break;
}
}
#endif // COMPILE_IN_WINDOWS
#ifdef COMPILE_IN_WINDOWS
Int32 WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
Int32 nCmdShow)
{
globHInstance = hInstance;
#else //#ifdef COMPILE_IN_LINUX
Int32 main(int argc, char **argv)
{
signal(SIGINT, sighandle);
signal(SIGTERM, sighandle);
signal(16, sighandle); /*user define signal, for cducom task debug*/
signal(17, sighandle); /*user define signal, for ipv6 network installed*/
signal(10, sighandle); /*user define signal, for peeping iic buffer*/
if(argc > 1)
{
if( argv[1][0] == 'r'
&& argv[1][1] == 'e'
&& argv[1][2] == 'b'
&& argv[1][3] == 'o'
&& argv[1][4] == 'o'
&& argv[1][5] == 't'
&& argv[1][6] == '\0')
{
globReboot = INS_TRUE;
}
}
#endif // COMPILE_IN_WINDOWS
gMainBoardCommunication.Init();
// gResourceLoader.Init();
gDisplayRender.Init();
gCduCommunication.Init();
RegisterRenderFuncs(Render, NULL, CleanUpRender, NULL);
#ifndef COMPILE_IN_WINDOWS
RegisterRender2Funcs(Render_FB1, NULL, CleanUpRender_FB1, NULL);
#endif // COMPILE_IN_WINDOWS
gMainBoardCommunication.Excute();
// gResourceLoader.Excute();
gDisplayRender.Excute();
gCduCommunication.Excute();
while(globAppQuit != INS_TRUE)
{
SLEEP(500);
}
gMainBoardCommunication.TryStop();
// gResourceLoader.TryStop();
gDisplayRender.TryStop();
gCduCommunication.TryStop();
SLEEP(200);
gMainBoardCommunication.Stop();
// gResourceLoader.Stop();
gDisplayRender.Stop();
gCduCommunication.Stop();
gMainBoardCommunication.DeInit();
// gResourceLoader.DeInit();
gDisplayRender.DeInit();
gCduCommunication.DeInit();
//fflush(stdout);
return 0;
}