Ejemplo n.º 1
0
        private void InitConfig()
        {
            //rtAGV_Control宣告
            DeliverData = new rtAGV_Control();
            ThreatPara = new ThreadWithState();
            GlobalVar.CurrentPosition = new NavigationInfo();

            //宣告使用到的Region數量
            DeliverData.tAGV_Cfg.tMapCfg.alRegionNum = 1;
            DeliverData.tAGV_Cfg.tMapCfg.Init();

            //宣告有幾個Region
            DeliverData.tAGV_Cfg.tMapCfg.alNodeNumLocal = new int[1];

            //Region裡面分別的節點數量
            DeliverData.tAGV_Cfg.tMapCfg.alNodeNumLocal[0] = 5;

            //宣告節點使用到的空間
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal = new rtAGV_MAP_node[1][];
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0] = new rtAGV_MAP_node[5];

            //節點座標資訊
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][0].tCoordinate.eX = 5000;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][0].tCoordinate.eY = -3500;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][0].tNodeId.lRegion = 0;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][0].tNodeId.lIndex = 0;

            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][1].tCoordinate.eX = 5000;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][1].tCoordinate.eY = -950;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][1].tNodeId.lRegion = 0;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][1].tNodeId.lIndex = 1;

            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][2].tCoordinate.eX = 17100;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][2].tCoordinate.eY = -950;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][2].tNodeId.lRegion = 0;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][2].tNodeId.lIndex = 2;

            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][3].tCoordinate.eX = 8400;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][3].tCoordinate.eY = -950;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][3].tNodeId.lRegion = 0;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][3].tNodeId.lIndex = 3;

            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][4].tCoordinate.eX = 11550;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][4].tCoordinate.eY = -950;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][4].tNodeId.lRegion = 0;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][4].tNodeId.lIndex = 4;
            //11550

            //宣告貨物空間
            DeliverData.tAGV_Cfg.atWarehousingCfg = new rtWarehousingInfo[1][];
            DeliverData.tAGV_Cfg.atWarehousingCfg[0] = new rtWarehousingInfo[4];

            //貨物資訊
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][0].eHeight = 51;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][0].DistanceDepth = 4500;

            DeliverData.tAGV_Cfg.atWarehousingCfg[0][1].eHeight = 110;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][1].DistanceDepth = 4500;

            DeliverData.tAGV_Cfg.atWarehousingCfg[0][2].eHeight = 110;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][2].DistanceDepth = 4500;

            DeliverData.tAGV_Cfg.atWarehousingCfg[0][3].eHeight = 110;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][3].DistanceDepth = 4500;

            //貨物地標
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][0].tCoordinate.eX = 17050;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][0].tCoordinate.eY = 120;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][0].eDirection = 90;

            DeliverData.tAGV_Cfg.atWarehousingCfg[0][1].tCoordinate.eX = 8400;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][1].tCoordinate.eY = 120;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][1].eDirection = 90;

            DeliverData.tAGV_Cfg.atWarehousingCfg[0][2].tCoordinate.eX = 5000;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][2].tCoordinate.eY = -4000;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][2].eDirection = 90;

            DeliverData.tAGV_Cfg.atWarehousingCfg[0][3].tCoordinate.eX = 11550;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][3].tCoordinate.eY = 120;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][3].eDirection = 90;

            //貨物對應到的節點索引
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][0].tNodeId.lIndex = 2;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][0].tNodeId.lRegion = 0;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][1].tNodeId.lIndex = 3;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][1].tNodeId.lRegion = 0;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][2].tNodeId.lIndex = 0;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][2].tNodeId.lRegion = 0;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][3].tNodeId.lIndex = 4;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][3].tNodeId.lRegion = 0;

            //路徑權重宣告
            DeliverData.tAGV_Cfg.tMapCfg.alPathTableLocal = new int[1][];

            DeliverData.tAGV_Cfg.tMapCfg.alPathTableLocal[0] = new int[]
            {   0, 2550, 99999, 99999, 99999,
                2550, 0, 12080, 3400 , 6550,
                99999, 12080, 0, 8680, 5550,
                99999,  3400, 8680, 0, 3150,
                99999,  6550, 5550, 3150, 0
            };
        }
Ejemplo n.º 2
0
        private void btnReadData_Click(object sender, EventArgs e)
        {
            if (txtDataIndex.Text == "")
            {
                MessageBox.Show("請輸入數值");
                return;
            }
            int Select_Index = Convert.ToInt16(txtDataIndex.Text) + 1;
            DeliverData = new rtAGV_Control();
            dataGridView_Log.Rows.Clear();

            //更新車體資訊
            DeliverData.tAGV_Data.tCarInfo.tPosition.eX = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][2].ToString());
            DeliverData.tAGV_Data.tCarInfo.tPosition.eY = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][3].ToString());
            DeliverData.tAGV_Data.tCarInfo.eAngle = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][0].ToString());

            DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedLeft = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][10].ToString());
            DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedRight = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][11].ToString());

            DeliverData.tAGV_Data.tCarInfo.tCarTirepositionR.eX = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][4].ToString());
            DeliverData.tAGV_Data.tCarInfo.tCarTirepositionR.eY = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][5].ToString());
            DeliverData.tAGV_Data.tCarInfo.tCarTirepositionL.eX = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][6].ToString());
            DeliverData.tAGV_Data.tCarInfo.tCarTirepositionL.eY = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][7].ToString());
            DeliverData.tAGV_Data.tCarInfo.tMotorPosition.eX = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][8].ToString());
            DeliverData.tAGV_Data.tCarInfo.tMotorPosition.eY = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][9].ToString());

            //更新車Sensor資訊
            DeliverData.tAGV_Data.tCarInfo.eWheelAngle = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][1].ToString());
            //DeliverData.tAGV_Data.tSensorData.tForkInputData.height = (int)GlobalVar.ForkCurrentHeight;

            //取得Path資訊
            string[] DataSrc = Main_Data.Tables[0].Rows[Select_Index][9].ToString().Split('/');
            string[] DataDst = Main_Data.Tables[0].Rows[Select_Index][10].ToString().Split('/');
            DeliverData.tAGV_Data.atPathInfo = new rtPath_Info[1];
            DeliverData.tAGV_Data.atPathInfo[0].tSrc.eX = Convert.ToDouble(DataSrc[0]);
            DeliverData.tAGV_Data.atPathInfo[0].tSrc.eY = Convert.ToDouble(DataSrc[1]);
            DeliverData.tAGV_Data.atPathInfo[0].tDest.eX = Convert.ToDouble(DataDst[0]);
            DeliverData.tAGV_Data.atPathInfo[0].tDest.eY = Convert.ToDouble(DataDst[1]);
            DeliverData.tAGV_Data.atPathInfo[0].ucTurnType = 2;
            DeliverData.tAGV_Data.atPathInfo[0].ucStatus = 1;

            object[] obj = new object[12] { Select_Index,  DeliverData.tAGV_Data.tCarInfo.tPosition.eX,  DeliverData.tAGV_Data.tCarInfo.tPosition.eY,
                        DeliverData.tAGV_Data.tCarInfo.eAngle,   DeliverData.tAGV_Data.tCarInfo.tCarTirepositionR.eX,   DeliverData.tAGV_Data.tCarInfo.tCarTirepositionR.eY,
                        DeliverData.tAGV_Data.tCarInfo.tCarTirepositionL.eX,  DeliverData.tAGV_Data.tCarInfo.tCarTirepositionL.eY,  DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedLeft,
             DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedRight,  DeliverData.tAGV_Data.atPathInfo[0].tSrc.eX+"/"+ DeliverData.tAGV_Data.atPathInfo[0].tSrc.eY,
             DeliverData.tAGV_Data.atPathInfo[0].tDest.eX + "/" +  DeliverData.tAGV_Data.atPathInfo[0].tDest.eY};

            DataGridViewRow dgvr = new DataGridViewRow();
            dgvr.CreateCells(dataGridView_Log, obj);
            dgvr.Height = 35;
            dgvr.DefaultCellStyle.BackColor = Color.LightBlue;
            dataGridView_Log.Rows.Add(dgvr);

            DeliverData.rtAGV_MotorCtrl(ref DeliverData.tAGV_Data.atPathInfo, 0, true);

            //Console.WriteLine("Power:" + DeliverData.tAGV_Data.CMotor.tMotorData.lMotorPower.ToString());
            //Console.WriteLine("lMotorAngle:" + DeliverData.tAGV_Data.CMotor.tMotorData.lMotorAngle.ToString());

            label_LogPower.Text = "Power:" + DeliverData.tAGV_Data.CMotor.tMotorData.lMotorPower.ToString();
            label_LogMotorAngle.Text = "MotorAngle:" + DeliverData.tAGV_Data.CMotor.tMotorData.lMotorAngle.ToString();
        }
Ejemplo n.º 3
0
        private void btnCalculationResults_Click(object sender, EventArgs e)
        {
            if (textBox_PositionX.Text == "" || textBox_PositionY.Text == "" || textBox_Angle.Text == ""
             || textBox_CarTireSpeedLeft.Text == "" || textBox_CarTireSpeedRight.Text == "" || textBox_CarTirepositionR_X.Text == ""
             || textBox_CarTirepositionR_Y.Text == "" || textBox_CarTirepositionL_X.Text == "" || textBox_CarTirepositionL_Y.Text == ""
             || textBox_MotorPosition_X.Text == "" || textBox_MotorPosition_Y.Text == "" || textBox_WheelAngle.Text == ""
             || textBox_Src_X.Text == "" || textBox_Src_Y.Text == "" || textBox_Dest_X.Text == "" || textBox_Dest_Y.Text == "")
            {
                MessageBox.Show("請輸入數值");
                return;
            }
            if (textBox_PositionX.Text == "")
            {
                return;
            }

            //int Select_Index = 1;
            DeliverData = new rtAGV_Control();
            dataGridView_Text.Rows.Clear();
            //更新車體資訊
            DeliverData.tAGV_Data.tCarInfo.tPosition.eX = Convert.ToDouble(textBox_PositionX.Text);
            DeliverData.tAGV_Data.tCarInfo.tPosition.eY = Convert.ToDouble(textBox_PositionY.Text);
            DeliverData.tAGV_Data.tCarInfo.eAngle = Convert.ToDouble(textBox_Angle.Text);

            DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedLeft = Convert.ToDouble(textBox_CarTireSpeedLeft.Text);
            DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedRight = Convert.ToDouble(textBox_CarTireSpeedRight.Text);

            DeliverData.tAGV_Data.tCarInfo.tCarTirepositionR.eX = Convert.ToDouble(textBox_CarTirepositionR_X.Text);
            DeliverData.tAGV_Data.tCarInfo.tCarTirepositionR.eY = Convert.ToDouble(textBox_CarTirepositionR_Y.Text);
            DeliverData.tAGV_Data.tCarInfo.tCarTirepositionL.eX = Convert.ToDouble(textBox_CarTirepositionL_X.Text);
            DeliverData.tAGV_Data.tCarInfo.tCarTirepositionL.eY = Convert.ToDouble(textBox_CarTirepositionL_Y.Text);
            DeliverData.tAGV_Data.tCarInfo.tMotorPosition.eX = Convert.ToDouble(textBox_MotorPosition_X.Text);
            DeliverData.tAGV_Data.tCarInfo.tMotorPosition.eY = Convert.ToDouble(textBox_MotorPosition_Y.Text);

            //更新車Sensor資訊
            DeliverData.tAGV_Data.tCarInfo.eWheelAngle = Convert.ToDouble(textBox_WheelAngle.Text);

            //取得Path資訊
            DeliverData.tAGV_Data.atPathInfo = new rtPath_Info[1];
            DeliverData.tAGV_Data.atPathInfo[0].tSrc.eX = Convert.ToDouble(textBox_Src_X.Text);
            DeliverData.tAGV_Data.atPathInfo[0].tSrc.eY = Convert.ToDouble(textBox_Src_Y.Text);
            DeliverData.tAGV_Data.atPathInfo[0].tDest.eX = Convert.ToDouble(textBox_Dest_X.Text);
            DeliverData.tAGV_Data.atPathInfo[0].tDest.eY = Convert.ToDouble(textBox_Dest_Y.Text);
            DeliverData.tAGV_Data.atPathInfo[0].ucTurnType = Convert.ToByte(textBox_TurnType.Text);
            DeliverData.tAGV_Data.atPathInfo[0].ucStatus = 1;

            object[] obj = new object[11] { DeliverData.tAGV_Data.tCarInfo.tPosition.eX,  DeliverData.tAGV_Data.tCarInfo.tPosition.eY,
                        DeliverData.tAGV_Data.tCarInfo.eAngle,   DeliverData.tAGV_Data.tCarInfo.tCarTirepositionR.eX,   DeliverData.tAGV_Data.tCarInfo.tCarTirepositionR.eY,
                        DeliverData.tAGV_Data.tCarInfo.tCarTirepositionL.eX,  DeliverData.tAGV_Data.tCarInfo.tCarTirepositionL.eY,  DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedLeft,
             DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedRight,  DeliverData.tAGV_Data.atPathInfo[0].tSrc.eX+"/"+ DeliverData.tAGV_Data.atPathInfo[0].tSrc.eY,
             DeliverData.tAGV_Data.atPathInfo[0].tDest.eX + "/" +  DeliverData.tAGV_Data.atPathInfo[0].tDest.eY};

            DataGridViewRow dgvr = new DataGridViewRow();
            dgvr.CreateCells(dataGridView_Text, obj);
            dgvr.Height = 35;
            dgvr.DefaultCellStyle.BackColor = Color.LightBlue;
            dataGridView_Text.Rows.Add(dgvr);

            DeliverData.rtAGV_MotorCtrl(ref DeliverData.tAGV_Data.atPathInfo, 0, true);

            //Console.WriteLine("Power:" + DeliverData.tAGV_Data.CMotor.tMotorData.lMotorPower.ToString());
            //Console.WriteLine("lMotorAngle:" + DeliverData.tAGV_Data.CMotor.tMotorData.lMotorAngle.ToString());

            label_TextPower.Text = "Power:" + DeliverData.tAGV_Data.CMotor.tMotorData.lMotorPower.ToString();
            label_TextMotorAngle.Text = "MotorAngle:" + DeliverData.tAGV_Data.CMotor.tMotorData.lMotorAngle.ToString();
        }
Ejemplo n.º 4
0
        public rtAGV_Control Read_ini_Cfg2(rtAGV_Control DeliverData)
        {
            //rtAGV_Control宣告
            DeliverData = new rtAGV_Control();
            DeliverData.tIS_Cfg.tMapCfg.Init();

            int           size = 3000;                    //temp file source size
            StringBuilder temp = new StringBuilder(size); //temp file source

            #region 自走車地圖設定
            GetPrivateProfileString("AGV MAP Cfg", "Region_Num", "", temp, size, ".\\" + filename_Cfg2);
            Region_Num = Convert.ToInt32(temp.ToString());

            //宣告使用到的Region數量
            DeliverData.tIS_Cfg.tMapCfg.alRegionNum = Region_Num;

            //宣告節點使用到的空間
            //DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal = new rtIS_MAP_node[Region_Num][];
            //DeliverData.tAGV_Cfg.tMapCfg.alPathTableLocal = new int[Region_Num][];
            DeliverData.tIS_Cfg.tMapCfg.atRegionCfg = new RegionOfMap[Region_Num];

            for (int i = 0; i < Region_Num; i++)
            {
                GetPrivateProfileString("AGV MAP Cfg", "Node_Num_Local_" + i.ToString(), "", temp, size, ".\\" + filename_Cfg2);
                Node_Num_Local = Convert.ToInt32(temp.ToString());
                DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].lNodeNum = Node_Num_Local;
                // DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[i] = new rtIS_MAP_node[Node_Num_Local];

                //第i區的路徑權重 (有Node_Num_Local個節點,所以table大小是 Node_Num_Local x Node_Num_Local = )
                int   Array_count             = 0;
                int[] Array_Region_Path_Table = new int[Node_Num_Local * Node_Num_Local];
                for (int j = 0; j < Node_Num_Local; j++)
                {
                    for (int k = 0; k < Node_Num_Local; k++)
                    {
                        GetPrivateProfileString("AGV MAP Cfg", "Region_Path_Table_" + i.ToString() + "_" + j.ToString() + "_" + k.ToString(), "", temp, size, ".\\" + filename_Cfg2);
                        Array_Region_Path_Table[Array_count++] = Convert.ToInt32(temp.ToString());
                    }
                }
                DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].alPathTableNode = Array_Region_Path_Table;

                DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].atNode = new rtNode[Node_Num_Local];
                for (int j = 0; j < Node_Num_Local; j++)
                {
                    GetPrivateProfileString("AGV MAP Cfg", "Region_Coordinate_X_" + i.ToString() + "_" + j.ToString(), "", temp, size, ".\\" + filename_Cfg2);
                    DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].atNode[j].tCoordinate.eX = Convert.ToInt32(temp.ToString());

                    GetPrivateProfileString("AGV MAP Cfg", "Region_Coordinate_Y_" + i.ToString() + "_" + j.ToString(), "", temp, size, ".\\" + filename_Cfg2);
                    DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].atNode[j].tCoordinate.eY = Convert.ToInt32(temp.ToString());
                }
            }

            #endregion

            #region 區域資訊設定

            for (int i = 0; i < Region_Num; i++)
            {
                GetPrivateProfileString("Block Info", "Block_Number_" + i.ToString(), "", temp, size, ".\\" + filename_Cfg2);
                Block_Number = Convert.ToInt32(temp.ToString());
                DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].lBlockNum = Block_Number;

                /*int iiii = DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[0].lBlockNum;
                 * DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[0].lBlockNum = 9; // by ancre ???????
                 */
                //DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[i] = new rtIS_MAP_node[Node_Num_Local];

                DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].atBlockCfg = new rtBlockInfo[Block_Number];

                for (int j = 0; j < Block_Number; j++)
                {
                    GetPrivateProfileString("Block Info", "Block_X_" + i.ToString() + "_" + j.ToString(), "", temp, size, ".\\" + filename_Cfg2);
                    DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].atBlockCfg[j].tCoordinate.eX = Convert.ToInt32(temp.ToString());

                    GetPrivateProfileString("Block Info", "Block_Y_" + i.ToString() + "_" + j.ToString(), "", temp, size, ".\\" + filename_Cfg2);
                    DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].atBlockCfg[j].tCoordinate.eY = Convert.ToInt32(temp.ToString());

                    GetPrivateProfileString("Block Info", "Block_Width_" + i.ToString() + "_" + j.ToString(), "", temp, size, ".\\" + filename_Cfg2);
                    DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].atBlockCfg[j].eWidth = Convert.ToInt32(temp.ToString());

                    GetPrivateProfileString("Block Info", "Block_Height_" + i.ToString() + "_" + j.ToString(), "", temp, size, ".\\" + filename_Cfg2);
                    DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].atBlockCfg[j].eHeight = Convert.ToInt32(temp.ToString());
                }
            }

            #endregion

            #region 貨倉資訊設定

            /*GetPrivateProfileString("Warehousing Info", "Container_Number_Region", "", temp, size, ".\\" + filename_Cfg2);
             * Container_Number_Region = Region_Num;*/

            /*GetPrivateProfileString("Warehousing Info", "Container_Number_0", "", temp, size, ".\\" + filename_Cfg2);
             * Container_Number_0 = Convert.ToInt32(temp.ToString());*/

            for (int i = 0; i < Region_Num; i++)
            {
                GetPrivateProfileString("Warehousing Info", "Container_Number_" + i.ToString(), "", temp, size, ".\\" + filename_Cfg2);
                Container_Number = Convert.ToInt32(temp.ToString());
                DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].lWarehouseNum  = Container_Number;
                DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].atWarehouseCfg = new rtWarehouseInfo[Container_Number];

                for (int j = 0; j < Container_Number; j++)
                {
                    GetPrivateProfileString("Warehousing Info", "Container_Region_Id_" + i.ToString() + "_" + j.ToString(), "", temp, size, ".\\" + filename_Cfg2);
                    DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].atWarehouseCfg[j].lRegion = Convert.ToInt32(temp.ToString());

                    GetPrivateProfileString("Warehousing Info", "Container_Index_Id_" + i.ToString() + "_" + j.ToString(), "", temp, size, ".\\" + filename_Cfg2);
                    DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].atWarehouseCfg[j].lNodeId = Convert.ToInt32(temp.ToString());

                    GetPrivateProfileString("Warehousing Info", "Container_Height_" + i.ToString() + "_" + j.ToString(), "", temp, size, ".\\" + filename_Cfg2);
                    DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].atWarehouseCfg[j].eHeight = Convert.ToInt32(temp.ToString());

                    GetPrivateProfileString("Warehousing Info", "Container_Depth_" + i.ToString() + "_" + j.ToString(), "", temp, size, ".\\" + filename_Cfg2);
                    DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].atWarehouseCfg[j].DistanceDepth = Convert.ToInt32(temp.ToString());

                    GetPrivateProfileString("Warehousing Info", "Container_X_" + i.ToString() + "_" + j.ToString(), "", temp, size, ".\\" + filename_Cfg2);
                    DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].atWarehouseCfg[j].tCoordinate.eX = Convert.ToInt32(temp.ToString());

                    GetPrivateProfileString("Warehousing Info", "Container_Y_" + i.ToString() + "_" + j.ToString(), "", temp, size, ".\\" + filename_Cfg2);
                    DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].atWarehouseCfg[j].tCoordinate.eY = Convert.ToInt32(temp.ToString());

                    GetPrivateProfileString("Warehousing Info", "Container_Direction_" + i.ToString() + "_" + j.ToString(), "", temp, size, ".\\" + filename_Cfg2);
                    DeliverData.tIS_Cfg.tMapCfg.atRegionCfg[i].atWarehouseCfg[j].eDirection = Convert.ToInt32(temp.ToString());
                }
            }
            #endregion

            GetPrivateProfileString("Car Cfg", "MACHINE_TYPE", "", temp, size, ".\\" + filename_Cfg1);
            MACHINE_TYPE = Convert.ToInt32(temp.ToString());
            return(DeliverData);
        }
Ejemplo n.º 5
0
        private void btnReadData_Click(object sender, EventArgs e)
        {
            if (txtDataIndex.Text == "")
            {
                MessageBox.Show("請輸入數值");
                return;
            }
            int Select_Index = Convert.ToInt16(txtDataIndex.Text) + 1;

            DeliverData = new rtAGV_Control();
            dataGridView_Log.Rows.Clear();
            try
            {
                //更新車體資訊
                DeliverData.tAGV_Data.tCarInfo.tPosition.eX = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][2].ToString());
                DeliverData.tAGV_Data.tCarInfo.tPosition.eY = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][3].ToString());
                DeliverData.tAGV_Data.tCarInfo.eAngle       = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][0].ToString());

                DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedLeft  = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][10].ToString());
                DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedRight = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][11].ToString());

                DeliverData.tAGV_Data.tCarInfo.tCarTirepositionR.eX = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][4].ToString());
                DeliverData.tAGV_Data.tCarInfo.tCarTirepositionR.eY = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][5].ToString());
                DeliverData.tAGV_Data.tCarInfo.tCarTirepositionL.eX = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][6].ToString());
                DeliverData.tAGV_Data.tCarInfo.tCarTirepositionL.eY = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][7].ToString());
                DeliverData.tAGV_Data.tCarInfo.tMotorPosition.eX    = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][8].ToString());
                DeliverData.tAGV_Data.tCarInfo.tMotorPosition.eY    = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][9].ToString());

                //更新車Sensor資訊
                DeliverData.tAGV_Data.tCarInfo.eWheelAngle = Convert.ToDouble(CarInfo.Tables[0].Rows[Select_Index][1].ToString());
                //DeliverData.tAGV_Data.tSensorData.tForkInputData.height = (int)GlobalVar.ForkCurrentHeight;

                //取得Path資訊
                string[] DataSrc = Main_Data.Tables[0].Rows[Select_Index][9].ToString().Split('/');
                string[] DataDst = Main_Data.Tables[0].Rows[Select_Index][10].ToString().Split('/');
                DeliverData.tAGV_Data.atPathInfo               = new rtPath_Info[1];
                DeliverData.tAGV_Data.atPathInfo[0].tSrc.eX    = Convert.ToDouble(DataSrc[0]);
                DeliverData.tAGV_Data.atPathInfo[0].tSrc.eY    = Convert.ToDouble(DataSrc[1]);
                DeliverData.tAGV_Data.atPathInfo[0].tDest.eX   = Convert.ToDouble(DataDst[0]);
                DeliverData.tAGV_Data.atPathInfo[0].tDest.eY   = Convert.ToDouble(DataDst[1]);
                DeliverData.tAGV_Data.atPathInfo[0].ucTurnType = 2;
                DeliverData.tAGV_Data.atPathInfo[0].ucStatus   = 1;



                if (MainForm.comboBox_MachineType_Num == (byte)rtAGV_Control.Type_Self_Carriage.BigCar)
                {
                    obj = new object[12] {
                        Select_Index, DeliverData.tAGV_Data.tCarInfo.tPosition.eX, DeliverData.tAGV_Data.tCarInfo.tPosition.eY,
                        DeliverData.tAGV_Data.tCarInfo.eAngle, DeliverData.tAGV_Data.tCarInfo.tCarTirepositionR.eX, DeliverData.tAGV_Data.tCarInfo.tCarTirepositionR.eY,
                        DeliverData.tAGV_Data.tCarInfo.tCarTirepositionL.eX, DeliverData.tAGV_Data.tCarInfo.tCarTirepositionL.eY, DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedLeft,
                        DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedRight, DeliverData.tAGV_Data.atPathInfo[0].tSrc.eX + "/" + DeliverData.tAGV_Data.atPathInfo[0].tSrc.eY,
                        DeliverData.tAGV_Data.atPathInfo[0].tDest.eX + "/" + DeliverData.tAGV_Data.atPathInfo[0].tDest.eY
                    };
                }
                else if (MainForm.comboBox_MachineType_Num == (byte)rtAGV_Control.Type_Self_Carriage.MediumCar)
                {
                }
                else if (MainForm.comboBox_MachineType_Num == (byte)rtAGV_Control.Type_Self_Carriage.SmallCar)
                {
                    obj = new object[8] {
                        Select_Index, DeliverData.tAGV_Data.tCarInfo.tPosition.eX, DeliverData.tAGV_Data.tCarInfo.tPosition.eY,
                        DeliverData.tAGV_Data.tCarInfo.eAngle, DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedLeft,
                        DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedRight, DeliverData.tAGV_Data.atPathInfo[0].tSrc.eX + "/" + DeliverData.tAGV_Data.atPathInfo[0].tSrc.eY,
                        DeliverData.tAGV_Data.atPathInfo[0].tDest.eX + "/" + DeliverData.tAGV_Data.atPathInfo[0].tDest.eY
                    };
                }
                else if (MainForm.comboBox_MachineType_Num == (byte)rtAGV_Control.Type_Self_Carriage.Other)
                {
                }


                DataGridViewRow dgvr = new DataGridViewRow();
                dgvr.CreateCells(dataGridView_Log, obj);
                dgvr.Height = 35;
                dgvr.DefaultCellStyle.BackColor = Color.LightBlue;
                dataGridView_Log.Rows.Add(dgvr);


                //判斷現在車種為何
                DeliverData.rtAGV_Chang_Type_Self_Carriage(MainForm.comboBox_MachineType_Num);

                DeliverData.rtAGV_MotorCtrl(ref DeliverData.tAGV_Data.atPathInfo, 0, true);

                //Console.WriteLine("Power:" + DeliverData.tAGV_Data.CMotor.tMotorData.lMotorPower.ToString());
                //Console.WriteLine("lMotorAngle:" + DeliverData.tAGV_Data.CMotor.tMotorData.lMotorAngle.ToString());

                label_LogPower.Text      = "Power:" + DeliverData.tAGV_Data.CMotor.tMotorData.lMotorPower.ToString();
                label_LogMotorAngle.Text = "MotorAngle:" + DeliverData.tAGV_Data.CMotor.tMotorData.lMotorAngle.ToString();
            }
            catch (Exception)
            {
                MessageBox.Show("此筆數據為非導航狀態");
            }
        }
Ejemplo n.º 6
0
        private void btnCalculationResults_Click(object sender, EventArgs e)
        {
            if (textBox_PositionX.Text == "" || textBox_PositionY.Text == "" || textBox_Angle.Text == "" ||
                textBox_CarTireSpeedLeft.Text == "" || textBox_CarTireSpeedRight.Text == "" || textBox_CarTirepositionR_X.Text == "" ||
                textBox_CarTirepositionR_Y.Text == "" || textBox_CarTirepositionL_X.Text == "" || textBox_CarTirepositionL_Y.Text == "" ||
                textBox_MotorPosition_X.Text == "" || textBox_MotorPosition_Y.Text == "" || textBox_WheelAngle.Text == "" ||
                textBox_Src_X.Text == "" || textBox_Src_Y.Text == "" || textBox_Dest_X.Text == "" || textBox_Dest_Y.Text == "")
            {
                MessageBox.Show("請輸入數值");
                return;
            }
            if (textBox_PositionX.Text == "")
            {
                return;
            }

            //int Select_Index = 1;
            DeliverData = new rtAGV_Control();
            dataGridView_Text.Rows.Clear();
            try
            {
                //if (MainForm.comboBox_MachineType_Num == (byte)rtAGV_Control.Type_Self_Carriage.BigCar)
                {
                    //更新車體資訊
                    DeliverData.tAGV_Data.tCarInfo.tPosition.eX = Convert.ToDouble(textBox_PositionX.Text);
                    DeliverData.tAGV_Data.tCarInfo.tPosition.eY = Convert.ToDouble(textBox_PositionY.Text);
                    DeliverData.tAGV_Data.tCarInfo.eAngle       = Convert.ToDouble(textBox_Angle.Text);

                    DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedLeft  = Convert.ToDouble(textBox_CarTireSpeedLeft.Text);
                    DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedRight = Convert.ToDouble(textBox_CarTireSpeedRight.Text);

                    DeliverData.tAGV_Data.tCarInfo.tCarTirepositionR.eX = Convert.ToDouble(textBox_CarTirepositionR_X.Text);
                    DeliverData.tAGV_Data.tCarInfo.tCarTirepositionR.eY = Convert.ToDouble(textBox_CarTirepositionR_Y.Text);
                    DeliverData.tAGV_Data.tCarInfo.tCarTirepositionL.eX = Convert.ToDouble(textBox_CarTirepositionL_X.Text);
                    DeliverData.tAGV_Data.tCarInfo.tCarTirepositionL.eY = Convert.ToDouble(textBox_CarTirepositionL_Y.Text);
                    DeliverData.tAGV_Data.tCarInfo.tMotorPosition.eX    = Convert.ToDouble(textBox_MotorPosition_X.Text);
                    DeliverData.tAGV_Data.tCarInfo.tMotorPosition.eY    = Convert.ToDouble(textBox_MotorPosition_Y.Text);

                    //更新車Sensor資訊
                    DeliverData.tAGV_Data.tCarInfo.eWheelAngle = Convert.ToDouble(textBox_WheelAngle.Text);

                    //取得Path資訊
                    DeliverData.tAGV_Data.atPathInfo               = new rtPath_Info[1];
                    DeliverData.tAGV_Data.atPathInfo[0].tSrc.eX    = Convert.ToDouble(textBox_Src_X.Text);
                    DeliverData.tAGV_Data.atPathInfo[0].tSrc.eY    = Convert.ToDouble(textBox_Src_Y.Text);
                    DeliverData.tAGV_Data.atPathInfo[0].tDest.eX   = Convert.ToDouble(textBox_Dest_X.Text);
                    DeliverData.tAGV_Data.atPathInfo[0].tDest.eY   = Convert.ToDouble(textBox_Dest_Y.Text);
                    DeliverData.tAGV_Data.atPathInfo[0].ucTurnType = Convert.ToByte(textBox_TurnType.Text);
                    DeliverData.tAGV_Data.atPathInfo[0].ucStatus   = 1;

                    //車種不同 顯示也會不一樣
                    if (MainForm.comboBox_MachineType_Num == (byte)rtAGV_Control.Type_Self_Carriage.BigCar)
                    {
                        obj = new object[11] {
                            DeliverData.tAGV_Data.tCarInfo.tPosition.eX, DeliverData.tAGV_Data.tCarInfo.tPosition.eY,
                            DeliverData.tAGV_Data.tCarInfo.eAngle, DeliverData.tAGV_Data.tCarInfo.tCarTirepositionR.eX, DeliverData.tAGV_Data.tCarInfo.tCarTirepositionR.eY,
                            DeliverData.tAGV_Data.tCarInfo.tCarTirepositionL.eX, DeliverData.tAGV_Data.tCarInfo.tCarTirepositionL.eY, DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedLeft,
                            DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedRight, DeliverData.tAGV_Data.atPathInfo[0].tSrc.eX + "/" + DeliverData.tAGV_Data.atPathInfo[0].tSrc.eY,
                            DeliverData.tAGV_Data.atPathInfo[0].tDest.eX + "/" + DeliverData.tAGV_Data.atPathInfo[0].tDest.eY
                        };
                    }
                    else if (MainForm.comboBox_MachineType_Num == (byte)rtAGV_Control.Type_Self_Carriage.MediumCar)
                    {
                    }
                    else if (MainForm.comboBox_MachineType_Num == (byte)rtAGV_Control.Type_Self_Carriage.SmallCar)
                    {
                        obj = new object[7] {
                            DeliverData.tAGV_Data.tCarInfo.tPosition.eX, DeliverData.tAGV_Data.tCarInfo.tPosition.eY,
                            DeliverData.tAGV_Data.tCarInfo.eAngle, DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedLeft,
                            DeliverData.tAGV_Data.tCarInfo.eCarTireSpeedRight, DeliverData.tAGV_Data.atPathInfo[0].tSrc.eX + "/" + DeliverData.tAGV_Data.atPathInfo[0].tSrc.eY,
                            DeliverData.tAGV_Data.atPathInfo[0].tDest.eX + "/" + DeliverData.tAGV_Data.atPathInfo[0].tDest.eY
                        };
                    }
                    else if (MainForm.comboBox_MachineType_Num == (byte)rtAGV_Control.Type_Self_Carriage.Other)
                    {
                    }


                    DataGridViewRow dgvr = new DataGridViewRow();
                    dgvr.CreateCells(dataGridView_Text, obj);
                    dgvr.Height = 35;
                    dgvr.DefaultCellStyle.BackColor = Color.LightBlue;
                    dataGridView_Text.Rows.Add(dgvr);

                    //判斷現在車種為何
                    DeliverData.rtAGV_Chang_Type_Self_Carriage(MainForm.comboBox_MachineType_Num);

                    DeliverData.rtAGV_MotorCtrl(ref DeliverData.tAGV_Data.atPathInfo, 0, true);

                    //Console.WriteLine("Power:" + DeliverData.tAGV_Data.CMotor.tMotorData.lMotorPower.ToString());
                    //Console.WriteLine("lMotorAngle:" + DeliverData.tAGV_Data.CMotor.tMotorData.lMotorAngle.ToString());

                    label_TextPower.Text      = "Power:" + DeliverData.tAGV_Data.CMotor.tMotorData.lMotorPower.ToString();
                    label_TextMotorAngle.Text = "MotorAngle:" + DeliverData.tAGV_Data.CMotor.tMotorData.lMotorAngle.ToString();

                    //將數值寫回儲存資料內
                    PositionX          = textBox_PositionX.Text;
                    PositionY          = textBox_PositionY.Text;
                    Angle              = textBox_Angle.Text;
                    CarTireSpeedLeft   = textBox_CarTireSpeedLeft.Text;
                    CarTireSpeedRight  = textBox_CarTireSpeedRight.Text;
                    CarTirepositionR_X = textBox_CarTirepositionR_X.Text;
                    CarTirepositionR_Y = textBox_CarTirepositionR_Y.Text;
                    CarTirepositionL_X = textBox_CarTirepositionL_X.Text;
                    CarTirepositionL_Y = textBox_CarTirepositionL_Y.Text;
                    MotorPosition_X    = textBox_MotorPosition_X.Text;
                    MotorPosition_Y    = textBox_MotorPosition_Y.Text;
                    WheelAngle         = textBox_WheelAngle.Text;
                    TurnType           = textBox_TurnType.Text;
                    Src_X              = textBox_Src_X.Text;
                    Src_Y              = textBox_Src_Y.Text;
                    Dest_X             = textBox_Dest_X.Text;
                    Dest_Y             = textBox_Dest_Y.Text;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("請正確輸入數值");
            }
        }