Example #1
0
        // Constructor, Initializes a new instance of the "FormGPS" class.
        public FormGPS()
        {
            //winform initialization
            InitializeComponent();

            //build the gesture structures
            SetupStructSizes();

            //create the world grid
            worldGrid = new CWorldGrid(this);

            //our vehicle made with gl object and pointer of mainform
            vehicle = new CVehicle(this);

            //create a new section and set left and right positions
            //created whether used or not, saves restarting program
            section = new CSection[MAXSECTIONS];
            for (int j = 0; j < MAXSECTIONS; j++)
            {
                section[j] = new CSection(this);
            }

            //our NMEA parser
            pn = new CNMEA(this);

            //create the ABLine instance
            ABLine = new CABLine(this);

            //new instance of contour mode
            ct = new CContour(this);

            //new instance of contour mode
            curve = new CABCurve(this);

            //module communication
            mc = new CModuleComm(this);

            //nmea simulator built in.
            sim = new CSim(this);

            //all the autosteer objects
            ast = new CAutoSteer(this);

            //all the attitude, heading, roll, pitch reference system
            ahrs = new CAHRS(this);

            //fieldData all in one place
            fd = new CFieldData(this);

            //resource for gloabal language strings
            _rm = new ResourceManager("ABC.gStr", Assembly.GetExecutingAssembly());

            // Add Message Event handler for Form decoupling from client socket thread
            updateRTCM_DataEvent = new UpdateRTCM_Data(OnAddMessage);

            // Access to workswitch functionality
            workSwitch = new CWorkSwitch(this);
        }
Example #2
0
        //set up connection to Caster
        public void StartNTRIP()
        {
            broadCasterIP   = Properties.Settings.Default.setNTRIP_casterIP;        //Select correct Address
            broadCasterPort = Properties.Settings.Default.setNTRIP_casterPort;      //Select correct port (usually 80 or 2101)
            mount           = Properties.Settings.Default.setNTRIP_mount;           //Insert the correct mount
            username        = Properties.Settings.Default.setNTRIP_userName;        //Insert your username!
            password        = Properties.Settings.Default.setNTRIP_userPassword;    //Insert your password!
            toUDP_Port      = Properties.Settings.Default.setNTRIP_sendToUDPPort;   //send rtcm to which udp port
            sendGGAInterval = Properties.Settings.Default.setNTRIP_sendGGAInterval; //how often to send fixes
            if (tmr != null)
            {
                tmr.Dispose();
            }

            if (sendGGAInterval > 0)
            {
                this.tmr          = new System.Windows.Forms.Timer();
                this.tmr.Interval = sendGGAInterval * 1000;
                this.tmr.Tick    += new EventHandler(NTRIPtick);
            }

            //toUDP_Port = Properties.Settings.Default.setNTRIP_sendToUDPPort; //send rtcm to which udp port
            //sendGGAInterval = Properties.Settings.Default.setNTRIP_sendGGAInterval; //how often to send fixes

            //// Add Message Event handler for Form decoupling from client socket thread
            updateRTCM_DataEvent = new UpdateRTCM_Data(OnAddMessage);

            try
            {
                // Close the socket if it is still open
                if (clientSocket != null && clientSocket.Connected)
                {
                    clientSocket.Shutdown(SocketShutdown.Both);
                    System.Threading.Thread.Sleep(100);
                    clientSocket.Close();
                }

                // Create the socket object
                clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                // Define the Server address and port
                IPEndPoint epServer = new IPEndPoint(IPAddress.Parse(broadCasterIP), broadCasterPort);

                // Connect to server non-Blocking method
                clientSocket.Blocking = false;
                AsyncCallback onconnect = new AsyncCallback(OnConnect);
                clientSocket.BeginConnect(epServer, onconnect, clientSocket);
            }
            catch (Exception)
            {
                TimedMessageBox(1000, "NTRIP Not Connected, Retrying", " At Socket Connect ");
                ReconnectRequest();
                return;
            }

            //make sure connection is made
            System.Threading.Thread.Sleep(1000);

            //send the authourization info for Broadcaster

            // Check we are connected
            if (clientSocket == null || !clientSocket.Connected)
            {
                TimedMessageBox(2000, "NTRIP Not Connected", " At the StartNTRIP() ");
                ReconnectRequest();
                return;
            }

            // Read the message from the text box and send it
            try
            {
                string auth = ToBase64(username + ":" + password);

                BuildGGA();
                GGASentence = sbGGA.ToString();


                // Convert to byte array and send.
                //string str = "GET /SRG HTTP / 1.1\r\nUser - Agent: NTRIP LefebureNTRIPClient/ 20131124\r\nAccept: */*\r\nConnection: close\r\n";

                string str = "GET /" + mount + " HTTP/1.1\r\n";
                str += "User-Agent: NTRIP LefebureNTRIPClient/20131124\r\n";
                str += "Authorization: Basic " + auth + "\r\n"; //This line can be removed if no authorization is needed
                str += GGASentence;                             //this line can be removed if no position feedback is needed
                str += "Accept: */*\r\nConnection: close\r\n";
                str += "\r\n";

                Byte[] byteDateLine = Encoding.ASCII.GetBytes(str.ToCharArray());
                clientSocket.Send(byteDateLine, byteDateLine.Length, 0);

                //enable to periodically send GGA sentence to server.
                if (sendGGAInterval > 0)
                {
                    tmr.Enabled = true;
                    System.Threading.Thread.Sleep(500);

                    //send GGA once again
                    SendGGA();
                }

                //say its connected
                isNTRIP_Connected      = true;
                isNTRIP_Starting       = false;
                btnStartStopNtrip.Text = "Stop";
            }
            catch (Exception)
            {
                //MessageBox.Show(this, ex.Message, "Send Message Failed!");
            }
        }