Exemplo n.º 1
0
Arquivo: DoCover.cs Projeto: MGajd/DP
 private void DownToUpLeftToRight(CoverLine _oldCoverLine, MachineObject _machineObject)
 {
     if (_oldCoverLine.IsDivide)
     {
         newLine = new CoverLine(_oldCoverLine, (int)MachineObject.WorkingWidth, 0);
     }
     else
         throw new NotImplementedException();
 }
Exemplo n.º 2
0
        private Response AssumedCoverLineFinishResponse(CoverLine actualCoverLine)
        {
            Response response = new Response();

            response.CoverLineFinish = new CoverLineFinishObject();
            response.CoverLineFinish.SetMachineActualCoverDirection(actualCoverLine);
            response.CoverLineFinish.CoverLineFinishTime = EndsAt;

            return response;
        }
Exemplo n.º 3
0
Arquivo: World.cs Projeto: MGajd/DP
        public static void AddCoverLine(CoverLine newCoverLine, decimal width)
        {
            CoverLinesList.Add(newCoverLine);

            if (newCoverLine.IsDivide)
                return;
            AreaToCover area = GetAreaByID(newCoverLine.AreaToCoverID);

            if (area.Width <= newCoverLine.Width)
            {
                World.RemoveAreaToCover(area.AreaToCoverID);
            }
            else
            {
                area.AddCoverLine(newCoverLine);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates new line by copying system info of old CoverLine. Use when adding the same value to both coordinates.
        /// </summary>
        /// <param name="_oldCoverLine">CovwrLine to create new one.</param>
        /// <param name="xCoordinateAdd">Add value to x coordinate.</param>
        /// <param name="yCoordinateAdd">Add value to y coordinate.</param>
        public CoverLine(CoverLine _oldCoverLine, int xCoordinateAdd, int yCoordinateAdd,bool isDivide = false, string areaToCoverID = null)
        {
            StartingCoordinates = new Coordinates(_oldCoverLine.EndingCoordinates.X + xCoordinateAdd, _oldCoverLine.EndingCoordinates.Y + yCoordinateAdd);
            EndingCoordinates = new Coordinates(_oldCoverLine.StartingCoordinates.X + xCoordinateAdd, _oldCoverLine.StartingCoordinates.Y + yCoordinateAdd);

            IsDivide = isDivide;
            AreaToCoverID = areaToCoverID ?? _oldCoverLine.AreaToCoverID;
            MachineID = _oldCoverLine.MachineID;
            Status = Enumerations.CoverLineStatus.reserved;
        }
Exemplo n.º 5
0
 public CoveredSubArea(CoverLine coverLineObject)
 {
 }
Exemplo n.º 6
0
 public void SetMachineActualCoverDirection(CoverLine actualCoverLine)
 {
     MachineActualCoverLineDirection = actualCoverLine.CoverLineDirection;
 }
Exemplo n.º 7
0
        private CoverLine GetFirstLineFromRight(decimal workingWidth, bool reverseDirection = false)
        {
            //TODO: can be incorrect
            int coef = 1;
            if (reverseDirection)
                coef = -1;
            CoverLine coverLine = new CoverLine();
            coverLine.StartingCoordinates = new Coordinates(MaxX + (coef * workingWidth) / 2, GetMinY(MaxX, (coef * workingWidth)));// RightDown.Y);
            coverLine.EndingCoordinates = new Coordinates(MaxX + (coef * workingWidth) / 2, GetMaxY(MaxX, (coef * workingWidth)));// RightUp.Y);

            coverLine.Status = Enumerations.CoverLineStatus.reserved;
            coverLine.IsDivide = false;
            coverLine.CoverLineID = World.CoverLineIDCounter++.ToString();

            if (reverseDirection)
                coverLine.ReverseCoordinates();
            return coverLine;
        }
Exemplo n.º 8
0
        private CoverLine GetFirstLineFromLeft(decimal workingWidth, bool reverseDirection = false)
        {
            int coef = 1;
            if (reverseDirection)
                coef = -1;
            CoverLine coverLine = new CoverLine();

            //TODO:blocker - DONE? change Y-coordinates to the proper Y due to shape
            coverLine.StartingCoordinates = new Coordinates(MinX + (coef * workingWidth) / 2, GetMinY(MinX, (coef * workingWidth)));
            coverLine.EndingCoordinates = new Coordinates(MinX + (coef * workingWidth) / 2, GetMaxY(MinX, (coef * workingWidth)));// LeftUp.Y);

            coverLine.Status = Enumerations.CoverLineStatus.reserved;
            coverLine.IsDivide = false;
            coverLine.CoverLineID = World.CoverLineIDCounter++.ToString();

            if (reverseDirection)
                coverLine.ReverseCoordinates();
            return coverLine;
        }
Exemplo n.º 9
0
        private void DeleteCoordinatesBetween(Coordinates coorFrom, Coordinates coorTo, CoverLine newCoverLine, int coef = 1)
        {
            List<Coordinates> newCoordinates = AddNewIndexes(coorFrom, coorTo, newCoverLine, coef);
            RemoveRedundantCoordinates();

            int coorFomIndex = Helpers.Methods.GetCoordinatecIndex(CoordinateList, newCoordinates.Last());
            int coorToIndex = Helpers.Methods.GetCoordinatecIndex(CoordinateList, newCoordinates.First());

            DeleteCoordinatesBetweenIndexes(coorFomIndex, coorToIndex);
        }
Exemplo n.º 10
0
        private List<Coordinates> AddNewIndexes(Coordinates coorFrom, Coordinates coorTo, CoverLine newCoverLine, int coef)
        {
            List<Coordinates> returnCoordinates = new List<Coordinates>();

            int coorToIndex = Helpers.Methods.GetCoordinatecIndex(CoordinateList, coorTo);
            returnCoordinates.Add(Helpers.Methods.LinearInterpolation(CoordinateList[GetSafeCoordinateListIndex(coorToIndex)], CoordinateList[GetSafeCoordinateListIndex(coorToIndex - 1)], newCoverLine.X + (newCoverLine.Width / 2) * coef));
            CoordinateList.Insert(coorToIndex, returnCoordinates.Last());

            int coorFromIndex = Helpers.Methods.GetCoordinatecIndex(CoordinateList, coorFrom);
            returnCoordinates.Add(Helpers.Methods.LinearInterpolation(CoordinateList[GetSafeCoordinateListIndex(coorFromIndex)], CoordinateList[GetSafeCoordinateListIndex(coorFromIndex + 1)], newCoverLine.X + (newCoverLine.Width / 2) * coef));
            CoordinateList.Insert(coorFromIndex + 1, returnCoordinates.Last());

            return returnCoordinates;
        }
Exemplo n.º 11
0
        internal void SetAsDividedRight(CoverLine coverLine, decimal workingWidth)
        {
            DeleteAllSmallerOrEqualXCoordinates(coverLine.X + workingWidth / 2);

            //CoordinateList[0] = new Coordinates(coverLine.StartingCoordinates.X + workingWidth / 2, CoordinateList[0].Y);
            //CoordinateList[3] = new Coordinates(coverLine.EndingCoordinates.X + workingWidth / 2, CoordinateList[3].Y);
        }
Exemplo n.º 12
0
        internal void SetAsDividedLeft(CoverLine coverLine, decimal workingWidth)
        {
            DeleteAllBiggerOrEqualXCoordinates(coverLine.X - workingWidth / 2);

            //CoordinateList[1] = new Coordinates(coverLine.StartingCoordinates.X - workingWidth / 2, CoordinateList[1].Y);
            //CoordinateList[2] = new Coordinates(coverLine.EndingCoordinates.X - workingWidth / 2, CoordinateList[2].Y);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Edit Coordinates in CoordinatesList due to coverLine
        /// </summary>
        /// <param name="newCoverLine"></param>
        internal void AddCoverLine(CoverLine newCoverLine)
        {
            int counter = 0;
            Coordinates leftDown = null,
                        leftUp = null,
                        rightDown = null,
                        rightUp = null;

            decimal leftX = newCoverLine.X - newCoverLine.Width / 2;
            decimal rightX = newCoverLine.X + newCoverLine.Width / 2;

            while (leftDown == null)
            {
                if (CoordinateList[GetSafeCoordinateListIndex(counter)].X <= leftX && CoordinateList[GetSafeCoordinateListIndex(counter + 1)].X > leftX)
                    leftDown = CoordinateList[GetSafeCoordinateListIndex(counter)];

                counter++;
            }

            while (rightDown == null)
            {
                if (CoordinateList[GetSafeCoordinateListIndex(counter)].X >= rightX && CoordinateList[GetSafeCoordinateListIndex(counter - 1)].X < rightX)
                    rightDown = CoordinateList[GetSafeCoordinateListIndex(counter)];
                else
                    counter++;
            }

            while (rightUp == null)
            {
                if (CoordinateList[GetSafeCoordinateListIndex(counter)].X >= rightX && CoordinateList[GetSafeCoordinateListIndex(counter + 1)].X < rightX)
                    rightUp = CoordinateList[GetSafeCoordinateListIndex(counter)];

                counter++;
            }

            while (leftUp == null)
            {
                if (CoordinateList[GetSafeCoordinateListIndex(counter)].X <= leftX && CoordinateList[GetSafeCoordinateListIndex(counter - 1)].X > leftX)
                    leftUp = CoordinateList[GetSafeCoordinateListIndex(counter)];

                counter++;
            }

            //zhora dole
            if (newCoverLine.CoverLineDirection == Enumerations.CoverLineDirection.upToDown)
            {
                if (World.CoverDirection == Enumerations.CoverDirection.leftToRight)
                    DeleteCoordinatesBetween(leftDown, leftUp, newCoverLine, -1);
                else if (World.CoverDirection == Enumerations.CoverDirection.rightToLeft)
                    DeleteCoordinatesBetween(rightUp, rightDown, newCoverLine);
            }

            //zdola hore
            else if (newCoverLine.CoverLineDirection == Enumerations.CoverLineDirection.downToUp)
            {
                if (World.CoverDirection == Enumerations.CoverDirection.leftToRight)
                    DeleteCoordinatesBetween(rightUp, rightDown, newCoverLine);
                else if (World.CoverDirection == Enumerations.CoverDirection.rightToLeft)
                    DeleteCoordinatesBetween(leftDown, leftUp, newCoverLine, -1);
            }
        }
Exemplo n.º 14
0
        public CoverLine GetLineFromRight(decimal width, decimal workingWidth, bool reverseDirection = false)
        {
            int coef = 1;
            if (reverseDirection)
                coef = -1;
            CoverLine coverLine = new CoverLine();
            coverLine.StartingCoordinates = new Coordinates(RightDown.X - width - (coef * workingWidth) / 2, RightDown.Y);
            coverLine.EndingCoordinates = new Coordinates(RightUp.X - width - (coef * workingWidth) / 2, RightUp.Y);

            coverLine.Status = Enumerations.CoverLineStatus.reserved;
            coverLine.IsDivide = false;
            coverLine.CoverLineID = World.CoverLineIDCounter++.ToString();

            if (reverseDirection)
                coverLine.ReverseCoordinates();
            return coverLine;
        }
Exemplo n.º 15
0
        public CoverLine GetLineFromLeft(decimal width, decimal workingWidth, bool reverseDirection = false)
        {
            //int coef = 1;
            //if (reverseDirection)
            //    coef = -1;

            //TODO:blocker - upravit kvoli moznosti pokrytia nepravidelnej plochy
            CoverLine coverLine = new CoverLine();
            coverLine.EndingCoordinates = new Coordinates(MinX + width - workingWidth / 2, LeftDown.Y);
            coverLine.StartingCoordinates = new Coordinates(MinX + width - workingWidth / 2, LeftUp.Y);

            coverLine.Status = Enumerations.CoverLineStatus.reserved;
            coverLine.IsDivide = false;
            coverLine.CoverLineID = World.CoverLineIDCounter++.ToString();

            if (reverseDirection)
                coverLine.ReverseCoordinates();
            return coverLine;
        }
Exemplo n.º 16
0
Arquivo: DoCover.cs Projeto: MGajd/DP
 private void DownToUpBoth(CoverLine _oldCoverLine, MachineObject _machineObject)
 {
     throw new NotImplementedException();
 }