Ejemplo n.º 1
0
Archivo: Day19.cs Proyecto: sujithq/aoc
        public Day19(string input)
        {
            StepSize.Add(DirectionEnumType.Up, new Day22Point(-1, 0));
            StepSize.Add(DirectionEnumType.Down, new Day22Point(1, 0));
            StepSize.Add(DirectionEnumType.Left, new Day22Point(0, -1));
            StepSize.Add(DirectionEnumType.Right, new Day22Point(0, 1));

            var splitted = input.Split(new[] { Environment.NewLine }, StringSplitOptions.None).ToList();

            var maxLine = splitted.Max(m => m.Length);

            var d = Math.Max(maxLine, splitted.Count);

            for (var i = 0; i < splitted.Count; i++)
            {
                splitted[i] = splitted[i].PadRight(d);
            }

            if (splitted.Count < d)
            {
                var count = d - splitted.Count;
                for (var i = 0; i < count; i++)
                {
                    splitted.Add(string.Empty.PadRight(d));
                }
            }

            Grid = To2D(string.Join("", splitted).AsSpan(), d).ToList();

            Current = new Point(0, Grid[0].FindIndex(f => f == '|'));
            Pointer = Grid[Current.X][Current.Y];
            Steps   = 1;
        }
Ejemplo n.º 2
0
        public PageFile StepPrevious(StepSize step)
        {
            if (this.Previous == null)
            {
                return(null);
            }

            //if current is 'first page', first goto previous 'book'
            PageFile lpfFile = this.Previous;

            switch (step)
            {
            case StepSize.small:
                break;

            case StepSize.large:
                for (int i = 0; i < 9 && lpfFile.Previous != null && lpfFile.Series.Equals(this.Series) && lpfFile.SeriesNumberTag.Equals(this.SeriesNumberTag); i++)
                {
                    lpfFile = lpfFile.Previous;
                }
                break;

            case StepSize.seriesTag:
                lpfFile = lpfFile.Book.First;
                break;

            case StepSize.series:
                lpfFile = lpfFile.Book.Series.First.First;
                break;
            }

            return(lpfFile);
        }
Ejemplo n.º 3
0
    TickProfile(Arc sourceArc, int stepToTickRate, int tickRate)
    {
        Contract.Assert(tickRate > 0, @"Zero tick rate for {0}.", sourceArc);

        motor     = sourceArc.motor;
        size      = sourceArc.motor.stepSize;
        direction = sourceArc.direction;

        stepRate = tickRate;
        // Sync the start with the platform conversion rate.
        startTick = sourceArc.startStep * stepToTickRate;

        // Figure out how many steps we can actually take at our rate.
        int stepsAvailable = Mathf.FloorToInt((float)(sourceArc.length * stepToTickRate) / (float)tickRate);

        tickLength = stepsAvailable * tickRate;

        // If we were supposed to take a step in the arc,
        // try to take at least one step.
        if (sourceArc.length > 0)
        {
            tickLength = Mathf.Max(1, tickLength);
        }

        Contract.Assert(tickLength % tickRate == 0 || tickLength < tickRate,
                        @"Non-integral tick rate for {0} from {1}.",
                        this, sourceArc);
        Contract.Assert((sourceArc.length == 0 && tickLength == 0) ||
                        (tickLength > 0), @"Should take at least one tick step for {0} => {1}",
                        sourceArc, this);
    }
Ejemplo n.º 4
0
        public IStepRequest CreateStepRequest(IThreadReference thread, StepSize size, StepDepth depth)
        {
            Contract.Requires <VirtualMachineMismatchException>(thread == null || this.GetVirtualMachine().Equals(thread.GetVirtualMachine()));
            Contract.Ensures(Contract.Result <IStepRequest>() != null);
            Contract.Ensures(this.GetVirtualMachine().Equals(Contract.Result <IStepRequest>().GetVirtualMachine()));

            throw new NotImplementedException();
        }
Ejemplo n.º 5
0
 public MotorRateMover(MotorRateMover aMover, int aGlobalStart)
 {
     motor           = aMover.motor;
     direction       = aMover.direction;
     size            = aMover.size;
     stepRate        = aMover.stepRate;
     globalStartStep = aGlobalStart;
     stepCount       = aMover.stepCount;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public AlgorithmBase(StepSize stepSize)
        {
            steps         = InitializeSteps(stepSize);
            drugs         = new DrugFactory().CreateDrugs();
            stepTime      = TimeSpan.FromMinutes(2);
            this.stepSize = stepSize;

            // Select first step
            CurrentStep = steps[0];
        }
 public static EventRequestModifier Step(ThreadId thread, StepSize size, StepDepth depth)
 {
     return(new EventRequestModifier()
     {
         Kind = ModifierKind.Step,
         Thread = thread,
         StepSize = size,
         StepDepth = depth,
     });
 }
Ejemplo n.º 8
0
 public MotorRateMover(PrinterMotor aMotor, StepDirection aDirection,
                       StepSize aSize, int aRate, int aGlobalStepStart, int totalStepCount)
 {
     motor           = aMotor;
     direction       = aDirection;
     size            = aSize;
     stepRate        = aRate;
     globalStartStep = aGlobalStepStart;
     stepCount       = totalStepCount;
 }
Ejemplo n.º 9
0
        public IStepRequest CreateStepRequest(IThreadReference thread, StepSize size, StepDepth depth)
        {
            ThreadReference threadReference = thread as ThreadReference;

            if ((threadReference == null || !threadReference.VirtualMachine.Equals(this.VirtualMachine)) && thread != null)
            {
                throw new VirtualMachineMismatchException();
            }

            var request = new StepRequest(VirtualMachine, threadReference, size, depth);

            _stepRequests.Add(request);
            return(request);
        }
Ejemplo n.º 10
0
        public StepRequest(VirtualMachine virtualMachine, ThreadReference thread, StepSize size, StepDepth depth)
            : base(virtualMachine)
        {
            Contract.Requires(virtualMachine != null);

            _thread = thread;
            _size = size;
            _depth = depth;

            ThreadId threadId = default(ThreadId);
            if (thread != null)
                threadId = thread.ThreadId;

            Modifiers.Add(Types.EventRequestModifier.Step(threadId, (Types.StepSize)size, (Types.StepDepth)depth));
        }
        public IStepRequest GetStepRequest(StepSize size, StepDepth depth)
        {
            int kindIndex;

            switch (depth)
            {
            case StepDepth.Into:
                kindIndex = 0;
                break;

            case StepDepth.Out:
                kindIndex = 1;
                break;

            case StepDepth.Over:
                kindIndex = 2;
                break;

            default:
                throw new NotSupportedException();
            }

            int unitIndex;

            switch (size)
            {
            case StepSize.Instruction:
                unitIndex = 0;
                break;

            case StepSize.Line:
                unitIndex = 1;
                break;

            case StepSize.Statement:
                unitIndex = 2;
                break;

            default:
                throw new NotSupportedException();
            }

            IStepRequest request = _stepRequests[kindIndex * 3 + unitIndex];

            Contract.Assert(request.Size == size);
            Contract.Assert(request.Depth == depth);
            return(request);
        }
Ejemplo n.º 12
0
    public TickProfile(TickProfile source, int aStartTick)
    {
        motor     = source.motor;
        size      = source.size;
        direction = source.direction;
        stepRate  = source.stepRate;

        startTick  = aStartTick;
        tickLength = source.tickLength;

        // NOTE: Negative tick profiles are OK
        // when pressurizing, so we don't
        // check for negative start ticks.
        Contract.Assert(tickLength >= 0, @"Negative tick length.");
        Contract.Assert(motor != null, @"No motor assigned to tick profile.");
        Contract.Assert(direction != StepDirection.Unknown, @"Unknown step direction.");
    }
Ejemplo n.º 13
0
        public PageFile StepNext(StepSize step)
        {
            if (this.Next == null)
            {
                return(null);
            }

            PageFile lpfFile = this.PictureFile;

            switch (step)
            {
            case StepSize.small:
                lpfFile = lpfFile.Next;
                break;

            case StepSize.large:
                for (int i = 0; i < 10 && lpfFile.Next != null && lpfFile.Series.Equals(this.Series) && lpfFile.SeriesNumberTag.Equals(this.SeriesNumberTag); i++)
                {
                    lpfFile = lpfFile.Next;
                }
                break;

            case StepSize.seriesTag:
                if (lpfFile.Book.Next == null)
                {
                    return(null);
                }

                lpfFile = lpfFile.Book.Next.First;
                for (int i = 0; lpfFile.Next != null && lpfFile.Series.Equals(this.Series) && lpfFile.SeriesNumberTag.Equals(this.SeriesNumberTag); i++)
                {
                    lpfFile = lpfFile.Next;
                }
                break;

            case StepSize.series:
                for (int i = 0; lpfFile.Next != null && lpfFile.Series.Equals(this.Series); i++)
                {
                    lpfFile = lpfFile.Next;
                }
                break;
            }

            return(lpfFile);
        }
Ejemplo n.º 14
0
        public IStepRequest GetStepRequest(StepSize size, StepDepth depth)
        {
            int kindIndex;
            switch (depth)
            {
            case StepDepth.Into:
                kindIndex = 0;
                break;

            case StepDepth.Out:
                kindIndex = 1;
                break;

            case StepDepth.Over:
                kindIndex = 2;
                break;

            default:
                throw new NotSupportedException();
            }

            int unitIndex;
            switch (size)
            {
            case StepSize.Instruction:
                unitIndex = 0;
                break;

            case StepSize.Line:
                unitIndex = 1;
                break;

            case StepSize.Statement:
                unitIndex = 2;
                break;

            default:
                throw new NotSupportedException();
            }

            IStepRequest request = _stepRequests[kindIndex * 3 + unitIndex];
            Contract.Assert(request.Size == size);
            Contract.Assert(request.Depth == depth);
            return request;
        }
        public StepRequest(VirtualMachine virtualMachine, ThreadReference thread, StepSize size, StepDepth depth)
            : base(virtualMachine)
        {
            Contract.Requires(virtualMachine != null);

            _thread = thread;
            _size   = size;
            _depth  = depth;

            ThreadId threadId = default(ThreadId);

            if (thread != null)
            {
                threadId = thread.ThreadId;
            }

            Modifiers.Add(Types.EventRequestModifier.Step(threadId, (Types.StepSize)size, (Types.StepDepth)depth));
        }
Ejemplo n.º 16
0
 public override IEnumerable <StateVariable> GetState()
 {
     return(new[] {
         new StateVariable
         {
             Name = nameof(Key),
             Value = Key,
             Type = StateVariable.StateType.Input
         },
         new StateVariable
         {
             Name = nameof(StepSize),
             Value = StepSize.ToString(),
             Type = StateVariable.StateType.Input
         },
         new StateVariable
         {
             Name = nameof(CounterType),
             Value = CounterType,
             Type = StateVariable.StateType.Input
         },
         new StateVariable
         {
             Name = nameof(Result),
             Value = Result,
             Type = StateVariable.StateType.Output
         }
         ,
         new StateVariable
         {
             Name = nameof(Response),
             Value = Response,
             Type = StateVariable.StateType.Output
         },
         new StateVariable
         {
             Name = nameof(SourceId),
             Value = SourceId.ToString(),
             Type = StateVariable.StateType.Input
         }
     });
 }
Ejemplo n.º 17
0
    public TickProfile(PrinterMotor aMotor, StepSize aSize, StepDirection aDirection,
                       int aStepRate, int aStartTick, int aTickLength)
    {
        Contract.Assert(aMotor != null,
                        @"Tried to assign null motor to tick profile.");
        Contract.Assert(aDirection != StepDirection.Unknown,
                        @"Tried to assign unknown direction to tick profile.");
        Contract.Assert(aStepRate >= 0,
                        @"Negative step rate of {0}.", aStepRate);
        // NOTE: Negative tick profiles are OK
        // when pressurizing, so we don't
        // check for negative start ticks.

        motor     = aMotor;
        size      = aSize;
        direction = aDirection;
        stepRate  = aStepRate;

        startTick  = aStartTick;
        tickLength = aTickLength;
    }
Ejemplo n.º 18
0
        public IStepRequest CreateStepRequest(IThreadReference thread, StepSize size, StepDepth depth)
        {
            ThreadReference threadReference = thread as ThreadReference;
            if ((threadReference == null || !threadReference.VirtualMachine.Equals(this.VirtualMachine)) && thread != null)
                throw new VirtualMachineMismatchException();

            var request = new StepRequest(VirtualMachine, threadReference, size, depth);
            _stepRequests.Add(request);
            return request;
        }
Ejemplo n.º 19
0
 public static EventRequestModifier Step(ThreadId thread, StepSize size, StepDepth depth)
 {
     return new EventRequestModifier()
     {
         Kind = ModifierKind.Step,
         Thread = thread,
         StepSize = size,
         StepDepth = depth,
     };
 }
        public IStepRequest CreateStepRequest(IThreadReference thread, StepSize size, StepDepth depth)
        {
            Contract.Requires<VirtualMachineMismatchException>(thread == null || this.GetVirtualMachine().Equals(thread.GetVirtualMachine()));
            Contract.Ensures(Contract.Result<IStepRequest>() != null);
            Contract.Ensures(this.GetVirtualMachine().Equals(Contract.Result<IStepRequest>().GetVirtualMachine()));

            throw new NotImplementedException();
        }
Ejemplo n.º 21
0
 public void InitAlgorithmBase(StepSize size)
 {
     StepSize        = size;
     algoBase        = new AlgorithmBase(size);
     CurrentPosition = algoBase.CurrentStep;
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Exports events to PlantUML.
        /// </summary>
        /// <param name="Output">PlantUML output.</param>
        /// <param name="TimeUnit">Time unit to use.</param>
        /// <param name="GoalWidth">Goal width of diagram, in pixels.</param>
        public void ExportPlantUml(StringBuilder Output, TimeUnit TimeUnit, int GoalWidth)
        {
            switch (TimeUnit)
            {
            case TimeUnit.DynamicPerEvent:
            case TimeUnit.DynamicPerThread:
                throw new InvalidOperationException("Diagram requires the same time base to be used through-out.");
            }

            Output.AppendLine("@startuml");

            foreach (ProfilerThread Thread in this.threads)
            {
                if (Thread.Parent is null)
                {
                    Thread.ExportPlantUmlDescription(Output, TimeUnit);
                }
            }

            lock (this.eventOrdinals)
            {
                foreach (KeyValuePair <string, int> P in this.eventOrdinals)
                {
                    Output.Append("concise \"");
                    Output.Append(P.Key);
                    Output.Append("\" as E");
                    Output.AppendLine(P.Value.ToString());
                }
            }

            lock (this.exceptionOrdinals)
            {
                foreach (KeyValuePair <string, int> P in this.exceptionOrdinals)
                {
                    Output.Append("concise \"");
                    Output.Append(P.Key);
                    Output.Append("\" as X");
                    Output.AppendLine(P.Value.ToString());
                }
            }

            double TimeSpan;
            double StepSize;
            int    NrSteps;

            do
            {
                KeyValuePair <double, string> TotalTime = this.ToTime(this.mainThread.StoppedAt ?? this.ElapsedTicks, this.mainThread, TimeUnit);

                TimeSpan = TotalTime.Key;
                StepSize = Math.Pow(10, Math.Round(Math.Log10(TimeSpan / 10)));
                NrSteps  = (int)Math.Floor(TimeSpan / StepSize);

                if (NrSteps >= 50)
                {
                    StepSize *= 5;
                }
                else if (NrSteps >= 25)
                {
                    StepSize *= 2.5;
                }
                else if (NrSteps >= 20)
                {
                    StepSize *= 2;
                }
                else if (NrSteps <= 2)
                {
                    StepSize /= 5;
                }
                else if (NrSteps <= 4)
                {
                    StepSize /= 2.5;
                }
                else if (NrSteps <= 5)
                {
                    StepSize /= 2;
                }

                if (StepSize < 1)
                {
                    this.timeScale *= 1e-3;
                }
            }while (StepSize < 1);

            StepSize = Math.Floor(StepSize);
            NrSteps  = (int)Math.Floor(TimeSpan / StepSize);
            int PixelsPerStep = GoalWidth / NrSteps;

            Output.Append("scale ");
            Output.Append(StepSize.ToString("F0"));
            Output.Append(" as ");
            Output.Append(PixelsPerStep);
            Output.AppendLine(" pixels");

            PlantUmlStates States = new PlantUmlStates(TimeUnit);

            foreach (ProfilerThread Thread in this.threads)
            {
                if (Thread.Parent is null)
                {
                    Thread.ExportPlantUmlEvents(States);
                }
            }

            foreach (KeyValuePair <long, StringBuilder> P in States.ByTime)
            {
                KeyValuePair <double, string> Time = this.ToTime(P.Key, null, TimeUnit);
                Output.Append('@');
                Output.AppendLine(Time.Key.ToString("F3").Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."));
                Output.Append(P.Value.ToString());
            }

            Output.Append(States.Summary.ToString());
            Output.AppendLine("@enduml");
        }
            public StepEventFilter(EventKind internalEventKind, RequestId requestId, SuspendPolicy suspendPolicy, IEnumerable<EventRequestModifier> modifiers, ThreadId thread, JvmtiEnvironment environment, JniEnvironment nativeEnvironment, StepSize size, StepDepth depth)
                : base(internalEventKind, requestId, suspendPolicy, modifiers, thread)
            {
                if (size == StepSize.Statement && JavaVM.DisableStatementStepping)
                    size = StepSize.Line;

                _size = size;
                _depth = depth;

                // gather reference information for the thread
                using (var threadHandle = environment.VirtualMachine.GetLocalReferenceForThread(nativeEnvironment, thread))
                {
                    if (threadHandle.IsAlive)
                    {
                        jvmtiError error = environment.GetFrameLocation(threadHandle.Value, 0, out _lastMethod, out _lastLocation);
                        if (error == jvmtiError.None)
                            error = environment.GetFrameCount(threadHandle.Value, out _stackDepth);

                        if (error == jvmtiError.None)
                            _hasMethodInfo = true;

                        UpdateLastLine(environment);

                        if (error == jvmtiError.None && size == StepSize.Statement && (depth == StepDepth.Over || depth == StepDepth.Into))
                        {
                            byte[] bytecode;
                            JvmtiErrorHandler.ThrowOnFailure(environment.GetBytecodes(_lastMethod, out bytecode));
                            _disassembledMethod = BytecodeDisassembler.Disassemble(bytecode);

                            TaggedReferenceTypeId declaringClass;
                            JvmtiErrorHandler.ThrowOnFailure(environment.GetMethodDeclaringClass(nativeEnvironment, _lastMethod, out declaringClass));
                            using (var classHandle = environment.VirtualMachine.GetLocalReferenceForClass(nativeEnvironment, declaringClass.TypeId))
                            {
                                int constantPoolCount;
                                byte[] data;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetConstantPool(classHandle.Value, out constantPoolCount, out data));

                                List<ConstantPoolEntry> entryList = new List<ConstantPoolEntry>();
                                int currentPosition = 0;
                                for (int i = 0; i < constantPoolCount - 1; i++)
                                {
                                    entryList.Add(ConstantPoolEntry.FromBytes(data, ref currentPosition));
                                    switch (entryList.Last().Type)
                                    {
                                    case ConstantType.Double:
                                    case ConstantType.Long:
                                        // these entries take 2 slots
                                        entryList.Add(ConstantPoolEntry.Reserved);
                                        i++;
                                        break;

                                    default:
                                        break;
                                    }
                                }

                                _constantPool = entryList.AsReadOnly();

                                string classSignature;
                                string classGenericSignature;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetClassSignature(classHandle.Value, out classSignature, out classGenericSignature));
                                string methodName;
                                string methodSignature;
                                string methodGenericSignature;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetMethodName(_lastMethod, out methodName, out methodSignature, out methodGenericSignature));

                                jobject classLoader;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetClassLoader(classHandle.Value, out classLoader));
                                long classLoaderTag;
                                JvmtiErrorHandler.ThrowOnFailure(environment.TagClassLoader(classLoader, out classLoaderTag));

                                ReadOnlyCollection<ExceptionTableEntry> exceptionTable;
                                JvmtiErrorHandler.ThrowOnFailure(environment.VirtualMachine.GetExceptionTable(classLoaderTag, classSignature, methodName, methodSignature, out exceptionTable));

                                _evaluationStackDepths = BytecodeDisassembler.GetEvaluationStackDepths(_disassembledMethod, _constantPool, exceptionTable);
                            }
                        }
                    }
                }
            }
            public StepEventFilter(EventKind internalEventKind, RequestId requestId, SuspendPolicy suspendPolicy, IEnumerable <EventRequestModifier> modifiers, ThreadId thread, JvmtiEnvironment environment, JniEnvironment nativeEnvironment, StepSize size, StepDepth depth)
                : base(internalEventKind, requestId, suspendPolicy, modifiers, thread)
            {
                if (size == StepSize.Statement && JavaVM.DisableStatementStepping)
                {
                    size = StepSize.Line;
                }

                _size  = size;
                _depth = depth;

                // gather reference information for the thread
                using (var threadHandle = environment.VirtualMachine.GetLocalReferenceForThread(nativeEnvironment, thread))
                {
                    if (threadHandle.IsAlive)
                    {
                        jvmtiError error = environment.GetFrameLocation(threadHandle.Value, 0, out _lastMethod, out _lastLocation);
                        if (error == jvmtiError.None)
                        {
                            error = environment.GetFrameCount(threadHandle.Value, out _stackDepth);
                        }

                        if (error == jvmtiError.None)
                        {
                            _hasMethodInfo = true;
                        }

                        UpdateLastLine(environment);

                        if (error == jvmtiError.None && size == StepSize.Statement && (depth == StepDepth.Over || depth == StepDepth.Into))
                        {
                            byte[] bytecode;
                            JvmtiErrorHandler.ThrowOnFailure(environment.GetBytecodes(_lastMethod, out bytecode));
                            _disassembledMethod = BytecodeDisassembler.Disassemble(bytecode);

                            TaggedReferenceTypeId declaringClass;
                            JvmtiErrorHandler.ThrowOnFailure(environment.GetMethodDeclaringClass(nativeEnvironment, _lastMethod, out declaringClass));
                            using (var classHandle = environment.VirtualMachine.GetLocalReferenceForClass(nativeEnvironment, declaringClass.TypeId))
                            {
                                int    constantPoolCount;
                                byte[] data;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetConstantPool(classHandle.Value, out constantPoolCount, out data));

                                List <ConstantPoolEntry> entryList = new List <ConstantPoolEntry>();
                                int currentPosition = 0;
                                for (int i = 0; i < constantPoolCount - 1; i++)
                                {
                                    entryList.Add(ConstantPoolEntry.FromBytes(data, ref currentPosition));
                                    switch (entryList.Last().Type)
                                    {
                                    case ConstantType.Double:
                                    case ConstantType.Long:
                                        // these entries take 2 slots
                                        entryList.Add(ConstantPoolEntry.Reserved);
                                        i++;
                                        break;

                                    default:
                                        break;
                                    }
                                }

                                _constantPool = entryList.AsReadOnly();

                                string classSignature;
                                string classGenericSignature;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetClassSignature(classHandle.Value, out classSignature, out classGenericSignature));
                                string methodName;
                                string methodSignature;
                                string methodGenericSignature;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetMethodName(_lastMethod, out methodName, out methodSignature, out methodGenericSignature));

                                jobject classLoader;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetClassLoader(classHandle.Value, out classLoader));
                                long classLoaderTag;
                                JvmtiErrorHandler.ThrowOnFailure(environment.TagClassLoader(classLoader, out classLoaderTag));

                                ReadOnlyCollection <ExceptionTableEntry> exceptionTable;
                                JvmtiErrorHandler.ThrowOnFailure(environment.VirtualMachine.GetExceptionTable(classLoaderTag, classSignature, methodName, methodSignature, out exceptionTable));

                                _evaluationStackDepths = BytecodeDisassembler.GetEvaluationStackDepths(_disassembledMethod, _constantPool, exceptionTable);
                            }
                        }
                    }
                }
            }
 public void Move(Dictionary <Axis, int> _newaxis, StepSize step, string M, string B)
 {
     System.Windows.Forms.MessageBox.Show("B= " + B + Environment.NewLine + "M= " + M + Environment.NewLine + "StepSizr= " + step + Environment.NewLine + "Axis.x= " + _newaxis[BL.Axis.X] + Environment.NewLine + "Axis.y= " + _newaxis[BL.Axis.Y] + Environment.NewLine);
 }
Ejemplo n.º 26
0
        private void buttonLK2ASC_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter           = "LK8000 DEM files (*.dem)|*.dem";
            openFileDialog1.FilterIndex      = 2;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                String fileName       = openFileDialog1.FileName;
                String outFileAscName = Path.ChangeExtension(fileName, ".asc");

                double Left;
                double Right;
                double Top;
                double Bottom;
                double StepSize;
                uint   Rows;
                uint   Columns;

                if (File.Exists(fileName))
                {
                    using (BinaryReader reader = new BinaryReader(File.Open(fileName, FileMode.Open)))
                    {
                        Left     = reader.ReadDouble();
                        Right    = reader.ReadDouble();
                        Top      = reader.ReadDouble();
                        Bottom   = reader.ReadDouble();
                        StepSize = reader.ReadDouble();
                        Rows     = reader.ReadUInt32();
                        Columns  = reader.ReadUInt32();

                        //uint nsize = Rows * Columns;

                        var          utf8WithoutBom = new System.Text.UTF8Encoding(false);
                        FileStream   ostream        = new FileStream(outFileAscName, FileMode.Create, FileAccess.ReadWrite);
                        StreamWriter writer         = new StreamWriter(ostream, utf8WithoutBom);


                        writer.WriteLine("ncols         " + Columns.ToString());
                        writer.WriteLine("nrows         " + Rows.ToString());
                        writer.WriteLine("xllcorner     " + Left.ToString());
                        writer.WriteLine("yllcorner     " + Bottom.ToString());
                        writer.WriteLine("cellsize      " + StepSize.ToString());

                        writer.WriteLine("NODATA_value  0");
                        writer.Flush();


                        for (int r = 0; r < Rows; r++)
                        {
                            String line = "";
                            short  val;
                            for (int c = 0; c < Columns; c++)
                            {
                                val   = reader.ReadInt16();
                                line += val.ToString() + " ";
                            }
                            writer.WriteLine(line);
                        }

                        writer.Flush();
                        ostream.Close();

                        MessageBox.Show("Done");
                    }
                }
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Consturct and Initialize algorithm steps.
        /// </summary>
        public List <AlgorithmStep> InitializeSteps(StepSize stepSize)
        {
            if (steps != null)
            {
                throw new Exception("AlgorithmBase - InitiliazeSteps() : Steps already initialized.");
            }

            List <AlgorithmStep> result = new List <AlgorithmStep>();

            // Initial Step
            step1 = new AssessmentStep("Vurder Rytmen", "Vurder patientens rytme");

            // Exit Step
            exit1 = new AlgorithmStep("Circulation restored", "Continue with further resuscitation");

            switch (stepSize)
            {
            case StepSize.Small:
                // Shockable Steps
                smallShock1            = new AlgorithmStep("Stød en gang", "Minimer afbrydelser");
                smallShock1.RythmStyle = RythmStyle.Shockable;
                smallShock2            = new AlgorithmStep("HLR 2 Minutter", "Fortsæt HLR for den resterende tid");
                smallShock2.RythmStyle = RythmStyle.Shockable;

                // Non-Shockable Steps
                smallNShock1            = new AlgorithmStep("Giv 1mg Adrenalin", "Med det samme");
                smallNShock1.RythmStyle = RythmStyle.NonShockable;
                smallNShock2            = new AlgorithmStep("HLR 2 Minutter", "Fortsæt HLR for den resterende tid");
                smallNShock2.RythmStyle = RythmStyle.Shockable;

                // Setup Step Relations
                step1.PreviousStep     = null;
                step1.CircRestoredStep = exit1;

                smallShock1.PreviousStep = step1;
                smallShock1.NextStep     = smallShock2;
                smallShock2.PreviousStep = smallShock1;
                smallShock2.NextStep     = step1;

                smallNShock1.PreviousStep = step1;
                smallNShock1.NextStep     = smallNShock2;
                smallNShock2.PreviousStep = smallNShock1;
                smallNShock2.NextStep     = step1;

                exit1.PreviousStep = step1;

                // Add everything to the list
                result.Add(step1);
                result.Add(smallShock1);
                result.Add(smallShock2);
                result.Add(smallNShock1);
                result.Add(smallNShock2);
                result.Add(exit1);
                break;

            case StepSize.Big:
                // Shockable Steps
                smallShock1            = new AlgorithmStep("Stød en gang", "Fortsæt HLR");
                smallShock1.RythmStyle = RythmStyle.Shockable;

                // Non-Shockable Steps
                smallNShock1            = new AlgorithmStep("Giv 1mg Adrenalin", "Fortsæt HLR");
                smallNShock1.RythmStyle = RythmStyle.NonShockable;
                smallNShock2            = new AlgorithmStep("Fortsæt HLR ", "");
                smallNShock2.RythmStyle = RythmStyle.NonShockable;

                // Setup Step Relations
                step1.PreviousStep     = null;
                step1.CircRestoredStep = exit1;

                smallShock1.PreviousStep = step1;
                smallShock1.NextStep     = step1;

                smallNShock1.PreviousStep = step1;
                smallNShock1.NextStep     = step1;
                smallNShock2.PreviousStep = step1;
                smallNShock2.NextStep     = step1;

                exit1.PreviousStep = step1;

                // Add everything to the list
                result.Add(step1);
                result.Add(smallShock1);
                result.Add(smallNShock1);
                result.Add(smallNShock2);
                result.Add(exit1);
                break;
            }



            return(result);
        }
Ejemplo n.º 28
0
		void Step (StepDepth depth, StepSize size)
		{
			ThreadPool.QueueUserWorkItem (delegate {
				try {
					Adaptor.CancelAsyncOperations (); // This call can block, so it has to run in background thread to avoid keeping the main session lock
					var req = vm.CreateStepRequest (current_thread);
					req.Depth = depth;
					req.Size = size;
					if (assemblyFilters != null && assemblyFilters.Count > 0)
						req.AssemblyFilter = assemblyFilters;
					req.Enabled = true;
					currentStepRequest = req;
					OnResumed ();
					vm.Resume ();
					DequeueEventsForFirstThread ();
				} catch (Exception ex) {
					LoggingService.LogError ("Next Line command failed", ex);
				}
			});
		}
Ejemplo n.º 29
0
 public int GanglionStepSizeFor(StepSize aSize)
 {
     return(kStepConversion[aSize]);
 }