Beispiel #1
0
        void vsWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            //int vsHour = 3;
            //int vsMinute = 30;
            int vsWait = 5000;
            //

            //while (bLoop)
            //{
            //    bLoop = false;

            // create server object
            VsServer vsServer = new VsServer();

            // start server
            bool bStarted = vsServer.StartServer();

            eventLog.WriteEntry("StartServer->" + bStarted.ToString());
            Thread.Sleep(vsWait);

            // start camera
            vsServer.StartAll();
            eventLog.WriteEntry("StartCameras");
            Thread.Sleep(vsWait);

            while (control)//(!vsWorker.CancellationPending && !bLoop)
            {
                // DateTime date = DateTime.Now;

                // if (date.Hour == vsHour && date.Minute >= vsMinute && date.Minute <= vsMinute + 1) bLoop = true;

                Thread.Sleep(vsWait);
            }

            // stop camera
            vsServer.StopAll();
            eventLog.WriteEntry("StopCameras");
            Thread.Sleep(vsWait);

            // stop server
            vsServer.ShutdownServer();
            eventLog.WriteEntry("ShutdownServer");
            Thread.Sleep(vsWait);

            vsServer = null;

            // sleep for five minutes
            // if (bLoop) Thread.Sleep(vsWait * 12);
            // }
        }
Beispiel #2
0
        /// <summary>
        /// Start the console server.
        /// </summary>
        /// <param name="args">These are optional arguments.Pass the local ip address of the server as the first argument and the local port as the second argument.</param>
        static void Main(string [] args)
        {
            int  vsHour   = 3;
            int  vsMinute = 50;
            int  vsWait   = 5000;
            bool bLoop    = true;

            // create new object
            Console.WriteLine(DateTime.Now.ToString() + " : Create object server");
            VsServer vsServer = new VsServer();

            logger.Log(LogLevel.Info, DateTime.Now.ToString() + " : Create object server");

            // start server
            Console.WriteLine(DateTime.Now.ToString() + " : Start server");
            vsServer.StartServer();
            logger.Log(LogLevel.Info, DateTime.Now.ToString() + " : Start server");
            Thread.Sleep(vsWait);

            while (bLoop)
            {
                bLoop = false;

                try
                {
                    // start all cameras
                    Console.WriteLine(DateTime.Now.ToString() + " : Start cameras");
                    vsServer.StartAll();
                    logger.Log(LogLevel.Info, DateTime.Now.ToString() + " : Start cameras");
                    Thread.Sleep(vsWait);

                    while (!bLoop)
                    {
                        DateTime date = DateTime.Now;

                        if (date.Hour == vsHour && date.Minute >= vsMinute && date.Minute <= vsMinute + 1)
                        {
                            bLoop = true;
                        }

                        Thread.Sleep(vsWait);
                    }

                    // stop all cameras
                    Console.WriteLine(DateTime.Now.ToString() + " : Stop cameras");
                    vsServer.StopAll();
                    logger.Log(LogLevel.Info, DateTime.Now.ToString() + " : Stop cameras");
                    Thread.Sleep(vsWait);
                }
                catch (Exception err)
                {
                    logger.Log(LogLevel.Error, err.Message + err.StackTrace);
                }

                if (bLoop)
                {
                    Thread.Sleep(vsWait * (12 + 1));
                }
            }

            // stop server
            vsServer.ShutdownServer();
            Console.WriteLine(DateTime.Now.ToString() + " : Stop server");
            logger.Log(LogLevel.Info, DateTime.Now.ToString() + " : Stop server");
            Thread.Sleep(vsWait);

            vsServer = null;
        }