Example #1
0
        /// <summary>
        /// Apply button pressed by operator, send service request
        /// </summary>
        private void buttonApply_Click(object sender, EventArgs e)
        {
            //StartRemoveInExercise9
            if (textBoxCurrentSpeed.Text.Length == 0)
            {
                statusStrip.Items["toolStripStatus"].Text = "Current speed must exist.";
                return;
            }

            if (textboxNewSpeed.Text.Length == 0)
            {
                statusStrip.Items["toolStripStatus"].Text = "New speed must be given.";
                return;
            }

            // Create service request
            Capabilities.CalculateSpeedDifference req = new Capabilities.CalculateSpeedDifference();

            // Set service request values
            try
            {
                req.Speed.Val = float.Parse(textboxNewSpeed.Text);
            }
            catch
            {
                statusStrip.Items["toolStripStatus"].Text = "Illegal speed format!";
                return;
            }

            req.ObjectWithSpeed.Obj = m_vehicle.Clone();

            try
            {
                // Send service request
                m_secDobConnection.ServiceRequest(req, new Safir.Dob.Typesystem.HandlerId(), this);
                statusStrip.Items["toolStripStatus"].Text = "OK";
            }
            catch (Safir.Dob.OverflowException)
            {
                statusStrip.Items["toolStripStatus"].Text = "Overflow when sending, please wait!";
            }
            //StopRemoveInExercise9
        }