//private byte[] nextPacket = null;

        /// <summary>
        /// Create reader object
        /// </summary>
        /// <param name="type">Type of the sensor</param>
        /// <param name="returnMode">Define return type for VLP-16, this variable is neglected for HDL-32E</param>
        /// <param name="indexFile">Index file path</param>
        /// <param name="pointFile">Point file path</param>
        private VelodyneReader(VelodyneSensorType type, ReturnMode returnMode, String indexFile, String pointFile)
        {
            this.IndexFile = indexFile;
            this.PointFile = pointFile;
            this.Sensor    = type;
            Indeces        = new List <IndexData>();

            if (!File.Exists(indexFile))
            {
                throw new FileNotFoundException("Index file does not exist!");
            }

            if (!File.Exists(pointFile))
            {
                throw new FileNotFoundException("Point file does not exist!");
            }

            if (type == VelodyneSensorType.HDL32E)
            {
                PacketInterpreter = new PacketInterpreterHDL32E();
            }
            else if (type == VelodyneSensorType.VLP16)
            {
                PacketInterpreter = new PacketInterpreterVLP16(returnMode);
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Exemple #2
0
        public void Return(ReturnMode mode)
        {
            CommandResult result;

            lock (this) {
                check_alive();
                result = servant.Return(mode);
                if (result == null)
                {
                    return;
                }
            }

            result.Wait();
        }
        /// <summary>
        /// Open Velodyne reader object
        /// </summary>
        /// <param name="type">Type of the sensor</param>
        /// <param name="returnMode">Define return type for VLP-16, this variable is neglected for HDL-32E</param>
        /// <param name="indexFile">Index file path</param>
        /// <param name="pointFile">Point file path</param>
        /// <returns></returns>
        public static VelodyneReader Open(VelodyneSensorType type, ReturnMode returnMode, String indexFile, String pointFile)
        {
            VelodyneReader obj      = new VelodyneReader(type, returnMode, indexFile, pointFile);
            FileInfo       fi       = new FileInfo(indexFile);
            long           fileSize = fi.Length;

            obj.Indeces.Clear();

            byte[]       idxData = File.ReadAllBytes(obj.IndexFile);
            MemoryStream mem     = new MemoryStream(idxData);
            long         idx     = 0;

            using (BinaryReader reader = new BinaryReader(mem))
            {
                while (reader.BaseStream.Position != reader.BaseStream.Length)
                {
                    long     internalTimeTicks    = reader.ReadInt64();
                    DateTime internalTime         = new DateTime(internalTimeTicks);
                    long     packetTimeStampTicks = reader.ReadInt64();
                    DateTime packetTimeStamp      = new DateTime(packetTimeStampTicks);

                    long position = reader.ReadInt64();

                    byte[] nmeBytes = reader.ReadBytes(IndexData.NMEA_LENGTH);
                    String nmea     = Encoding.ASCII.GetString(nmeBytes);

                    obj.Indeces.Add(new IndexData(packetTimeStamp, internalTime, position, nmea));
                    idx++;

                    if (idx % 500 == 0)
                    {
                        ProgressReportEventArgs args = new ProgressReportEventArgs((((double)reader.BaseStream.Position / (double)fileSize) * 100.0), reader.BaseStream.Position, packetTimeStamp.ToUniversalTime());
                        OnReportProgress(args);
                    }
                }
            }

            obj.pointReader = new BinaryReader(File.Open(obj.PointFile, FileMode.Open));

            return(obj);
        }
Exemple #4
0
 public override CommandResult Return(ReturnMode mode)
 {
     throw new InvalidOperationException();
 }
Exemple #5
0
        protected override bool DoResolve(ScriptingContext context)
        {
            if (context.Interpreter.IsInteractive && !unconfirmed) {
                if (context.Interpreter.Query ("Make the current stack frame return?")) {
                    return true;
                } else {
                    Console.WriteLine ("Not confirmed.");
                    return false;
                }
            }

            if (Native && Invocation)
                throw new ScriptingException ("Cannot use both -native and -invocation");

            if (Native)
                mode = ReturnMode.Native;
            else if (Invocation)
                mode = ReturnMode.Invocation;
            else
                mode = ReturnMode.Managed;

            return true;
        }
Exemple #6
0
 public PacketInterpreterVLP16(ReturnMode returnMode)
 {
     ReturnMode = returnMode;
 }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="returnMode">The return mode.</param>
 internal ObjectDisposer(T item, ReturnMode returnMode)
 {
     this.item       = item;
     this.returnMode = returnMode;
 }
Exemple #8
0
 public abstract CommandResult Return(ReturnMode mode);
Exemple #9
0
        public void Return(ReturnMode mode)
        {
            CommandResult result;

            lock (this) {
                check_alive ();
                result = servant.Return (mode);
                if (result == null)
                    return;
            }

            result.Wait ();
        }
        public override CommandResult Return(ReturnMode mode)
        {
            return (CommandResult) SendCommand (delegate {
                if (!engine_stopped) {
                    Report.Debug (DebugFlags.Wait,
                              "{0} not stopped", this);
                    throw new TargetException (TargetError.NotStopped);
                }

                if (current_frame == null)
                    throw new TargetException (TargetError.NoStack);

                process.UpdateSymbolTable (inferior);

                if (!process.IsManagedApplication) {
                    if (mode == ReturnMode.Managed)
                        mode = ReturnMode.Native;
                    else if (mode == ReturnMode.Invocation)
                        throw new TargetException (TargetError.InvalidReturn, "Not a managed application.");
                }

                CommandResult result = new ThreadCommandResult (thread);

                Backtrace bt = new Backtrace (current_frame);

                if (mode == ReturnMode.Invocation) {
                    var cframe = inferior.GetCallbackFrame (current_frame.StackPointer, false);
                    if (cframe == null)
                        throw new TargetException (TargetError.NoInvocation);

                    if (MonoDebuggerInfo.HasAbortRuntimeInvoke) {
                        OperationRuntimeInvoke rti = rti_stack.Peek ();
                        if (rti.ID != cframe.ID)
                            throw new TargetException (TargetError.NoInvocation);

                        return StartOperation (new OperationAbortRuntimeInvoke (this, result));
                    }

                    bt.GetBacktrace (this, inferior, Backtrace.Mode.Native, cframe.StackPointer, -1);
                    for (int i = 0; i < bt.Count; i++) {
                        if ((bt.Frames [i].Type == FrameType.Normal) && bt.Frames [i].IsManaged)
                            continue;
                        else if ((bt.Frames [i].Type == FrameType.RuntimeInvoke) && (i + 1 == bt.Count))
                            break;
                        throw new TargetException (TargetError.InvalidReturn,
                                       "Cannot abort an invocation which contains non-managed frames.");
                    }
                } else {
                    bt.GetBacktrace (this, inferior, Backtrace.Mode.Native,
                             TargetAddress.Null, 2);
                }

                if (bt.Count < 2)
                    throw new TargetException (TargetError.NoStack);

                StackFrame parent_frame = bt.Frames [1];
                if (parent_frame == null)
                    return null;

                Report.Debug (DebugFlags.SSE, "{0} return: {1} {2} {3}", this, mode, current_frame.Type,
                          parent_frame.Type);

                if (mode == ReturnMode.Native) {
                    if ((current_frame.Type == FrameType.Signal) || (parent_frame.Type == FrameType.Signal) ||
                        (current_frame.Type == FrameType.Callback) || (parent_frame.Type == FrameType.Callback))
                        throw new TargetException (TargetError.InvalidReturn,
                                       "Cannot return from a signal handler or mdb-internal callback.");
                    if ((current_frame.Type != FrameType.Normal) || (parent_frame.Type != FrameType.Normal))
                        throw new TargetException (TargetError.InvalidReturn);
                } else if (mode == ReturnMode.Managed) {
                    bool ok = true;
                    if (current_frame.Type == FrameType.Normal) {
                        if (!current_frame.IsManaged)
                            ok = false;
                    } else {
                        if (current_frame.Type == FrameType.RuntimeInvoke)
                            throw new TargetException (TargetError.InvalidReturn,
                                           "Cannot return from an invocation.");
                        ok = false;
                    }

                    if (parent_frame.Type == FrameType.Normal) {
                        if (!parent_frame.IsManaged)
                            ok = false;
                    } else {
                        if (parent_frame.Type == FrameType.RuntimeInvoke)
                            throw new TargetException (TargetError.InvalidReturn,
                                           "Cannot return from an invocation.");
                        ok = false;
                    }

                    if (!ok)
                        throw new TargetException (TargetError.InvalidReturn,
                                       "Cannot return from a non-managed frame.");
                }

                if (mode == ReturnMode.Native) {
                    inferior.SetRegisters (parent_frame.Registers);
                    frame_changed (inferior.CurrentFrame, null);
                    TargetEventArgs args = new TargetEventArgs (
                        TargetEventType.TargetStopped, 0, current_frame);
                    process.Debugger.OnTargetEvent (thread, args);
                    return null;
                }

                return StartOperation (new OperationReturn (this, bt, mode, result));
            });
        }
 public OperationReturn(SingleSteppingEngine sse, Backtrace bt, ReturnMode mode, CommandResult result)
     : base(sse, result)
 {
     this.Backtrace = bt;
     this.Mode = mode;
 }
Exemple #12
0
 internal void _EmitAssignReturnMode(ReturnMode returnMode)
 {
     EmitLoadArg(ParamReturnModeIndex);
     EmitLdcI4((int) returnMode);
     Il.Emit(OpCodes.Stind_I4);
 }
Exemple #13
0
 private void _testReturnMode(string id, ReturnMode mode, PValue retVal)
 {
     var fctx = target.Functions[id].CreateFunctionContext(engine);
     engine.Process(fctx);
     Assert.AreEqual(fctx.ReturnMode, mode,
         "Return mode for function " + id + " does not match.");
     Assert.IsTrue((bool) retVal.Equality(fctx, fctx.ReturnValue).Value,
         "Return value for function " + id + " does not match.");
 }
Exemple #14
0
 public override CommandResult Return(ReturnMode mode)
 {
     throw new InvalidOperationException ();
 }
Exemple #15
0
 public abstract CommandResult Return(ReturnMode mode);