Esempio n. 1
0
 /// <summary>
 /// ���ƶ�λ����Ϣ
 /// </summary>
 /// <param name="pos"></param>
 public AlarmPosition(int pid, Position pos)
 {
     id = pid;
     CarID = pos.CarID;
     GpsTime = pos.GpsTime;
     Pointed = pos.Pointed;
     Lo = pos.Lo;
     La = pos.La;
     Speed = pos.Speed;
     Direction = pos.Direction;
     Status = pos.Status;
     Alarm = pos.Alarm;
     AlarmHandle = 1;
 }
Esempio n. 2
0
 //�ظ���ʷ�켣
 private void C_Pos_HisPos(DataClient dataClient, String rec)
 {
     try
     {
         StringBuilder stb = new StringBuilder(Constant.HEAD).Append(Constant.C_POS).Append(Constant.C_POS_HIS_POS);
         String[] para = rec.Split(Constant.SPLIT1);
         stb.Append(para[0]).Append(Constant.SPLIT1);
         DataTable dt = dbm.ExecuteQuery("select_his_pos " + para[0] + ",'" + para[1] + "','" + para[2] + "'");
         if(dt != null && dt.Rows.Count > 0)
         {
             Position pos = new Position();
             foreach(DataRow dr in dt.Rows)
             {
                 for(int i = 0; i < 9; i++)
                     stb.Append(dr[i].ToString()).Append(Constant.SPLIT2);
                 stb.Append(Constant.SPLIT1);
             }
             stb.Remove(stb.Length - 1, 1);
         }
         stb.Append(Constant.FOOT);
         dataClient.Send(stb.ToString());
     }
     catch(Exception e)
     {
         if(FormMain.LOG_ERR)
             logger.AddErr(e, "");
     }
 }
Esempio n. 3
0
        //���Ŷ�λ��Ϣ
        //*RS,123456789,V1,181003,A,2233.1055,N,11358.1257,E,51.00,000,070925,FFFFFBFD#
        public static Position GetSMSPos(String src)
        {
            Position pos = new Position();
            try
            {
                //Console.WriteLine(src);
                String[] ss = src.Split(',');
                pos.MNO = ss[0];
                int add = 0;
                if(ss[1] == "V4")
                {
                    if(ss[2] == "S32")
                    {
                        add = 3;
                        pos.Mileage = (int)(Double.Parse(ss[4]) * 0.51444 / 1000);
                    }/*
                    else if(ss[2] == "S5")
                    {
                        add = 5;
                        pos.IsPointMsg = true;
                    }/*/
                    else if(ss[2] == "S26")
                    {
                        pos.IsGetSetMsg = true;
                        pos.SettingStr = src.Substring(src.IndexOf(ss[5]));
                        return pos;
                    }
                    else add = 2;
                }
                else pos.IsPointMsg = true;//��Э���޵�����λָ�ֻ����v1����
                try
                {/*
                    pos.GpsTime = "20" + ss[add + 10].Substring(4) + "-" + ss[add + 10].Substring(2, 2) + "-" + ss[add + 10].Substring(0, 2)
                        + " " + ss[add + 2].Substring(0, 2) + ":" + ss[add + 2].Substring(2, 2) + ":" + ss[add + 2].Substring(4);
                    DateTime dt = DateTime.Parse(pos.GpsTime);
                    dt = dt.AddHours(8);
                    pos.GpsTime = dt.ToString("yyyy-MM-dd HH:mm:ss");*/
                    pos.GpsTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }
                catch { pos.GpsTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); }

                pos.Pointed = (ss[add + 3] == "A") ? 1 : 0;

                pos.La = Double.Parse(ss[add + 4].Substring(0, 2)) + Double.Parse(ss[add + 4].Substring(2)) / 60;
                if(ss[add + 5] == "S")
                    pos.La = 0 - pos.La;
                pos.Lo = Double.Parse(ss[add + 6].Substring(0, 3)) + Double.Parse(ss[add + 6].Substring(3)) / 60;
                if(ss[add + 7] == "W")
                    pos.Lo = 0 - pos.Lo;
                pos.Speed = Pub.KtsToKms((int)Double.Parse(ss[add + 8]));
                if(ss[add + 9] == "")
                    pos.Direction = 0;
                else
                {
                    pos.Direction = 0;
                    double dir = Double.Parse(ss[add + 9]);
                    if(dir < 90) pos.Direction = 1;
                    else if(dir == 90) pos.Direction = 2;
                    else if(dir < 180) pos.Direction = 3;
                    else if(dir == 180) pos.Direction = 4;
                    else if(dir < 270) pos.Direction = 5;
                    else if(dir == 270) pos.Direction = 6;
                    else if(dir > 270) pos.Direction = 7;
                }
                if(ss[add + 11].Length > 8)
                    ss[add + 11] = ss[add + 11].Substring(0, 8);
                String hex = Pub.HexToBin(ss[add + 11]);
                String[] status = {
                        "�͵紫����1����",      "�ߵ紫����2Ϊ��",      "�ߵ紫����1Ϊ��",      "��ƿ�������",
                        "�������͵�",           "GPRS��������",         "����������󱨾�",     "�¶ȱ���",
                        "�͵紫����2����",      "GPS���߶�·",          "GPS���߿�·",          "��ƿ�����",
                        "�����ɺ󱸵�ع���",   "",                     "",                     "GPS���߹��ϱ���",
                        "����",                 "�Զ��屨��",           "��������",             "",
                        "",                     "ACC��",                "�������",             "���ſ�",
                        "��ֹʻ��Խ�籨��",     "GPS���߶�·����",      "GPS���߿�·����",      "��ֹʻ��Խ�籨��",
                        "�Ƿ���𱨾�",         "���ٱ���",             "�پ�",                 "����"
                    };
                for(int i = 0; i < 32; i++)
                    if(hex[i] == '0' && status[i] != "")
                    {
                        if(status[i].IndexOf("��") > 0)
                            pos.Alarm = pos.Alarm + status[i] + " ";
                        else pos.Status = pos.Status + status[i] + " ";
                    }
                if(pos.Status.IndexOf("ACC��") < 0)
                    pos.Status = pos.Status + "ACC��";
                pos.AlarmHandle = (pos.Alarm == "") ? 0 : 1;
                return pos;
            }
            catch { }
            return null;
        }
Esempio n. 4
0
        //gprs/cdmaѹ����Ϣ
        public static Position GetPosEx(String src)
        {
            Position pos = new Position();
            try
            {
                String ss = Pub.RealHexToHex(src.Substring(1, src.Length - 2));
                Console.WriteLine(ss.Length.ToString());
                if(src[0] == HEAD_HEX_2)
                {
                    pos.Mileage = (int)(Int32.Parse(ss.Substring(0, 10)) * 0.51444 / 1000);
                }
                StringBuilder stb = new StringBuilder();
                pos.MNO = ss.Substring(0, 10);
                try
                {/*
                    stb.Append("20").Append(ss.Substring(20, 2)).Append("-");
                    stb.Append(ss.Substring(18, 2)).Append("-").Append(ss.Substring(16, 2)).Append(" ");
                    stb.Append(ss.Substring(10, 2)).Append(":").Append(ss.Substring(12, 2)).Append(":");
                    stb.Append(ss.Substring(14, 2));
                    DateTime dt = DateTime.Parse(stb.ToString());
                    dt = dt.AddHours(8);
                    pos.GpsTime = dt.ToString("yyyy-MM-dd HH:mm:ss");*/
                    pos.GpsTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }
                catch { pos.GpsTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); }

                pos.La = Double.Parse(ss.Substring(22, 2)) + Double.Parse(ss.Substring(24, 6).Insert(2, ".")) / 60;
                pos.Lo = Double.Parse(ss.Substring(32, 3)) + Double.Parse(ss.Substring(35, 6).Insert(2, ".")) / 60;

                String temp = Pub.HexToBin(ss.Substring(41, 1));
                //if(temp[0] == '0')
                    //pos.Lo = 0 - pos.Lo;
                //if(ss[1] == '0')
                    //pos.La = 0 - pos.La;
                if(ss[2] == '0')
                    pos.Pointed = 0;
                else pos.Pointed = 1;

                pos.Speed = Pub.KtsToKms(Int32.Parse(ss.Substring(42, 3)));
                pos.Direction = 0;
                double dir = Double.Parse(ss.Substring(45, 3));
                if(dir < 90) pos.Direction = 1;
                else if(dir == 90) pos.Direction = 2;
                else if(dir < 180) pos.Direction = 3;
                else if(dir == 180) pos.Direction = 4;
                else if(dir < 270) pos.Direction = 5;
                else if(dir == 270) pos.Direction = 6;
                else if(dir > 270) pos.Direction = 7;
                String hex = Pub.HexToBin(ss.Substring(48, 8));
                String[] status = {
                        "�͵紫����1����",      "�ߵ紫����2Ϊ��",      "�ߵ紫����1Ϊ��",      "��ƿ�������",
                        "�������͵�",           "GPRS��������",         "����������󱨾�",     "�¶ȱ���",
                        "�͵紫����2����",      "GPS���߶�·",          "GPS���߿�·",          "��ƿ�����",
                        "�����ɺ󱸵�ع���",   "",                     "",                     "GPS���߹��ϱ���",
                        "����",                 "�Զ��屨��",           "��������",             "",
                        "",                     "ACC��",                "�������",             "���ſ�",
                        "��ֹʻ��Խ�籨��",     "GPS���߶�·����",      "GPS���߿�·����",      "��ֹʻ��Խ�籨��",
                        "�Ƿ���𱨾�",         "���ٱ���",             "�پ�",                 "����"
                    };
                for(int i = 0; i < 32; i++)
                    if(hex[i] == '0' && status[i] != "")
                    {
                        if(status[i].IndexOf("��") > 0)
                            pos.Alarm = pos.Alarm + status[i] + " ";
                        else pos.Status = pos.Status + status[i] + " ";
                    }
                if(pos.Status.IndexOf("ACC��") < 0)
                    pos.Status = pos.Status + "ACC��";
                pos.AlarmHandle = (pos.Alarm == "") ? 0 : 1;
                return pos;
            }
            catch { }
            return null;
        }
Esempio n. 5
0
 //gprs/cdma��λ��Ϣ
 public static Position GetGPRSPos(String src)
 {
     Position pos = new Position();
     try
     {
         return GetSMSPos(src);
     }
     catch { }
     return null;
 }
Esempio n. 6
0
        public static Position GetSMSPos(String src)
        {
            Position pos = new Position();
            String[] ss = src.Split(',');
            src = ss[1];

              //   MessageBox.Show(src);

            pos.MNO = src.Substring(0, 8);

            pos.MNO = pos.MNO.Substring(6, 2) + pos.MNO.Substring(4, 2) + pos.MNO.Substring(2, 2) + pos.MNO.Substring(0, 2);

             //   MessageBox.Show(pos.MNO);

               // var id = Int32.Parse("c0801081", System.Clobalization.NumberStyles.HexNumber);
            // var newid = IPAddress.HostToNetworkOrder( id );

            if((src.Substring(20,6)=="020301")||(src.Substring(20,6)=="020302")||(src.Substring(20,6)=="020307")||(src.Substring(20,6)=="020308")||(src.Substring(20,6)=="020304")||(src.Substring(20,6)=="02030B"))
            {
                try
                {
                    pos.GpsTime = "20" + src.Substring(54, 2) + "-" + src.Substring(56, 2) + "-" + src.Substring(58, 2) + " " + src.Substring(60, 2) + ":" + src.Substring(62, 2) + ":" + src.Substring(64, 2);
                  //  MessageBox.Show(pos.GpsTime);

                    DateTime dt = DateTime.Parse(pos.GpsTime);
                    dt = dt.AddHours(8);
                    pos.GpsTime = dt.ToString("yyyy-MM-dd HH:mm:ss");

                }
                catch

                { pos.GpsTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); }

            pos.Pointed = 1;

             //   pos.Mileage = (int)(((Double.Parse(src.Substring(46, 3)) + 0.1 * Double.Parse(src.Substring(49, 1))) * 0.51444 / 1000));
               // pos.Mileage = 200;//(每移动200米报位一次.来计算

            pos.La = Double.Parse(src.Substring(28, 2)) + (Double.Parse(src.Substring(30, 2))/60 +  ((Double.Parse(src.Substring(32, 4)))/10000)/60); // 维度
            pos.Lo = Double.Parse(src.Substring(37, 3)) + (Double.Parse(src.Substring(40, 2))/60 +  ((Double.Parse(src.Substring(42, 4)))/10000)/60); //精度
            pos.Speed = Pub.KtsToKms((int)(Double.Parse(src.Substring(46, 3)) + 0.1 * Double.Parse(src.Substring(49, 1))));
            double dir = Double.Parse(src.Substring(50, 2)) + 0.1 * Double.Parse(src.Substring(52, 2));
            if (dir < 90) pos.Direction = 1;
            else if (dir == 90) pos.Direction = 2;
            else if (dir < 180) pos.Direction = 3;
            else if (dir == 180) pos.Direction = 4;
            else if (dir < 270) pos.Direction = 5;
            else if (dir == 270) pos.Direction = 6;
            else if (dir > 270) pos.Direction = 7;

            if (src.Substring(20, 6) == "020302") { pos.Alarm = "紧急报警" + ""; pos.Status = pos.Status + "ACC开"; }
            if (src.Substring(20, 6) == "020307") { pos.Alarm = "断电报警" + ""; pos.Status = pos.Status + "ACC开"; }
            if (src.Substring(20, 6) == "02030B") { pos.Alarm = "超速报警" + ""; pos.Status = pos.Status + "ACC开"; }
            if (src.Substring(20, 6) == "020304") { pos.Alarm = "区域报警" + ""; pos.Status = pos.Status + "ACC开"; }
            pos.AlarmHandle = (pos.Alarm == "") ? 0 : 1;

             //  pos.IsGetSetMsg = true;
             //  pos.SettingStr = src;//硬件目前无独立获得设置命令

            }

            return pos;
        }
Esempio n. 7
0
 /// <summary>
 /// ���ƶ�λ����Ϣ
 /// </summary>
 /// <param name="pos"></param>
 public void Clone(Position pos)
 {
     this.gpsTime = pos.gpsTime;
     this.pointed = pos.pointed;
     this.lo = pos.lo;
     this.la = pos.la;
     this.speed = pos.speed;
     this.direction = pos.direction;
     this.status = pos.status;
     this.alarm = pos.alarm;
     this.alarmHandle = pos.alarmHandle;
 }
Esempio n. 8
0
 /// <summary>
 /// ���ַ���������λ��
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public static Position Parse(String s)
 {
     Position pos = new Position();
     String[] ss = s.Split(Constant.SPLIT2);
     try
     {
         pos.GpsTime = ss[0];
         pos.Pointed = Int32.Parse(ss[1]);
         pos.Lo = Double.Parse(ss[2]);
         pos.La = Double.Parse(ss[3]);
         pos.Speed = Int32.Parse(ss[4]);
         pos.Direction = Int32.Parse(ss[5]);
         pos.Status = ss[6];
         pos.Alarm = ss[7];
         pos.AlarmHandle = Int32.Parse(ss[8]);
     }
     catch { return null; }
     return pos;
 }