Пример #1
0
        private void PathDisplayForm_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 10; i++)
            {
                Mapz[i] = new Coor();
                Mapz[i].X = 36000 - i * 3600;
                //Map[i].y=-800+1600/9*i;
//                Map[i].y = -90;
                Mapz[i].Y = -80;
            }
    
                for ( int i = 0; i < 10; i = i + 2)
                {

                    Mapz[i].Y = +80;
                }


                for (int i = 0; i < 10; i++)
                {
                    Maps[i] = new Coor();
                    Maps[i].X = 36000 - i * 3600;
                    //Map[i].y=-800+1600/9*i;
                    //                Map[i].y = -90;
                    Maps[i].Y = 450;
                }


            path_list = new ArrayList();
            DrawAxis(OrgX, OrgY, 1000, Color.Blue);

        }
Пример #2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            FileStream fs1;

            if (!File.Exists("D:\\processed.txt"))
            {
                //StreamWriter sw = new StreamWriter("D:\\processed.txt", false);

                fs1 = new FileStream("D:\\processed.txt", FileMode.Create, FileAccess.Write);//创建写入文件 
                

            }
            else
            {
                fs1 = new FileStream("D:\\processed.txt", FileMode.Open, FileAccess.Write);
              
                
            }
            StreamWriter sw = new StreamWriter(fs1);
            
            
            System.Windows.Forms.OpenFileDialog openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
             //StreamWriter sw = new StreamWriter("txtwriter.txt", false);

                  openFileDialog1.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*";

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string FileName = openFileDialog1.FileName;
                // your file-processing code
                StreamReader sr = new StreamReader(FileName);
                fileContent = sr.ReadToEnd();

                String[] path_points = fileContent.Split('<', '>');


                path_list.Clear();
                for (int i = 0; i < path_points.GetLength(0); i++)
                {
                    if (path_points[i] != null && path_points[i] != "")
                    {
                        path_list.Add(path_points[i]);


                    }
                }

                DrawAxis(OrgX, OrgY, 1000, Color.Blue);

                for (int i = 0; i < path_list.Count; i++)
                {
                    Coor Apoint = new Coor();
                    String[] x_y = new String[2];
                    if (path_list[i].ToString().Contains("Map"))
                    {
                        path_list[i] = path_list[i].ToString().Replace("Map", "");
                        x_y = path_list[i].ToString().Split(' ');
                        DrawCoorodinates_withColor(Convert.ToInt32(x_y[1]), Convert.ToInt32(x_y[3]), Color.Blue);

                    }
                    else
                    {
                        path_list[i] = path_list[i].ToString().Replace("Real ", "");
                        
                        x_y = path_list[i].ToString().Split(' ');
                        if (x_y.GetLength(0) >= 4)
                        {
                            if (x_y[1]!=""&&!x_y[1].Contains("\n")&&x_y[3]!=""&&!x_y[3].Contains("\n"))
                            {
                                if (Convert.ToInt32( x_y[1])>Convert.ToInt32( x_y[3]))
                                {
                                    String tempswap = "";
                                    tempswap = x_y[3];
                                    x_y[3] = x_y[1];
                                    x_y[1]=tempswap;

                                }
                                DrawCoorodinates_withColor(Convert.ToInt32(x_y[1])/100+OrgX, Convert.ToInt32(x_y[3])/100+OrgY, Color.Black);
                                writebuf =  x_y[1] + " " + x_y[3] ;  
                                sw.WriteLine(writebuf);


                            }

                          
                        }

                    }

                }

            }
            sw.Close();
            fs1.Close();
            //sw.Close();
        }
Пример #3
0
        /// <summary>
        /// timer's tick in which we recive and update the data sent to the PC then update them to the htable
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timerRecieve_Tick(object sender, EventArgs e)
        {
            
            PVCI_CAN_OBJ[] sendbuf = new PVCI_CAN_OBJ[200];
            int NumValue = 0;
            NumValue = VCI_Receive(2, 0, 0, sendbuf);/////////////////Get the msg from the CAN NetWork
            showCan(0, 1, sendbuf, NumValue);
            int len=sendbuf.GetLength(0);

            if (sendbuf[0].DataLen > 0)
            {
                CurrentBuff = sendbuf[0];
                for (int i = 0; i < CurrentBuff.ID.GetLength(0); i++)
                {
                    CurrentBuff.ID[i] = (byte)((CurrentBuff.ID[i])>> 3);
                }
                ////////////////Recive the data from the dsp /////recive data of valid distance and draw on board ////the ID is 00 11 12 19
                if (CurrentBuff.ID[0] == 0x00 && CurrentBuff.ID[1] == 0x11 && CurrentBuff.ID[2] == 0x12 && CurrentBuff.ID[3] == 0x19)
                {
                    Int32[] temp = new Int32[8];
                    CurrentBuff = sendbuf[0];
                    for (int i = 0; i < 6; i++)
                    {
                        temp[i] = CurrentBuff.Data[i];
                    }
                    temp[0] = (temp[0] << 16);
                    temp[1] = (temp[1] << 8);
                    temp[2] = (temp[2]);
                    distance = temp[0] + temp[1] + temp[2];
                    angle = (temp[3]<<16) + (temp[4]<<8) + temp[5];
                    angle = angle * 360 /1152000;
                    valid_coord = new Coor();
                    valid_coord= pollor_to_Descart(distance, angle);
                    file_txt+="<Real X " + valid_coord.X.ToString() + " Y " + valid_coord.Y.ToString() + ">\n\r ";
                    //write_file("E:\\trail.txt","","X "+valid_coord.X.ToString()+"Y "+valid_coord.Y.ToString()+"\n\r");

                    //"D:\\trail.txt"
                    DrawCoorodinates( ORG_X+ (valid_coord.X)/100,ORG_Y+ (valid_coord.Y)/100);

                }

                ////////////////Recive the data from the dsp /////valid aim map point 00 11 12 1a
                if (CurrentBuff.ID[0] == 0x00 && CurrentBuff.ID[1] == 0x11 && CurrentBuff.ID[2] == 0x12 && CurrentBuff.ID[3] == 0x1a)
                {
                    Int32[] temp = new Int32[8];
                    CurrentBuff = sendbuf[0];
                    for (int i = 0; i < 6; i++)
                    {
                        temp[i] = CurrentBuff.Data[i];
                    }
                    temp[0] = (temp[0] << 16);
                    temp[1] = (temp[1] << 8);
                    temp[2] = (temp[2]);
                    x_map = temp[0] + temp[1] + temp[2];
                    y_map = (temp[3] << 16) + (temp[4] << 8) + temp[5];
                    //angle = angle * 360 / 1152000;
                    valid_coord = new Coor();
                    valid_coord = pollor_to_Descart(distance, angle);
                    file_txt += "<Map :X " + valid_coord.X.ToString() + " Y " + valid_coord.Y.ToString() + ">\n\r ";
                    //write_file("E:\\trail.txt","","X "+valid_coord.X.ToString()+"Y "+valid_coord.Y.ToString()+"\n\r");

                    //"D:\\trail.txt"
                    DrawCoorodinates_with_pen(ORG_X + (valid_coord.X) / 100, ORG_Y + (valid_coord.Y) / 100,new Pen(Color.Red));

                }
         
            }
            //  TempVpOnMain.Value = (int)Form1.htable[pressure]/TempVpOnMain.Maximum;
            //DrawBar(sendbuf[sendbuf.GetLength(0)-1]);

        }
Пример #4
0
        Coor pollor_to_Descart(float dis, float angle) 
        {
            Coor tempCoor = new Coor();

            tempCoor.X = (int)(dis *(float)Math.Cos(3.14159*angle/180));
            tempCoor.Y = (int)(dis * (float)Math.Sin(3.14159*angle/180));
            return tempCoor;
        }