#include <stdio.h>
#include <stdlib.h>
#include "ModuleList.h"
UINT32 portNo = 15002;
UINT32 portNo1 = 15002, portNo2 = 15004;
UINT32 twoSocketsFlag = 0;
UINT32 enableLoggingFlag = 0;
static const void* moduleDescriptorTable[] =
{
LISTOFCLASSOBJECTS
};
UINT32 moduleDescriptorTableSize = sizeof(moduleDescriptorTable) / sizeof(moduleDescriptorTable[0]);
static void usage(const char *program)
{
printf(
"Usage: %s [args]\n"
" -portno:<int> Port Number to open the single multi-instance tuning interface socket. Default 15002 \n"
" -twosockets If this flag is defined, then an individual tuning interface socket will be opened on each instance\n"
" -portno1:<int> twointerface mode only! port number to open the socket for the first instance. Default 15002\n"
" -portno2:<int> twointerface mode only! port number to open the socket for the second instance. Default 15004\n"
" -enableLogging Enable tuning interface logging. with -twosockets enabled, an individual tuning log file is generated per instance. Disabled by default.\n"
" -help show usage.\n"
"This program demonstrates multi instance functionality in AWE Core OS.\n",
program);
exit(0);
}
int main(int argc, char **argv)
{
UINT32 i;
if (1 == argc)
{
printf("No command line options specified. Opening in default single socket mode with TCP socket on port number %d \n", portNo);
}
else
{
for (i = 1; i < argc; i++)
{
const char *arg = argv[i];
if ((0 == strncmp(arg, "-portno:", 8)) && (0 != strncmp(arg, "-twosockets", 12)))
{
portNo = atoi(arg + 8);
printf("singlesocket mode: portno for socket is %d \n", portNo);
}
else if ((0 == strncmp(arg, "-portno1:", 9)))
{
portNo1 = atoi(arg + 9);
printf("twosockets mode: First socket will open on port %d \n", portNo1);
}
else if ((0 == strncmp(arg, "-portno2:", 9)))
{
portNo2 = atoi(arg + 9);
printf("twosockets mode: Second socket will open on port %d \n", portNo2);
}
else if (0 == strncmp(arg, "-twosockets", 12))
{
printf("twosockets mode enabled. Opening an individual socket for each of the two AWEOSInstances on ports %d and %d \n", portNo1, portNo2);
twoSocketsFlag = 1;
}
else if ((0 == strncmp(arg, "-enableLogging", 14)))
{
enableLoggingFlag = 1;
printf("enableLogging set to true. Tuning logging enabled\n");
}
else if ((0 == strncmp(arg, "-help", 5)))
{
usage(argv[0]);
}
else
{
printf("main: unknown option '%s'\n", arg);
}
}
}
configParams.
pName =
"#1";
configParams2.
pName =
"#2";
if(twoSocketsFlag == 1)
{
configParams.
pName =
"#1-sock";
configParams2.
pName =
"#2-sock2";
}
else
{
}
INT32 ret =
aweOS_init(&g_AWEOSInstanceArray[0], &configParams, moduleDescriptorTable, moduleDescriptorTableSize);
INT32 ret2 =
aweOS_init(&g_AWEOSInstanceArray[1], &configParams2, moduleDescriptorTable, moduleDescriptorTableSize);
if (ret != 0 && ret2 != 0)
{
printf("aweOS init failed, exiting application \n");
}
else
{
if (!twoSocketsFlag)
{
printf("Single Socket Mode \n");
if (enableLoggingFlag)
{
if (loggingRet != 0)
{
printf("failed to open tuning log: ret = %d\n", ret);
}
else
{
printf("Tuning Logging enabled, a single log file will be generated for both AWEOSInstances.\n");
}
}
if (interfaceRet != 0)
{
printf("failed to open aweOS integrated tuning interface \n");
}
else
{
printf("Succesfully opened a TCP single socket tuning interface on port number %d \n ", portNo);
}
}
else
{
if (enableLoggingFlag)
{
if (loggingRet != 0)
{
printf("failed to open tuning log: ret = %d\n", ret);
}
else
{
printf("Tuning Logging enabled, individual log files created for socket %d \n", portNo1);
}
}
if (interfaceRet != 0)
{
printf("failed to open aweOS integrated tuning interface \n");
}
else
{
printf("Successfully opened a TCP socket for the first AWEOSInstance on port number %d \n", portNo1);
}
if (enableLoggingFlag)
{
if (loggingRet != 0)
{
printf("failed to open tuning log: ret = %d\n", ret);
}
else
{
printf("Tuning Logging enabled, individual log files created for socket %d \n", portNo2);
}
}
if (interfaceRet != 0)
{
printf("failed to open aweOS integrated tuning interface \n");
}
else
{
printf("Successfully opened a TCP socket for the second AWEOSInstance on port number %d \n", portNo2);
}
}
while (1)
{
sleep(1);
}
}
return 0;
}