public void RaiseStatusEvent()
 {
     if (OnStatusUpdate != null)
     {
         OnStatusUpdate.Invoke(this);
     }
 }
 public void ResetTransfrom()
 {
     currentRotation = Vector3.zero;
     rootEntity.gameObject.transform.eulerAngles = currentRotation;
     rootEntity.gameObject.transform.localScale  = Vector3.one;
     OnStatusUpdate?.Invoke(this);
 }
Beispiel #3
0
 public void DoStatusUpdate(string lefttext, string righttext, int leftcount, int leftmaxcount, int rightcount, int rightmaxcount)
 {
     if (OnStatusUpdate != null)
     {
         OnStatusUpdate.Invoke(lefttext, righttext, leftcount, leftmaxcount, rightcount, rightmaxcount);
     }
 }
        protected async void StartListening(CancellationToken cancellationToken)
        {
            while (_webSocket.State == WebSocketState.Open && !cancellationToken.IsCancellationRequested)
            {
                WebSocketMessage webSocketMessage = null;
                string           receivedMsg      = null;
                try
                {
                    webSocketMessage = await _webSocket.ReceiveMessageAsync(cancellationToken);

                    receivedMsg = (string)webSocketMessage.Data;
                }
                catch (WebSocketException e) when(e.WebSocketErrorCode == WebSocketError.InvalidState)
                {
                    break;
                }

                SensorStatus parsedMsg;
                try
                {
                    parsedMsg = JSON.Deserialize <SensorStatus>(receivedMsg);
                }
                catch (DeserializationException)
                {
                    // Failed to parse message - Happens occasionally - We are currently ignoring this
                    continue;
                }

                OnStatusUpdate?.Invoke(this, new OnUpdateEventArgs(receivedMsg, parsedMsg));
            }
        }
Beispiel #5
0
        void Player()
        {
            MusicFile file;

            while (IsActive)
            {
                do
                {
                    Queue.TryDequeue(out file);
                    if (!IsActive)
                    {
                        return;
                    }
                } while (file == null);
                if (OnFileListUpdate != null)
                {
                    OnFileListUpdate.Invoke(Queue.ToList());
                }
                Mp3Frame frame = null;
                try
                {
                    file.Open();
                    frame = file.GetFrame();
                }
                catch (Exception)
                {
                    Logger.SetError(string.Format("MusicPlayer error: 'can't decode file [{0}]'", file.Filename));
                }
                while (frame != null)
                {
                    foreach (Stream output in OutputStreams.Keys)
                    {
                        try
                        {
                            output.WriteAsync(frame.RawData, 0, frame.RawData.Length);
                            output.FlushAsync();
                        }
                        catch
                        {
                            output.Close();
                            Disattach(output);
                        }
                    }
                    frame = file.GetFrame();
                    if (!IsActive)
                    {
                        return;
                    }
                    if (OnStatusUpdate != null)
                    {
                        OnStatusUpdate.Invoke(new MusicPlayerStatus()
                        {
                            CurrentFile = file,
                            Connections = OutputStreams.Count,
                            Queue       = Queue.ToList()
                        });
                    }
                }
            }
        }
Beispiel #6
0
        public void Generate(int depth, int seconds)
        {
            int done = 0;

            OnStatusUpdate?.Invoke(done, 12643);

            // Blue's first move
            var blueStart = GenerateBookForPosition(depth, seconds, "", true);

            OnStatusUpdate?.Invoke(++done, 12643);

            // Blue's second and third move (after all possible moves from orange)
            var allGamesBlue = GetAllTranscriptsAfterPosition(blueStart, false);

            // Orange's first and second move (after all possible moves from blue)
            var allGamesOrange = GetAllTranscriptsAfterPosition("", true);

            Parallel.ForEach(allGamesBlue, transcript =>
            {
                GenerateBookForPosition(depth, seconds, transcript, false);

                OnStatusUpdate?.Invoke(++done, 12643);
            });

            Parallel.ForEach(allGamesOrange, transcript =>
            {
                GenerateBookForPosition(depth, seconds, transcript, false);

                OnStatusUpdate?.Invoke(++done, 12643);
            });

            OnStatusUpdate?.Invoke(12643, 12643);
        }
Beispiel #7
0
 public void UpdateQuestEvent(EventStatus es)
 {
     status = es;
     OnStatusUpdate?.Invoke(this, new OnStatusUpdateEventArgs {
         name = name, status = status
     });
 }
Beispiel #8
0
 private void DoStateUpdate(string msg)
 {
     OnStatusUpdate?.Invoke(this, new WStoryExporterUpdateEventArgs()
     {
         MessageUpdated = true,
         Message        = GetStateUpdateMsg(msg)
     });
 }
Beispiel #9
0
    public void ResetTransfrom()
    {
        currentRotation = Vector3.zero;
        rootEntity.gameObject.transform.eulerAngles = currentRotation;
        rootEntity.gameObject.transform.position    = initialPosition;

        OnStatusUpdate?.Invoke(this);
    }
Beispiel #10
0
 private void StatusUpdate(string text, int percent)
 {
     Debug.WriteLine(text + " (" + percent + "%)");
     OnStatusUpdate?.Invoke(this, new StatusUpdateArgs()
     {
         statusText = text, progressPercent = percent
     });
     //Thread.Sleep(2000);
 }
Beispiel #11
0
 public ThreadRecordSupplier(ThroughputConfiguration configuration,
                             IRecordProvider context,
                             OnStatusUpdate onStatus = null)
 {
     this.Configuration = configuration;
     this.Provider      = context;
     this.OnStatus      = onStatus;
     PopulateRecordList();
 }
Beispiel #12
0
        public void Notify(float price)
        {
            //For way 1 lets notify the observers with change
            foreach (Shop p in list)
            {
                p.Update(price);
            }

            //For way 2 lets notify the observers with change
            OnStatusUpdate?.Invoke(price);
        }
Beispiel #13
0
        public void Notify(float price)
        {
            // for first kind
            foreach (Shop p in list)
            {
                p.Update(price);
            }

            // for second kind
            OnStatusUpdate?.Invoke(price);
        }
Beispiel #14
0
 public void Reset()
 {
     OnIsBusy.Reset();
     OnIsNotBusy.Reset();
     OnStatusUpdate.Reset();
     OnActiveBranchChanged.Reset();
     OnActiveRemoteChanged.Reset();
     OnLocalBranchListChanged.Reset();
     OnRemoteBranchListChanged.Reset();
     OnLocksUpdated.Reset();
 }
Beispiel #15
0
 private void DoStateUpdate(string msg, int progressValue, int progressMax)
 {
     OnStatusUpdate?.Invoke(this, new WStoryExporterUpdateEventArgs()
     {
         MessageUpdated  = true,
         Message         = GetStateUpdateMsg(msg),
         ProgressUpdated = true,
         ProgressValue   = progressValue,
         ProgressMax     = progressMax
     });
 }
Beispiel #16
0
 public Task <bool> LoadMetadataAsync(Stream metadataStream) =>
 Task.Run(() => {
     try {
         OnStatusUpdate?.Invoke(this, "Processing metadata");
         metadata = new Metadata(metadataStream);
         return(true);
     }
     catch (Exception ex) {
         LastException = ex;
         return(false);
     }
 });
Beispiel #17
0
 public JobManager(
     IRecordProvider recordProvider,
     ThroughputConfiguration context,
     OnRecordCompleted jobComplete,
     OnStatusUpdate update,
     OnAllJobsCompleted allCompleted)
     : this()
 {
     this.RecordProvider       = recordProvider;
     this.Context              = context;
     this.RecordCompleted     += jobComplete;
     this.StatusUpdate        += update;
     this.AllThreadsCompleted += allCompleted;
 }
    public void SetDescriptiveName(string newName)
    {
        if (rootEntity.TryGetSharedComponent(CLASS_ID.NAME, out ISharedComponent nameComponent))
        {
            ((DCLName)nameComponent).SetNewName(newName);
        }
        else
        {
            ParcelScene scene = rootEntity.scene as ParcelScene;
            DCLName     name  = (DCLName)scene.SharedComponentCreate(Guid.NewGuid().ToString(), Convert.ToInt32(CLASS_ID.NAME));
            name.SetNewName(newName);
            scene.SharedComponentAttach(rootEntity.entityId, name.id);
        }

        OnStatusUpdate?.Invoke(this);
    }
Beispiel #19
0
        // Attempt to load an IL2CPP application package (APK or IPA)
        public async Task <bool> LoadPackageAsync(string packageFile)
        {
            try {
                OnStatusUpdate?.Invoke(this, "Extracting package");

                var streams = Inspector.GetStreamsFromPackage(packageFile);
                if (streams == null)
                {
                    throw new InvalidOperationException("The supplied package is not an APK or IPA file, or does not contain an IL2CPP application");
                }

                return(await LoadMetadataAsync(streams.Value.Metadata) && await LoadBinaryAsync(streams.Value.Binary));
            }
            catch (Exception ex) {
                LastException = ex;
                return(false);
            }
        }
Beispiel #20
0
 private void UpdateStatus(string message)
 {
     OnStatusUpdate?.Invoke(message);
 }
Beispiel #21
0
        public IDictionary <int, object> LoadRecords(RecordProviderConfiguration configuration, OnStatusUpdate onStatus = null)
        {
            Dictionary <int, object> returnValue = new Dictionary <int, object>();

            String fileContent = System.IO.File.ReadAllText(this.FileInput);

            for (int i = 0; i < configuration.RecordCount; i++)
            {
                returnValue.Add(i, fileContent);
            }

            return(returnValue);
        }
Beispiel #22
0
        /// <summary>
        /// Return a list of objects that match your API input. This one returns a simple JSON object for an image detection
        /// API.
        ///
        /// There are currently two options in the RecordProviderConfiguration : "storage" or "local", but in reality in the check
        /// below, if we don't find storage, we assume local.
        ///
        /// "storage" in this case means records will be loaded from Azure Storage using the information in RecordProviderConfiguration.Storage
        /// object.
        /// </summary>
        public IDictionary <int, object> LoadRecords(RecordProviderConfiguration configuration, OnStatusUpdate onStatus = null)
        {
            Dictionary <int, object> returnObjects = new Dictionary <int, object>();

            if (String.Compare(configuration.ExecutionType, "storage", true) == 0)
            {
                onStatus?.Invoke($"Loading {configuration.RecordCount} records from storage.");

                AzureStorageUtility storageUtility = new AzureStorageUtility(configuration.Storage);
                List <String>       blobList       = storageUtility.ListBlobs(
                    configuration.RecordCount,
                    configuration.Storage.StorageAccountContainer,
                    configuration.Storage.BlobPrefix,
                    configuration.Storage.FileType);

                foreach (String blob in blobList)
                {
                    String content = storageUtility.GetBlobBase64(configuration.Storage.StorageAccountContainer, blob);
                    returnObjects.Add(RecordId++, PackageRecord(System.IO.Path.GetFileName(blob), content));
                }


                onStatus?.Invoke($"Loaded {returnObjects.Count} records from storage.");
            }
            else
            {
                onStatus?.Invoke($"Creating {configuration.RecordCount} records from local system.");

                // Loading from file -
                String fileToLoad = configuration.Local.LocalFile;
                if (System.IO.File.Exists(fileToLoad))
                {
                    byte[] fileData = System.IO.File.ReadAllBytes(fileToLoad);
                    String content  = Convert.ToBase64String(fileData);
                    String name     = System.IO.Path.GetFileName(fileToLoad);

                    for (int i = 0; i < configuration.RecordCount; i++)
                    {
                        returnObjects.Add(RecordId++, PackageRecord(String.Format("{0}_{1}", i, name), content));
                    }

                    onStatus?.Invoke($"Created {returnObjects.Count} records from local system.");
                }
            }

            return(returnObjects);
        }
Beispiel #23
0
 private void StatusUpdate(object sender, string status) => OnStatusUpdate?.Invoke(sender, status);
Beispiel #24
0
 void OnNameUpdate(DCLName.Model model)
 {
     OnStatusUpdate?.Invoke(this);
 }
 public void ToggleShowStatus()
 {
     rootEntity.gameObject.SetActive(!rootEntity.gameObject.activeSelf);
     IsVisible = rootEntity.gameObject.activeSelf;
     OnStatusUpdate?.Invoke(this);
 }
Beispiel #26
0
        private void OnPerformanceTimerCallback(object state)
        {
            var nodeStatus = new NodeStatus();

            StatusInfoCollection bootstrapStatus = new StatusInfoCollection();

            m_Helper.Collect(bootstrapStatus);

            nodeStatus.BootstrapStatus = bootstrapStatus;

            var instancesStatus = new List <StatusInfoCollection>(m_AppServers.Length);

            var perfBuilder = new StringBuilder();

            perfBuilder.AppendLine("---------------------------------------------------");
            perfBuilder.AppendLine(string.Format("CPU Usage: {0:0.00}%, Physical Memory Usage: {1:N}, Total Thread Count: {2}", bootstrapStatus[StatusInfoKeys.CpuUsage], bootstrapStatus[StatusInfoKeys.MemoryUsage], bootstrapStatus[StatusInfoKeys.TotalThreadCount]));
            perfBuilder.AppendLine(string.Format("AvailableWorkingThreads: {0}, AvailableCompletionPortThreads: {1}", bootstrapStatus[StatusInfoKeys.AvailableWorkingThreads], bootstrapStatus[StatusInfoKeys.AvailableCompletionPortThreads]));
            perfBuilder.AppendLine(string.Format("MaxWorkingThreads: {0}, MaxCompletionPortThreads: {1}", bootstrapStatus[StatusInfoKeys.MaxWorkingThreads], bootstrapStatus[StatusInfoKeys.MaxCompletionPortThreads]));

            for (var i = 0; i < m_AppServers.Length; i++)
            {
                var s = m_AppServers[i];

                var metadata = m_ServerStatusMetadataSource[i + 1].Value;

                if (metadata == null)
                {
                    perfBuilder.AppendLine(string.Format("{0} ----------------------------------", s.Name));
                    perfBuilder.AppendLine(string.Format("{0}: {1}", "State", s.State));
                }
                else
                {
                    StatusInfoCollection serverStatus;

                    try
                    {
                        serverStatus = s.CollectServerStatus(bootstrapStatus);
                    }
                    catch (Exception e)
                    {
                        m_PerfLog.Error("Failed to CollectServerStatus of " + s.Name, e);

                        perfBuilder.AppendLine(string.Format("{0} ----------------------------------", s.Name));
                        perfBuilder.AppendLine(string.Format("{0}: {1}", "State", s.State));
                        continue;
                    }

                    instancesStatus.Add(serverStatus);

                    perfBuilder.AppendLine(string.Format("{0} ----------------------------------", serverStatus.Tag));

                    for (var j = 0; j < metadata.Length; j++)
                    {
                        var statusInfoAtt = metadata[j];

                        if (!statusInfoAtt.OutputInPerfLog)
                        {
                            continue;
                        }

                        var statusValue = serverStatus[statusInfoAtt.Key];

                        if (statusValue == null)
                        {
                            continue;
                        }

                        perfBuilder.AppendLine(
                            string.Format("{0}: {1}", statusInfoAtt.Name,
                                          string.IsNullOrEmpty(statusInfoAtt.Format) ? statusValue : string.Format(statusInfoAtt.Format, statusValue)));
                    }
                }
            }

            m_PerfLog.Info(perfBuilder.ToString());

            nodeStatus.InstancesStatus = instancesStatus.ToArray();

            OnStatusUpdate?.Invoke(nodeStatus);

            if (m_ServerManager != null && m_ServerManager.State == ServerState.Running)
            {
                m_ServerManager.TransferSystemMessage("ServerStatusCollected", nodeStatus);
            }
        }
Beispiel #27
0
 protected virtual void StatusUpdate(ServiceStatusCode statusCode, IRuneScapeForm account = null, string message = null)
 {
     OnStatusUpdate?.Invoke(statusCode, account, message);
 }
 void OnNameUpdate(object model)
 {
     OnStatusUpdate?.Invoke(this);
 }
        public void Login(string host, int port, OnLoginDoneDel onLoginDone, OnStatusUpdate onStatusUpdate)
        {
            _onLoginDone    = onLoginDone;
            _onStatusUpdate = onStatusUpdate;

            RaiseStatusUpdate(string.Format("正在连接 {0}:{1} ...", host, port), false);

            Func <string, int, bool> connectFunc = _client.Connect;

            connectFunc.BeginInvoke(host, port,
                                    delegate(IAsyncResult ar)
            {
                bool connectSucc = false;
                try
                {
                    connectSucc = connectFunc.EndInvoke(ar);
                }
                catch (System.Exception ex)
                {
                    LogManager.Logger.ErrorFormat("Failed to connect {0}:{1} due to {2}", host, port, ex.Message);
                }

                if (connectSucc)
                {
                    // wait for client really connected
                    if (_eventLogin.WaitOne(LoginTimeout))
                    {
                        if (_connectionEstablished)
                        {
                            RaiseStatusUpdate("已经与服务器建立连接.");

                            ServerLoginParam tradeLoginInfo = _getServerLoginParamFunc();
                            RaiseStatusUpdate(string.Format("正在登录CTP交易 {0} ...", tradeLoginInfo.TradeAddress));
                            // begin login trade
                            _client.TradeLogin(tradeLoginInfo.TradeAddress, tradeLoginInfo.BrokerId, tradeLoginInfo.InvestorId, tradeLoginInfo.UserId, tradeLoginInfo.Password);

                            if (_eventTradeLogin.WaitOne(LoginTimeout))
                            {
                                if (_tradeLogged)
                                {
                                    RaiseStatusUpdate("登录CTP交易成功.");
                                    RaiseStatusUpdate(string.Format("正在登录CTP行情 {0}...", tradeLoginInfo.QuoteAddress));
                                    _client.QuoteLogin(tradeLoginInfo.QuoteAddress, tradeLoginInfo.BrokerId, tradeLoginInfo.InvestorId, tradeLoginInfo.UserId, tradeLoginInfo.Password);

                                    if (_eventQuoteLogin.WaitOne(LoginTimeout))
                                    {
                                        if (_quoteLogged)
                                        {
                                            RaiseStatusUpdate("登录CTP行情成功.");
                                            RaiseLoginDone(true);
                                        }
                                        else
                                        {
                                            RaiseLoginDone(false, _quoteLoggedError);
                                        }
                                    }
                                    else
                                    {
                                        RaiseLoginDone(false, "登录CTP行情超时");
                                    }
                                }
                                else
                                {
                                    RaiseLoginDone(false, _tradeLoggedError);
                                }
                            }
                            else
                            {
                                RaiseLoginDone(false, "登录CTP交易超时");
                            }
                        }
                        else
                        {
                            RaiseLoginDone(false, _connectionEstablishError);
                        }
                    }
                    else
                    {
                        RaiseLoginDone(false, "连接服务器超时");
                    }
                }
                else
                {
                    RaiseLoginDone(false, string.Format("无法连接到 {0}:{1}", host, port));
                }
            }, null);
        }
Beispiel #30
0
 public void DatalinkTest_OnStatusUpdate(TransformWriterResult writer)
 {
     OnStatusUpdate?.Invoke(writer);
 }