示例#1
0
        private async void updatecal_Click(object sender, EventArgs e)
        {
            var Speedometer = speedometerBox.Text;
            var Tachometer  = tachometerBox.Text;
            var Oil         = oilBox.Text;
            var Volt        = voltBox.Text;
            var Fuel        = fuelBox.Text;
            var Coolant     = coolantBox.Text;
            var Trans       = transmissionBox.Text;

            Stepper = string.Concat(Speedometer, Tachometer, Fuel, Coolant, Volt, Oil, Trans);

            Response <uint> osidResponse = await this.Vehicle.QueryOperatingSystemId(CancellationToken.None);

            if (osidResponse.Status != ResponseStatus.Success)
            {
                this.logger.AddUserMessage("Operating system query failed: " + osidResponse.Status);
                return;
            }

            PcmInfo info = new PcmInfo(osidResponse.Value);

            bool unlocked = await this.Vehicle.UnlockEcu(info.KeyAlgorithm);

            if (!unlocked)
            {
                this.logger.AddUserMessage("Unable to unlock PCM.");
                return;
            }

            Response <bool> vinmodified = await this.Vehicle.UpdateStepperCals(Stepper.Trim());

            if (vinmodified.Value)
            {
                this.logger.AddUserMessage("Stepper Calibration successfully updated to " + Stepper);
                MessageBox.Show("Stepper Calibration updated to " + Stepper + " successfully.", "Good news.", MessageBoxButtons.OK);
            }
            else
            {
                MessageBox.Show("Unable to change the Stepper Calibration to " + Stepper + ". Error: " + vinmodified.Status, "Bad news.", MessageBoxButtons.OK);
            }
        }