Exemplo n.º 1
0
        public void Create(string sWorkFolder, string sData)
        {
			_iEffect = null;
            _eStatus = BTL.EffectStatus.Idle;
            _dtStatusChanged = DateTime.Now;
            _sWorkFolder = sWorkFolder;
            _cPreferences = new Preferences(sWorkFolder, sData);
        }
Exemplo n.º 2
0
        public void Prepare()
        {
            try
            {
                //PixelsMap.DisComInit();
                lock (_oLock)
                {
                    if (bPrepared)
                    {
                        (new Logger()).WriteWarning("Comingup has already prepared!");
                        return;
                    }
                    bPrepared = true;
                }
                (new Logger()).WriteDebug("prepare:in");
                _cPreferences.cOverTop.Stopped += COverTop_Stopped;

                foreach (btl.Roll cR in _cPreferences.aRoll)
                {
                    _aEffects.Add(cR);
                }
                _aEffects.Add(_cPreferences.cHashTag);
                _aEffects.Add(_cPreferences.cOverTop);
                _aEffects.Add(_cPreferences.cOverBot);

                ulong  nSimulID    = (ulong)DateTime.Now.Subtract(DateTime.MinValue).Ticks;
                ushort nEffectsQty = (ushort)(_aEffects.Count + 1);

                _cCredits.SetSimultaneousParams(nSimulID, nEffectsQty);
                _cCredits.Prepare();

                int nI = 0;
                foreach (BTL.IEffect cE in _aEffects)
                {
                    cE.SimultaneousSet(nSimulID, nEffectsQty);
                    cE.Prepare();
                    if (cE is btl.Roll && nI++ < 2)
                    {
                        System.Threading.Thread.Sleep(500); // паузы при заборе фрагментов клипов, а то один раз дало сбой - не хватило времени эфиру взять клипы. // устарело, но зазор пусть будет ))
                    }
                }
                lock (_oLockStatus)
                {
                    _estatus         = BTL.EffectStatus.Preparing;
                    _dtStatusChanged = DateTime.Now;
                }
                if (null != Prepared)
                {
                    Plugin.EventSend(Prepared, this);
                }
                (new Logger()).WriteDebug("prepare:out");
            }
            catch (Exception ex)
            {
                (new Logger()).WriteError(ex);
            }
        }
Exemplo n.º 3
0
 public void Create(string sWorkFolder, string sData)
 {
     _iEffect         = null;
     _eStatus         = BTL.EffectStatus.Idle;
     _dtStatusChanged = DateTime.Now;
     _sWorkFolder     = sWorkFolder;
     _cPreferences    = new Preferences(sWorkFolder, sData);
     _oLock           = new object();
 }
Exemplo n.º 4
0
 public void Start()
 {
     ThreadPool.QueueUserWorkItem(Worker);
     _eStatus         = BTL.EffectStatus.Running;
     _dtStatusChanged = DateTime.Now;
     if (null != Started)
     {
         Plugin.EventSend(Started, this);
     }
 }
Exemplo n.º 5
0
 public Chat()
 {
     _eStatus                    = BTL.EffectStatus.Idle;
     _dtStatusChanged            = DateTime.Now;
     _bWorkerEnd                 = true;
     _bWorkerSMSEnd              = true;
     _oLock                      = new object();
     _oLockStop                  = new object();
     _aqHistorySMSs              = new Queue <SMS>();
     _bChatWasAddedToLogsOnStart = false;
 }
Exemplo n.º 6
0
 public bool StatusIsOlderThen(BTL.EffectStatus eStat, int nSeconds)
 {
     lock (oEffect)
         if (cEffectParrent != null && (eStat == BTL.EffectStatus.Preparing || eStat == BTL.EffectStatus.Idle) && (cEffectParrent.eStatus == BTL.EffectStatus.Preparing || cEffectParrent.eStatus == BTL.EffectStatus.Running))
         {
             return(false);
         }
     if (eStatus == eStat && dtStatusChanged.AddSeconds(nSeconds) < DateTime.Now)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 7
0
 public void Create(string sWorkFolder, string sData)
 {
     (new Logger()).WriteDebug("create");
     BTL.Baetylus cBTL = BTL.Baetylus.Helper.cBaetylus;
     _aEffects        = new List <BTL.IEffect>();
     _estatus         = BTL.EffectStatus.Idle;
     _dtStatusChanged = DateTime.Now;
     _oLock           = new object();
     _oLockStatus     = new object();
     _bStopped        = false;
     _cPreferences    = new Preferences(sData);
     _cCredits        = new Credits();
     _cCredits.Create(sWorkFolder, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + _cPreferences.sCredits);
 }
Exemplo n.º 8
0
 public void Prepare()
 {
     try
     {
         _bStopped = true;
         _aqSMSs   = new Queue <SMS>();
         (_cSMSChat = new SMSChat(_cPreferences)).Init();
         _eStatus         = BTL.EffectStatus.Preparing;
         _dtStatusChanged = DateTime.Now;
         if (null != Prepared)
         {
             Plugin.EventSend(Prepared, this);
         }
         (new Logger()).WriteDebug3("ok");
     }
     catch (Exception ex)
     {
         (new Logger()).WriteError(ex);
     }
 }
Exemplo n.º 9
0
        public void Start()
        {
            (new Logger()).WriteDebug("start:in");
            _cCredits.Start();
            foreach (BTL.IEffect cE in _aEffects)
            {
                cE.Start();
            }

            lock (_oLockStatus)
            {
                _estatus         = BTL.EffectStatus.Running;
                _dtStatusChanged = DateTime.Now;
            }
            if (null != Started)
            {
                Plugin.EventSend(Started, this);
            }
            (new Logger()).WriteDebug("start:out");
        }
Exemplo n.º 10
0
        public void Prepare()
        {
            lock (_oLock)
            {
                if (_bPrepared)
                {
                    (new Logger()).WriteWarning("Blender has already prepared!");
                    return;
                }
                _bPrepared = true;
            }
            try
            {
                if (null != _cPreferences.iVideo)
                {
                    if (!_cPreferences.bExists)
                    {
                        (new Logger()).WriteDebug2("render from prepare [pf=" + _cPreferences.sPythonFile + "]");
                        Render(_cPreferences.sBlendFile, _cPreferences.sPythonFile, _cPreferences.sOutputTarget, "0", _cPreferences.bUseOutput, _cPreferences.bZip);
                    }
                    _cPreferences.EffectVideoInit();
                    (_iEffect = (BTL.IEffect)_cPreferences.iVideo).Prepare();
                }
                else
                {
                    _eStatus = BTL.EffectStatus.Preparing;
                }

                if (null != Prepared)
                {
                    Plugin.EventSend(Prepared, this);
                }
                (new Logger()).WriteDebug3("prepared");
            }
            catch (Exception ex)
            {
                (new Logger()).WriteError(ex);
            }
        }
Exemplo n.º 11
0
 public void Stop()
 {
     lock (_oLock)
     {
         if (_bStopped)
         {
             return;
         }
         _bStopped = true;
     }
     try
     {
         (new Logger()).WriteDebug("stop:in");
         if (((IPlugin)_cCredits).eStatus == BTL.EffectStatus.Running)
         {
             _cCredits.Stop();
         }
         foreach (BTL.IEffect cE in _aEffects)
         {
             cE.Dispose();
         }
         (new Logger()).WriteDebug("stop:mid");
     }
     catch (Exception ex)
     {
         (new Logger()).WriteError(ex);
     }
     lock (_oLockStatus)
     {
         _estatus         = BTL.EffectStatus.Stopped;
         _dtStatusChanged = DateTime.Now;
     }
     if (null != Stopped)
     {
         Plugin.EventSend(Stopped, this);
     }
     (new Logger()).WriteDebug("stop:out");
 }
Exemplo n.º 12
0
		private void Render(string sBlendFile, string sPythonFile, string sOutput, string sPrefix, bool bUseOutput)//(System.Diagnostics.ProcessStartInfo cProcessStartInfo)
        {
			string sTaskFoldername, sTaskFolder, sPythonFilename;
			while (Directory.Exists(sTaskFolder = Path.Combine(_cPreferences.sPath, sTaskFoldername = Path.GetRandomFileName()))) ;
			Directory.CreateDirectory(sTaskFolder);
			Encoding cEncoding = Encoding.GetEncoding(1251);
			File.WriteAllText(sPythonFile, File.ReadAllText(sPythonFile, cEncoding).Replace("{%_RENDER_FOLDER_%}", sTaskFoldername), cEncoding);
			(new Logger()).WriteNotice("render task start [" + sTaskFolder + "][" + sBlendFile + "][" + sPythonFile + "][" + sOutput + "]");
			File.Copy(sPythonFile, Path.Combine(sTaskFolder, sPythonFilename = Path.GetFileName(sPythonFile)));
			File.WriteAllLines(Path.Combine(sTaskFolder, "task"), new string[] { sBlendFile, sPythonFilename, sPrefix, bUseOutput.ToString() });

			string sResultFolder = Path.Combine(sTaskFolder, "result");
			DateTime dtTimeout = DateTime.Now.AddMinutes(10);  // каминап теперь 7 минут где-то
			while(!Directory.Exists(sResultFolder))
			{
				if(DateTime.Now > dtTimeout)
				{
					(new Logger()).WriteError("render timeout [" + sTaskFolder + "][" + sBlendFile + "][" + sPythonFile + "][" + sOutput + "]");
					_eStatus = BTL.EffectStatus.Error;
					if (!Directory.EnumerateFileSystemEntries(sOutput).Any())
					{
						Directory.Delete(sOutput);
						(new Logger()).WriteNotice("пустая директория удалена после таймаута: [" + sOutput + "]");
					}
					return;
				}
				//что-нить и как-нить логировать и отваливаться по таймауту
				System.Threading.Thread.Sleep(200);
			}

			CopyAll(sResultFolder, sOutput);
			try
			{
				(new Logger()).WriteNotice("попытка удалить [" + sTaskFolder + "]");
				Directory.Delete(sTaskFolder, true);
			}
			catch (Exception ex)
			{
				(new Logger()).WriteError(ex);
			}
			(new Logger()).WriteNotice("render task stop [" + sTaskFolder + "][" + sBlendFile + "][" + sPythonFile + "][" + sOutput + "]");
			_cPreferences.RenderFinished();

			//bool bLogged = false;
			//while (_nQueueLength > Preferences.nQueueLengthMax)
			//{
			//    if (!bLogged)
			//        (new Logger()).WriteNotice("rendering: waiting [c:" + _nQueueLength + "][m:" + Preferences.nQueueLengthMax + "]");
			//    bLogged = true;
			//    System.Threading.Thread.Sleep(500);
			//}
			//_nQueueLength++;
			//(new Logger()).WriteNotice("rendering [" + cProcessStartInfo.Arguments + "]");
			//System.Diagnostics.Process cProcess = System.Diagnostics.Process.Start(cProcessStartInfo);
			////helpers.Logger cLogger = new helpers.Logger("render:" + GetHashCode(), "blender_render_last");
			////cLogger.WriteNotice("***************************************************************<br>Arguments:" + cProcess.StartInfo.Arguments);
			//_sMessage = "<br>";
			//cProcess.OutputDataReceived += (sender, args) => _sMessage += "[" + DateTime.Now.ToStr() + "][notice][" + args.Data + "]<br>";// cLogger.WriteNotice(args.Data);
			//cProcess.ErrorDataReceived += (sender, args) => _sMessage += "[" + DateTime.Now.ToStr() + "][error][" + args.Data + "]<br>";// cLogger.WriteNotice("error<br>", args.Data);
			//cProcess.BeginOutputReadLine();
			//cProcess.BeginErrorReadLine();
			//cProcess.WaitForExit();
			//_cPreferences.RenderFinished();
			////cLogger.WriteNotice(_sMessage + "Exit code:" + cProcess.ExitCode);
			//_nQueueLength--;
		}
Exemplo n.º 13
0
        public void Stop()
        {
            lock (_oLockStop)
            {
                if (_bStopped)
                {
                    return;
                }
                _bStopped = true;
            }
            try
            {
                _cSMSChat.IsChatTerminating = true;
                (new Logger()).WriteNotice("Stop: IsChatTerminating = true");
                DateTime dtNow = DateTime.Now.AddSeconds(5);
                while ((_cSMSChat.IsChatTerminating || _cSMSChat.IsInfoOnAir) && DateTime.Now < dtNow)
                {
                    Thread.Sleep(50);
                }

                while (!_bWorkerSMSEnd && !_bWorkerEnd)
                {
                    Thread.Sleep(50);
                }

                _cSMSChat.Stop();
                _cSMSChat.Release();
                (new Logger()).WriteNotice("Stop: after _cSMSChat.Release();");
                lock (_oLock)
                {
                    _cSMSChat = null;
                }
            }
            catch (Exception ex)
            {
                (new Logger()).WriteError(ex);
            }
            finally
            {
                try
                {
                    DBInteract cDBI   = new DBInteract();
                    bool       bIsAir = cDBI.IsThereAnyStartedLiveBroadcast();
                    (new Logger()).WriteDebug2("ChatLogStopAdd [isair=" + bIsAir + "][type=" + _cPreferences.eBroadcastType + "][release=" + _cPreferences.bMessagesRelease + "]");
                    if (_cPreferences.bMessagesRelease && !(_cPreferences.eBroadcastType == Preferences.BroadcastType.linear && bIsAir) && !(_cPreferences.eBroadcastType == Preferences.BroadcastType.live && !bIsAir))
                    {
                        bool bOk = cDBI.ChatLogStopAdd(DateTime.Now.AddSeconds(4));
                        (new Logger()).WriteNotice("ChatLogStopAdd - " + bOk);
                    }
                    else if (_bChatWasAddedToLogsOnStart)
                    {
                        bool bOk = cDBI.ChatLogStopAdd(DateTime.Now.AddSeconds(4));
                        (new Logger()).WriteNotice("ChatLogStopAdd-2 - " + bOk);
                    }
                    _bChatWasAddedToLogsOnStart = false;
                    _eStatus         = BTL.EffectStatus.Stopped;
                    _dtStatusChanged = DateTime.Now;
                    _cPreferences    = null;
                    if (null != Stopped)
                    {
                        Plugin.EventSend(Stopped, this);
                    }
                }
                catch (Exception ex)
                {
                    (new Logger()).WriteError("Stop: ", ex);
                }
            }
        }
Exemplo n.º 14
0
        public void Stop()
        {
            try
            {
				if (_bStopped)
					return;
                _bStopped = true;
                _cSMSChat.IsChatTerminating = true;
				(new Logger()).WriteNotice("Stop: IsChatTerminating = true");
                DateTime dtNow = DateTime.Now.AddSeconds(15);
				while ((_cSMSChat.IsChatTerminating || _cSMSChat.IsInfoOnAir) && DateTime.Now < dtNow)
                    Thread.Sleep(50);

				while (!_bWorkerSMSEnd && !_bWorkerEnd)
					Thread.Sleep(50);

				_cSMSChat.Release();
				(new Logger()).WriteNotice("Stop: after _cSMSChat.Release();");
				_cSMSChat = null;
				_cPreferences = null;
			}
            catch (Exception ex)
            {
                (new Logger()).WriteError(ex);
			}
			_eStatus = BTL.EffectStatus.Stopped;
			_dtStatusChanged = DateTime.Now;
			if (null != Stopped)
                Plugin.EventSend(Stopped, this);
		}
Exemplo n.º 15
0
        public void Start()
        {
            ThreadPool.QueueUserWorkItem(Worker);
			_eStatus = BTL.EffectStatus.Running;
			_dtStatusChanged = DateTime.Now;
            if (null != Started)
                Plugin.EventSend(Started, this);
		}
Exemplo n.º 16
0
        public void Prepare()
        {
            try
            {
                DisCom.Init();
                _bStopped = true;
                _aqSMSs = new Queue<SMS>();
                (_cSMSChat = new SMSChat(_cPreferences)).Init(); 
                _eStatus = BTL.EffectStatus.Preparing;
				_dtStatusChanged = DateTime.Now;
				if (null != Prepared)
                    Plugin.EventSend(Prepared, this);
				(new Logger()).WriteDebug3("ok");
            }
            catch (Exception ex)
            {
                (new Logger()).WriteError(ex);
            }
        }
Exemplo n.º 17
0
        public Chat()
        {
            _eStatus = BTL.EffectStatus.Idle;
			_dtStatusChanged = DateTime.Now;
			_bWorkerEnd = true;
			_bWorkerSMSEnd = true;
        }
Exemplo n.º 18
0
        private void Render(string sBlendFile, string sPythonFile, string sOutput, string sPrefix, bool bUseOutput, bool bZip)        //(System.Diagnostics.ProcessStartInfo cProcessStartInfo)
        {
            //int nPF = Convert.ToInt32(Path.GetFileName(sPythonFile).Substring(3, 4), 16) - 1;
            //string sPF = Path.Combine(Path.GetTempPath(), ("tmp" + nPF.ToString("X") + ".tmp"));
            //if (File.Exists(sPF))
            //	(new Logger()).WriteNotice("render task start [file is there! " + sPF + "]");
            //else
            //	(new Logger()).WriteNotice("render task start [no file! " + sPF + "]");



            string sTaskFoldername, sTaskFolder, sPythonFilename;

            while (Directory.Exists(sTaskFolder = Path.Combine(_cPreferences.sPath, sTaskFoldername = Path.GetRandomFileName())))
            {
                ;
            }
            Directory.CreateDirectory(sTaskFolder);
            Encoding cEncoding = Encoding.GetEncoding(1251);

            File.WriteAllText(sPythonFile, File.ReadAllText(sPythonFile, cEncoding).Replace("{%_RENDER_FOLDER_%}", sTaskFoldername), cEncoding);
            (new Logger()).WriteNotice("render task start [" + sTaskFolder + "][" + sBlendFile + "][" + sPythonFile + "][" + sOutput + "]");
            File.Copy(sPythonFile, Path.Combine(sTaskFolder, sPythonFilename = Path.GetFileName(sPythonFile)));
            File.WriteAllLines(Path.Combine(sTaskFolder, "task"), new string[] { sBlendFile, sPythonFilename, sPrefix, bUseOutput.ToString(), bZip ? "zip_yes" : "zip_no" });



            //File.Copy(sPythonFile, Path.Combine(Path.GetTempPath(), sPythonFilename + ".py"));

            //if (File.Exists(sPF))
            //	(new Logger()).WriteNotice("render task start2 [file is there! " + sPF + "]");
            //else
            //	(new Logger()).WriteNotice("render task start2 [no file! " + sPF + "]");



            string   sResultFolder = Path.Combine(sTaskFolder, "result");
            DateTime dtTimeout     = DateTime.Now.AddMinutes(30);          // каминап теперь 17 минут где-то... иногда 24  (на normal priority на фоне эфира)

            while (!Directory.Exists(sResultFolder))
            {
                if (DateTime.Now > dtTimeout)
                {
                    (new Logger()).WriteError("render timeout [" + sTaskFolder + "][" + sBlendFile + "][" + sPythonFile + "][" + sOutput + "]");
                    _eStatus = BTL.EffectStatus.Error;
                    if (!Directory.EnumerateFileSystemEntries(sOutput).Any())
                    {
                        Directory.Delete(sOutput);
                        (new Logger()).WriteNotice("пустая директория удалена после таймаута: [" + sOutput + "]");

                        if (null != _cPreferences.sPythonFile && File.Exists(_cPreferences.sPythonFile))
                        {
                            File.Delete(_cPreferences.sPythonFile);
                            (new Logger()).WriteDebug("deleted on timeout: [pythonf=" + _cPreferences.sPythonFile + "]");
                        }
                    }
                    return;
                }
                //что-нить и как-нить логировать и отваливаться по таймауту
                System.Threading.Thread.Sleep(200);
            }

            CopyAll(sResultFolder, sOutput);
            try
            {
                (new Logger()).WriteNotice("попытка удалить [" + sTaskFolder + "]");
                Directory.Delete(sTaskFolder, true);
            }
            catch (Exception ex)
            {
                (new Logger()).WriteError(ex);
            }
            (new Logger()).WriteNotice("render task stop [" + sTaskFolder + "][" + sBlendFile + "][" + sPythonFile + "][" + sOutput + "]");
            _cPreferences.RenderFinished();

            //bool bLogged = false;
            //while (_nQueueLength > Preferences.nQueueLengthMax)
            //{
            //    if (!bLogged)
            //        (new Logger()).WriteNotice("rendering: waiting [c:" + _nQueueLength + "][m:" + Preferences.nQueueLengthMax + "]");
            //    bLogged = true;
            //    System.Threading.Thread.Sleep(500);
            //}
            //_nQueueLength++;
            //(new Logger()).WriteNotice("rendering [" + cProcessStartInfo.Arguments + "]");
            //System.Diagnostics.Process cProcess = System.Diagnostics.Process.Start(cProcessStartInfo);
            ////helpers.Logger cLogger = new helpers.Logger("render:" + GetHashCode(), "blender_render_last");
            ////cLogger.WriteNotice("***************************************************************<br>Arguments:" + cProcess.StartInfo.Arguments);
            //_sMessage = "<br>";
            //cProcess.OutputDataReceived += (sender, args) => _sMessage += "[" + DateTime.Now.ToStr() + "][notice][" + args.Data + "]<br>";// cLogger.WriteNotice(args.Data);
            //cProcess.ErrorDataReceived += (sender, args) => _sMessage += "[" + DateTime.Now.ToStr() + "][error][" + args.Data + "]<br>";// cLogger.WriteNotice("error<br>", args.Data);
            //cProcess.BeginOutputReadLine();
            //cProcess.BeginErrorReadLine();
            //cProcess.WaitForExit();
            //_cPreferences.RenderFinished();
            ////cLogger.WriteNotice(_sMessage + "Exit code:" + cProcess.ExitCode);
            //_nQueueLength--;
        }