public static void TestMultipleThreads(int i_iNumThreads, int i_iNumIterations, int i_iSleep, string i_sPath)
        {
            Console.WriteLine("Starting test on {0} threads with {1} iterations to '{2}'...", i_iNumThreads, i_iNumIterations, i_sPath);

            ILegacyLogger log = new LegacyLogger();

            Thread[]        aThreads    = new Thread[i_iNumThreads];
            LoggingThread[] aLTs        = new LoggingThread[i_iNumThreads];
            string          sThreadName = Thread.CurrentThread.Name = "LoggingTestsT";

//			string				sThreadName = Thread.CurrentThread.Name = "";

//			log.Init("", "", sThreadName, "", "LogTester", i_sPath);
            log.Init("", "", sThreadName, "", "", i_sPath);                             // Let logger look up the component name
            log.Open();

            log.Log(Level.Debug, "Starting threads...");

            for (int ii = 0; ii < i_iNumThreads; ii++)
            {
                aLTs[ii]     = new LoggingThread(log, ii, i_iNumIterations, i_iSleep);
                aThreads[ii] = new Thread(new ThreadStart(aLTs[ii].ThreadProc));
                aThreads[ii].Start();
            }

            foreach (Thread tThread in aThreads)
            {
                tThread.Join();
            }

            log.Log(Level.Debug, "Done.");

            log.Close();
        }
Exemple #2
0
		public void Setup()
		{
			m_Log = new LegacyLogger();
			m_Log.Init("", "", "", "", "", "");
			m_Log.Open();

			m_oDE = new DialogEngine.DialogEngine(m_Log, 0);
		} // Setup
Exemple #3
0
        }         // Main

        /// <summary>
        ///
        /// </summary>
        /// <param name="i_logConsole"></param>
        /// <param name="i_logFile"></param>
        /// <param name="i_logger"></param>
        /// <returns></returns>
        protected static bool StartLoggers(out ILegacyLogger o_logger)
        {
            bool   bRet  = true;
            string sPath = "";

            // Set up the logger(s)
            sPath    = ConfigurationManager.AppSettings["DefaultLogFilePath"];
            o_logger = new LegacyLogger();
            o_logger.Init("", "", Thread.CurrentThread.Name, "", "", sPath);
            bRet = o_logger.Open();

            return(bRet);
        }         // Start Loggers
Exemple #4
0
        static void Main(string[] args)
        {
            ILegacyLogger logger = null;
            bool          bRes = true;
            string        sAsr = "", sGramPath = "", sUttPath = "";
            int           iRes, iNumIt = 0, iPause = 0, iNumArgsExpected = 5, iAsrIdx = 0, iGramIdx = 1, iUttIdx = 2, iItIdx = 3, iPauseIdx = 4;
            eAsrType      eAsr = eAsrType.unknown;

            try
            {
                for (int ii = 0; ii < args.Length; ii++)
                {
                    Console.Error.WriteLine("Arg {0}: '{1}'", ii, args[ii].ToString());
                }
                Thread.CurrentThread.Name = "asrtest";
                logger = new LegacyLogger();
                logger.Init("", "", Thread.CurrentThread.Name, "", "", "/opt/speechbridge/logs");
                bRes = logger.Open();

                if (!bRes || (args.Length != iNumArgsExpected))
                {
                    if (!bRes)
                    {
                        Console.Error.WriteLine("Unable to open the console logger!");
                    }
                    else
                    {
                        logger.Log(Level.Warning, "Usage:  asrtest AsrType GrammarFile UttWav NumIterations PauseInSecs");
                        logger.Log(Level.Warning, "    AsrType can be:  lumenvox, lumenvox2, OR vestec");
                    }
                    return;
                }
                else
                {
                    sAsr      = args[iAsrIdx];
                    sGramPath = args[iGramIdx];
                    sUttPath  = args[iUttIdx];
                    iNumIt    = int.Parse(args[iItIdx]);
                    iPause    = int.Parse(args[iPauseIdx]);

                    if ((sAsr == eAsrType.julius.ToString()) || (sAsr == eAsrType.loquendo.ToString()) || (sAsr == eAsrType.pocketsphinx.ToString()))
                    {
                        logger.Log(Level.Exception, "That AsrType is not yet supported.");
                    }
                    else if (sAsr == eAsrType.lumenvox.ToString())
                    {
                        eAsr = eAsrType.lumenvox;
                    }
                    else if (sAsr == eAsrType.lumenvox2.ToString())
                    {
                        eAsr = eAsrType.lumenvox2;
                    }
                    else if (sAsr == eAsrType.vestec.ToString())
                    {
                        eAsr = eAsrType.vestec;
                    }

                    if (eAsr != eAsrType.unknown)
                    {
                        iRes = RunTestBuffer(logger, eAsr, sGramPath, sUttPath, iNumIt, iPause);

                        logger.Log(Level.Info, "Successfully completed " + iRes.ToString() + " iterations.");
                    }
                }

                logger.Close();
            }
            catch (Exception exc)
            {
                logger.Log(Level.Exception, "Main caught exception: " + exc.ToString());
            }

            return;
        }
        static void Main(string[] args)
        {
            bool            bRes = true;
            string          sPrompt = "> ", sCmd = "", sLogPath = "";
            AudioEngine_srv amSrv = null;
            ILegacyLogger   logger = null;
            string          sDisableKeyboard = "", sVer = "";
            AssemblyName    asmName = null;

            //Name the main thread
            Thread.CurrentThread.Name = "AudioMgrMainT";

            // Set up the logger(s)
            sLogPath = ConfigurationManager.AppSettings[cs_LogFilePath];
            if (!(sLogPath.EndsWith("/") || sLogPath.EndsWith("\\")))
            {
                sLogPath = sLogPath + "/";
            }
            logger = new LegacyLogger();
            logger.Init("", "", Thread.CurrentThread.Name, "", "", sLogPath);
            bRes = logger.Open();
            if (!bRes)
            {
                Console.Error.WriteLine("AudioMgr failed to open the logger!");
            }
            else
            {
                asmName = Assembly.GetAssembly(typeof(AudioMgr.AudioEngine)).GetName();
                sVer    = asmName.Version.ToString();
                logger.Log(Level.Info, "AudioMgr v" + sVer);

                bRes = RemotingConfig(logger);

                amSrv = new AudioEngine_srv(logger);
                bRes  = RegisterEventHandlers(amSrv);

                if (!bRes)
                {
                    logger.Log(Level.Exception, " AudioMgr failed registering event handlers!");
                }
                else
                {
                    bRes = amSrv.LoadASR(logger);
                    if (!bRes)
                    {
                        logger.Log(Level.Exception, " AudioMgr failed to load ASR(s)!");
                    }
                    else
                    {
                        bRes = amSrv.CreateWorkerThreads(sLogPath);
                        if (!bRes)
                        {
                            logger.Log(Level.Exception, " AudioMgr failed to create worker threads!");
                        }
                        else
                        {
                            //Console.WriteLine("AudioMgr startup successful.");
                            logger.Log(Level.Info, "AudioMgr startup successful.");

                            sDisableKeyboard = ConfigurationManager.AppSettings[cs_DisableKeyboard];
                            sDisableKeyboard = (sDisableKeyboard == null) ? "" : sDisableKeyboard;
                            if (sDisableKeyboard == "false")
                            {
                                Console.Write(sPrompt);
                                sCmd = Console.ReadLine();
                                while (bRes)
                                {
                                    bRes = amSrv.ProcessCmdString(sCmd);
                                    if (bRes)
                                    {
                                        Console.Write(sPrompt);
                                        sCmd = Console.ReadLine();
                                    }
                                }
                            }

                            // Join worker threads before exiting
                            amSrv.JoinWorkerThreads();

                            UnregisterEventHandlers(amSrv);
                        }
                    }
                }

                logger.Log(Level.Info, "AudioMgr shutdown.");
                logger.Close();
            }
        }
        static void Main(string[] args)
        {
            bool bRes;

            DialogMgr_srv.eDMResult eRes  = DialogMgr_srv.eDMResult.eUnknown;
            DialogMgr_srv           dmSrv = null;
            string        sPath;
            string        sDisableKeyboard = "", sVer = "";
            AssemblyName  asmName = null;
            ILegacyLogger logger  = null;

            // Name the main thread
            Thread.CurrentThread.Name = "DialogMgrMainT";

            // Set up the logger(s)
            sPath  = ConfigurationManager.AppSettings["LogFilePath"];
            logger = new LegacyLogger();
            logger.Init("", "", Thread.CurrentThread.Name, "", "", sPath);
            bRes = logger.Open();
            if (!bRes)
            {
                Console.Error.WriteLine("DialogMgr failed to open the logger!");
            }
            else
            {
                asmName = Assembly.GetAssembly(typeof(DialogMgr_Console.DialogMgr)).GetName();
                sVer    = asmName.Version.ToString();
                logger.Log(Level.Info, "DialogMgr v" + sVer);

                bRes = LoadCustomAssemblies(logger);

                bRes = RemotingConfig(logger);

                dmSrv = new DialogMgr_srv(logger);
                bRes  = RegisterEventHandlers(dmSrv);

                if (bRes)
                {
                    bRes = dmSrv.CreateWorkerThreads("");

                    //Console.WriteLine("DialogMgr_Console startup successful.");
                    logger.Log(Level.Info, "DialogMgr_Console startup successful.");

                    sDisableKeyboard = ConfigurationManager.AppSettings["DisableKeyboard"];
                    sDisableKeyboard = (sDisableKeyboard == null) ? "" : sDisableKeyboard;
                    if (sDisableKeyboard == "false")
                    {
                        // Start processing messages
                        eRes = dmSrv.ProcessKbMsgLoop();
                    }

                    // Join worker threads before exiting
                    dmSrv.JoinWorkerThreads();

                    // Clean up
                    UnregisterEventHandlers(dmSrv);
                }
                else
                {
                    //Console.WriteLine("DialogMgr_Console startup unsuccessful!!!");
                    logger.Log(Level.Exception, "DialogMgr_Console startup unsuccessful!!!");
                }

                logger.Log(Level.Info, "DialogMgr_Console shutdown.");
                logger.Close();
            }
        }