示例#1
0
 private async Task UpdateSlotCollectionFromMessage(FahClientMessage message)
 {
     SlotCollection = SlotCollection.Load(message.MessageText);
     SlotOptionsCollection.Clear();
     foreach (var slot in SlotCollection)
     {
         var slotOptionsCommandText = String.Format(CultureInfo.InvariantCulture, DefaultSlotOptions, slot.ID);
         // not an expected situation at application runtime but when running some
         // tests the Connection will be null and that's fine in those scenarios
         var connection = _client.Connection;
         if (connection != null)
         {
             await connection.CreateCommand(slotOptionsCommandText).ExecuteAsync().ConfigureAwait(false);
         }
     }
 }
示例#2
0
        private void Connect()
        {
            Connection?.Dispose();
            Connection = Model.CreateConnection();
            Connection.Open();
            if (!String.IsNullOrWhiteSpace(Model.Password))
            {
                Connection.CreateCommand("auth " + Model.Password).Execute();
            }

            Model.ConnectEnabled = !Connection.Connected;
            if (Connection.Connected)
            {
                Connection.CreateCommand("slot-info").Execute();
                var reader = Connection.CreateReader();
                if (reader.Read())
                {
                    var slotCollection = SlotCollection.Load(reader.Message.MessageText);
                    foreach (var slot in slotCollection)
                    {
                        Connection.CreateCommand(String.Format(CultureInfo.InvariantCulture, FahClientMessages.DefaultSlotOptions, slot.ID)).Execute();
                        if (reader.Read())
                        {
                            var slotOptions = SlotOptions.Load(reader.Message.MessageText);
                            if (slotOptions[Options.MachineID] != null)
                            {
                                slot.SlotOptions = slotOptions;
                            }
                        }
                    }

                    Model.RefreshSlots(slotCollection);
                }
                else
                {
                    MessageBox.ShowError(Dialog, "Connected to the FAHClient but did not read any slot information.  Are you missing a password?", Core.Application.NameAndVersion);
                    Connection.Close();
                    Model.ConnectEnabled = !Connection.Connected;
                }
            }
        }
示例#3
0
        private async void FahClientMessageReceived(FahClientMessage message)
        {
            AppendTextToMessageDisplayTextBox(String.Empty);
            AppendTextToMessageDisplayTextBox(FahClientMessageHelper.FormatForDisplay(message));
            var identifier = message.Identifier.ToString();

            AddTextToStatusMessageListBox(identifier);
            SetStatusLabelText(identifier);
            FahClientDataReceived(message.MessageText.Length);

            if (message.Identifier.MessageType == FahClientMessageType.SlotInfo)
            {
                if (message.MessageFormat == FahClientMessage.PyonMessageFormat)
                {
                    message = new FahClientJsonMessageExtractor().Extract(message.MessageText);
                }
                var slotCollection = SlotCollection.Load(message.MessageText);
                foreach (var slot in slotCollection)
                {
                    await ExecuteFahClientCommandAsync("slot-options " + slot.ID + " client-type client-subtype cpu-usage machine-id max-packet-size core-priority next-unit-percentage max-units checkpoint pause-on-start gpu-index gpu-usage");
                    await ExecuteFahClientCommandAsync("simulation-info " + slot.ID);
                }
            }
        }