Beispiel #1
0
        public void UpdateStatus(MAHADynoStatus status)
        {
            if (InvokeRequired)
            {
                var d = new UpdateStatusDelegate(UpdateStatus);
                Invoke(d, new object[] { status });
            }
            else
            {
                _currentStatus = status;
                if (_currentStatus != null)
                {
                    if (_currentStatus.LiftBeamUp)
                    {
                        buttonLiftBeam.Text = "Down";
                        labelLiftBeam.Text  = "Lift Beam: Up";
                    }
                    if (_currentStatus.LiftBeamDown)
                    {
                        buttonLiftBeam.Text = "Up";
                        labelLiftBeam.Text  = "Lift Beam: Down";
                    }
                    if (_currentStatus.DrivingMotorRunning)
                    {
                        buttonDriveMotor.Text = "Off";
                        labelDriveMotor.Text  = "Drive Motor: On";
                    }
                    else
                    {
                        buttonDriveMotor.Text = "On";
                        labelDriveMotor.Text  = "Drive Motor: Off";
                    }
                }

                if (_currentValues != null && _currentStatus != null)
                {
                    buttonStartLog.Enabled        = true;
                    buttonSpeedRegulator.Enabled  = true;
                    textBoxVariable.Enabled       = true;
                    numericUpDownVariable.Enabled = true;
                    buttonVariableWrite.Enabled   = true;
                    if (_currentValues.Speed > 1)
                    {
                        buttonLiftBeam.Enabled = false;
                        if (buttonLiftBeam.Text != "Down" || buttonDriveMotor.Text != "On")
                        {
                            buttonDriveMotor.Enabled = true;
                        }
                        else
                        {
                            buttonDriveMotor.Enabled = false;
                        }
                    }
                    else
                    {
                        buttonLiftBeam.Enabled = true;
                        if (buttonLiftBeam.Text != "Down")
                        {
                            buttonDriveMotor.Enabled = true;
                        }
                        else
                        {
                            buttonDriveMotor.Enabled = false;
                        }
                    }
                }
                else
                {
                    buttonStartLog.Enabled        = false;
                    buttonSpeedRegulator.Enabled  = false;
                    buttonLiftBeam.Enabled        = false;
                    buttonDriveMotor.Enabled      = false;
                    buttonSpeedRegulator.Text     = "Hold";
                    buttonLiftBeam.Text           = "Down";
                    labelLiftBeam.Text            = "Lift Beam: N/A";
                    buttonDriveMotor.Text         = "On";
                    labelDriveMotor.Text          = "Drive Motor: N/A";
                    textBoxVariable.BackColor     = Color.White;
                    textBoxVariable.Text          = "";
                    textBoxVariable.Enabled       = false;
                    numericUpDownVariable.Enabled = false;
                    numericUpDownVariable.Value   = 0;
                    buttonVariableWrite.Enabled   = false;
                }
            }
        }
Beispiel #2
0
        public MAHADynoStatus GetDynoStatus()
        {
            char[] s = new char[4];
            s[0] = (char)0xB4;
            s[1] = (char)0x11;
            s[2] = 'D';
            s[3] = (char)0x05;

            _uartService.Send(s);

            MAHADynoStatus status = new MAHADynoStatus();

            for (int i = 0; i < 21; i++)
            {
                int t = Read();
                if (t == -1)
                {
                    goto badStatus;
                }
                char c = (char)t;

                if (i == 0 && c != 0x02)
                {
                    goto badStatus;
                }
                if (i == 1)
                {
                    status.LiftBeamUp = c == '1';
                }
                if (i == 2)
                {
                    status.LiftBeamDown = c == '1';
                }
                if (i == 3)
                {
                    status.TorqueTooHigh = c == '1';
                }
                if (i == 4)
                {
                    status.ASMSpeedTooHigh = c == '1';
                }
                if (i == 5)
                {
                    status.AugmentedBrakingEnabled = c == '1';
                }
                if (i == 6)
                {
                    status.PowerTooHigh = c == '1';
                }
                if (i == 7)
                {
                    status.BrakeExcessTemperature = c == '1';
                }
                if (i == 8)
                {
                    status.ImpulseSensorError = c == '1';
                }
                if (i == 9)
                {
                    status.ShortCircuit = c == '1';
                }
                if (i == 10)
                {
                    status.AutoOffsetError = c == '1';
                }
                if (i == 11)
                {
                    status.RollerCovers = c == '1';
                }
                if (i == 12)
                {
                    status.RestrainSystem = c == '1';
                }
                if (i == 13)
                {
                    status.BearingExcessTemperature = c == '1';
                }
                if (i == 14)
                {
                    status.ConverterMotorCurrentAndTemperature = c == '1';
                }
                if (i == 15)
                {
                    status.Reserve = c == '1';
                }
                if (i == 16)
                {
                    status.DrivingMotorRunning = c == '1';
                }
                if (i == 17 && c != 0x17)
                {
                    goto badStatus;
                }
                if (i == 18 || i == 19)
                {
                    //todo do check checksum
                }
                if (i == 20 && c != '$')
                {
                    goto badStatus;
                }
            }

            return(status);

badStatus:
            while (Read() != -1)
            {
                ;
            }
            return(null);
        }