Пример #1
0
 public CoverObject(AreaToCover coverArea, MachineObject machine, Coordinates machinePosition, Coordinates direction)
 {
     CoverArea = coverArea;
     MachineObject = machine;
     MachinePosition = machinePosition;
     Direction = direction;
 }
Пример #2
0
        public static bool IsInMyWay(MachineObject machineObject, AreaToCover areaToCover)
        {
            string coverlineID = areaToCover.GetLastCoverLine(machineObject.VerticalPosition);
            string reciverMachineID = string.Empty;
            try
            {
                reciverMachineID = World.CoverLinesList.Where(a => a.CoverLineID == coverlineID).First().MachineID;
            }
            catch { }

            if (string.IsNullOrEmpty(reciverMachineID))
                return false;

            Request request = new Communication.Request();

            request.RequestType = Communication.Enum.RequestType.CoverLineFinishStatus;
            request.SenderMachineID = machineObject.MachineID;
            request.ReceiverMachineID = reciverMachineID;
            request.CommunicationRequestID = (++World.CommunicationRequestID).ToString();

            Response response = request.Send();

            if (response.CoverLineFinish.MachineActualCoverLineDirection == World.GetCoverLineByID(machineObject.ActualCoverLineID).CoverLineDirection)
            {
                Coordinates a;
                Coordinates b;

                if ((World.CoverDirection == Enumerations.CoverDirection.leftToRight && machineObject.VerticalPosition == Enumerations.VerticalPosition.down)
                    || (World.CoverDirection == Enumerations.CoverDirection.rightToLeft && machineObject.VerticalPosition == Enumerations.VerticalPosition.up))
                {
                    a = areaToCover.LeftDown;
                    b = areaToCover.LeftUp;
                }

                else if ((World.CoverDirection == Enumerations.CoverDirection.leftToRight && machineObject.VerticalPosition == Enumerations.VerticalPosition.up)
                    || (World.CoverDirection == Enumerations.CoverDirection.rightToLeft && machineObject.VerticalPosition == Enumerations.VerticalPosition.down))
                {
                    a = areaToCover.RightDown;
                    b = areaToCover.RightUp;
                }

                else
                {
                    //TODO: minor - if coverDirection == both

                    a = areaToCover.RightDown;
                    b = areaToCover.RightUp;
                }

                //if the finishing time of cover line in front of current machine is smaller, then take this cover line
                if (response.CoverLineFinish.CoverLineFinishTime < DateTime.Now.AddSeconds(Helpers.Methods.GetCoveringTimeSeconds(a, b, machineObject.CoverSpeed)))
                    return true;
                else
                    return false;

            }
            //if the directions are same, machine are going opposite
            else
                return false;
        }
Пример #3
0
 private void DownToUpLeftToRight(CoverLine _oldCoverLine, MachineObject _machineObject)
 {
     if (_oldCoverLine.IsDivide)
     {
         newLine = new CoverLine(_oldCoverLine, (int)MachineObject.WorkingWidth, 0);
     }
     else
         throw new NotImplementedException();
 }
Пример #4
0
        public CoverLine GetNewCoverLine(string oldCoverLineID, MachineObject machineObject)
        {
            _oldCoverLine = WorldToCover.World.GetCoverLineByID(oldCoverLineID);
            _machineObject = machineObject;

            if (_oldCoverLine.IsDivide)
            {

            }
            int coverDirectionCoefficient;
            if (WorldToCover.World.CoverDirection == Enumerations.CoverDirection.leftToRight)
                coverDirectionCoefficient = 1;
            else if (WorldToCover.World.CoverDirection == Enumerations.CoverDirection.rightToLeft)
                coverDirectionCoefficient = -1;
            else
                coverDirectionCoefficient = 0;

            //newLine = new CoverLine();

            if (_oldCoverLine.StartingCoordinates.Point.Y > _oldCoverLine.EndingCoordinates.Point.Y)
            {
                if (coverDirectionCoefficient == 1)
                {
                    UpToDownLeftToRight(_oldCoverLine, _machineObject);
                }
                else if (coverDirectionCoefficient == -1)
                {
                    UpToDownRightToLeft(_oldCoverLine, _machineObject);
                }
                else
                {
                    DownToUpBoth(_oldCoverLine, _machineObject);
                }
            }

            else
            {
                if (coverDirectionCoefficient == 1)
                {
                    DownToUpLeftToRight(_oldCoverLine, _machineObject);
                }
                else if (coverDirectionCoefficient == -1)
                {
                    DownToUpRightToLeft(_oldCoverLine, _machineObject);
                }
                else
                {
                    DownToUpBoth(_oldCoverLine, _machineObject);
                }
            }

            // World.

            //TODO:blocker - add newLine to List<CoveredSubArea>

            return newLine;
        }
Пример #5
0
        public static void RemoveMachineFromList(MachineObject machineObject)
        {
            int index = 0;
            foreach (var machine in MachineList)
            {
                if (machine.MachineID == machineObject.MachineID)
                {
                    TotalWorkingWidth -= machine.WorkingWidth;
                    break;
                }

                index++;
            }

            MachineList.RemoveAt(index);
        }
Пример #6
0
 public static void AddMachineToList(MachineObject machineObject)
 {
     MachineList.Add(machineObject);
     TotalWorkingWidth += machineObject.WorkingWidth;
 }
Пример #7
0
 private void DownToUpBoth(CoverLine _oldCoverLine, MachineObject _machineObject)
 {
     throw new NotImplementedException();
 }
Пример #8
0
 private void SetNewMachine()
 {
     var machine = new MachineObject();
     machine.CoverSpeed = Helpers.Methods.GetMetersPerSecond(nudWorkingSpeed.Value, cbWorkingSpeedUnit.SelectedItem.ToString());
     machine.Position = new Coordinates(0, 0);
     machine.TransportSpeed = Helpers.Methods.GetMetersPerSecond(nudTransportSpeed.Value, cbTransportSpeedUnit.SelectedItem.ToString());
     machine.TurningRadius = Helpers.Methods.GetMeters(nudTurningRadius.Value, cbTurningRadiusUnit.SelectedItem.ToString());
     machine.WorkingWidth = Helpers.Methods.GetMeters(nudWorkingWidth.Value, cbWorkingWidthUnits.SelectedItem.ToString());
     machine.Type = rbPrimary.Checked ? Enumerations.MachineType.primary : Enumerations.MachineType.secondary;
 }
Пример #9
0
Файл: World.cs Проект: MGajd/DP
        internal static string AddMachineToCover(MachineObject machineObject)
        {
            if (AreasToCover != null && AreasToCover.Count > 0)
            {
                if (GoAroundAreaTimes != 0)
                {
                    //TODO:major - implement GoAround
                    throw new NotImplementedException();
                }
                else
                {
                    //TODO:major - divide machines into groups
                    if (string.IsNullOrEmpty(machineObject.ActualCoverLineID))
                        machineObject.GetCoverLine();
                    else
                        machineObject.GetCoverLine(World.GetAreaToCoverByCoverLineID(machineObject.ActualCoverLineID).AreaToCoverID);

                    return machineObject.StartWork();

                }

            }
            else
            {
                AreaCovered = true;
                return "NOTHING TO COVER / AREA (ALREADY) FULLY COVERED";
            }
        }