Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            txtTime.Text = DateTime.Now.ToString();
            GPS      thisGPS   = new GPS();
            string   StartDate = "01/01/1970 00:00:00";
            TimeSpan nowSpan   = DateTime.Now - Convert.ToDateTime(StartDate);

            thisGPS.Id     = Math.Abs(nowSpan.Milliseconds);
            thisGPS.Speed  = Convert.ToDouble(txtSpeed.Text);
            thisGPS.Lat    = Convert.ToDouble(txtLat.Text);
            thisGPS.Lon    = Convert.ToDouble(txtLon.Text);
            thisGPS.MaxSpd = Convert.ToDouble(txtMaxSpeed.Text);
            thisGPS.MLat   = Convert.ToDouble(txtMLat.Text);
            thisGPS.MLon   = Convert.ToDouble(txtMLon.Text);
            thisGPS.Time   = Convert.ToDateTime(txtTime.Text);
            thisGPS.Status = "Valid";
            thisGPS.DOP    = 7.0;
            thisGPS.Alt    = 5280;
            thisGPS.Head   = Convert.ToInt32(txtHead.Text);
            XmlSerializer           ser        = new XmlSerializer(typeof(GPS));
            XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();

            namespaces.Add(string.Empty, string.Empty);
            StringWriter str = new StringWriter();

            ser.Serialize(str, thisGPS, namespaces);
            string  msg   = str.ToString();
            SendUDP myUDP = new SendUDP();

            txtMessageStatus.Text += myUDP.SendUDPPacket("<FWD>" + txtIPAddress.Text + "</FWD>" + msg, ddlServiceAddress.Text);
        }
Example #2
0
        private void SendTimerState()
        {
            State    thisState = new State();
            string   StartDate = "01/01/1970 00:00:00";
            TimeSpan nowSpan   = DateTime.Now - Convert.ToDateTime(StartDate);

            thisState.Id           = Math.Abs(nowSpan.Milliseconds);
            thisState.CarID        = "NA";
            thisState.GpsRate      = 30;
            thisState.Log          = "F";
            thisState.ServerIP     = "127.10.0.1";
            thisState.Version      = "1.0.0";
            thisState.SFTPServerIP = "127.10.0.1";
            XmlSerializer           ser        = new XmlSerializer(typeof(State));
            XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();

            namespaces.Add(string.Empty, string.Empty);
            StringWriter str = new StringWriter();

            ser.Serialize(str, thisState, namespaces);
            //ser.Serialize(str, thisState);
            string  msg   = str.ToString();
            SendUDP myUDP = new SendUDP();

            txtMessageStatus.Text += myUDP.SendUDPPacket(msg, ddlServiceAddress.Text);
        }
Example #3
0
        private void btnSendAbePacket_Click(object sender, EventArgs e)
        {
            string  msg   = "<GPS><Id>67546</Id><MLon>-118.109129734817</MLon><Speed>0</Speed><Head>0</Head><Lon>-118.109129734817</Lon><Alt>1307</Alt><Time>09/06/2012 18:45:46</Time><MLat>33.7978439719052</MLat><Status>Valid</Status><MaxSpd>0</MaxSpd><Lat>33.7978439719052</Lat><DOP>6</DOP></GPS>";
            SendUDP myUDP = new SendUDP();

            txtMessageStatus.Text += myUDP.SendUDPPacket(msg, ddlServiceAddress.Text);
        }
Example #4
0
        private void btnSendIPHistory_Click(object sender, EventArgs e)
        {
            string   StartDate = "01/01/1970 00:00:00";
            TimeSpan nowSpan   = DateTime.Now - Convert.ToDateTime(StartDate);
            string   msg       = "<IPHistory><Id>" + Math.Abs(nowSpan.Milliseconds).ToString() + "</Id><IP>" + txtIPHistory.Text + "</IP></IPHistory>";
            SendUDP  myUDP     = new SendUDP();

            myUDP.SendUDPPacket(msg, ddlServiceAddress.Text);
        }
Example #5
0
        public void RunKMLThread()
        {
            for (int i = 0; i < RunKML.Coords.Count(); i++)
            {
                GPS      thisGPS   = new GPS();
                string   StartDate = "01/01/1970 00:00:00";
                TimeSpan nowSpan   = DateTime.Now - Convert.ToDateTime(StartDate);
                thisGPS.Id     = Math.Abs(nowSpan.Milliseconds);
                thisGPS.Speed  = Convert.ToDouble(txtSpeed.Text);
                thisGPS.Lat    = RunKML.Coords[i].lat;
                thisGPS.Lon    = RunKML.Coords[i].lon;
                thisGPS.MaxSpd = Convert.ToDouble(txtMaxSpeed.Text);
                thisGPS.MLat   = Convert.ToDouble(txtMLat.Text);
                thisGPS.MLon   = Convert.ToDouble(txtMLon.Text);
                thisGPS.Time   = Convert.ToDateTime(txtTime.Text);
                thisGPS.Status = "Valid";
                thisGPS.DOP    = 7.0;
                thisGPS.Alt    = 5280;
                thisGPS.Cell   = txtCell.Text;
                thisGPS.Head   = Convert.ToInt32(txtHead.Text);
                XmlSerializer           ser        = new XmlSerializer(typeof(GPS));
                XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();
                namespaces.Add(string.Empty, string.Empty);
                StringWriter str = new StringWriter();
                ser.Serialize(str, thisGPS, namespaces);
                string  msg         = str.ToString();
                SendUDP myUDP       = new SendUDP();
                SendUDP playbackUdp = new SendUDP();
                txtMessageStatus.Invoke(new MethodInvoker(delegate {
                    txtMessageStatus.Text += playbackUdp.SendUDPPacket(msg, ddlServiceAddress.Text);
                }));

                if (i == RunKML.Coords.Count() - 1)
                {
                    txtMessageStatus.Invoke(new MethodInvoker(delegate {
                        txtMessageStatus.Text = "Playback finished " + DateTime.Now.ToString();
                    }));
                    runKMLThread.Abort();
                    break;
                }

                double distBetween = 0.0;  //should be miles
                if ((i + 1) < RunKML.Coords.Count())
                {
                    distBetween = GeoCodeCalc.CalcDistance(RunKML.Coords[i].lat, RunKML.Coords[i].lon, RunKML.Coords[i + 1].lat, RunKML.Coords[i + 1].lon);
                }
                //int Pause = Convert.ToInt32(thisGPS.Speed * distBetween);
                int Pause = 5;
                System.Threading.Thread.Sleep(Pause * 1000);
            }
        }
Example #6
0
        public void sendState(string IPList)
        {
            State    thisState = new State();
            string   StartDate = "01/01/1970 00:00:00";
            TimeSpan nowSpan   = DateTime.Now - Convert.ToDateTime(StartDate);

            thisState.Id             = Math.Abs(nowSpan.Milliseconds);
            thisState.CarID          = "NA";
            thisState.GpsRate        = 30;
            thisState.Log            = "F";
            thisState.ServerIP       = "127.10.0.1";
            thisState.Version        = "1.0.0";
            thisState.SFTPServerIP   = "127.10.0.1";
            thisState.BillStartDay   = "15";
            thisState.LastBillReset  = "2015/05/15 13:04:12";
            thisState.DataUsed       = "1.1234567890";
            thisState.IgnTimeoutSecs = "2400";
            if (!string.IsNullOrEmpty(IPList))
            {
                thisState.IPList = IPList;
            }
            XmlSerializer           ser        = new XmlSerializer(typeof(State));
            XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();

            namespaces.Add(string.Empty, string.Empty);
            StringWriter str = new StringWriter();

            ser.Serialize(str, thisState, namespaces);
            //ser.Serialize(str, thisState);
            string  msg    = str.ToString();
            SendUDP myUDP  = new SendUDP();
            string  ipSend = string.Empty;

            Invoke(new MethodInvoker(delegate() { ipSend = ddlServiceAddress.Text; }));
            txtMessageStatus.Text += myUDP.SendUDPPacket(msg, ipSend);
        }
Example #7
0
        private void RunCSVThread()
        {
            for (int i = 0; i < RunCSV.playbackTrucks.Count; i++)
            {
                GPS      thisGPS   = new GPS();
                string   StartDate = "01/01/1970 00:00:00";
                TimeSpan nowSpan   = DateTime.Now - Convert.ToDateTime(StartDate);
                thisGPS.Id     = Math.Abs(nowSpan.Milliseconds);
                thisGPS.Speed  = RunCSV.playbackTrucks[i].Speed;
                thisGPS.Lat    = RunCSV.playbackTrucks[i].Lat;
                thisGPS.Lon    = RunCSV.playbackTrucks[i].Lon;
                thisGPS.MaxSpd = RunCSV.playbackTrucks[i].MaxSpeed;
                thisGPS.MLat   = RunCSV.playbackTrucks[i].Lat;
                thisGPS.MLon   = RunCSV.playbackTrucks[i].Lon;
                thisGPS.Time   = RunCSV.playbackTrucks[i].timeStamp;
                thisGPS.Status = RunCSV.playbackTrucks[i].VehicleStatus;
                thisGPS.Cell   = txtCell.Text;
                thisGPS.DOP    = 7.0;
                thisGPS.Alt    = 5280;
                thisGPS.Head   = RunCSV.playbackTrucks[i].Direction;
                XmlSerializer           ser        = new XmlSerializer(typeof(GPS));
                XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();
                namespaces.Add(string.Empty, string.Empty);
                StringWriter str = new StringWriter();
                ser.Serialize(str, thisGPS, namespaces);
                string  msg         = str.ToString();
                SendUDP myUDP       = new SendUDP();
                SendUDP playbackUdp = new SendUDP();

                txtMessageStatus.Invoke(new MethodInvoker(delegate
                {
                    txtMessageStatus.Text += playbackUdp.SendUDPPacket(msg, ddlServiceAddress.Text);
                }));

                if (i == RunCSV.playbackTrucks.Count() - 1)
                {
                    txtMessageStatus.Invoke(new MethodInvoker(delegate
                    {
                        txtMessageStatus.Text = "Playback finished " + DateTime.Now.ToString() + Environment.NewLine;
                    }));
                    runCSVThread.Abort();
                    break;
                }

                double distBetween = 0.0;  //should be miles
                if ((i + 1) < RunCSV.playbackTrucks.Count())
                {
                    distBetween = GeoCodeCalc.CalcDistance(RunCSV.playbackTrucks[i].Lat, RunCSV.playbackTrucks[i].Lon, RunCSV.playbackTrucks[i + 1].Lat, RunCSV.playbackTrucks[i + 1].Lon);
                }
                //int Pause = Convert.ToInt32(thisGPS.Speed * distBetween);
                int Pause = 5;
                if (thisGPS.Speed >= 0)
                {
                    System.Threading.Thread.Sleep(Pause * 1000);
                }
            }
            txtMessageStatus.Invoke(new MethodInvoker(delegate
            {
                txtMessageStatus.Text = "Restarting.  Press Stop CSV to stop playback" + Environment.NewLine;
                runCSVThread.Abort();
                runCSVThread.Start();
            }));
        }