Пример #1
0
        private bool mergerFinishMessageEvent(DispetcherMessage dispMessage)
        {
            try
            {
                MergerFinishMessage mergMessage = dispMessage as MergerFinishMessage;
                if (!mergMessage.IsError)
                {
                    m_connectionHandlers[dispMessage.SessionId].SendSynchMessage(new RenderFinishMessage(mergMessage.FlmUri, mergMessage.SPP));
                }
                else
                {
                    sendError(m_connectionHandlers[dispMessage.SessionId], "Error occurred on worker. Likely scene is damaged");
                }
                m_log.Info("SPP: " + mergMessage.SPP.ToString());
            }
            catch (Exception e)
            {
                m_log.Warning("Error sending sync message. " + e.Message);
            }
            if (m_renderAbortHandlers.ContainsKey(m_threadsID[dispMessage.SessionId]))
            {
                m_renderAbortHandlers.Remove(m_threadsID[dispMessage.SessionId]);
            }
            MessageQueue <DispetcherMessage> dispatcherHandler = new MessageQueue <DispetcherMessage>(m_threadsID[dispMessage.SessionId].ToString());

            dispatcherHandler.Delete();
            m_log.Info("/MergerFinishMessage.");
            return(true);
        }
Пример #2
0
        public void WaitForMerger(MessageQueue <DispetcherMessage> dispatcherHandler, int sceneID, LoopAction action)
        {
            DispetcherMessage dispMessage = dispatcherHandler.WaitForMessage(typeof(MergerIsReady), null, action);
            MergerIsReady     go          = dispMessage as MergerIsReady;

            if (go.MergerQueueSuffix != sceneID.ToString())  //check for thread error
            {
                m_log.Error("Unknown error while waiting for 'MergerIsReady' message. ID: " + sceneID.ToString());
                throw (new Exception("Unknown error while waiting for 'MergerIsReady' message"));
            }
        }
Пример #3
0
        private bool mergerUpdateFailedMessageEvent(DispetcherMessage dispMessage)
        {
            m_log.Info("MergerUpdateFailedMessage. ID: " + m_threadsID[dispMessage.SessionId].ToString());
            MergerUpdateFailedMessage errMessage = dispMessage as MergerUpdateFailedMessage;

            sendError(m_connectionHandlers[dispMessage.SessionId], errMessage.ErrorMessage);
            if (m_renderAbortHandlers.ContainsKey(m_threadsID[dispMessage.SessionId]))
            {
                m_renderAbortHandlers.Remove(m_threadsID[dispMessage.SessionId]);
            }
            m_log.Info("/MergerUpdateFailedMessage");
            return(true);
        }
Пример #4
0
        private bool mergerUpdateMessageEvent(DispetcherMessage dispMessage)
        {
            try
            {
                m_log.Info("MergerUpdateMessage. ID: " + m_threadsID[dispMessage.SessionId].ToString());
                MergerUpdateMessage mergMessage = dispMessage as MergerUpdateMessage;
                CloudBlockBlob      imageBlob;
                lock (m_BlobLock)
                {
                    imageBlob = renderStorage.Get().CreateBlob(BlobName.IMAGE_BLOB, mergMessage.ImagePath);
                }

                m_log.Info("Merger completed percent: " + mergMessage.PercentageCompleted);
                float percentageCompleted = Math.Min(mergMessage.PercentageCompleted, 100);
                percentageCompleted = (float)Math.Round(percentageCompleted, 2, MidpointRounding.AwayFromZero);
                m_log.Info("Percentage completed: " + percentageCompleted.ToString());
                m_log.Info("Merger completed spp: " + mergMessage.SPP.ToString());

                m_log.Info("Fetching image. ID: " + m_threadsID[dispMessage.SessionId].ToString());
                byte[] image = Utils.DownloadBlobToArray(imageBlob);
                m_log.Info("Deleting image from blob");

                double spp = 0;
                if ((mergMessage.RequiredSpp != 0) && (mergMessage.SPP > mergMessage.RequiredSpp))
                {
                    spp = mergMessage.RequiredSpp;
                }
                else
                {
                    spp = mergMessage.SPP;
                }

                ImageMessage pngMes = new ImageMessage(image.Length, percentageCompleted, spp);
                m_log.Info("Sending message to client. ID: " + m_threadsID[dispMessage.SessionId].ToString());
                m_connectionHandlers[dispMessage.SessionId].SendSynchMessage(pngMes);
                m_log.Info("Sending picture to client. ID: " + m_threadsID[dispMessage.SessionId].ToString());
                m_connectionHandlers[dispMessage.SessionId].SendFile(image);
                m_log.Info("/MergerUpdateMessage. ID: " + m_threadsID[dispMessage.SessionId].ToString());
            }
            catch (Exception ex)
            {
                m_log.Error("MergerUpdateMessage ex: " + ex.Message);
            }
            return(false);
        }
Пример #5
0
        public void WaitForWorkers(int workersCount, MessageQueue <DispetcherMessage> dispatcherHandler,
                                   string sessionGuid, int sceneID, LoopAction action)
        {
            MessageQueue <RenderMessage> renderHandler = new MessageQueue <RenderMessage>();

            for (int i = 0; i < workersCount; ++i)
            {
                IsFreeMessage isFreeMes = new IsFreeMessage(sessionGuid, sceneID); //send check message to worker
                renderHandler.AddMessage(isFreeMes);
            }
            int workersReadyCount = 0;

            while (workersReadyCount < workersCount)
            {
                DispetcherMessage dispMessage = dispatcherHandler.WaitForMessage(typeof(WorkerIsReady), null, action);
                ++workersReadyCount;
            }
        }