Пример #1
0
 public void PrintPerformance(SRKStringBuilder sb)
 {
     sb.AppendLine($"Avg Runtime = {AverageRuntime:0.0000}ms   ({AverageRuntime * invMaxRuntimePercent:0.00}%)");
     sb.AppendLine($"Peak Runtime = {PeakRuntime:0.0000}ms\n");
     sb.AppendLine($"Avg Complexity = {AverageComplexity:0.00}   ({AverageComplexity * invMaxInstCountPercent:0.00}%)");
     sb.AppendLine($"Peak Complexity = {PeakComplexity:0.00}");
 }
 public void GetOutput(SRKStringBuilder builder)
 {
     for (int i = 0; i < LogLines.Length; ++i)
     {
         if (i == LogIndex)
         {
             builder.AppendLine("==== WRAP ====");
         }
         else
         {
             builder.AppendLine(LogLines[i]);
         }
     }
 }
Пример #3
0
        public void Main(string argument, UpdateType updateSource)
        {
            if (commandLine.TryParse(argument))
            {
                Action commandAction;

                string command = commandLine.Argument(0);
                if (command == null)
                {
                    Echo("No command specified");
                }
                else if (commands.TryGetValue(command, out commandAction))
                {
                    // We have found a command. Invoke it.
                    commandAction();
                }
                else
                {
                    echoBuilder.AppendLine($"Unknown command {command}");
                }
            }
            else
            {
                echoBuilder.Clear();
                echoBuilder.Append(setupBuilder.ToString());

                Action updateAction;
                if (updates.TryGetValue(currentState, out updateAction))
                {
                    updateAction();
                }

                doDisplay();
            }
        }
Пример #4
0
 public void PrintSectionBreakdown(SRKStringBuilder sb)
 {
     foreach (KeyValuePair <string, SectionValues> entry in AverageBreakdown)
     {
         double runtime = entry.Value.AccumulatedRuntime / entry.Value.AccumulatedCount;
         sb.AppendLine($"{entry.Key} = {runtime:0.0000}ms");
     }
 }
Пример #5
0
            public string GetStatus()
            {
                statusBuilder.Clear();

                statusBuilder.Append("CON: ");
                statusBuilder.Append(connector != null ? "AOK" : "LST");
                statusBuilder.Append(" | EXT: ");
                statusBuilder.Append(extender != null ? "AOK" : "LST");
                statusBuilder.Append(" | ROT: ");
                statusBuilder.Append(rotor != null ? "AOK" : "LST");
                statusBuilder.Append(" | GTS: ");
                statusBuilder.Append(gates.Count.ToString());

                statusBuilder.AppendLine();

                statusBuilder.AppendLine($"State: {state.ToString()}");

                statusBuilder.AppendLine($"Rotor: {rotor.Angle}");
                statusBuilder.AppendLine($"Target: {getWorldBoxTargetAngle()}");

                /*
                 * if (connector.Status == MyShipConnectorStatus.Connected)
                 * {
                 *  var dockedShipBoundingBox = connector.OtherConnector.CubeGrid.WorldAABB;
                 *  var dockedShipCenterDirection = dockedShipBoundingBox.Center - rotor.Top.WorldMatrix.Translation;
                 *  var myDir = Vector3D.TransformNormal(dockedShipCenterDirection, MatrixD.Transpose(rotor.Top.WorldMatrix));
                 *  myDir.Y = 0;
                 *  myDir.Normalize();
                 *  statusBuilder.AppendLine($"Debug: {myDir.X}");
                 *  statusBuilder.AppendLine($"Debug: {myDir.Z}");
                 *
                 *  statusBuilder.AppendLine();
                 *
                 *  var dirVector = new Vector3D(1, 0, 0);
                 *  var worldDirVector = Vector3D.TransformNormal(dirVector, connector.OtherConnector.WorldMatrix);
                 *  myDir = Vector3D.TransformNormal(worldDirVector, MatrixD.Transpose(rotor.Top.WorldMatrix));
                 *  statusBuilder.AppendLine($"Debug: {myDir.X}");
                 *  statusBuilder.AppendLine($"Debug: {myDir.Z}");
                 *  statusBuilder.AppendLine($"Target 2: {getWorldBoxTargetAngle()}");
                 * }*/

                return(statusBuilder.ToString());
            }
Пример #6
0
        public void Save()
        {
            mySerializeBuilder.Clear();
            mySerializeBuilder.AppendLine(displays.Count.ToString());

            for (int i = 0; i < displays.Count; i++)
            {
                mySerializeBuilder.AppendLine(displays[i].EntityId.ToString());
            }

            mySerializeBuilder.AppendLine(surfaceProviders.Count.ToString());

            for (int i = 0; i < surfaceProviders.Count; i++)
            {
                mySerializeBuilder.AppendLine($"{surfaceProviders[i].EntityId.ToString()} {surfaceIndices[i]}");
            }

            MySave(mySerializeBuilder);

            Me.GetSurface(1).WriteText(mySerializeBuilder.ToString());
        }
        public string SerializeManager()
        {
            SRKStringBuilder saveBuilder = new SRKStringBuilder();

            // Save my settings here

            // Save subsystem settings here
            saveBuilder.AppendLine(Subsystems.Count().ToString());
            foreach (KeyValuePair <string, ISubsystem> kvp in Subsystems)
            {
                string subsystemSave = kvp.Value.SerializeSubsystem();
                int    lns           = subsystemSave.Split(
                    new[] { "\r\n", "\r", "\n" },
                    StringSplitOptions.None
                    ).Count();

                saveBuilder.AppendLine($"{kvp.Key} {lns.ToString()}");
                saveBuilder.AppendLine(subsystemSave);
            }

            return(saveBuilder.ToString());
        }
Пример #8
0
 void ConnectDisplay(long id, int subId)
 {
     try
     {
         var block = GridTerminalSystem.GetBlockWithId(id);
         if (block is IMyTextPanel)
         {
             displays.Add((IMyTextPanel)block);
         }
         else
         {
             surfaceProviders.Add(block);
             surfaceIndices.Add(subId);
         }
     }
     catch (Exception e)
     {
         setupBuilder.AppendLine(e.ToString());
     }
 }
        public void DeserializeManager(string serialized)
        {
            try
            {
                var loadBuilder = new SRKStringBuilder();
                var reader      = new MyStringReader(serialized);

                loadBuilder.Clear();

                // Load subsystem settings here
                int numSubsystems = int.Parse(reader.NextLine());


                for (int i = 0; i < numSubsystems; i++)
                {
                    string[] header = reader.NextLine().Split(' ');
                    string   name   = header[0];

                    int numLines = int.Parse(header[1]);

                    for (int j = 0; j < numLines; j++)
                    {
                        loadBuilder.AppendLine(reader.NextLine());
                    }

                    if (Subsystems.ContainsKey(name))
                    {
                        Subsystems[name].DeserializeSubsystem(loadBuilder.ToString());
                    }

                    loadBuilder.Clear();
                }
            }
            catch (Exception exc)
            {
                ExceptionBuilder.AppendLine(exc.StackTrace);
            }
        }
        public string GetStatus()
        {
            StatusBuilder.Clear();
            StatusBuilder.AppendLine($"OUTPUT MODE: {(int)OutputMode}");
            if (OutputMode == OutputMode.Profile)
            {
                profiler.StartSectionWatch("Profiler");
                profiler.PrintPerformance(StatusBuilder);
                StatusBuilder.AppendLine("============");
                profiler.PrintSectionBreakdown(StatusBuilder);
                profiler.StopSectionWatch("Profiler");
            }
            else if (OutputMode == OutputMode.Debug)
            {
                StatusBuilder.AppendLine(ExceptionBuilder.ToString());

                StatusBuilder.AppendLine("=====");

                StatusBuilder.Append("Cycle ").AppendLine(Context.Frame.ToString());
                StatusBuilder.Append(Subsystems.Count.ToString()).AppendLine("systems connected");

                foreach (KeyValuePair <string, ISubsystem> kvp in Subsystems)
                {
                    StatusBuilder.AppendLine("[" + kvp.Key + "]");
                    StatusBuilder.AppendLine(kvp.Value.GetStatus());
                }

                Context.Log.GetOutput(DebugBuilder);
                StatusBuilder.AppendLine(DebugBuilder.ToString());
                DebugBuilder.Clear();
            }
            else
            {
                return(string.Empty);
            }

            return(StatusBuilder.ToString());
        }
Пример #11
0
        void MySave(SRKStringBuilder builder)
        {
            builder.AppendLine(currentState.ToString());

            builder.AppendLine(tag);
        }