コード例 #1
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 38, Configuration.FieldSeparator),
                       Id,
                       CycleStartTime.HasValue ? CycleStartTime.Value.ToString(Consts.TimeFormatPrecisionSecond, culture) : null,
                       CycleCount.HasValue ? CycleCount.Value.ToString(Consts.NumericFormat, culture) : null,
                       TempMax?.ToDelimitedString(),
                       TempMin?.ToDelimitedString(),
                       LoadNumber.HasValue ? LoadNumber.Value.ToString(Consts.NumericFormat, culture) : null,
                       ConditionTime?.ToDelimitedString(),
                       SterilizeTime?.ToDelimitedString(),
                       ExhaustTime?.ToDelimitedString(),
                       TotalCycleTime?.ToDelimitedString(),
                       DeviceStatus?.ToDelimitedString(),
                       CycleStartDateTime.HasValue ? CycleStartDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       DryTime?.ToDelimitedString(),
                       LeakRate?.ToDelimitedString(),
                       ControlTemperature?.ToDelimitedString(),
                       SterilizerTemperature?.ToDelimitedString(),
                       CycleCompleteTime.HasValue ? CycleCompleteTime.Value.ToString(Consts.TimeFormatPrecisionSecond, culture) : null,
                       UnderTemperature?.ToDelimitedString(),
                       OverTemperature?.ToDelimitedString(),
                       AbortCycle?.ToDelimitedString(),
                       Alarm?.ToDelimitedString(),
                       LongInChargePhase?.ToDelimitedString(),
                       LongInExhaustPhase?.ToDelimitedString(),
                       LongInFastExhaustPhase?.ToDelimitedString(),
                       Reset?.ToDelimitedString(),
                       OperatorUnload?.ToDelimitedString(),
                       DoorOpen?.ToDelimitedString(),
                       ReadingFailure?.ToDelimitedString(),
                       CycleType?.ToDelimitedString(),
                       ThermalRinseTime?.ToDelimitedString(),
                       WashTime?.ToDelimitedString(),
                       InjectionRate?.ToDelimitedString(),
                       ProcedureCode?.ToDelimitedString(),
                       PatientIdentifierList != null ? string.Join(Configuration.FieldRepeatSeparator, PatientIdentifierList.Select(x => x.ToDelimitedString())) : null,
                       AttendingDoctor?.ToDelimitedString(),
                       DilutionFactor?.ToDelimitedString(),
                       FillTime?.ToDelimitedString(),
                       InletTemperature?.ToDelimitedString()
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
コード例 #2
0
        public void StartSimulation(int sessionNumber, bool showOutput = true)
        {
            var sim       = new LanderSimulator();
            var sessionId = network.SessionStart();

            while (sim.Flying)
            {
                var inputs = new List <RlmIOWithValue>();
                inputs.Add(new RlmIOWithValue(network.Inputs.First(a => a.Name == "fuel"), sim.Fuel.ToString()));
                inputs.Add(new RlmIOWithValue(network.Inputs.First(a => a.Name == "altitude"), Math.Round(sim.Altitude, 2).ToString()));
                inputs.Add(new RlmIOWithValue(network.Inputs.First(a => a.Name == "velocity"), Math.Round(sim.Velocity, 2).ToString()));

                var cycle = new RlmCycle();
                watcher.Restart();
                var cycleOutcome = cycle.RunCycle(network, network.CurrentSessionID, inputs, Learn);
                watcher.Stop();
                TotalCycleTime.Add(watcher.ElapsedMilliseconds);

                bool thrust = Convert.ToBoolean(cycleOutcome.CycleOutput.Outputs.First(a => a.Name == "thrust").Value);
                if (thrust && showOutput && !Learn)
                {
                    Console.WriteLine("@THRUST");
                }

                var score = scoreTurn(sim, thrust);
                network.ScoreCycle(cycleOutcome.CycleOutput.CycleID, score);

                sim.Turn(thrust);

                if (showOutput && !Learn)
                {
                    Console.WriteLine(sim.Telemetry());
                }

                if (sim.Fuel == 0 && sim.Altitude > 0 && sim.Velocity == -LanderSimulator.TerminalVelocity)
                {
                    break;
                }
            }

            if (showOutput)
            {
                Console.WriteLine($"Session #{ sessionNumber } \t Score: {sim.Score}");
            }

            network.SessionEnd(lastScore = sim.Score);
        }