//-----------------------------------------------------------------------
//
// Copyright © 2012 Nils Hammar. All rights reserved.
//
//-----------------------------------------------------------------------
/*
* Software to access vehicle information via the OBD-II connector.
*
* Copyright © 2012 Nils Hammar
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Alternative licensing is possible, see the licensing document.
*
* The above text may not be removed or modified.
*/
namespace ObdSimulator.Data
{
using System.Windows.Forms;
///
/// Monitor status.
///
public partial class MonitorStatus : UserControl
{
///
/// If the display refers to the current drive cycle.
///
private bool currentDriveCycle;
///
/// Initializes a new instance of the class.
///
/// 'true' if data is for current drive cycle.
/// Heading text for panel.
public MonitorStatus(bool currentDriveCycle, string heading)
{
this.currentDriveCycle = currentDriveCycle;
this.InitializeComponent();
this.groupBox1.Text = heading;
}
///
/// Provide data to present.
///
/// Payload data.
public void setData(byte[] payload)
{
if (payload != null)
{
if (this.currentDriveCycle)
{
this.dtcLBL.Visible = false;
this.dtcCountTB.Visible = false;
this.milLBL.Visible = false;
this.milCB.Visible = false;
}
this.dtcCountTB.Text = ((byte)(payload[PidParser.BYTE_A] & 0x7F)).ToString();
this.milCB.Checked = (payload[PidParser.BYTE_A] & 0x80) != 0;
this.b0CB.Checked = (payload[PidParser.BYTE_B] & 0x01) != 0;
this.b1CB.Checked = (payload[PidParser.BYTE_B] & 0x02) != 0;
this.b2CB.Checked = (payload[PidParser.BYTE_B] & 0x04) != 0;
this.b3CB.Checked = (payload[PidParser.BYTE_B] & 0x08) != 0;
this.b4CB.Checked = (payload[PidParser.BYTE_B] & 0x10) != 0;
this.b5CB.Checked = (payload[PidParser.BYTE_B] & 0x20) != 0;
this.b6CB.Checked = (payload[PidParser.BYTE_B] & 0x40) != 0;
// If Compression ignition, use other labels.
if ((payload[PidParser.BYTE_B] & 0x08) != 0)
{
this.xlbl1.Text = "NMHC catalyst";
this.xlbl2.Text = "NOx/SCR aftertreatment";
this.xlbl3.Text = "N/A";
this.xlbl4.Text = "Boost pressure";
this.xlbl5.Text = "N/A";
this.xlbl6.Text = "Exhaust gas sensor";
this.xlbl7.Text = "PM filter";
this.xlbl8.Text = "EGR and/or VVT";
}
this.c0CB.Checked = (payload[PidParser.BYTE_C] & 0x01) != 0;
this.c1CB.Checked = (payload[PidParser.BYTE_C] & 0x02) != 0;
this.c2CB.Checked = (payload[PidParser.BYTE_C] & 0x04) != 0;
this.c3CB.Checked = (payload[PidParser.BYTE_C] & 0x08) != 0;
this.c4CB.Checked = (payload[PidParser.BYTE_C] & 0x10) != 0;
this.c5CB.Checked = (payload[PidParser.BYTE_C] & 0x20) != 0;
this.c6CB.Checked = (payload[PidParser.BYTE_C] & 0x40) != 0;
this.c7CB.Checked = (payload[PidParser.BYTE_C] & 0x80) != 0;
this.d0CB.Checked = (payload[PidParser.BYTE_D] & 0x01) != 0;
this.d1CB.Checked = (payload[PidParser.BYTE_D] & 0x02) != 0;
this.d2CB.Checked = (payload[PidParser.BYTE_D] & 0x04) != 0;
this.d3CB.Checked = (payload[PidParser.BYTE_D] & 0x08) != 0;
this.d4CB.Checked = (payload[PidParser.BYTE_D] & 0x10) != 0;
this.d5CB.Checked = (payload[PidParser.BYTE_D] & 0x20) != 0;
this.d6CB.Checked = (payload[PidParser.BYTE_D] & 0x40) != 0;
this.d7CB.Checked = (payload[PidParser.BYTE_D] & 0x80) != 0;
}
}
}
}