Пример #1
0
 private void ClearList()
 {
     try
     {
         moveCmdInfo = null;
         MainForm_AddressList.Items.Clear();
         AddressList.Items.Clear();
     }
     catch { }
 }
Пример #2
0
        private void SetMovingAddressList()
        {
            try
            {
                AddressList.Items.Clear();

                MoveCmdInfo tempMoveCmdInfo = moveCmdInfo;

                if (tempMoveCmdInfo != null)
                {
                    for (int i = 0; i < tempMoveCmdInfo.MovingAddress.Count; i++)
                    {
                        AddressList.Items.Add(tempMoveCmdInfo.MovingAddress[i].Id);
                    }
                }
            }
            catch { }
        }
Пример #3
0
        private void SettingSpeed(MoveCmdInfo temp)
        {
            double lineVelocity;
            double otherVelocity;

            if (!double.TryParse(lineSpeed.ValueString, out lineVelocity) || lineVelocity < localData.MoveControlData.CreateMoveCommandConfig.EQ.Velocity)
            {
                lineVelocity          = 400;
                lineSpeed.ValueString = lineVelocity.ToString();
            }

            if (!double.TryParse(otherSpeed.ValueString, out otherVelocity) || otherVelocity < localData.MoveControlData.CreateMoveCommandConfig.EQ.Velocity)
            {
                otherVelocity          = 400;
                otherSpeed.ValueString = otherVelocity.ToString();
            }

            double deltaAngle;

            temp.SpecifySpeed = new List <double>();
            for (int i = 0; i < temp.MovingSections.Count; i++)
            {
                if (temp.MovingSections[i].FromVehicleAngle != temp.MovingSections[i].ToVehicleAngle)
                {
                    temp.SpecifySpeed.Add(temp.MovingSections[i].Speed);
                }
                else
                {
                    deltaAngle = computeFunction.GetCurrectAngle(temp.MovingSections[i].FromVehicleAngle - temp.MovingSections[i].SectionAngle);

                    if (deltaAngle == 0 || deltaAngle == 180)
                    {
                        temp.SpecifySpeed.Add(lineVelocity);
                    }
                    else
                    {
                        temp.SpecifySpeed.Add(otherVelocity);
                    }
                }
            }
        }
Пример #4
0
        private bool CheckMovingAddress(ref string errorMessage)
        {
            try
            {
                moveCmdInfo = new MoveCmdInfo();

                if (moveControl.CreateMoveCommandList.Step0_CheckMovingAddress(originAddressList, ref moveCmdInfo, ref errorMessage))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errorMessage = ex.ToString();
                return(false);
            }
        }
Пример #5
0
        private void button_DebugModeSend_Click(object sender, EventArgs e)
        {
            button_DebugModeSend.Enabled = false;

            try
            {
                if (localData.AutoManual == EnumAutoState.Manual)
                {
                    MoveCmdInfo temp = moveCmdInfo;

                    if (temp != null)
                    {
                        if (rB_SettingSpeed.Checked)
                        {
                            SettingSpeed(temp);
                        }

                        temp.CommandID = string.Concat("localCommand ", DateTime.Now.ToString("MM/dd HH:mm:ss"));

                        string errorMessage = "";

                        if (moveControl.VehicleMove_DebugForm(temp, ref errorMessage))
                        {
                            tC_MoveControl.SelectedIndex = 1;
                        }
                        else
                        {
                            MessageBox.Show(String.Concat("命令產生失敗 : ", errorMessage));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception : ", ex.ToString());
            }

            button_DebugModeSend.Enabled = true;
        }
Пример #6
0
        public bool FindFromToAddressSectionList(MapAddress start, MapAddress end, ref MoveCmdInfo moveCmdInfo)
        {
            try
            {
                if (start != end)
                {
                    #region 終點在目前SectionList最後一個之中.
                    if (moveCmdInfo.MovingSections.Count != 0 && moveCmdInfo.MovingSections[moveCmdInfo.MovingSections.Count - 1] == end.InsideSection)
                    {
                        double sectionAngle = ComputeAngle(moveCmdInfo.MovingAddress[moveCmdInfo.MovingAddress.Count - 2].AGVPosition,
                                                           moveCmdInfo.MovingAddress[moveCmdInfo.MovingAddress.Count - 1].AGVPosition);

                        double endAngle = ComputeAngle(moveCmdInfo.MovingAddress[moveCmdInfo.MovingAddress.Count - 2].AGVPosition, end.AGVPosition);

                        if (sectionAngle != endAngle)
                        {
                            moveCmdInfo.MovingAddress.Add(moveCmdInfo.MovingAddress[moveCmdInfo.MovingAddress.Count - 2]);
                            moveCmdInfo.MovingSections.Add(moveCmdInfo.MovingSections[moveCmdInfo.MovingSections.Count - 1]);
                        }

                        moveCmdInfo.EndAddress = end;
                        return(true);
                    }
                    #endregion

                    #region 起點和終點都是內點.
                    if (start.InsideSection != null && end.InsideSection != null &&
                        start.InsideSection == end.InsideSection)
                    {
                        double angleStartToEnd = ComputeAngle(start.AGVPosition, end.AGVPosition);
                        double sectionAngle    = ComputeAngle(start.InsideSection.FromAddress.AGVPosition, start.InsideSection.ToAddress.AGVPosition);

                        moveCmdInfo.MovingSections.Add(start.InsideSection);

                        if (angleStartToEnd == sectionAngle)
                        {
                            moveCmdInfo.MovingAddress.Add(start.InsideSection.FromAddress);
                            moveCmdInfo.MovingAddress.Add(start.InsideSection.ToAddress);
                        }
                        else
                        {
                            moveCmdInfo.MovingAddress.Add(start.InsideSection.ToAddress);
                            moveCmdInfo.MovingAddress.Add(start.InsideSection.FromAddress);
                        }

                        moveCmdInfo.EndAddress = end;

                        return(true);
                    }
                    #endregion

                    List <MapAddress> movingAddress = new List <MapAddress>();
                    List <MapSection> movingSection = new List <MapSection>();

                    List <double>     startAddressToSectionNodeDistance = new List <double>();
                    List <MapAddress> startSectionNode  = new List <MapAddress>();
                    List <MapAddress> startSectionNode2 = new List <MapAddress>();
                    List <double>     endAddressToSectionNodeDistance = new List <double>();
                    List <MapAddress> endSectionNode = new List <MapAddress>();

                    double distance = 0;

                    if (start.InsideSection == null)
                    {
                        startAddressToSectionNodeDistance.Add(0);
                        startSectionNode.Add(start);
                    }
                    else
                    {
                        distance = GetTwoPositionDistance(start.AGVPosition, start.InsideSection.FromAddress.AGVPosition);
                        startAddressToSectionNodeDistance.Add(distance / start.InsideSection.Speed);
                        startSectionNode.Add(start.InsideSection.FromAddress);
                        startSectionNode2.Add(start.InsideSection.ToAddress);

                        distance = GetTwoPositionDistance(start.AGVPosition, start.InsideSection.ToAddress.AGVPosition);
                        startAddressToSectionNodeDistance.Add(distance / start.InsideSection.Speed);
                        startSectionNode.Add(start.InsideSection.ToAddress);
                        startSectionNode2.Add(start.InsideSection.FromAddress);
                    }

                    if (end.InsideSection == null)
                    {
                        endAddressToSectionNodeDistance.Add(0);
                        endSectionNode.Add(end);
                    }
                    else
                    {
                        distance = GetTwoPositionDistance(end.AGVPosition, end.InsideSection.FromAddress.AGVPosition);
                        endAddressToSectionNodeDistance.Add(distance / end.InsideSection.Speed);
                        endSectionNode.Add(end.InsideSection.ToAddress);

                        distance = GetTwoPositionDistance(end.AGVPosition, end.InsideSection.FromAddress.AGVPosition);
                        endAddressToSectionNodeDistance.Add(distance / end.InsideSection.Speed);
                        endSectionNode.Add(end.InsideSection.FromAddress);
                    }

                    if (startSectionNode.Count > 1 && (startSectionNode[0] == endSectionNode[0] || startSectionNode[1] == endSectionNode[0]))
                    {
                        if (startSectionNode[0] == endSectionNode[0])
                        {
                            moveCmdInfo.MovingAddress.Add(startSectionNode[1]);
                        }
                        else
                        {
                            moveCmdInfo.MovingAddress.Add(startSectionNode[0]);
                        }

                        moveCmdInfo.MovingAddress.Add(endSectionNode[0]);
                        moveCmdInfo.MovingSections.Add(start.InsideSection);
                        return(true);
                    }

                    List <MapSection> tempSectionList = new List <MapSection>();
                    double            minDistance     = -1;
                    List <MapAddress> nodeList        = new List <MapAddress>();

                    for (int i = 0; i < startSectionNode.Count; i++)
                    {
                        for (int j = 0; j < endSectionNode.Count; j++)
                        {
                            //if (start.InsideSection != null)
                            //    nodeList.Add(start);
                            tempSectionList = new List <MapSection>();

                            if (start.InsideSection != null)
                            {
                                tempSectionList.Add(start.InsideSection);
                            }

                            nodeList.Add(startSectionNode[i]);
                            if (startSectionNode2.Count > 0)
                            {
                                nodeList.Add(startSectionNode2[i]);
                            }

                            FindAGVFromToPath(endSectionNode[j], nodeList, startAddressToSectionNodeDistance[i] + endAddressToSectionNodeDistance[j], ref movingAddress, ref minDistance, tempSectionList, ref movingSection);
                            nodeList = new List <MapAddress>();
                        }
                    }

                    if (minDistance != -1)
                    {
                        double sectionAngle;
                        double tempAngle;

                        //if (start.InsideSection != null)
                        //{
                        //    movingSection.Insert(0, start.InsideSection);
                        //    sectionAngle = ComputeAngle(movingSection[0].FromAddress.AGVPosition, movingSection[0].ToAddress.AGVPosition);
                        //    tempAngle = ComputeAngle(start.AGVPosition, movingSection[0].ToAddress.AGVPosition);

                        //    if (sectionAngle == tempAngle)
                        //        movingAddress[0] = movingSection[0].FromAddress;
                        //    else
                        //        movingAddress[0] = movingSection[0].ToAddress;
                        //}

                        if (end.InsideSection != null)
                        {
                            movingSection.Add(end.InsideSection);
                            sectionAngle = ComputeAngle(movingSection[movingSection.Count - 1].FromAddress.AGVPosition, movingSection[movingSection.Count - 1].ToAddress.AGVPosition);
                            tempAngle    = ComputeAngle(start.AGVPosition, movingSection[movingSection.Count - 1].ToAddress.AGVPosition);

                            if (sectionAngle == tempAngle)
                            {
                                movingAddress[movingAddress.Count - 1] = movingSection[movingSection.Count - 1].ToAddress;
                            }
                            else
                            {
                                movingAddress[movingAddress.Count - 1] = movingSection[movingSection.Count - 1].FromAddress;
                            }
                        }

                        if (moveCmdInfo.MovingAddress.Count == 0)
                        {
                            moveCmdInfo.MovingAddress.Add(movingAddress[0]);
                        }

                        for (int i = 1; i < movingAddress.Count; i++)
                        {
                            moveCmdInfo.MovingAddress.Add(movingAddress[i]);
                        }

                        for (int i = 0; i < movingSection.Count; i++)
                        {
                            moveCmdInfo.MovingSections.Add(movingSection[i]);
                        }

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }