示例#1
0
 /// <summary>
 /// Given an address, attempts to make sure that it points to a valid
 /// position in the address space or to the EOF
 /// </summary>
 /// <param name="position"></param>
 /// <returns></returns>
 private ModelPosition SanitizePosition(ModelPosition position)
 {
     if (program.ImageMap.TryFindItem(position.Address, out var item))
     {
         if (item.IsInRange(position.Address))
         {
             // Safely inside an item.
             return(position);
         }
         // If we're positioned at the end of the item
         // advance to the start of the next item if possible.
         int iItem = program.ImageMap.Items.Keys.IndexOf(item.Address) + 1;
         if (iItem >= program.ImageMap.Items.Count)
         {
             return(this.endPos);
         }
         return(Pos(program.ImageMap.Items.Keys[iItem]));
     }
     // We're outside the range of all items, so peg the position
     // at either the beginning or the end.
     if (position.Address < program.ImageMap.BaseAddress)
     {
         return(Pos(program.ImageMap.BaseAddress));
     }
     return(endPos);
 }
示例#2
0
        public MixedCodeDataModel(Program program)
        {
            this.program = program;
            var firstSeg = program.SegmentMap.Segments.Values.FirstOrDefault();

            if (firstSeg == null)
            {
                this.curPos        = Pos(program.ImageMap.BaseAddress);
                this.StartPosition = Pos(program.ImageMap.BaseAddress);
                this.endPos        = Pos(program.ImageMap.BaseAddress);
                this.LineCount     = 0;
            }
            else
            {
                var lastSeg = program.SegmentMap.Segments.Values.Last();
                this.curPos        = Pos(firstSeg.Address);
                this.StartPosition = Pos(firstSeg.Address);
                this.endPos        = Pos(lastSeg.EndAddress);
                this.CollectInstructions();
                this.LineCount = CountLines();
            }
            this.comments = program.User.Annotations.ToSortedList(
                a => a.Address,
                a => Lines(a.Text));
        }
示例#3
0
 public MixedCodeDataModel(MixedCodeDataModel that)
 {
     this.program      = that.program;
     this.curPos       = that.curPos;
     this.endPos       = that.endPos;
     this.instructions = that.instructions;
     this.LineCount    = that.LineCount;
 }
示例#4
0
        public void SetPositionAsFraction(int numer, int denom)
        {
            if (denom <= 0)
            {
                throw new ArgumentOutOfRangeException("denom", "Denominator must be larger than 0.");
            }
#if SIMPLE
            // This is PTomin's simpler implementation of SetPositionAsFraction
            // Notice that just like the original implementation, it is O(n) where
            // n is the number of items in the image map. Consider measuring
            // performance on really large image maps (1,000,000 items or more)
            // to see if the brittle code in the #else branch makes any difference
            // and if not, keep the SIMPLE implementation.

            long total = LineCount;
            long iPos  = (numer * total) / denom;

            MoveToLine(StartPosition, (int)iPos);
#else
            if (numer <= 0)
            {
                curPos = (ModelPosition)StartPosition;
                return;
            }
            else if (numer >= denom)
            {
                curPos = (ModelPosition)EndPosition;
                return;
            }

            var targetLine = (int)(((long)numer * LineCount) / denom);
            int curLine    = 0;
            foreach (var item in program.ImageMap.Items.Values)
            {
                int size;
                if (item is ImageMapBlock bi)
                {
                    size = CountDisassembledLines(bi);
                    if (curLine + size > targetLine)
                    {
                        this.curPos = Pos(instructions[bi][targetLine - curLine].Address);
                        return;
                    }
                }
                else
                {
                    size = CountMemoryLines(item);
                    if (curLine + size > targetLine)
                    {
                        this.curPos = Pos(GetAddressOfLine(item, targetLine - curLine));
                        return;
                    }
                }
                curLine += size;
            }
            curPos = (ModelPosition)EndPosition;
#endif
        }
示例#5
0
 public MemSpanifyer(
     Program program,
     ImageMapItem item,
     ModelPosition pos)
 {
     this.program  = program;
     this.item     = item;
     this.position = pos;
 }
        private SpanGenerator CreateSpanifier(
            ImageMapItem item,
            ModelPosition pos)
        {
            SpanGenerator sp;

            if (item is ImageMapBlock b && b.Block.Procedure != null)
            {
                sp = new AsmSpanifyer(program, b.Block.Procedure.Architecture, instructions[b], pos);
            }
示例#7
0
 public MixedCodeDataModel(MixedCodeDataModel that)
 {
     this.program       = that.program;
     this.imageMap      = that.imageMap;
     this.curPos        = that.curPos;
     this.StartPosition = that.StartPosition;
     this.endPos        = that.endPos;
     this.instructions  = that.instructions;
     this.LineCount     = that.LineCount;
     this.comments      = that.comments;
 }
示例#8
0
        private void InitSetData()
        {
            try
            {
                modelPosition = new ModelPosition();

                initPosition      = perspectiveCamera.Position;
                initLookDirection = perspectiveCamera.LookDirection;
                initUpDirection   = perspectiveCamera.UpDirection;
                initFieldofView   = perspectiveCamera.FieldOfView;
                modelPosition.OriCameraPosition = initPosition;
                modelPosition.LookDirection     = initLookDirection;

                StackerPartsInfo zaihuotai001 = new StackerPartsInfo("zaihuotai001");
                stackerParts_Info.Add(zaihuotai001.ModelName, zaihuotai001);

                StackerPartsInfo duiduojilizhu001 = new StackerPartsInfo("duiduojilizhu001");
                stackerParts_Info.Add(duiduojilizhu001.ModelName, duiduojilizhu001);

                StackerPartsInfo shangcha001 = new StackerPartsInfo("shangcha001");
                stackerParts_Info.Add(shangcha001.ModelName, shangcha001);

                StackerPartsInfo xiacha001 = new StackerPartsInfo("xiacha001");
                stackerParts_Info.Add(xiacha001.ModelName, xiacha001);

                StackerPartsInfo zhongcha001 = new StackerPartsInfo("zhongcha001");
                stackerParts_Info.Add(zhongcha001.ModelName, zhongcha001);

                StackerPartsInfo VIFS001 = new StackerPartsInfo("VIFS001");
                stackerParts_Info.Add(VIFS001.ModelName, VIFS001);

                StackerPartsInfo zaihuotai002 = new StackerPartsInfo("zaihuotai002");
                stackerParts_Info.Add(zaihuotai002.ModelName, zaihuotai002);

                StackerPartsInfo duiduojilizhu002 = new StackerPartsInfo("duiduojilizhu002");
                stackerParts_Info.Add(duiduojilizhu002.ModelName, duiduojilizhu002);

                StackerPartsInfo shangcha002 = new StackerPartsInfo("shangcha002");
                stackerParts_Info.Add(shangcha002.ModelName, shangcha002);

                StackerPartsInfo xiacha002 = new StackerPartsInfo("xiacha002");
                stackerParts_Info.Add(xiacha002.ModelName, xiacha002);

                StackerPartsInfo zhongcha002 = new StackerPartsInfo("zhongcha002");
                stackerParts_Info.Add(zhongcha002.ModelName, zhongcha002);

                StackerPartsInfo VIFS002 = new StackerPartsInfo("VIFS002");
                stackerParts_Info.Add(VIFS002.ModelName, VIFS002);
            }
            catch (Exception ex)
            {
                HintEvent(string.Format("WareHouseModel_InitGetXmlData has exception:" + ex.ToString()));
            }
        }
示例#9
0
            public AsmSpanifyer(
                Program program,
                MachineInstruction[] instrs,
                ModelPosition pos)
            {
                this.instrs = instrs;
                var addr = pos.Address;

                this.offset   = FindIndexOfInstructionAddress(instrs, addr);
                this.position = pos;
                this.program  = program;
            }
示例#10
0
 public PartialViewResult Edit(ModelPosition model, int id)
 {
     if (ModelState.IsValid)
     {
         Save_Position(model, id);
         return(PartialView("TablePosition", Get_Positions()));
     }
     else
     {
         return(PartialView(model));
     }
 }
示例#11
0
        private object Get_Id_Position(int id)
        {
            ModelPosition model = new ModelPosition();

            using (RestaurantEnt db = new RestaurantEnt())
            {
                var pos = db.Position.FirstOrDefault(z => z.Id == id);
                model.Id       = pos.Id;
                model.Position = pos.Name_Posinion;
            }

            return(model);
        }
示例#12
0
        private void Save_Position(ModelPosition model, int id)//сохранение в базу
        {
            using (RestaurantEnt db = new RestaurantEnt())
            {
                var pos = db.Position.FirstOrDefault(z => z.Id == id);
                if (pos != null)
                {
                    pos.Name_Posinion = model.Position;
                }

                db.SaveChanges();
            }
        }
示例#13
0
        private SpanGenerator CreateSpanifier(
            ImageMapItem item,
            ModelPosition pos)
        {
            SpanGenerator sp;

            if (item is ImageMapBlock b)
            {
                sp = new AsmSpanifyer(program, instructions[b], pos);
            }
            else
            {
                sp = new MemSpanifyer(program, item, pos);
            }
            return(sp);
        }
示例#14
0
        public List <ModelPosition> Get_Positions()
        {
            List <ModelPosition> lists = new List <ModelPosition>();

            using (RestaurantEnt db = new RestaurantEnt())
            {
                var pos = db.Position.ToList();
                foreach (var VARIABLE in pos)
                {
                    ModelPosition model = new ModelPosition {
                        Id = VARIABLE.Id, Position = VARIABLE.Name_Posinion
                    };
                    lists.Add(model);
                }
            }

            return(lists);
        }
示例#15
0
 public PartialViewResult AddPosition(ModelPosition pos)
 {
     if (ModelState.IsValid)
     {
         using (RestaurantEnt db = new RestaurantEnt())
         {
             Position position = new Position {
                 Name_Posinion = pos.Position
             };
             db.Position.Add(position);
             db.SaveChanges();
         }
         return(PartialView("TablePosition", Get_Positions()));
     }
     else
     {
         return(PartialView());
     }
 }
示例#16
0
            public override Tuple <ModelPosition, LineSpan> GenerateSpan()
            {
                if (offset >= instrs.Length || offset < 0)
                {
                    return(null);
                }
                var instr = instrs[offset];

                ++offset;
                var asmLine = DisassemblyTextModel.RenderAsmLine(
                    position,
                    program,
                    instr,
                    MachineInstructionWriterOptions.ResolvePcRelativeAddress);

                if (offset == instrs.Length)
                {
                    DecorateLastLine(asmLine);
                }
                this.position = Pos(instr.Address + instr.Length);
                return(Tuple.Create(position, asmLine));
            }
示例#17
0
            public override Tuple <ModelPosition, LineSpan> GenerateSpan()
            {
                var addr = this.position.Address;
                var line = new List <TextSpan>
                {
                    new AddressSpan(addr.ToString(), addr, UiStyles.MemoryWindow)
                };

                var addrStart = Align(addr, BytesPerLine);
                var addrEnd   = Address.Min(addrStart + BytesPerLine, item.Address + item.Size);
                var linStart  = addrStart.ToLinear();
                var linEnd    = addrEnd.ToLinear();
                var cbFiller  = addr.ToLinear() - linStart;
                var cbBytes   = linEnd - addr.ToLinear();
                var cbPadding = BytesPerLine - (cbFiller + cbBytes);

                var abCode = new List <byte>();

                // Do any filler first

                if (cbFiller > 0)
                {
                    line.Add(new MemoryTextSpan(new string(' ', 3 * (int)cbFiller), UiStyles.MemoryWindow));
                }

                var rdr = program.CreateImageReader(addr);

                while (rdr.Address.ToLinear() < linEnd)
                {
                    if (rdr.IsValid)
                    {
                        var  addr1 = rdr.Address;
                        byte b     = rdr.ReadByte();
                        line.Add(new MemoryTextSpan(addr1, string.Format(" {0:X2}", b), UiStyles.MemoryWindow));
                        //$BUG: should use platform.Encoding
                        abCode.Add(b);
                    }
                    else
                    {
                        cbPadding = linEnd - rdr.Address.ToLinear();
                        addrEnd   = rdr.Address;
                        break;
                    }
                }

                // Do any padding after.

                if (cbPadding > 0)
                {
                    line.Add(new MemoryTextSpan(new string(' ', 3 * (int)cbPadding), UiStyles.MemoryWindow));
                }

                // Now display the code bytes.
                string sBytes = RenderBytesAsText(abCode.ToArray());

                line.Add(new MemoryTextSpan(" ", UiStyles.MemoryWindow));
                line.Add(new MemoryTextSpan(sBytes, UiStyles.MemoryWindow));

                var memLine = new LineSpan(position, line.ToArray());

                this.position = Pos(addrEnd);
                if (rdr.Address >= item.EndAddress)
                {
                    DecorateLastLine(memLine);
                }
                return(Tuple.Create(position, memLine));
            }
示例#18
0
        public int MoveToLine(object position, int offset)
        {
            if (position == null)
            {
                throw new ArgumentNullException("position");
            }
            curPos = SanitizePosition((ModelPosition)position);
            if (offset == 0)
            {
                return(0);
            }
            int moved = 0;

            if (offset > 0)
            {
                if (!program.ImageMap.TryFindItem(curPos.Address, out var item))
                {
                    return(moved);
                }
                int iItem = program.ImageMap.Items.IndexOfKey(item.Address);
                for (;;)
                {
                    Debug.Assert(item != null);
                    if (item is ImageMapBlock bi)
                    {
                        var instrs = instructions[bi];
                        int i      = FindIndexOfInstructionAddress(
                            instrs, curPos.Address);
                        Debug.Assert(i >= 0, "TryFindItem said this item contains the address.");
                        int iNew = i + offset;
                        if (0 <= iNew && iNew < instrs.Length)
                        {
                            moved += offset;
                            curPos = Pos(instrs[iNew].Address);
                            return(moved);
                        }
                        // Fell off the end.

                        if (offset > 0)
                        {
                            moved  += instrs.Length - i;
                            offset -= instrs.Length - i;
                        }
                        else
                        {
                            moved  -= i;
                            offset += i;
                        }
                    }
                    else
                    {
                        // Determine current line # within memory block

                        int i    = FindIndexOfMemoryAddress(item, curPos.Address);
                        int iEnd = CountBlockLines(item);
                        Debug.Assert(i >= 0, "Should have been inside item");
                        int iNew = i + offset;
                        if (0 <= iNew && iNew < iEnd)
                        {
                            moved += offset;
                            curPos = Pos(GetAddressOfLine(item, iNew));
                            return(moved);
                        }
                        // Fall of the end
                        if (offset > 0)
                        {
                            moved  += iEnd - i;
                            offset -= iEnd - i;
                        }
                        else
                        {
                            moved  -= i;
                            offset += i;
                        }
                    }

                    // Since we fall off the current map item,
                    // move to next image map item.
                    ++iItem;
                    if (iItem >= program.ImageMap.Items.Count)
                    {
                        // At the end of image, no need for SanitizeAddress
                        curPos = (ModelPosition)this.EndPosition;
                        return(moved);
                    }
                    else
                    {
                        // At the start of an item, no need for SanitizeAddress
                        item   = program.ImageMap.Items.Values[iItem];
                        curPos = Pos(item.Address);
                    }
                }
            }
            throw new NotImplementedException("Moving backwards not implemented yet.");
        }
示例#19
0
        public static Conveyor GetConveyor(string conveyorName, MissionType missionType, string startShelfNo, string endShelfNo, Direction_ Direction_, ModelPosition modelPosition)
        {
            Conveyor conveyor = null;

            switch (Direction_)
            {
            case Direction_.Roadway:
                conveyor = new Stacker_RoadWay(missionType, conveyorName, startShelfNo, endShelfNo, modelPosition, Direction_);
                break;
            }
            return(conveyor);
        }
示例#20
0
 public Stacker_ShelfOut(MissionType missionType, string conveyorName, string shelfNo, ModelPosition modelPosition, Direction_ direction) : base(conveyorName, direction)
 {
     SetPos(modelPosition.GetShelfPos(shelfNo), modelPosition.GetShelfLinePos(shelfNo));
     SetSpeed();
 }
示例#21
0
 public Stacker_RoadWay(MissionType missionType, string conveyorName, string startShelfNo, string endShelfNo, ModelPosition modelPosition, Direction_ Direction_) : base(conveyorName, Direction_)
 {
     SetPos(modelPosition.GetShelfLinePos(startShelfNo), modelPosition.GetShelfLinePos(endShelfNo));
     SetSpeed();
 }
示例#22
0
 public Stacker_RoadWay(MissionType missionType, string conveyorName, string shelfNo, ModelPosition modelPosition, Direction_ Direction_) : base(conveyorName, Direction_)
 {
     if (missionType.Equals(MissionType.ProdIn) || missionType.Equals(MissionType.BackIn) || missionType.Equals(MissionType.PalletIn))
     {
         SetPos(GetLeftBottomPos(conveyorName), modelPosition.GetShelfLinePos(shelfNo));
     }
     else if (missionType.Equals(MissionType.ProdOut) || missionType.Equals(MissionType.PalletOut) || missionType.Equals(MissionType.GetPallet))
     {
         SetPos(modelPosition.GetShelfLinePos(shelfNo), GetLeftBottomPos(conveyorName));
     }
     SetSpeed();
 }
示例#23
0
        public static Conveyor GetConveyor(string conveyorName, MissionType missionType, string shelfNo, Direction_ Direction, ModelPosition modelPosition)
        {
            Conveyor conveyor = null;

            switch (Direction)
            {
            case Direction_.Vertical:
                conveyor = new Conveyor_V(missionType, conveyorName, Direction);
                break;

            case Direction_.Horizontal:
                conveyor = new Conveyor_H(missionType, conveyorName, Direction);
                break;

            case Direction_.Roadway:
                conveyor = new Stacker_RoadWay(missionType, conveyorName, shelfNo, modelPosition, Direction);
                break;

            case Direction_.PortIn:
                conveyor = new Stacker_Port(missionType, conveyorName, Direction);
                break;

            case Direction_.PortOut:
                conveyor = new Stacker_Port(missionType, conveyorName, Direction);
                break;

            case Direction_.ShelfOut:
                conveyor = new Stacker_ShelfOut(missionType, conveyorName, shelfNo, modelPosition, Direction);
                break;

            case Direction_.ShelfIn:
                conveyor = new Stacker_ShelfIn(missionType, conveyorName, shelfNo, modelPosition, Direction);
                break;
            }
            return(conveyor);
        }