Exemplo n.º 1
0
        public void Main(string arg, UpdateType updateType)
        {
            // The update type is binary. Must look it up on Malware's wikia to figure out how to manipulate it.
            if ((updateType & FrequencyByUpdateType[FREQUENCY]) == 0)
            {
                return;
            }

            terminalManager.Run();
            programmableBlock.Draw();
        }
Exemplo n.º 2
0
        /// <summary>
        /// The Main.
        /// </summary>
        /// <param name="arg">The arg<see cref="string"/>.</param>
        /// <param name="updateType">The updateType<see cref="UpdateType"/>.</param>
        public void Main(string arg, UpdateType updateType)
        {
            if (updateType == UpdateType.IGC)
            {
                Echo(echoOutput.ToString()); // ensure that output is not lost
                return;
            }

            if (USE_REAL_TIME)
            {
                DateTime n = DateTime.Now;
                if (n - currentCycleStartTime >= cycleUpdateWaitTime)
                {
                    currentCycleStartTime = n;
                }
                else
                {
                    Echo(echoOutput.ToString()); // ensure that output is not lost
                    return;
                }
            }
            else
            {
                currentCycleStartTime = DateTime.Now;
            }

            echoOutput.Clear();

            // output terminal info
            EchoR(string.Format(scriptUpdateText, ++totalCallCount, currentCycleStartTime.ToString("h:mm:ss tt")));

            if (processStep == processSteps.Length)
            {
                processStep = 0;
            }
            int  processStepTmp       = processStep;
            bool didAtLeastOneProcess = false;

            try
            {
                processSteps[processStep]();
                processStep++;
                didAtLeastOneProcess = true;
            }
            catch (PutOffExecutionException) { }
            catch (Exception ex)
            {
                // if the process step threw an exception, make sure we print the info
                // we need to debug it
                string err = "An error occured,\n" +
                             "please give the following information to the developer:\n" +
                             string.Format("Current step on error: {0}\n{1}", processStep, ex.ToString().Replace("\r", ""));
                EchoR(err);
                throw ex;
            }

            if (!terminalCycle.MoveNext())
            {
                terminalCycle.Dispose();
            }

            //EchoR(string.Format("Instructions: {0}", Runtime.CurrentInstructionCount + "/" + Runtime.MaxInstructionCount));
            //EchoR(string.Format("Call chain: {0}", Runtime.CurrentCallChainDepth + "/" + Runtime.MaxCallChainDepth));
            //EchoR(string.Format("Execution time: {0}", Runtime.LastRunTimeMs.ToString("F2") + " ms"));

            //if (shipController.Main == null)
            //{
            //    EchoR("Status\n- Controller does not exist.");
            //}

            string stepText;
            int    theoryProcessStep = processStep == 0 ? processSteps.Count() : processStep;
            int    exTime            = ExecutionTime;
            double exLoad            = Math.Round(100.0f * ExecutionLoad, 1);

            if (processStep == 0 && processStepTmp == 0 && didAtLeastOneProcess)
            {
                stepText = "all steps";
            }
            else if (processStep == processStepTmp)
            {
                stepText = string.Format("step {0} partially", processStep);
            }
            else if (theoryProcessStep - processStepTmp == 1)
            {
                stepText = string.Format("step {0}", processStepTmp);
            }
            else
            {
                stepText = string.Format("steps {0} to {1}", processStepTmp, theoryProcessStep - 1);
            }
            EchoR(string.Format("Completed {0} in {1}ms\n{2}% load ({3} instructions)",
                                stepText, exTime, exLoad, Runtime.CurrentInstructionCount));

            programmableBlock.Draw();
        }